Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify localization of the "default-content" in FreeText editors #18920

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions l10n/en-US/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ pdfjs-editor-free-highlight-thickness-input = Thickness
pdfjs-editor-free-highlight-thickness-title =
.title = Change thickness when highlighting items other than text

pdfjs-free-text =
pdfjs-free-text2 =
Snuffleupagus marked this conversation as resolved.
Show resolved Hide resolved
.aria-label = Text Editor
pdfjs-free-text-default-content = Start typing…
.default-content = Start typing…
pdfjs-ink =
.aria-label = Draw Editor
pdfjs-ink-canvas =
Expand Down
7 changes: 1 addition & 6 deletions src/display/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class AnnotationEditor {
* Initialize the l10n stuff for this type of editor.
* @param {Object} l10n
*/
static initialize(l10n, _uiManager, options) {
static initialize(l10n, _uiManager) {
AnnotationEditor._l10nResizer ||= Object.freeze({
topLeft: "pdfjs-editor-resizer-top-left",
topMiddle: "pdfjs-editor-resizer-top-middle",
Expand All @@ -236,11 +236,6 @@ class AnnotationEditor {
].map(str => [str, l10n.get.bind(l10n, str)]),
]);

if (options?.strings) {
for (const str of options.strings) {
AnnotationEditor._l10nPromise.set(str, l10n.get(str));
}
}
if (AnnotationEditor._borderLineWidth !== -1) {
return;
}
Expand Down
10 changes: 3 additions & 7 deletions src/display/editor/freetext.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ class FreeTextEditor extends AnnotationEditor {

/** @inheritdoc */
static initialize(l10n, uiManager) {
AnnotationEditor.initialize(l10n, uiManager, {
strings: ["pdfjs-free-text-default-content"],
Snuffleupagus marked this conversation as resolved.
Show resolved Hide resolved
});
AnnotationEditor.initialize(l10n, uiManager);
const style = getComputedStyle(document.documentElement);

if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
Expand Down Expand Up @@ -563,12 +561,10 @@ class FreeTextEditor extends AnnotationEditor {
this.editorDiv.className = "internal";

this.editorDiv.setAttribute("id", this.#editorDivId);
this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text");
this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text2");
this.editorDiv.setAttribute("data-l10n-attrs", "default-content");
this.enableEditing();

AnnotationEditor._l10nPromise
.get("pdfjs-free-text-default-content")
.then(msg => this.editorDiv?.setAttribute("default-content", msg));
this.editorDiv.contentEditable = true;

const { style } = this.editorDiv;
Expand Down