mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	fix(build): remove usage of global
This commit is contained in:
		| @@ -35,7 +35,7 @@ export default class AutoformatMath extends Plugin { | ||||
| 				command.display = true; | ||||
|  | ||||
| 				// Wait until selection is removed. | ||||
| 				global.window.setTimeout( | ||||
| 				window.setTimeout( | ||||
| 					() => { | ||||
| 						const mathUIInstance = editor.plugins.get( 'MathUI' ); | ||||
| 						if ( mathUIInstance instanceof MathUI ) { | ||||
|   | ||||
| @@ -57,7 +57,7 @@ export default class AutoMath extends Plugin { | ||||
|  | ||||
| 		editor.commands.get( 'undo' )?.on( 'execute', () => { | ||||
| 			if ( this._timeoutId ) { | ||||
| 				global.window.clearTimeout( this._timeoutId ); | ||||
| 				window.clearTimeout( this._timeoutId ); | ||||
| 				this._positionToInsert?.detach(); | ||||
|  | ||||
| 				this._timeoutId = null; | ||||
| @@ -104,7 +104,7 @@ export default class AutoMath extends Plugin { | ||||
| 		this._positionToInsert = LivePosition.fromPosition( leftPosition ); | ||||
|  | ||||
| 		// With timeout user can undo conversation if want use plain text | ||||
| 		this._timeoutId = global.window.setTimeout( () => { | ||||
| 		this._timeoutId = window.setTimeout( () => { | ||||
| 			editor.model.change( writer => { | ||||
| 				this._timeoutId = null; | ||||
|  | ||||
|   | ||||
| @@ -44,7 +44,7 @@ export default class MathUI extends Plugin { | ||||
| 		this.formView?.destroy(); | ||||
|  | ||||
| 		// Destroy preview element | ||||
| 		const previewEl = global.document.getElementById( this._previewUid ); | ||||
| 		const previewEl = document.getElementById( this._previewUid ); | ||||
| 		if ( previewEl ) { | ||||
| 			previewEl.parentNode?.removeChild( previewEl ); | ||||
| 		} | ||||
| @@ -149,7 +149,7 @@ export default class MathUI extends Plugin { | ||||
| 		} | ||||
|  | ||||
| 		// Show preview element | ||||
| 		const previewEl = global.document.getElementById( this._previewUid ); | ||||
| 		const previewEl = document.getElementById( this._previewUid ); | ||||
| 		if ( previewEl && this.formView.previewEnabled ) { | ||||
| 			// Force refresh preview | ||||
| 			this.formView.mathView?.updateMath(); | ||||
| @@ -194,7 +194,7 @@ export default class MathUI extends Plugin { | ||||
| 			this._balloon.remove( this.formView ); | ||||
|  | ||||
| 			// Hide preview element | ||||
| 			const previewEl = global.document.getElementById( this._previewUid ); | ||||
| 			const previewEl = document.getElementById( this._previewUid ); | ||||
| 			if ( previewEl ) { | ||||
| 				previewEl.style.visibility = 'hidden'; | ||||
| 			} | ||||
|   | ||||
							
								
								
									
										22
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/utils.ts
									
									
									
									
									
								
							| @@ -113,7 +113,7 @@ export async function renderEquation( | ||||
| 				previewClassName, | ||||
| 				el => { | ||||
| 					// Fixme: MathJax typesetting cause occasionally math processing error without asynchronous call | ||||
| 					global.window.setTimeout( () => { | ||||
| 					window.setTimeout( () => { | ||||
| 						renderMathJax2( equation, el, display ); | ||||
|  | ||||
| 						// Move and scale after rendering | ||||
| @@ -154,9 +154,9 @@ export async function renderEquation( | ||||
| 	} else { | ||||
| 		if ( lazyLoad != null ) { | ||||
| 			try { | ||||
| 				global.window.CKEDITOR_MATH_LAZY_LOAD ??= lazyLoad(); | ||||
| 				window.CKEDITOR_MATH_LAZY_LOAD ??= lazyLoad(); | ||||
| 				element.innerHTML = equation; | ||||
| 				await global.window.CKEDITOR_MATH_LAZY_LOAD; | ||||
| 				await window.CKEDITOR_MATH_LAZY_LOAD; | ||||
| 				await renderEquation( | ||||
| 					equation, | ||||
| 					element, | ||||
| @@ -293,20 +293,20 @@ function getPreviewElement( | ||||
| 	previewUid: string, | ||||
| 	previewClassName: Array<string> | ||||
| ) { | ||||
| 	let previewEl = global.document.getElementById( previewUid ); | ||||
| 	let previewEl = document.getElementById( previewUid ); | ||||
| 	// Create if not found | ||||
| 	if ( !previewEl ) { | ||||
| 		previewEl = global.document.createElement( 'div' ); | ||||
| 		previewEl = document.createElement( 'div' ); | ||||
| 		previewEl.setAttribute( 'id', previewUid ); | ||||
| 		previewEl.classList.add( ...previewClassName ); | ||||
| 		previewEl.style.visibility = 'hidden'; | ||||
| 		global.document.body.appendChild( previewEl ); | ||||
| 		document.body.appendChild( previewEl ); | ||||
|  | ||||
| 		let ticking = false; | ||||
|  | ||||
| 		const renderTransformation = () => { | ||||
| 			if ( !ticking ) { | ||||
| 				global.window.requestAnimationFrame( () => { | ||||
| 				window.requestAnimationFrame( () => { | ||||
| 					if ( previewEl ) { | ||||
| 						moveElement( element, previewEl ); | ||||
| 						ticking = false; | ||||
| @@ -318,8 +318,8 @@ function getPreviewElement( | ||||
| 		}; | ||||
|  | ||||
| 		// Create scroll listener for following | ||||
| 		global.window.addEventListener( 'resize', renderTransformation ); | ||||
| 		global.window.addEventListener( 'scroll', renderTransformation ); | ||||
| 		window.addEventListener( 'resize', renderTransformation ); | ||||
| 		window.addEventListener( 'scroll', renderTransformation ); | ||||
| 	} | ||||
| 	return previewEl; | ||||
| } | ||||
| @@ -336,8 +336,8 @@ function moveAndScaleElement( parent: HTMLElement, child: HTMLElement ) { | ||||
|  | ||||
| function moveElement( parent: HTMLElement, child: HTMLElement ) { | ||||
| 	const domRect = parent.getBoundingClientRect(); | ||||
| 	const left = global.window.scrollX + domRect.left; | ||||
| 	const top = global.window.scrollY + domRect.top; | ||||
| 	const left = window.scrollX + domRect.left; | ||||
| 	const top = window.scrollY + domRect.top; | ||||
| 	child.style.position = 'absolute'; | ||||
| 	child.style.left = left + 'px'; | ||||
| 	child.style.top = top + 'px'; | ||||
|   | ||||
| @@ -14,8 +14,8 @@ describe( 'AutoMath - integration', () => { | ||||
| 	let editorElement: HTMLDivElement, editor: ClassicEditor; | ||||
|  | ||||
| 	beforeEach( async () => { | ||||
| 		editorElement = global.document.createElement( 'div' ); | ||||
| 		global.document.body.appendChild( editorElement ); | ||||
| 		editorElement = document.createElement( 'div' ); | ||||
| 		document.body.appendChild( editorElement ); | ||||
|  | ||||
| 		return ClassicEditor | ||||
| 			.create( editorElement, { | ||||
|   | ||||
| @@ -11,8 +11,8 @@ describe( 'Math', () => { | ||||
| 	let editorElement: HTMLDivElement, editor: ClassicEditor; | ||||
|  | ||||
| 	beforeEach( async () => { | ||||
| 		editorElement = global.document.createElement( 'div' ); | ||||
| 		global.document.body.appendChild( editorElement ); | ||||
| 		editorElement = document.createElement( 'div' ); | ||||
| 		document.body.appendChild( editorElement ); | ||||
|  | ||||
| 		return ClassicEditor | ||||
| 			.create( editorElement, { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user