mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	client: Enable syntax highlight for read-only notes
This commit is contained in:
		| @@ -90,6 +90,7 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget { | |||||||
|         // we could load just ckeditor-content.css but that causes CSS conflicts when both build CSS and this content CSS is loaded at the same time |         // we could load just ckeditor-content.css but that causes CSS conflicts when both build CSS and this content CSS is loaded at the same time | ||||||
|         // (see https://github.com/zadam/trilium/issues/1590 for example of such conflict) |         // (see https://github.com/zadam/trilium/issues/1590 for example of such conflict) | ||||||
|         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); |         await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); | ||||||
|  |         await libraryLoader.requireLibrary(libraryLoader.HIGHLIGHT_JS); | ||||||
|  |  | ||||||
|         const blob = await note.getBlob(); |         const blob = await note.getBlob(); | ||||||
|  |  | ||||||
| @@ -110,6 +111,14 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget { | |||||||
|  |  | ||||||
|             renderMathInElement(this.$content[0], {trust: true}); |             renderMathInElement(this.$content[0], {trust: true}); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         // Enable syntax highlight | ||||||
|  |         const codeBlocks = this.$content.find("pre code"); | ||||||
|  |         for (const codeBlock of codeBlocks) { | ||||||
|  |             const text = codeBlock.innerText; | ||||||
|  |             const highlightedText = hljs.highlightAuto(text).value; | ||||||
|  |             codeBlock.innerHTML = highlightedText; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     async refreshIncludedNoteEvent({noteId}) { |     async refreshIncludedNoteEvent({noteId}) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user