mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-05 07:08:14 +08:00
client: Remove syntax highlight in preview when disabled
This commit is contained in:
parent
f57ab4b9f0
commit
c3e10b2b76
@ -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");
|
||||||
library_loader
|
}
|
||||||
.requireLibrary(library_loader.HIGHLIGHT_JS)
|
|
||||||
.then(() => {
|
#setupPreview(shouldEnableSyntaxHighlight) {
|
||||||
const highlightedText = hljs.highlight(SAMPLE_CODE, {
|
const text = SAMPLE_CODE;
|
||||||
language: SAMPLE_LANGUAGE
|
if (shouldEnableSyntaxHighlight) {
|
||||||
|
library_loader
|
||||||
|
.requireLibrary(library_loader.HIGHLIGHT_JS)
|
||||||
|
.then(() => {
|
||||||
|
const highlightedText = hljs.highlight(text, {
|
||||||
|
language: SAMPLE_LANGUAGE
|
||||||
|
});
|
||||||
|
this.$sampleEl.html(highlightedText.value);
|
||||||
});
|
});
|
||||||
sampleEl.html(highlightedText.value);
|
} else {
|
||||||
});
|
this.$sampleEl.text(text);
|
||||||
this.$sampleWrapper = this.$widget.find(".note-detail-readonly-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");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user