mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 07:01:31 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/bugfix/lazy_loading_not_working'
This commit is contained in:
		
						commit
						10e073c658
					
				@ -129,7 +129,7 @@ export async function renderEquation(
 | 
				
			|||||||
			);
 | 
								);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
						// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
				
			||||||
	} else if ( engine === 'katex' ) {
 | 
						} else if ( engine === 'katex' && window.katex !== undefined ) {
 | 
				
			||||||
		selectRenderMode(
 | 
							selectRenderMode(
 | 
				
			||||||
			element,
 | 
								element,
 | 
				
			||||||
			preview,
 | 
								preview,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										49
									
								
								tests/lazyload.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								tests/lazyload.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 | 
				
			||||||
 | 
					import MathUI from '../src/mathui';
 | 
				
			||||||
 | 
					import type { EditorConfig } from '@ckeditor/ckeditor5-core/src/editor/editorconfig';
 | 
				
			||||||
 | 
					import { expect } from 'chai';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe( 'Lazy load', () => {
 | 
				
			||||||
 | 
						let editorElement: HTMLDivElement;
 | 
				
			||||||
 | 
						let editor: ClassicEditor;
 | 
				
			||||||
 | 
						let lazyLoadInvoked: boolean;
 | 
				
			||||||
 | 
						let mathUIFeature: MathUI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						function buildEditor( config: EditorConfig ) {
 | 
				
			||||||
 | 
							return ClassicEditor
 | 
				
			||||||
 | 
								.create( editorElement, {
 | 
				
			||||||
 | 
									...config,
 | 
				
			||||||
 | 
									plugins: [ MathUI ]
 | 
				
			||||||
 | 
								} )
 | 
				
			||||||
 | 
								.then( newEditor => {
 | 
				
			||||||
 | 
									editor = newEditor;
 | 
				
			||||||
 | 
									mathUIFeature = editor.plugins.get( MathUI );
 | 
				
			||||||
 | 
								} );
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						beforeEach( () => {
 | 
				
			||||||
 | 
							editorElement = document.createElement( 'div' );
 | 
				
			||||||
 | 
							document.body.appendChild( editorElement );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							lazyLoadInvoked = false;
 | 
				
			||||||
 | 
						} );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						afterEach( () => {
 | 
				
			||||||
 | 
							editorElement.remove();
 | 
				
			||||||
 | 
							return editor.destroy();
 | 
				
			||||||
 | 
						} );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						it( 'initializes lazy load for KaTeX', async () => {
 | 
				
			||||||
 | 
							await buildEditor( {
 | 
				
			||||||
 | 
								math: {
 | 
				
			||||||
 | 
									engine: 'katex',
 | 
				
			||||||
 | 
									lazyLoad: async () => {
 | 
				
			||||||
 | 
										lazyLoadInvoked = true;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							mathUIFeature._showUI();
 | 
				
			||||||
 | 
							expect( lazyLoadInvoked ).to.be.true;
 | 
				
			||||||
 | 
						} );
 | 
				
			||||||
 | 
					} );
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user