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