🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(ui): customize codemirror theme (#5305)
Marc Klingen4ec1fc53d151
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 7433bcd17c..b62b7833af 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -59,7 +59,7 @@ importers:version: 14.2.21(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected])next-auth:specifier: ^4.24.11- version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])+ version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])zod:specifier: ^3.23.8version: 3.23.8@@ -224,7 +224,7 @@ importers:version: 4.17.21next-auth:specifier: ^4.24.11- version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])+ version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])nodemailer:specifier: ^6.9.15version: 6.9.15@@ -376,6 +376,9 @@ importers:'@langfuse/shared':specifier: workspace:*version: link:../packages/shared+ '@lezer/highlight':+ specifier: ^1.2.1+ version: 1.2.1'@marsidev/react-turnstile':specifier: ^0.5.4@@ -538,8 +541,8 @@ importers:'@trpc/server':specifier: ^10.45.0version: 10.45.2- '@uiw/codemirror-theme-github':- specifier: ^4.21.24+ '@uiw/codemirror-themes':+ specifier: ^4.23.7version: 4.23.7(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])'@uiw/react-codemirror':specifier: ^4.21.24@@ -618,7 +621,7 @@ importers:version: 14.2.21(@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected])next-auth:specifier: ^4.24.11- version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])+ version: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])next-query-params:specifier: ^5.0.1version: 5.0.1([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]([email protected]))([email protected]))@@ -5092,9 +5095,6 @@ packages:'@codemirror/state': '>=6.0.0''@codemirror/view': '>=6.0.0'- '@uiw/[email protected]':- resolution: {integrity: sha512-r9SstBZD7Ow1sQ8F0EpsRGx9b11K552M2FayvyLWTkal64YJmQMKW0S2KcWykgCMKLWhmDFi7LX+h8cg6nek8g==}-'@uiw/[email protected]':resolution: {integrity: sha512-UNf1XOx1hG9OmJnrtT86PxKcdcwhaNhbrcD+nsk8WxRJ3n5c8nH6euDvgVPdVLPwbizsaQcZTILACgA/FjRpVg==}peerDependencies:@@ -12127,25 +12127,6 @@ snapshots:- '@aws-sdk/client-sso-oidc'- aws-crt- '@aws-sdk/[email protected]':- dependencies:- '@aws-sdk/core': 3.667.0- '@aws-sdk/credential-provider-env': 3.667.0- '@aws-sdk/credential-provider-http': 3.667.0- '@aws-sdk/credential-provider-process': 3.667.0- '@aws-sdk/credential-provider-sso': 3.675.0- '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])- '@aws-sdk/types': 3.667.0- '@smithy/credential-provider-imds': 3.2.4- '@smithy/property-provider': 3.1.7- '@smithy/shared-ini-file-loader': 3.1.8- '@smithy/types': 3.5.0- tslib: 2.6.3- transitivePeerDependencies:- - '@aws-sdk/client-sso-oidc'- - aws-crt- optional: true-'@aws-sdk/[email protected](@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])':dependencies:'@aws-sdk/client-sts': 3.668.0@@ -12207,10 +12188,10 @@ snapshots:dependencies:'@aws-sdk/credential-provider-env': 3.667.0'@aws-sdk/credential-provider-http': 3.667.0- '@aws-sdk/credential-provider-ini': 3.675.0+ '@aws-sdk/credential-provider-ini': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])'@aws-sdk/credential-provider-process': 3.667.0- '@aws-sdk/credential-provider-sso': 3.675.0- '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])+ '@aws-sdk/credential-provider-sso': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))+ '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])'@aws-sdk/types': 3.667.0'@smithy/credential-provider-imds': 3.2.4'@smithy/property-provider': 3.1.7@@ -12284,21 +12265,6 @@ snapshots:- '@aws-sdk/client-sso-oidc'- aws-crt- '@aws-sdk/[email protected]':- dependencies:- '@aws-sdk/client-sso': 3.675.0- '@aws-sdk/core': 3.667.0- '@aws-sdk/token-providers': 3.667.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))- '@aws-sdk/types': 3.667.0- '@smithy/property-provider': 3.1.7- '@smithy/shared-ini-file-loader': 3.1.8- '@smithy/types': 3.5.0- tslib: 2.6.3- transitivePeerDependencies:- - '@aws-sdk/client-sso-oidc'- - aws-crt- optional: true-dependencies:'@aws-sdk/client-sso': 3.675.0@@ -12716,7 +12682,7 @@ snapshots:'@babel/traverse': 7.24.1'@babel/types': 7.24.0convert-source-map: 2.0.0- debug: 4.3.7+ debug: 4.3.7([email protected])gensync: 1.0.0-beta.2json5: 2.2.3semver: 6.3.1@@ -12939,7 +12905,7 @@ snapshots:'@babel/helper-split-export-declaration': 7.22.6'@babel/parser': 7.24.1'@babel/types': 7.24.0- debug: 4.3.7+ debug: 4.3.7([email protected])globals: 11.12.0transitivePeerDependencies:- supports-color@@ -12951,7 +12917,7 @@ snapshots:'@babel/parser': 7.26.2'@babel/template': 7.25.9'@babel/types': 7.26.0- debug: 4.3.7+ debug: 4.3.7([email protected])globals: 11.12.0transitivePeerDependencies:- supports-color@@ -13410,7 +13376,7 @@ snapshots:'@eslint/[email protected]':dependencies:ajv: 6.12.6- debug: 4.3.7+ debug: 4.3.7([email protected])espree: 9.6.1globals: 13.24.0ignore: 5.3.1@@ -13514,7 +13480,7 @@ snapshots:'@humanwhocodes/[email protected]':dependencies:'@humanwhocodes/object-schema': 2.0.2- debug: 4.3.7+ debug: 4.3.7([email protected])minimatch: 3.1.2transitivePeerDependencies:- supports-color@@ -13532,7 +13498,7 @@ snapshots:'@antfu/install-pkg': 0.4.1'@antfu/utils': 0.7.10'@iconify/types': 2.0.0- debug: 4.3.7+ debug: 4.3.7([email protected])kolorist: 1.8.0local-pkg: 0.5.0mlly: 1.7.1@@ -14132,7 +14098,7 @@ snapshots:'@next-auth/[email protected](@prisma/[email protected]([email protected]))([email protected](patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]))':dependencies:'@prisma/client': 5.22.0([email protected])- next-auth: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])+ next-auth: 4.24.11(patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])'@next/[email protected]': {}@@ -16922,7 +16888,7 @@ snapshots:dependencies:'@typescript-eslint/typescript-estree': 6.21.0([email protected])'@typescript-eslint/utils': 6.21.0([email protected])([email protected])- debug: 4.3.7+ debug: 4.3.7([email protected])eslint: 8.57.0ts-api-utils: 1.3.0([email protected])optionalDependencies:@@ -16934,7 +16900,7 @@ snapshots:dependencies:'@typescript-eslint/typescript-estree': 7.3.1([email protected])'@typescript-eslint/utils': 7.3.1([email protected])([email protected])- debug: 4.3.7+ debug: 4.3.7([email protected])eslint: 8.57.0ts-api-utils: 1.3.0([email protected])optionalDependencies:@@ -16968,7 +16934,7 @@ snapshots:dependencies:'@typescript-eslint/types': 6.21.0'@typescript-eslint/visitor-keys': 6.21.0- debug: 4.3.7+ debug: 4.3.7([email protected])globby: 11.1.0is-glob: 4.0.3minimatch: 9.0.3@@ -16983,7 +16949,7 @@ snapshots:dependencies:'@typescript-eslint/types': 7.12.0'@typescript-eslint/visitor-keys': 7.12.0- debug: 4.3.7+ debug: 4.3.7([email protected])globby: 11.1.0is-glob: 4.0.3minimatch: 9.0.5@@ -16998,7 +16964,7 @@ snapshots:dependencies:'@typescript-eslint/types': 7.3.1'@typescript-eslint/visitor-keys': 7.3.1- debug: 4.3.7+ debug: 4.3.7([email protected])globby: 11.1.0is-glob: 4.0.3minimatch: 9.0.3@@ -17082,14 +17048,6 @@ snapshots:'@codemirror/state': 6.5.1'@codemirror/view': 6.36.2- '@uiw/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])':- dependencies:- '@uiw/codemirror-themes': 4.23.7(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])- transitivePeerDependencies:- - '@codemirror/language'- - '@codemirror/state'- - '@codemirror/view'-'@uiw/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])':dependencies:'@codemirror/language': 6.10.8@@ -17123,7 +17081,7 @@ snapshots:'@typescript-eslint/eslint-plugin': 7.3.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])'@typescript-eslint/parser': 7.12.0([email protected])([email protected])eslint-config-prettier: 9.1.0([email protected])- eslint-import-resolver-alias: 1.1.2([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))+ eslint-import-resolver-alias: 1.1.2([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])eslint-plugin-eslint-comments: 3.2.0([email protected])eslint-plugin-import: 2.29.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])@@ -17169,7 +17127,7 @@ snapshots:dependencies:'@vitest/spy': 2.1.2estree-walker: 3.0.3- magic-string: 0.30.13+ magic-string: 0.30.11optionalDependencies:vite: 5.2.14(@types/[email protected])optional: true@@ -17374,7 +17332,7 @@ snapshots:dependencies:- debug: 4.3.7+ debug: 4.3.7([email protected])transitivePeerDependencies:- supports-color@@ -18565,10 +18523,6 @@ snapshots:dependencies:ms: 2.1.2- dependencies:- ms: 2.1.3-dependencies:ms: 2.1.3@@ -19026,7 +18980,7 @@ snapshots:eslint: 8.57.0eslint-plugin-turbo: 1.13.4([email protected])- [email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])):+ [email protected]([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])):dependencies:eslint-plugin-import: 2.29.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])@@ -19040,7 +18994,7 @@ snapshots:[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]):dependencies:- debug: 4.3.7+ debug: 4.3.7([email protected])enhanced-resolve: 5.17.1eslint: 8.57.0eslint-module-utils: 2.8.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected])@@ -19144,7 +19098,7 @@ snapshots:doctrine: 2.1.0eslint: 8.57.0eslint-import-resolver-node: 0.3.9- eslint-module-utils: 2.8.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected])+ eslint-module-utils: 2.8.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])hasown: 2.0.2is-core-module: 2.15.1is-glob: 4.0.3@@ -19498,7 +19452,7 @@ snapshots:dependencies:- debug: 4.3.7+ debug: 4.3.7([email protected])get-stream: 5.2.0yauzl: 2.10.0optionalDependencies:@@ -20041,7 +19995,7 @@ snapshots:dependencies:'@tootallnate/once': 2.0.0agent-base: 6.0.2- debug: 4.3.7+ debug: 4.3.7([email protected])transitivePeerDependencies:- supports-color@@ -20062,7 +20016,7 @@ snapshots:dependencies:agent-base: 6.0.2- debug: 4.3.7+ debug: 4.3.7([email protected])transitivePeerDependencies:- supports-color@@ -20076,7 +20030,7 @@ snapshots:dependencies:agent-base: 7.1.3- debug: 4.3.7+ debug: 4.3.7([email protected])transitivePeerDependencies:- supports-color@@ -20452,7 +20406,7 @@ snapshots:dependencies:- debug: 4.3.7+ debug: 4.3.7([email protected])istanbul-lib-coverage: 3.2.2source-map: 0.6.1transitivePeerDependencies:@@ -20872,7 +20826,7 @@ snapshots:dependencies:- '@types/node': 20.10.5+ '@types/node': 20.14.8merge-stream: 2.0.0supports-color: 8.1.1@@ -21728,7 +21682,7 @@ snapshots:dependencies:'@types/debug': 4.1.8- debug: 4.3.7+ debug: 4.3.7([email protected])decode-named-character-reference: 1.0.2devlop: 1.1.0micromark-core-commonmark: 2.0.1@@ -21897,7 +21851,7 @@ snapshots:dependencies:type-fest: 2.19.0- [email protected](patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@babel/[email protected])(@opentelemetry/[email protected])(@playwright/[email protected])([email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]):+ [email protected](patch_hash=cczsf6i6qe2m2htirvgxjtoclu)([email protected](@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected]):dependencies:'@babel/runtime': 7.26.0'@panva/hkdf': 1.1.1@@ -23120,7 +23074,7 @@ snapshots:dependencies:- debug: 4.3.7+ debug: 4.3.7([email protected])module-details-from-path: 1.0.3resolve: 1.22.8transitivePeerDependencies:@@ -24267,7 +24221,7 @@ snapshots:[email protected](@types/[email protected]):dependencies:cac: 6.7.14- debug: 4.3.7+ debug: 4.3.7([email protected])pathe: 1.1.2vite: 5.2.14(@types/[email protected])transitivePeerDependencies:@@ -24327,8 +24281,8 @@ snapshots:'@vitest/spy': 2.1.2'@vitest/utils': 2.1.2chai: 5.1.1- debug: 4.3.7- magic-string: 0.30.13+ debug: 4.3.7([email protected])+ magic-string: 0.30.11pathe: 1.1.2std-env: 3.7.0tinybench: 2.9.0diff --git a/web/package.json b/web/package.jsonindex 028eda86b4..717edb0c70 100644--- a/web/package.json+++ b/web/package.json@@ -41,6 +41,7 @@"@langchain/openai": "^0.3.14","@langfuse/ee": "workspace:*","@langfuse/shared": "workspace:*",+ "@lezer/highlight": "^1.2.1","@marsidev/react-turnstile": "^0.5.4","@mui/x-tree-view": "^7.19.0","@next-auth/prisma-adapter": "^1.0.7",@@ -95,7 +96,7 @@"@trpc/next": "^10.45.0","@trpc/react-query": "^10.45.0","@trpc/server": "^10.45.0",- "@uiw/codemirror-theme-github": "^4.21.24",+ "@uiw/codemirror-themes": "^4.23.7","@uiw/react-codemirror": "^4.21.24","ai": "^3.4.9","bcryptjs": "^2.4.3",diff --git a/web/src/components/editor.tsx b/web/src/components/editor/CodeMirrorEditor.tsxsimilarity index 87%rename from web/src/components/editor.tsxrename to web/src/components/editor/CodeMirrorEditor.tsxindex d73789cf46..3dd9bf07b2 100644--- a/web/src/components/editor.tsx+++ b/web/src/components/editor/CodeMirrorEditor.tsx@@ -1,5 +1,4 @@import CodeMirror, { EditorView } from "@uiw/react-codemirror";-import { githubLight, githubDark } from "@uiw/codemirror-theme-github";import { json, jsonParseLinter } from "@codemirror/lang-json";import { linter, type Diagnostic } from "@codemirror/lint";import { useTheme } from "next-themes";@@ -13,6 +12,8 @@ import {MUSTACHE_REGEX,UNCLOSED_VARIABLE_REGEX,} from "@langfuse/shared";+import { lightTheme } from "@/src/components/editor/light-theme";+import { darkTheme } from "@/src/components/editor/dark-theme";// Custom language mode for prompts that highlights mustache variablesconst promptLanguage = StreamLanguage.define({@@ -107,7 +108,7 @@ export function CodeMirrorEditor({placeholder?: string;}) {const { resolvedTheme } = useTheme();- const codeMirrorTheme = resolvedTheme === "dark" ? githubDark : githubLight;+ const codeMirrorTheme = resolvedTheme === "dark" ? darkTheme : lightTheme;// used to disable linter when field is emptyconst [linterEnabled, setLinterEnabled] = useState<boolean>(@@ -119,12 +120,25 @@ export function CodeMirrorEditor({value={value}theme={codeMirrorTheme}basicSetup={{- foldGutter: true,+ foldGutter: lineNumbers,highlightActiveLine: false,lineNumbers: lineNumbers,}}lang={mode === "json" ? "json" : undefined}extensions={[+ // Hide gutter when lineNumbers is false+ // Fix missing gutter border+ ...(!lineNumbers+ ? [+ EditorView.theme({+ ".cm-gutters": { display: "none" },+ }),+ ]+ : [+ EditorView.theme({+ ".cm-gutters": { borderRight: "1px solid" },+ }),+ ]),// Extend gutter to full height when minHeight > content height// This also enlarges the text area to minHeight...(minHeight === "none"diff --git a/web/src/components/editor/dark-theme.ts b/web/src/components/editor/dark-theme.tsnew file mode 100644index 0000000000..32898710af--- /dev/null+++ b/web/src/components/editor/dark-theme.ts@@ -0,0 +1,46 @@+import { defaultSettingsBothThemes } from "@/src/components/editor/shared-theme";+import { tags as t } from "@lezer/highlight";+import { createTheme, type CreateThemeOptions } from "@uiw/codemirror-themes";+import { bothThemeStyles } from "@/src/components/editor/shared-theme";++export const defaultSettingsDarkTheme: CreateThemeOptions["settings"] = {+ ...defaultSettingsBothThemes,+};++export const darkThemeStyle: CreateThemeOptions["styles"] = [+ ...bothThemeStyles,+ { tag: t.keyword, color: "#bb9af7" },+ {+ tag: [t.processingInstruction, t.string, t.inserted, t.special(t.string)],+ color: "#9ece6a",+ },+ { tag: [t.labelName], color: "#7aa2f7" },+ { tag: [t.color, t.constant(t.name), t.standard(t.name)], color: "#bb9af7" },+ { tag: [t.definition(t.name), t.separator], color: "#c0caf5" },+ { tag: [t.className], color: "#c0caf5" },+ {+ tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],+ color: "#ff9e64",+ },+ { tag: [t.typeName], color: "#0db9d7" },+ { tag: [t.operator, t.operatorKeyword], color: "#bb9af7" },+ { tag: [t.url, t.escape, t.regexp, t.link], color: "#b4f9f8" },+ { tag: [t.meta, t.comment], color: "#444b6a" },+ { tag: t.heading, fontWeight: "bold", color: "#89ddff" },+ { tag: [t.atom, t.bool], color: "#c0caf5" },+ { tag: t.strikethrough, textDecoration: "line-through" },+];++export const darkThemeInit = (options?: Partial<CreateThemeOptions>) => {+ const { theme = "dark", settings = {}, styles = [] } = options || {};+ return createTheme({+ theme: theme,+ settings: {+ ...defaultSettingsDarkTheme,+ ...settings,+ },+ styles: [...darkThemeStyle, ...styles],+ });+};++export const darkTheme = darkThemeInit();diff --git a/web/src/components/editor/index.ts b/web/src/components/editor/index.tsnew file mode 100644index 0000000000..707d0f68c2--- /dev/null+++ b/web/src/components/editor/index.ts@@ -0,0 +1 @@+export * from "./CodeMirrorEditor";diff --git a/web/src/components/editor/light-theme.ts b/web/src/components/editor/light-theme.tsnew file mode 100644index 0000000000..656c7ed978--- /dev/null+++ b/web/src/components/editor/light-theme.ts@@ -0,0 +1,75 @@+import { defaultSettingsBothThemes } from "@/src/components/editor/shared-theme";+import { tags as t } from "@lezer/highlight";+import { createTheme, type CreateThemeOptions } from "@uiw/codemirror-themes";+import { bothThemeStyles } from "@/src/components/editor/shared-theme";++export const defaultSettingsLightTheme: CreateThemeOptions["settings"] = {+ ...defaultSettingsBothThemes,+};++export const lightThemeStyle: CreateThemeOptions["styles"] = [+ ...bothThemeStyles,+ {+ tag: [+ t.keyword,+ t.operatorKeyword,+ t.modifier,+ t.color,+ t.constant(t.name),+ t.standard(t.name),+ t.standard(t.tagName),+ t.special(t.brace),+ t.atom,+ t.bool,+ t.special(t.variableName),+ ],+ color: "#0000ff",+ },+ { tag: [t.moduleKeyword, t.controlKeyword], color: "#af00db" },+ { tag: t.heading, fontWeight: "bold", color: "#0070c1" },+ {+ tag: [+ t.typeName,+ t.className,+ t.tagName,+ t.number,+ t.changed,+ t.annotation,+ t.self,+ t.namespace,+ ],+ color: "#267f99",+ },+ {+ tag: [t.function(t.variableName), t.function(t.propertyName)],+ color: "#795e26",+ },+ { tag: [t.number], color: "#098658" },+ {+ tag: [t.operator, t.punctuation, t.separator, t.url, t.escape, t.regexp],+ color: "#383a42",+ },+ { tag: [t.regexp], color: "#af00db" },+ {+ tag: [t.special(t.string), t.processingInstruction, t.string, t.inserted],+ color: "#a31515",+ },+ { tag: [t.angleBracket], color: "#383a42" },+ { tag: t.strikethrough, textDecoration: "line-through" },+ { tag: [t.meta, t.comment], color: "#008000" },+ { tag: t.link, color: "#4078f2", textDecoration: "underline" },+];++export function lightThemeInit(options?: Partial<CreateThemeOptions>) {+ const { theme = "light", settings = {}, styles = [] } = options || {};+ return createTheme({+ theme: theme,+ settings: {+ ...defaultSettingsLightTheme,+ ...settings,+ },+ styles: [...lightThemeStyle, ...styles],+ });+}++export const lightTheme = lightThemeInit();diff --git a/web/src/components/editor/shared-theme.ts b/web/src/components/editor/shared-theme.tsnew file mode 100644index 0000000000..ba62320944--- /dev/null+++ b/web/src/components/editor/shared-theme.ts@@ -0,0 +1,35 @@+import { type CreateThemeOptions } from "@uiw/codemirror-themes";+import { tags as t } from "@lezer/highlight";++export const defaultSettingsBothThemes: CreateThemeOptions["settings"] = {+ background: "hsl(var(--background))",+ foreground: "hsl(var(--foreground))",+ caret: "hsl(var(--foreground))",+ gutterBackground: "hsl(var(--sidebar-background))",+ gutterForeground: "hsl(var(--sidebar-foreground))",+ gutterBorder: "hsl(var(--sidebar-border))",+ gutterActiveForeground: "hsl(var(--sidebar-primary))",+ selection: "hsl(var(--accent))",+ selectionMatch: "hsl(var(--accent-foreground))",+ lineHighlight: "hsl(var(--accent-foreground))",+};++export const bothThemeStyles: CreateThemeOptions["styles"] = [+ { tag: t.invalid, color: "hsl(var(--dark-red))" },+ {+ tag: [+ t.name,+ t.deleted,+ t.character,+ t.macroName,+ t.propertyName,+ t.variableName,+ t.labelName,+ t.definition(t.name),+ ],+ color: "hsl(var(--primary-accent))",+ },+ { tag: t.strong, fontWeight: "bold" },+ { tag: t.emphasis, fontStyle: "italic" },+ { tag: t.link, textDecoration: "underline" },+];diff --git a/web/src/styles/globals.css b/web/src/styles/globals.cssindex 5bf5b0009e..4512793091 100644--- a/web/src/styles/globals.css+++ b/web/src/styles/globals.css@@ -26,7 +26,7 @@--secondary-foreground: 222.2 47.4% 11.2%;--accent: 210 40% 96.1%;- --accent-foreground: ;+ --accent-foreground: 210 40% 98%;--destructive: 0 84.2% 60.2%;--destructive-foreground: 210 40% 98%;@@ -159,6 +159,7 @@}@layer base {+input[type="number"].appearance-none::-webkit-inner-spin-button,input[type="number"].appearance-none::-webkit-outer-spin-button {-webkit-appearance: none;@@ -169,4 +170,4 @@-moz-appearance: textfield;appearance: none;}-}+}\ No newline at end of file