Skip to content

Commit 312f2b0

Browse files
committed
PB-284: Improve live edit
1 parent 3233a56 commit 312f2b0

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/binding/live-edit.js

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/binding/live-edit.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ import {DataObject} from "../data-store";
1818
* @returns {string}
1919
*/
2020
function stripHtml(html: string) {
21-
const tempDiv = document.createElement("div");
21+
const tempDiv = new DOMParser().parseFromString(html, "text/html");
2222

23-
tempDiv.innerHTML = html;
24-
return tempDiv.textContent;
23+
return tempDiv.body.textContent;
2524
}
2625

2726
/**
@@ -171,7 +170,7 @@ ko.bindingHandlers.liveEdit = {
171170
_.defer(() => {
172171
const strippedValue = stripHtml(element.innerHTML);
173172
lastUpdateValue = strippedValue;
174-
element.innerHTML = strippedValue;
173+
element.textContent = strippedValue;
175174
/**
176175
* Calculate the position the caret should end up at, the difference in string length + the original
177176
* end offset position

0 commit comments

Comments
 (0)