X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c6ad16dba657c82512ae495a4a38b99b8cfa9eeb..refs/pull/3994/head:/resources/js/components/details-highlighter.js diff --git a/resources/js/components/details-highlighter.js b/resources/js/components/details-highlighter.js index 1f3b66c67..6466fb584 100644 --- a/resources/js/components/details-highlighter.js +++ b/resources/js/components/details-highlighter.js @@ -1,21 +1,22 @@ -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; - if (this.elem.querySelector('pre')) { + if (this.container.querySelector('pre')) { window.importVersioned('code').then(Code => { - Code.highlightWithin(this.elem); + Code.highlightWithin(this.container); }); } this.dealtWith = true; } -} - -export default DetailsHighlighter; \ No newline at end of file +} \ No newline at end of file