1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #18523 from Snuffleupagus/Toolbar-more-bindListeners

Move all event listeners into `Toolbar.prototype.#bindListeners`
This commit is contained in:
Tim van der Meij 2024-08-01 20:41:32 +02:00 committed by GitHub
commit d562e0525d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,31 +118,7 @@ class Toolbar {
// Bind the event listeners for click and various other actions.
this.#bindListeners(buttons);
if (options.editorHighlightColorPicker) {
eventBus._on(
"annotationeditoruimanager",
({ uiManager }) => {
this.#setAnnotationEditorUIManager(
uiManager,
options.editorHighlightColorPicker
);
},
// Once the color picker has been added, we don't want to add it again.
{ once: true }
);
}
eventBus._on("showannotationeditorui", ({ mode }) => {
switch (mode) {
case AnnotationEditorType.HIGHLIGHT:
options.editorHighlightButton.click();
break;
}
});
eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
this.#updateToolbarDensity({ value: toolbarDensity });
this.reset();
}
@ -188,7 +164,12 @@ class Toolbar {
#bindListeners(buttons) {
const { eventBus } = this;
const { pageNumber, scaleSelect } = this.#opts;
const {
editorHighlightColorPicker,
editorHighlightButton,
pageNumber,
scaleSelect,
} = this.#opts;
const self = this;
// The buttons within the toolbar.
@ -243,6 +224,28 @@ class Toolbar {
"annotationeditormodechanged",
this.#editorModeChanged.bind(this)
);
eventBus._on("showannotationeditorui", ({ mode }) => {
switch (mode) {
case AnnotationEditorType.HIGHLIGHT:
editorHighlightButton.click();
break;
}
});
eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
if (editorHighlightColorPicker) {
eventBus._on(
"annotationeditoruimanager",
({ uiManager }) => {
this.#setAnnotationEditorUIManager(
uiManager,
editorHighlightColorPicker
);
},
// Once the color picker has been added, we don't want to add it again.
{ once: true }
);
}
}
#editorModeChanged({ mode }) {