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

[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.
This commit is contained in:
Calixte Denizet 2022-06-29 18:09:32 +02:00
parent 2e83fa8e2d
commit a694e360a4
4 changed files with 27 additions and 1 deletions

View file

@ -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

View file

@ -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;

View file

@ -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