2023-04-19 05:20:02 +08:00
|
|
|
import {Component} from './component';
|
2020-01-16 04:18:02 +08:00
|
|
|
|
2022-11-15 19:24:31 +08:00
|
|
|
export class DetailsHighlighter extends Component {
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
this.container = this.$el;
|
2020-01-16 04:18:02 +08:00
|
|
|
this.dealtWith = false;
|
2022-11-15 19:24:31 +08:00
|
|
|
|
|
|
|
this.container.addEventListener('toggle', this.onToggle.bind(this));
|
2020-01-16 04:18:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
onToggle() {
|
|
|
|
if (this.dealtWith) return;
|
|
|
|
|
2022-11-15 19:24:31 +08:00
|
|
|
if (this.container.querySelector('pre')) {
|
2022-02-08 19:10:01 +08:00
|
|
|
window.importVersioned('code').then(Code => {
|
2022-11-15 19:24:31 +08:00
|
|
|
Code.highlightWithin(this.container);
|
2022-02-08 19:10:01 +08:00
|
|
|
});
|
|
|
|
}
|
2020-01-16 04:18:02 +08:00
|
|
|
this.dealtWith = true;
|
|
|
|
}
|
2023-04-19 05:20:02 +08:00
|
|
|
|
|
|
|
}
|