Skip to content

Commit

Permalink
Handle the "switchannotationeditorparams" event in the editor-code (i…
Browse files Browse the repository at this point in the history
…ssue 18196)

The problem seems to be caused by the browser trying to "restore" editing input-elements, in the various toolbars, to their previous values when the tab is re-opened.

Hence the simplest solution appears to be to move the event handling into the editor-code, which is also less code overall, since the listener thus won't be registered early enough for the problem to appear.
  • Loading branch information
Snuffleupagus committed Aug 13, 2024
1 parent 8273553 commit 9e0c6ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/display/editor/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ class AnnotationEditorUIManager {
signal,
});
eventBus._on("setpreference", this.onSetPreference.bind(this), { signal });
eventBus._on(
"switchannotationeditorparams",
evt => this.updateParams(evt.type, evt.value),
{ signal }
);
this.#addSelectionListener();
this.#addDragAndDropListeners();
this.#addKeyboardManager();
Expand Down
5 changes: 0 additions & 5 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1939,11 +1939,6 @@ const PDFViewerApplication = {
evt => (pdfViewer.annotationEditorMode = evt),
{ signal }
);
eventBus._on(
"switchannotationeditorparams",
evt => (pdfViewer.annotationEditorParams = evt),
{ signal }
);
eventBus._on("print", this.triggerPrinting.bind(this), { signal });
eventBus._on("download", this.downloadOrSave.bind(this), { signal });
eventBus._on("firstpage", () => (this.page = 1), { signal });
Expand Down
8 changes: 0 additions & 8 deletions web/pdf_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2363,14 +2363,6 @@ class PDFViewer {
updater();
}

// eslint-disable-next-line accessor-pairs
set annotationEditorParams({ type, value }) {
if (!this.#annotationEditorUIManager) {
throw new Error(`The AnnotationEditor is not enabled.`);
}
this.#annotationEditorUIManager.updateParams(type, value);
}

refresh(noUpdate = false, updateArgs = Object.create(null)) {
if (!this.pdfDocument) {
return;
Expand Down

0 comments on commit 9e0c6ef

Please sign in to comment.