diff --git a/apps/server/src/routes/api/options.ts b/apps/server/src/routes/api/options.ts index 0e9071992..c6de37f8c 100644 --- a/apps/server/src/routes/api/options.ts +++ b/apps/server/src/routes/api/options.ts @@ -8,6 +8,7 @@ import type { Request } from "express"; import { changeLanguage, getLocales } from "../../services/i18n.js"; import { listSyntaxHighlightingThemes } from "../../services/code_block_theme.js"; import type { OptionNames } from "@triliumnext/commons"; +import { ColorThemes } from "@triliumnext/codemirror"; // options allowed to be updated directly in the Options dialog const ALLOWED_OPTIONS = new Set([ @@ -193,6 +194,13 @@ function getSyntaxHighlightingThemes() { return listSyntaxHighlightingThemes(); } +function getCodeNoteThemes() { + return ColorThemes.map((theme) => ({ + val: theme.id, + title: theme.id + })); +} + function getSupportedLocales() { return getLocales(); } @@ -210,5 +218,6 @@ export default { updateOptions, getUserThemes, getSyntaxHighlightingThemes, + getCodeNoteThemes, getSupportedLocales }; diff --git a/apps/server/src/routes/routes.ts b/apps/server/src/routes/routes.ts index 2707c3cd8..4cab8d943 100644 --- a/apps/server/src/routes/routes.ts +++ b/apps/server/src/routes/routes.ts @@ -245,6 +245,7 @@ function register(app: express.Application) { apiRoute(PUT, "/api/options", optionsApiRoute.updateOptions); apiRoute(GET, "/api/options/user-themes", optionsApiRoute.getUserThemes); apiRoute(GET, "/api/options/codeblock-themes", optionsApiRoute.getSyntaxHighlightingThemes); + apiRoute(GET, "/api/options/codenote-themes", optionsApiRoute.getCodeNoteThemes) apiRoute(GET, "/api/options/locales", optionsApiRoute.getSupportedLocales); apiRoute(PST, "/api/password/change", passwordApiRoute.changePassword); diff --git a/apps/server/tsconfig.app.json b/apps/server/tsconfig.app.json index 591b4a5db..d95d85b20 100644 --- a/apps/server/tsconfig.app.json +++ b/apps/server/tsconfig.app.json @@ -36,6 +36,9 @@ { "path": "../../packages/ckeditor5/tsconfig.lib.json" }, + { + "path": "../../packages/codemirror/tsconfig.lib.json" + }, { "path": "../../packages/turndown-plugin-gfm/tsconfig.lib.json" }, diff --git a/apps/server/tsconfig.json b/apps/server/tsconfig.json index 6bc224295..6b7017100 100644 --- a/apps/server/tsconfig.json +++ b/apps/server/tsconfig.json @@ -6,6 +6,9 @@ { "path": "../../packages/ckeditor5" }, + { + "path": "../../packages/codemirror" + }, { "path": "../../packages/turndown-plugin-gfm" }, diff --git a/packages/codemirror/src/color_themes.ts b/packages/codemirror/src/color_themes.ts index 1420e39ef..a03a8b57d 100644 --- a/packages/codemirror/src/color_themes.ts +++ b/packages/codemirror/src/color_themes.ts @@ -1,17 +1,17 @@ import type { Extension } from '@codemirror/state'; export interface ThemeDefinition { - name: string; + id: string; load(): Promise; } const themes: ThemeDefinition[] = [ { - name: "abyss", + id: "abyss", load: async () => (await import("@fsegurai/codemirror-theme-abyss")).abyss }, { - name: "abcdef", + id: "abcdef", load: async () => (await import("@fsegurai/codemirror-theme-abcdef")).abcdef } ] diff --git a/packages/codemirror/src/index.ts b/packages/codemirror/src/index.ts index 7ca000402..f6560920c 100644 --- a/packages/codemirror/src/index.ts +++ b/packages/codemirror/src/index.ts @@ -8,7 +8,7 @@ import byMimeType from "./syntax_highlighting.js"; import smartIndentWithTab from "./extensions/custom_tab.js"; import type { ThemeDefinition } from "./color_themes.js"; -export * from "./color_themes.js"; +export { default as ColorThemes, type ThemeDefinition } from "./color_themes.js"; type ContentChangedListener = () => void;