client,server: Allow disabling syntax highlight

This commit is contained in:
Elian Doran 2024-10-31 18:03:52 +02:00
parent bbc038f254
commit ac13291744
No known key found for this signature in database
4 changed files with 20 additions and 3 deletions

View File

@ -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);
if (options.get("codeBlockTheme") !== "none") {
initSyntaxHighlighting(editor); initSyntaxHighlighting(editor);
}
editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate()); editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());

View File

@ -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
];
} }

View File

@ -183,5 +183,8 @@
}, },
"special_notes": { "special_notes": {
"search_prefix": "Search:" "search_prefix": "Search:"
},
"code_block": {
"theme_none": "None"
} }
} }

View File

@ -183,5 +183,8 @@
}, },
"special_notes": { "special_notes": {
"search_prefix": "Căutare:" "search_prefix": "Căutare:"
},
"code_block": {
"theme_none": "Niciuna"
} }
} }