mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-19 02:10:04 +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 appContext from "../../components/app_context.js";
|
||||||
import dialogService from "../../services/dialog.js";
|
import dialogService from "../../services/dialog.js";
|
||||||
import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js";
|
import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js";
|
||||||
|
import options from "../../services/options.js";
|
||||||
|
|
||||||
const ENABLE_INSPECTOR = false;
|
const ENABLE_INSPECTOR = false;
|
||||||
|
|
||||||
@ -169,7 +170,10 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
|
|
||||||
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
this.watchdog.setCreator(async (elementOrData, editorConfig) => {
|
||||||
const editor = await BalloonEditor.create(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());
|
editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import themeNames from "./code_block_theme_names.json" assert { type: "json" }
|
import themeNames from "./code_block_theme_names.json" assert { type: "json" }
|
||||||
|
import { t } from "i18next";
|
||||||
|
|
||||||
export function listSyntaxHighlightingThemes() {
|
export function listSyntaxHighlightingThemes() {
|
||||||
const path = "node_modules/@highlightjs/cdn-assets/styles";
|
const path = "node_modules/@highlightjs/cdn-assets/styles";
|
||||||
const allThemes = fs
|
const systemThemes = fs
|
||||||
.readdirSync(path)
|
.readdirSync(path)
|
||||||
.filter((el) => el.endsWith(".min.css"))
|
.filter((el) => el.endsWith(".min.css"))
|
||||||
.map((name) => {
|
.map((name) => {
|
||||||
@ -19,5 +20,11 @@ export function listSyntaxHighlightingThemes() {
|
|||||||
title: title
|
title: title
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return allThemes;
|
return [
|
||||||
|
{
|
||||||
|
val: "none",
|
||||||
|
title: t("code_block.theme_none")
|
||||||
|
},
|
||||||
|
...systemThemes
|
||||||
|
];
|
||||||
}
|
}
|
@ -183,5 +183,8 @@
|
|||||||
},
|
},
|
||||||
"special_notes": {
|
"special_notes": {
|
||||||
"search_prefix": "Search:"
|
"search_prefix": "Search:"
|
||||||
|
},
|
||||||
|
"code_block": {
|
||||||
|
"theme_none": "None"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,5 +183,8 @@
|
|||||||
},
|
},
|
||||||
"special_notes": {
|
"special_notes": {
|
||||||
"search_prefix": "Căutare:"
|
"search_prefix": "Căutare:"
|
||||||
|
},
|
||||||
|
"code_block": {
|
||||||
|
"theme_none": "Niciuna"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user