]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/details-highlighter.js
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / resources / js / components / details-highlighter.js
index 18c5165faf49408e140685d5cc0e0ddceeaead2c..71c2026294917abd63dc8b58ab54e3527eb99469 100644 (file)
@@ -1,18 +1,23 @@
-import Code from "../services/code"
-class DetailsHighlighter {
+import {Component} from './component';
 
-    constructor(elem) {
-        this.elem = elem;
+export class DetailsHighlighter extends Component {
+
+    setup() {
+        this.container = this.$el;
         this.dealtWith = false;
-        elem.addEventListener('toggle', this.onToggle.bind(this));
+
+        this.container.addEventListener('toggle', this.onToggle.bind(this));
     }
 
     onToggle() {
         if (this.dealtWith) return;
 
-        Code.highlightWithin(this.elem);
+        if (this.container.querySelector('pre')) {
+            window.importVersioned('code').then(Code => {
+                Code.highlightWithin(this.container);
+            });
+        }
         this.dealtWith = true;
     }
-}
 
-export default DetailsHighlighter;
\ No newline at end of file
+}