mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	allow ssr with global
Co-authored-by: Austin Buckler <buckleraustin@gmail.com>
This commit is contained in:
		
							parent
							
								
									03d6cb58db
								
							
						
					
					
						commit
						47d3bb7575
					
				| @ -2,8 +2,9 @@ | |||||||
| // maintainable code, while at the same time manually optimizing for tiny minified file size,
 | // maintainable code, while at the same time manually optimizing for tiny minified file size,
 | ||||||
| // browser compatibility without additional requirements
 | // browser compatibility without additional requirements
 | ||||||
| // and very few assumptions about the user's page layout.
 | // and very few assumptions about the user's page layout.
 | ||||||
| const global = window | const global = typeof window !== 'undefined' ? window : null | ||||||
| const { document } = global | const ssr = global === null | ||||||
|  | const document = !ssr ? global.document : undefined | ||||||
| 
 | 
 | ||||||
| // Save a couple long function names that are used frequently.
 | // Save a couple long function names that are used frequently.
 | ||||||
| // This optimization saves around 400 bytes.
 | // This optimization saves around 400 bytes.
 | ||||||
| @ -21,14 +22,16 @@ const NOOP = () => false | |||||||
| //
 | //
 | ||||||
| // Tests -webkit, -moz and -o prefixes. Modified from StackOverflow:
 | // Tests -webkit, -moz and -o prefixes. Modified from StackOverflow:
 | ||||||
| // http://stackoverflow.com/questions/16625140/js-feature-detection-to-detect-the-usage-of-webkit-calc-over-calc/16625167#16625167
 | // http://stackoverflow.com/questions/16625140/js-feature-detection-to-detect-the-usage-of-webkit-calc-over-calc/16625167#16625167
 | ||||||
| const calc = `${['', '-webkit-', '-moz-', '-o-'] | const calc = ssr | ||||||
|     .filter(prefix => { |     ? 'calc' | ||||||
|         const el = document.createElement('div') |     : `${['', '-webkit-', '-moz-', '-o-'] | ||||||
|         el.style.cssText = `width:${prefix}calc(9px)` |           .filter(prefix => { | ||||||
|  |               const el = document.createElement('div') | ||||||
|  |               el.style.cssText = `width:${prefix}calc(9px)` | ||||||
| 
 | 
 | ||||||
|         return !!el.style.length |               return !!el.style.length | ||||||
|     }) |           }) | ||||||
|     .shift()}calc` |           .shift()}calc` | ||||||
| 
 | 
 | ||||||
| // Helper function checks if its argument is a string-like type
 | // Helper function checks if its argument is a string-like type
 | ||||||
| const isString = v => typeof v === 'string' || v instanceof String | const isString = v => typeof v === 'string' || v instanceof String | ||||||
| @ -126,6 +129,8 @@ const defaultGutterStyleFn = (dim, gutSize) => ({ [dim]: `${gutSize}px` }) | |||||||
| //    `pair` object and a gutter.
 | //    `pair` object and a gutter.
 | ||||||
| // 5. Actually size the pair elements, insert gutters and attach event listeners.
 | // 5. Actually size the pair elements, insert gutters and attach event listeners.
 | ||||||
| const Split = (idsOption, options = {}) => { | const Split = (idsOption, options = {}) => { | ||||||
|  |     if (ssr) return {} | ||||||
|  | 
 | ||||||
|     let ids = idsOption |     let ids = idsOption | ||||||
|     let dimension |     let dimension | ||||||
|     let clientAxis |     let clientAxis | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nathan Cahill
						Nathan Cahill