From 00c3bc3aab6c3a3a0ad4edea30307be373e85bec Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 12 Oct 2022 09:02:23 +0200 Subject: [PATCH] [GENERIC viewer] Ensure that the we register the `editorTypes` for each `AnnotationEditorUIManager`-instance (issue 15564) When a new PDF document is opened in the GENERIC viewer we (obviously) create a new `AnnotationEditorUIManager`-instance, since those are document-specific, and thus we need to ensure that we actually register the `editorTypes` for each one. --- src/display/editor/annotation_editor_layer.js | 4 ++-- src/display/editor/tools.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index daf48342e..3204b2dbb 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -69,9 +69,9 @@ class AnnotationEditorLayer { AnnotationEditorLayer._initialized = true; FreeTextEditor.initialize(options.l10n); InkEditor.initialize(options.l10n); - - options.uiManager.registerEditorTypes([FreeTextEditor, InkEditor]); } + options.uiManager.registerEditorTypes([FreeTextEditor, InkEditor]); + this.#uiManager = options.uiManager; this.annotationStorage = options.annotationStorage; this.pageIndex = options.pageIndex; diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 884205a4b..542784d1e 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -637,6 +637,9 @@ class AnnotationEditorUIManager { } registerEditorTypes(types) { + if (this.#editorTypes) { + return; + } this.#editorTypes = types; for (const editorType of this.#editorTypes) { this.#dispatchUpdateUI(editorType.defaultPropertiesToUpdate);