]> BookStack Code Mirror - bookstack/blob - resources/js/components/details-highlighter.js
Merge branch 'development' of github.com:BookStackApp/BookStack into development
[bookstack] / resources / js / components / details-highlighter.js
1 import {Component} from './component';
2
3 export class DetailsHighlighter extends Component {
4
5     setup() {
6         this.container = this.$el;
7         this.dealtWith = false;
8
9         this.container.addEventListener('toggle', this.onToggle.bind(this));
10     }
11
12     onToggle() {
13         if (this.dealtWith) return;
14
15         if (this.container.querySelector('pre')) {
16             window.importVersioned('code').then(Code => {
17                 Code.highlightWithin(this.container);
18             });
19         }
20         this.dealtWith = true;
21     }
22
23 }