Skip to content

Commit 746711e

Browse files
authored
feat: support html as string in content property in Editortabs (#1309)
1 parent 71d2fef commit 746711e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/editorFile.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Sidebar from "components/sidebar";
22
import tile from "components/tile";
33
import confirm from "dialogs/confirm";
4+
import DOMPurify from "dompurify";
45
import fsOperation from "fileSystem";
56
import startDrag from "handlers/editorFileTab";
67
import tag from "html-tag-js";
@@ -244,7 +245,12 @@ export default class EditorFile {
244245
const content = tag("div", {
245246
className: "tab-page-content",
246247
});
247-
content.appendChild(options.content);
248+
249+
if (typeof options.content === "string") {
250+
content.innerHTML = DOMPurify.sanitize(options.content);
251+
} else {
252+
content.appendChild(options.content);
253+
}
248254

249255
// Append content container to shadow DOM
250256
shadow.appendChild(content);

0 commit comments

Comments
 (0)