Merge pull request #21263 from Snuffleupagus/editor-_l10nAlert

[Editor] Avoid "generating" the l10n-ids used for the `a11yAlert`
This commit is contained in:
calixteman 2026-05-12 22:07:54 +02:00 committed by GitHub
commit 0e0f7b7696
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 5 deletions

View File

@ -113,7 +113,7 @@ class DrawingEditor extends AnnotationEditor {
this.#drawOutlines = drawOutlines;
this._drawingOptions ||= drawingOptions;
if (!this.annotationElementId) {
this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`);
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert[this.editorType]);
}
if (drawId >= 0) {

View File

@ -109,6 +109,8 @@ class AnnotationEditor {
static _l10n = null;
static _l10nAlert = null;
static _l10nResizer = null;
#isDraggable = false;
@ -247,7 +249,15 @@ class AnnotationEditor {
static initialize(l10n, _uiManager) {
AnnotationEditor._l10n ??= l10n;
AnnotationEditor._l10nResizer ||= Object.freeze({
AnnotationEditor._l10nAlert ??= Object.freeze({
highlight: "pdfjs-editor-highlight-added-alert",
freetext: "pdfjs-editor-freetext-added-alert",
ink: "pdfjs-editor-ink-added-alert",
stamp: "pdfjs-editor-stamp-added-alert",
signature: "pdfjs-editor-signature-added-alert",
});
AnnotationEditor._l10nResizer ??= Object.freeze({
topLeft: "pdfjs-editor-resizer-top-left",
topMiddle: "pdfjs-editor-resizer-top-middle",
topRight: "pdfjs-editor-resizer-top-right",

View File

@ -133,7 +133,7 @@ class FreeTextEditor extends AnnotationEditor {
AnnotationEditor._defaultLineColor;
this.#fontSize = params.fontSize || FreeTextEditor._defaultFontSize;
if (!this.annotationElementId) {
this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert");
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.freetext);
}
this.canAddComment = false;
}

View File

@ -128,7 +128,7 @@ class HighlightEditor extends AnnotationEditor {
}
if (!this.annotationElementId) {
this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert");
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.highlight);
}
}

View File

@ -483,7 +483,7 @@ class StampEditor extends AnnotationEditor {
this.div.setAttribute("aria-description", this.#bitmapFileName);
}
if (!this.annotationElementId) {
this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert");
this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.stamp);
}
}