mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
feat(server): add endpoint to list code note themes
This commit is contained in:
parent
7475e94c53
commit
ca467fcd7a
@ -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<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
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -36,6 +36,9 @@
|
||||
{
|
||||
"path": "../../packages/ckeditor5/tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/codemirror/tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/turndown-plugin-gfm/tsconfig.lib.json"
|
||||
},
|
||||
|
@ -6,6 +6,9 @@
|
||||
{
|
||||
"path": "../../packages/ckeditor5"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/codemirror"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/turndown-plugin-gfm"
|
||||
},
|
||||
|
@ -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
|
||||
}
|
||||
]
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user