BookStack/resources/js/components/details-highlighter.js

21 lines
491 B
JavaScript
Raw Normal View History

2020-01-16 04:18:02 +08:00
class DetailsHighlighter {
constructor(elem) {
this.elem = elem;
this.dealtWith = false;
elem.addEventListener('toggle', this.onToggle.bind(this));
}
onToggle() {
if (this.dealtWith) return;
if (this.elem.querySelector('pre')) {
window.importVersioned('code').then(Code => {
Code.highlightWithin(this.elem);
});
}
2020-01-16 04:18:02 +08:00
this.dealtWith = true;
}
}
export default DetailsHighlighter;