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
feat(server): add endpoint to list code note themes
Elian Doranca467fcd7a90
diff --git a/apps/server/src/routes/api/options.ts b/apps/server/src/routes/api/options.tsindex 0e90719924..c6de37f8cb 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 dialogconst ALLOWED_OPTIONS = new Set<OptionNames>([@@ -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.tsindex 2707c3cd8f..4cab8d9436 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.jsonindex 591b4a5dbc..d95d85b207 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.jsonindex 6bc2242953..6b70171002 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.tsindex 1420e39ef5..a03a8b57d3 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<Extension>;}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.tsindex 7ca0004024..f6560920c6 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;