Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client,server: Allow disabling syntax highlight
Elian Doranac132917440d
diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.jsindex 1aa0804230..34ef689956 100644--- a/src/public/app/widgets/type_widgets/editable_text.js+++ b/src/public/app/widgets/type_widgets/editable_text.js@@ -11,6 +11,7 @@ import link from "../../services/link.js";import appContext from "../../components/app_context.js";import dialogService from "../../services/dialog.js";import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js";+import options from "../../services/options.js";const ENABLE_INSPECTOR = false;@@ -169,7 +170,10 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {this.watchdog.setCreator(async (elementOrData, editorConfig) => {const editor = await BalloonEditor.create(elementOrData, editorConfig);- initSyntaxHighlighting(editor);++ if (options.get("codeBlockTheme") !== "none") {+ initSyntaxHighlighting(editor);+ }editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());diff --git a/src/services/code_block_theme.ts b/src/services/code_block_theme.tsindex 661041d311..e415378728 100644--- a/src/services/code_block_theme.ts+++ b/src/services/code_block_theme.ts@@ -1,9 +1,10 @@import fs from "fs";import themeNames from "./code_block_theme_names.json" assert { type: "json" }+import { t } from "i18next";export function listSyntaxHighlightingThemes() {const path = "node_modules/@highlightjs/cdn-assets/styles";- const allThemes = fs+ const systemThemes = fs.readdirSync(path).filter((el) => el.endsWith(".min.css")).map((name) => {@@ -19,5 +20,11 @@ export function listSyntaxHighlightingThemes() {title: title};});- return allThemes;+ return [+ {+ val: "none",+ title: t("code_block.theme_none")+ },+ ...systemThemes+ ];}\ No newline at end of filediff --git a/translations/en/server.json b/translations/en/server.jsonindex 069094f280..c5cb1c4f5e 100644--- a/translations/en/server.json+++ b/translations/en/server.json@@ -183,5 +183,8 @@},"special_notes": {"search_prefix": "Search:"+ },+ "code_block": {+ "theme_none": "None"}}diff --git a/translations/ro/server.json b/translations/ro/server.jsonindex 5fd329a80c..7235ed4fa0 100644--- a/translations/ro/server.json+++ b/translations/ro/server.json@@ -183,5 +183,8 @@},"special_notes": {"search_prefix": "Căutare:"+ },+ "code_block": {+ "theme_none": "Niciuna"}}