X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/82a8db373961d89ab1c9a3736ba5fc467fe2e03d..refs/pull/3908/head:/resources/js/components/code-highlighter.js diff --git a/resources/js/components/code-highlighter.js b/resources/js/components/code-highlighter.js index db6112887..14bfc97f0 100644 --- a/resources/js/components/code-highlighter.js +++ b/resources/js/components/code-highlighter.js @@ -1,10 +1,16 @@ -import Code from "../services/code" -class CodeHighlighter { +import {Component} from "./component"; - constructor(elem) { - Code.highlightWithin(elem); - } +export class CodeHighlighter extends Component{ + + setup() { + const container = this.$el; -} + const codeBlocks = container.querySelectorAll('pre'); + if (codeBlocks.length > 0) { + window.importVersioned('code').then(Code => { + Code.highlightWithin(container); + }); + } + } -export default CodeHighlighter; \ No newline at end of file +} \ No newline at end of file