]> BookStack Code Mirror - bookstack/blob - resources/js/components/details-highlighter.js
1f3b66c674c2c882b7f1d71b4fcb79867c06dcfe
[bookstack] / resources / js / components / details-highlighter.js
1 class DetailsHighlighter {
2
3     constructor(elem) {
4         this.elem = elem;
5         this.dealtWith = false;
6         elem.addEventListener('toggle', this.onToggle.bind(this));
7     }
8
9     onToggle() {
10         if (this.dealtWith) return;
11
12         if (this.elem.querySelector('pre')) {
13             window.importVersioned('code').then(Code => {
14                 Code.highlightWithin(this.elem);
15             });
16         }
17         this.dealtWith = true;
18     }
19 }
20
21 export default DetailsHighlighter;