From a694e360a462ee25fe0a3ef1af9c8f03399494bd Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 29 Jun 2022 18:09:32 +0200 Subject: [PATCH] [Editor] Allow to select a freetext editor when in ink mode - and when in ink mode, change the toolbar active button when a freetext edited. --- src/display/editor/annotation_editor_layer.js | 9 +++++++++ src/display/editor/freetext.js | 1 + src/display/editor/tools.js | 17 ++++++++++++++++- web/annotation_editor_layer_builder.css | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index 89ebc64b3..8b7cf869d 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -95,6 +95,15 @@ class AnnotationEditorLayer { this.#uiManager.addLayer(this); } + /** + * Update the toolbar if it's required to reflect the tool currently used. + * @param {number} mode + * @returns {undefined} + */ + updateToolbar(mode) { + this.#uiManager.updateToolbar(mode); + } + /** * The mode has changed: it must be updated. * @param {number} mode diff --git a/src/display/editor/freetext.js b/src/display/editor/freetext.js index 0f37734c8..841e4098f 100644 --- a/src/display/editor/freetext.js +++ b/src/display/editor/freetext.js @@ -209,6 +209,7 @@ class FreeTextEditor extends AnnotationEditor { /** @inheritdoc */ enableEditMode() { + this.parent.updateToolbar(AnnotationEditorType.FREETEXT); super.enableEditMode(); this.overlayDiv.classList.remove("enabled"); this.editorDiv.contentEditable = true; diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index bef2d92b2..10e532e4f 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -319,7 +319,7 @@ class AnnotationEditorUIManager { } #dispatchUpdateUI(details) { - this.#eventBus?.dispatch("annotationeditorparamschanged", { + this.#eventBus.dispatch("annotationeditorparamschanged", { source: this, details, }); @@ -377,6 +377,21 @@ class AnnotationEditorUIManager { } } + /** + * Update the toolbar if it's required to reflect the tool currently used. + * @param {number} mode + * @returns {undefined} + */ + updateToolbar(mode) { + if (mode === this.#mode) { + return; + } + this.#eventBus.dispatch("switchannotationeditormode", { + source: this, + mode, + }); + } + /** * Update a parameter in the current editor or globally. * @param {number} type diff --git a/web/annotation_editor_layer_builder.css b/web/annotation_editor_layer_builder.css index 0ea57b282..1f72954db 100644 --- a/web/annotation_editor_layer_builder.css +++ b/web/annotation_editor_layer_builder.css @@ -47,6 +47,7 @@ resize: none; width: auto; height: auto; + z-index: 1; transform-origin: 0 0; }