mirror of
				https://github.com/BookStackApp/BookStack.git
				synced 2025-11-03 02:13:16 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			491 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			491 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
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);
 | 
						|
            });
 | 
						|
        }
 | 
						|
        this.dealtWith = true;
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
export default DetailsHighlighter; |