Skip to content

Commit 0e0f7b7

Browse files
authored
Merge pull request #21263 from Snuffleupagus/editor-_l10nAlert
[Editor] Avoid "generating" the l10n-ids used for the `a11yAlert`
2 parents 10abe66 + 4072d3f commit 0e0f7b7

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/display/editor/draw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class DrawingEditor extends AnnotationEditor {
113113
this.#drawOutlines = drawOutlines;
114114
this._drawingOptions ||= drawingOptions;
115115
if (!this.annotationElementId) {
116-
this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`);
116+
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert[this.editorType]);
117117
}
118118

119119
if (drawId >= 0) {

src/display/editor/editor.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ class AnnotationEditor {
109109

110110
static _l10n = null;
111111

112+
static _l10nAlert = null;
113+
112114
static _l10nResizer = null;
113115

114116
#isDraggable = false;
@@ -247,7 +249,15 @@ class AnnotationEditor {
247249
static initialize(l10n, _uiManager) {
248250
AnnotationEditor._l10n ??= l10n;
249251

250-
AnnotationEditor._l10nResizer ||= Object.freeze({
252+
AnnotationEditor._l10nAlert ??= Object.freeze({
253+
highlight: "pdfjs-editor-highlight-added-alert",
254+
freetext: "pdfjs-editor-freetext-added-alert",
255+
ink: "pdfjs-editor-ink-added-alert",
256+
stamp: "pdfjs-editor-stamp-added-alert",
257+
signature: "pdfjs-editor-signature-added-alert",
258+
});
259+
260+
AnnotationEditor._l10nResizer ??= Object.freeze({
251261
topLeft: "pdfjs-editor-resizer-top-left",
252262
topMiddle: "pdfjs-editor-resizer-top-middle",
253263
topRight: "pdfjs-editor-resizer-top-right",

src/display/editor/freetext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class FreeTextEditor extends AnnotationEditor {
133133
AnnotationEditor._defaultLineColor;
134134
this.#fontSize = params.fontSize || FreeTextEditor._defaultFontSize;
135135
if (!this.annotationElementId) {
136-
this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert");
136+
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.freetext);
137137
}
138138
this.canAddComment = false;
139139
}

src/display/editor/highlight.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class HighlightEditor extends AnnotationEditor {
128128
}
129129

130130
if (!this.annotationElementId) {
131-
this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert");
131+
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.highlight);
132132
}
133133
}
134134

src/display/editor/stamp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class StampEditor extends AnnotationEditor {
483483
this.div.setAttribute("aria-description", this.#bitmapFileName);
484484
}
485485
if (!this.annotationElementId) {
486-
this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert");
486+
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.stamp);
487487
}
488488
}
489489

0 commit comments

Comments
 (0)