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); } } }