Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
squi-ddy committed Sep 18, 2023
1 parent 800c503 commit 8ef0621
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion frontend/src/components/notebookViewer/BlockOutput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/components/notebookViewer/HTMLOutput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 8ef0621

Please sign in to comment.