Skip to content

Commit

Permalink
[Editor] Remove use of innerHtml
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman authored and rousek committed Aug 10, 2022
1 parent 3349595 commit fca82b7
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 fca82b7

Please sign in to comment.