mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-18 17:31:53 +08:00
client,server: Allow disabling syntax highlight
This commit is contained in:
parent
bbc038f254
commit
ac13291744
@ -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());
|
||||
|
||||
|
@ -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
|
||||
];
|
||||
}
|
@ -183,5 +183,8 @@
|
||||
},
|
||||
"special_notes": {
|
||||
"search_prefix": "Search:"
|
||||
},
|
||||
"code_block": {
|
||||
"theme_none": "None"
|
||||
}
|
||||
}
|
||||
|
@ -183,5 +183,8 @@
|
||||
},
|
||||
"special_notes": {
|
||||
"search_prefix": "Căutare:"
|
||||
},
|
||||
"code_block": {
|
||||
"theme_none": "Niciuna"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user