]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/code-highlighter.js
Updated a batch of JS components
[bookstack] / resources / js / components / code-highlighter.js
index db611288701d060e7bfa56fee39567b26b260522..14bfc97f04ed5358b2758112e9cf3f06d47ae423 100644 (file)
@@ -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