From 8ef06210a6805d04dd267538e9999375c04eb909 Mon Sep 17 00:00:00 2001 From: SquiddyPoos Date: Tue, 19 Sep 2023 07:25:13 +0800 Subject: [PATCH] fix --- .../components/notebookViewer/BlockOutput.vue | 4 +++- .../src/components/notebookViewer/HTMLOutput.vue | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/notebookViewer/BlockOutput.vue b/frontend/src/components/notebookViewer/BlockOutput.vue index ec6a68e..4d1a030 100644 --- a/frontend/src/components/notebookViewer/BlockOutput.vue +++ b/frontend/src/components/notebookViewer/BlockOutput.vue @@ -45,7 +45,9 @@ import Convert from "ansi-to-html"; import HTMLOutput from "@/components/notebookViewer/HTMLOutput.vue"; const convert = new Convert(); -@Component +@Component({ + components: {HTMLOutput} +}) export default class BlockOutput extends Vue { name = "BlockOutput" @Prop(Object) readonly cell!: Cell; diff --git a/frontend/src/components/notebookViewer/HTMLOutput.vue b/frontend/src/components/notebookViewer/HTMLOutput.vue index 76b756f..f682e4c 100644 --- a/frontend/src/components/notebookViewer/HTMLOutput.vue +++ b/frontend/src/components/notebookViewer/HTMLOutput.vue @@ -10,15 +10,23 @@ export default class HTMLOutput extends Vue { name = "HTMLOutput" @Prop(String) readonly html!: string; + createScript(node: HTMLScriptElement) { + var script = document.createElement("script"); + script.text = node.innerHTML; + + for (var i=0; i < node.attributes.length; i++) { + var attr = node.attributes[i]; + script.setAttribute(attr.name, attr.value); + } + return script; + } + recurseDescendants (node: Element) { for (var i = 0; i < node.children.length; i++) { var child = node.children[i]; this.recurseDescendants(child); if (child.tagName === 'SCRIPT') { - console.log(child.innerHTML); - eval?.(child.innerHTML); - child.remove(); - i--; + node.replaceChild(this.createScript(child as HTMLScriptElement), child); } } }