From 396cff56528e45a30a300d6baa5e8ee23e2886b7 Mon Sep 17 00:00:00 2001 From: legraina Date: Sun, 2 Nov 2025 08:55:50 -0500 Subject: [PATCH] Pointer type initialization only when the user changes the mode Clear the pointer type of CurrentPointers outside of the DrawingEditor to always keep the same, until the user changes the mode. One of the goal is to keep the same pointer type in case of a refresh of the page or if the user changes the pdf document. --- src/display/editor/draw.js | 1 - src/display/editor/tools.js | 8 ++++++++ web/pdf_viewer.js | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/display/editor/draw.js b/src/display/editor/draw.js index 3ca7dfcfab4f9..778b1d73f16f0 100644 --- a/src/display/editor/draw.js +++ b/src/display/editor/draw.js @@ -824,7 +824,6 @@ class DrawingEditor extends AnnotationEditor { this._currentParent = null; DrawingEditor.#currentDraw = null; DrawingEditor.#currentDrawingOptions = null; - CurrentPointers.clearPointerType(); CurrentPointers.clearTimeStamp(); } diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 21023fd0f20e5..84d2f23c244e2 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -1923,6 +1923,8 @@ class AnnotationEditorUIManager { * Change the editor mode (None, FreeText, Ink, ...) * @param {number} mode * @param {string|null} editId + * @param {boolean} [isFromUser] - true if the mode change is due to a + * user action. * @param {boolean} [isFromKeyboard] - true if the mode change is due to a * keyboard action. * @param {boolean} [mustEnterInEditMode] - true if the editor must enter in @@ -1933,6 +1935,7 @@ class AnnotationEditorUIManager { async updateMode( mode, editId = null, + isFromUser = false, isFromKeyboard = false, mustEnterInEditMode = false, editComment = false @@ -1980,6 +1983,11 @@ class AnnotationEditorUIManager { await this.#signatureManager?.loadSignatures(); } + if (isFromUser) { + // reinitialize the pointer type when the mode is changed by the user + CurrentPointers.clearPointerType(); + } + this.setEditingState(true); await this.#enableAll(); this.unselectAll(); diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 2ec0dcf91d5ad..2a96a552ff496 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -2501,6 +2501,7 @@ class PDFViewer { await this.#annotationEditorUIManager.updateMode( mode, editId, + /* isFromUser = */ true, isFromKeyboard, mustEnterInEditMode, editComment