]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/code-highlighter.js
Split out codemirror JS to its own module
[bookstack] / resources / js / components / code-highlighter.js
index db611288701d060e7bfa56fee39567b26b260522..5ffab377525d875f34e02f7be6d65e68dee1c4c3 100644 (file)
@@ -1,8 +1,12 @@
-import Code from "../services/code"
 class CodeHighlighter {
 
     constructor(elem) {
-        Code.highlightWithin(elem);
+        const codeBlocks = elem.querySelectorAll('pre');
+        if (codeBlocks.length > 0) {
+            window.importVersioned('code').then(Code => {
+               Code.highlightWithin(elem);
+            });
+        }
     }
 
 }