mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	client: Remove syntax highlight in preview when disabled
This commit is contained in:
		| @@ -71,16 +71,23 @@ export default class CodeBlockOptions extends OptionsWidget { | |||||||
|         this.$wordWrap.on("change", () => this.updateCheckboxOption("codeBlockWordWrap", this.$wordWrap)); |         this.$wordWrap.on("change", () => this.updateCheckboxOption("codeBlockWordWrap", this.$wordWrap)); | ||||||
|  |  | ||||||
|         // Set up preview |         // Set up preview | ||||||
|         const sampleEl = this.$widget.find(".code-sample"); |         this.$sampleEl = this.$widget.find(".code-sample");         | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     #setupPreview(shouldEnableSyntaxHighlight) { | ||||||
|  |         const text = SAMPLE_CODE; | ||||||
|  |         if (shouldEnableSyntaxHighlight) { | ||||||
|             library_loader |             library_loader | ||||||
|                 .requireLibrary(library_loader.HIGHLIGHT_JS) |                 .requireLibrary(library_loader.HIGHLIGHT_JS) | ||||||
|                 .then(() => { |                 .then(() => { | ||||||
|                 const highlightedText = hljs.highlight(SAMPLE_CODE, { |                     const highlightedText = hljs.highlight(text, { | ||||||
|                         language: SAMPLE_LANGUAGE |                         language: SAMPLE_LANGUAGE | ||||||
|                     }); |                     }); | ||||||
|                 sampleEl.html(highlightedText.value); |                     this.$sampleEl.html(highlightedText.value); | ||||||
|                 }); |                 }); | ||||||
|         this.$sampleWrapper = this.$widget.find(".note-detail-readonly-text"); |         } else { | ||||||
|  |             this.$sampleEl.text(text); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     async optionsLoaded(options) { |     async optionsLoaded(options) { | ||||||
| @@ -106,5 +113,7 @@ export default class CodeBlockOptions extends OptionsWidget { | |||||||
|         this.$themeSelect.val(options.codeBlockTheme); |         this.$themeSelect.val(options.codeBlockTheme); | ||||||
|         this.setCheckboxState(this.$wordWrap, options.codeBlockWordWrap); |         this.setCheckboxState(this.$wordWrap, options.codeBlockWordWrap); | ||||||
|         this.$widget.closest(".note-detail-printable").toggleClass("word-wrap", options.codeBlockWordWrap === "true"); |         this.$widget.closest(".note-detail-printable").toggleClass("word-wrap", options.codeBlockWordWrap === "true"); | ||||||
|  |  | ||||||
|  |         this.#setupPreview(options.codeBlockTheme !== "none"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user