Skip to content

Commit

Permalink
Merge pull request #15287 from calixteman/inserthtml
Browse files Browse the repository at this point in the history
[Editor] Remove use of innerHtml
  • Loading branch information
Snuffleupagus authored Aug 7, 2022
2 parents 2363fc0 + 5e0ddfb commit 40f9f7e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/display/editor/freetext.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class FreeTextEditor extends AnnotationEditor {

#content = "";

#contentHTML = "";

#hasAlreadyBeenCommitted = false;

#fontSize;
Expand Down Expand Up @@ -333,7 +331,6 @@ class FreeTextEditor extends AnnotationEditor {
}

this.disableEditMode();
this.#contentHTML = this.editorDiv.innerHTML;
this.#content = this.#extractText().trimEnd();

this.#setEditorDimensions();
Expand Down Expand Up @@ -445,8 +442,15 @@ class FreeTextEditor extends AnnotationEditor {
this.width * parentWidth,
this.height * parentHeight
);
// eslint-disable-next-line no-unsanitized/property
this.editorDiv.innerHTML = this.#contentHTML;

for (const line of this.#content.split("\n")) {
const div = document.createElement("div");
div.append(
line ? document.createTextNode(line) : document.createElement("br")
);
this.editorDiv.append(div);
}

this.div.draggable = true;
this.editorDiv.contentEditable = false;
} else {
Expand All @@ -468,10 +472,6 @@ class FreeTextEditor extends AnnotationEditor {
editor.#fontSize = data.fontSize;
editor.#color = Util.makeHexColor(...data.color);
editor.#content = data.value;
editor.#contentHTML = data.value
.split("\n")
.map(line => `<div>${line}</div>`)
.join("");

return editor;
}
Expand Down

0 comments on commit 40f9f7e

Please sign in to comment.