1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

[Editor] Init the default highlight color before creating the first editor instance

We want to be able to draw an highlight with the default color but without having an
instance of the HighlightEditor.
This commit is contained in:
Calixte Denizet 2024-01-05 10:10:01 +01:00
parent 130a0fef3d
commit 17e1519410
10 changed files with 89 additions and 15 deletions

View file

@ -110,7 +110,7 @@ class AnnotationEditorLayer {
if (!AnnotationEditorLayer._initialized) {
AnnotationEditorLayer._initialized = true;
for (const editorType of editorTypes) {
editorType.initialize(l10n);
editorType.initialize(l10n, uiManager);
}
}
uiManager.registerEditorTypes(editorTypes);

View file

@ -185,7 +185,7 @@ class AnnotationEditor {
* Initialize the l10n stuff for this type of editor.
* @param {Object} l10n
*/
static initialize(l10n, options = null) {
static initialize(l10n, _uiManager, options) {
AnnotationEditor._l10nPromise ||= new Map(
[
"pdfjs-editor-alt-text-button-label",

View file

@ -144,8 +144,8 @@ class FreeTextEditor extends AnnotationEditor {
}
/** @inheritdoc */
static initialize(l10n) {
AnnotationEditor.initialize(l10n, {
static initialize(l10n, uiManager) {
AnnotationEditor.initialize(l10n, uiManager, {
strings: ["pdfjs-free-text-default-content"],
});
const style = getComputedStyle(document.documentElement);

View file

@ -59,8 +59,6 @@ class HighlightEditor extends AnnotationEditor {
constructor(params) {
super({ ...params, name: "highlightEditor" });
HighlightEditor._defaultColor ||=
this._uiManager.highlightColors?.values().next().value || "#fff066";
this.color = params.color || HighlightEditor._defaultColor;
this.#opacity = params.opacity || HighlightEditor._defaultOpacity;
this.#boxes = params.boxes || null;
@ -97,8 +95,10 @@ class HighlightEditor extends AnnotationEditor {
];
}
static initialize(l10n) {
AnnotationEditor.initialize(l10n);
static initialize(l10n, uiManager) {
AnnotationEditor.initialize(l10n, uiManager);
HighlightEditor._defaultColor ||=
uiManager.highlightColors?.values().next().value || "#fff066";
}
static updateDefaultParams(type, value) {

View file

@ -84,8 +84,8 @@ class InkEditor extends AnnotationEditor {
}
/** @inheritdoc */
static initialize(l10n) {
AnnotationEditor.initialize(l10n);
static initialize(l10n, uiManager) {
AnnotationEditor.initialize(l10n, uiManager);
}
/** @inheritdoc */

View file

@ -55,8 +55,8 @@ class StampEditor extends AnnotationEditor {
}
/** @inheritdoc */
static initialize(l10n) {
AnnotationEditor.initialize(l10n);
static initialize(l10n, uiManager) {
AnnotationEditor.initialize(l10n, uiManager);
}
static get supportedTypes() {