mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-01 05:21:32 +08:00 
			
		
		
		
	Set up highlight.js
This commit is contained in:
		
							parent
							
								
									88cd2ac25c
								
							
						
					
					
						commit
						c81b847b61
					
				
							
								
								
									
										9
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										9
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -12,6 +12,7 @@ | |||||||
|         "@braintree/sanitize-url": "7.1.0", |         "@braintree/sanitize-url": "7.1.0", | ||||||
|         "@electron/remote": "2.1.2", |         "@electron/remote": "2.1.2", | ||||||
|         "@excalidraw/excalidraw": "0.17.6", |         "@excalidraw/excalidraw": "0.17.6", | ||||||
|  |         "@highlightjs/cdn-assets": "11.10.0", | ||||||
|         "archiver": "7.0.1", |         "archiver": "7.0.1", | ||||||
|         "async-mutex": "0.5.0", |         "async-mutex": "0.5.0", | ||||||
|         "autocomplete.js": "0.38.1", |         "autocomplete.js": "0.38.1", | ||||||
| @ -2445,6 +2446,14 @@ | |||||||
|       "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", |       "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/@highlightjs/cdn-assets": { | ||||||
|  |       "version": "11.10.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/@highlightjs/cdn-assets/-/cdn-assets-11.10.0.tgz", | ||||||
|  |       "integrity": "sha512-vWXpu+Rdm0YMJmugFdUiL/9DmgYjEiV+d5DBqlXdApnGPSIeo6+LRS5Hpx6fvVsKkvR4RsLYD9rQ6DOLkj7OKA==", | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=12.0.0" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/@humanwhocodes/module-importer": { |     "node_modules/@humanwhocodes/module-importer": { | ||||||
|       "version": "1.0.1", |       "version": "1.0.1", | ||||||
|       "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", |       "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", | ||||||
|  | |||||||
| @ -52,6 +52,7 @@ | |||||||
|     "@braintree/sanitize-url": "7.1.0", |     "@braintree/sanitize-url": "7.1.0", | ||||||
|     "@electron/remote": "2.1.2", |     "@electron/remote": "2.1.2", | ||||||
|     "@excalidraw/excalidraw": "0.17.6", |     "@excalidraw/excalidraw": "0.17.6", | ||||||
|  |     "@highlightjs/cdn-assets": "11.10.0", | ||||||
|     "archiver": "7.0.1", |     "archiver": "7.0.1", | ||||||
|     "async-mutex": "0.5.0", |     "async-mutex": "0.5.0", | ||||||
|     "autocomplete.js": "0.38.1", |     "autocomplete.js": "0.38.1", | ||||||
|  | |||||||
| @ -84,6 +84,11 @@ const MIND_ELIXIR = { | |||||||
|     ] |     ] | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | const HIGHLIGHT_JS = { | ||||||
|  |     js: [ "node_modules/@highlightjs/cdn-assets/highlight.min.js" ], | ||||||
|  |     css: [ "node_modules/@highlightjs/cdn-assets/styles/atom-one-dark.css" ] | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| async function requireLibrary(library) { | async function requireLibrary(library) { | ||||||
|     if (library.css) { |     if (library.css) { | ||||||
|         library.css.map(cssUrl => requireCss(cssUrl)); |         library.css.map(cssUrl => requireCss(cssUrl)); | ||||||
| @ -143,5 +148,6 @@ export default { | |||||||
|     EXCALIDRAW, |     EXCALIDRAW, | ||||||
|     MARKJS, |     MARKJS, | ||||||
|     I18NEXT, |     I18NEXT, | ||||||
|     MIND_ELIXIR |     MIND_ELIXIR, | ||||||
|  |     HIGHLIGHT_JS | ||||||
| } | } | ||||||
|  | |||||||
| @ -105,6 +105,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { | |||||||
| 
 | 
 | ||||||
|     async initEditor() { |     async initEditor() { | ||||||
|         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); |         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); | ||||||
|  |         await libraryLoader.requireLibrary(libraryLoader.HIGHLIGHT_JS); | ||||||
| 
 | 
 | ||||||
|         const codeBlockLanguages = |         const codeBlockLanguages = | ||||||
|             (await mimeTypesService.getMimeTypes()) |             (await mimeTypesService.getMimeTypes()) | ||||||
|  | |||||||
| @ -102,6 +102,7 @@ function register(app: express.Application) { | |||||||
|     app.use(`/${assetPath}/node_modules/codemirror/keymap/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/codemirror/keymap/'))); |     app.use(`/${assetPath}/node_modules/codemirror/keymap/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/codemirror/keymap/'))); | ||||||
| 
 | 
 | ||||||
|     app.use(`/${assetPath}/node_modules/mind-elixir/dist/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/mind-elixir/dist/"))); |     app.use(`/${assetPath}/node_modules/mind-elixir/dist/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/mind-elixir/dist/"))); | ||||||
|  |     app.use(`/${assetPath}/node_modules/@highlightjs/cdn-assets/`, persistentCacheStatic(path.join(srcRoot, "..", "node_modules/@highlightjs/cdn-assets/"))); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default { | export default { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran