skir-codemirror-plugin 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -6
- package/dist/codemirror/create_editor_state.d.ts +4 -2
- package/dist/codemirror/create_editor_state.d.ts.map +1 -1
- package/dist/codemirror/create_editor_state.js +178 -31
- package/dist/codemirror/create_editor_state.js.map +1 -1
- package/dist/codemirror/json_linter.d.ts.map +1 -1
- package/dist/codemirror/json_linter.js +67 -3
- package/dist/codemirror/json_linter.js.map +1 -1
- package/dist/codemirror/json_state.d.ts +5 -1
- package/dist/codemirror/json_state.d.ts.map +1 -1
- package/dist/codemirror/json_state.js +26 -1
- package/dist/codemirror/json_state.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/json/json_parser.js +35 -1
- package/dist/json/json_parser.js.map +1 -1
- package/dist/json/json_parser.test.js +48 -0
- package/dist/json/json_parser.test.js.map +1 -1
- package/dist/json/schema_validator.d.ts.map +1 -1
- package/dist/json/schema_validator.js +22 -14
- package/dist/json/schema_validator.js.map +1 -1
- package/dist/json/schema_validator.test.js +146 -5
- package/dist/json/schema_validator.test.js.map +1 -1
- package/dist/json/to_json.d.ts +1 -1
- package/dist/json/to_json.d.ts.map +1 -1
- package/dist/json/to_json.js +3 -3
- package/dist/json/to_json.js.map +1 -1
- package/dist/json/types.d.ts +4 -0
- package/dist/json/types.d.ts.map +1 -1
- package/dist/json/types.js.map +1 -1
- package/package.json +4 -6
- package/src/codemirror/create_editor_state.ts +272 -31
- package/src/codemirror/json_linter.ts +89 -4
- package/src/codemirror/json_state.ts +44 -1
- package/src/index.ts +1 -0
- package/src/json/json_parser.test.ts +51 -0
- package/src/json/json_parser.ts +37 -1
- package/src/json/schema_validator.test.ts +166 -5
- package/src/json/schema_validator.ts +26 -13
- package/src/json/to_json.ts +3 -3
- package/src/json/types.ts +7 -0
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# skir-codemirror-plugin
|
|
2
2
|
|
|
3
|
-
This library provides a CodeMirror-based
|
|
4
|
-
It helps users edit Skir request/response payloads in a human-readable JSON form while preserving schema-aware guidance and validation.
|
|
3
|
+
This library provides a CodeMirror-based editor for editing Skir value in readable JSON format.
|
|
5
4
|
|
|
6
5
|
Demo: `npx skir-studio-demo`
|
|
7
6
|
|
|
@@ -13,9 +12,12 @@ Demo: `npx skir-studio-demo`
|
|
|
13
12
|
- In-editor hints and completions informed by the Skir type schema.
|
|
14
13
|
- Read-only mode support for response viewing.
|
|
15
14
|
- Built-in theme support:
|
|
16
|
-
-
|
|
17
|
-
- `tokyo-night-day`
|
|
15
|
+
- all presets from `@uiw/codemirror-themes-all`
|
|
18
16
|
- custom theme object
|
|
17
|
+
- Optional `otherExtension` hook to append your own CodeMirror extension(s).
|
|
18
|
+
|
|
19
|
+
Theme previews and names:
|
|
20
|
+
https://www.npmjs.com/package/@uiw/codemirror-themes-all?activeTab=readme
|
|
19
21
|
|
|
20
22
|
## Install
|
|
21
23
|
|
|
@@ -31,6 +33,7 @@ The package root exports:
|
|
|
31
33
|
- `ensureJsonState`
|
|
32
34
|
- `toJson`
|
|
33
35
|
- `CreateEditorStateParams` (type)
|
|
36
|
+
- `BuiltinThemeName` (type)
|
|
34
37
|
- `CustomTheme` (type)
|
|
35
38
|
- `JsonState` (type)
|
|
36
39
|
- all types from `./json/types`
|
|
@@ -52,7 +55,8 @@ const params: CreateEditorStateParams = {
|
|
|
52
55
|
// Optional:
|
|
53
56
|
// readOnly: true,
|
|
54
57
|
// json: "hello",
|
|
55
|
-
// theme: "
|
|
58
|
+
// theme: "github-light",
|
|
59
|
+
// otherExtension: EditorView.lineWrapping,
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
const state = createEditorState(params);
|
|
@@ -105,7 +109,8 @@ if (jsonState.parseResult.value) {
|
|
|
105
109
|
schema: TypeDefinition,
|
|
106
110
|
readOnly?: true,
|
|
107
111
|
json?: Json,
|
|
108
|
-
theme?:
|
|
112
|
+
theme?: BuiltinThemeName | CustomTheme,
|
|
113
|
+
otherExtension?: Extension,
|
|
109
114
|
}
|
|
110
115
|
```
|
|
111
116
|
|
|
@@ -115,6 +120,10 @@ Behavior:
|
|
|
115
120
|
- If `json` is omitted, a JSON template is generated from the schema.
|
|
116
121
|
- `readOnly: true` enables non-editable mode.
|
|
117
122
|
- `theme` defaults to `tokyo-night`.
|
|
123
|
+
- `theme` accepts any built-in preset name from `BuiltinThemeName` (powered by `@uiw/codemirror-themes-all`) or a custom theme object.
|
|
124
|
+
See available theme previews in the package README:
|
|
125
|
+
https://www.npmjs.com/package/@uiw/codemirror-themes-all?activeTab=readme
|
|
126
|
+
- `otherExtension` appends extra CodeMirror extension(s) at the end of the editor extension list.
|
|
118
127
|
|
|
119
128
|
## Local Dev Flow
|
|
120
129
|
|
|
@@ -4,9 +4,11 @@ export type CreateEditorStateParams = {
|
|
|
4
4
|
schema: TypeDefinition;
|
|
5
5
|
readOnly?: true;
|
|
6
6
|
json?: Json;
|
|
7
|
-
theme?:
|
|
7
|
+
theme?: BuiltinThemeName | CustomTheme;
|
|
8
|
+
otherExtension?: Extension;
|
|
8
9
|
};
|
|
9
|
-
export
|
|
10
|
+
export type BuiltinThemeName = "abcdef" | "abyss" | "androidstudio" | "andromeda" | "atomone" | "aura" | "basic-dark" | "basic-light" | "bbedit" | "bespin" | "console-dark" | "console-light" | "copilot" | "darcula" | "dracula" | "duotone-dark" | "duotone-light" | "eclipse" | "github-dark" | "github-light" | "gruvbox-dark" | "gruvbox-light" | "kimbie" | "material" | "material-dark" | "material-light" | "monokai" | "monokai-dimmed" | "noctis-lilac" | "nord" | "okaidia" | "quietlight" | "red" | "solarized-dark" | "solarized-light" | "sublime" | "tokyo-night" | "tokyo-night-day" | "tokyo-night-storm" | "tomorrow-night-blue" | "vscode-dark" | "vscode-light" | "white" | "white-dark" | "white-light" | "xcode-dark" | "xcode-light";
|
|
11
|
+
export declare function createEditorState({ schema, readOnly, json, theme, otherExtension, }: CreateEditorStateParams): EditorState;
|
|
10
12
|
export interface CustomTheme {
|
|
11
13
|
backgroundColor: string;
|
|
12
14
|
lighterBgColor: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_editor_state.d.ts","sourceRoot":"","sources":["../../src/codemirror/create_editor_state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"create_editor_state.d.ts","sourceRoot":"","sources":["../../src/codemirror/create_editor_state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK3D,OAAO,KAAK,EAAE,IAAI,EAAoB,cAAc,EAAE,MAAM,eAAe,CAAC;AAO5E,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAAC;IACvC,cAAc,CAAC,EAAE,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,OAAO,GACP,eAAe,GACf,WAAW,GACX,SAAS,GACT,MAAM,GACN,YAAY,GACZ,aAAa,GACb,QAAQ,GACR,QAAQ,GACR,cAAc,GACd,eAAe,GACf,SAAS,GACT,SAAS,GACT,SAAS,GACT,cAAc,GACd,eAAe,GACf,SAAS,GACT,aAAa,GACb,cAAc,GACd,cAAc,GACd,eAAe,GACf,QAAQ,GACR,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,SAAS,GACT,gBAAgB,GAChB,cAAc,GACd,MAAM,GACN,SAAS,GACT,YAAY,GACZ,KAAK,GACL,gBAAgB,GAChB,iBAAiB,GACjB,SAAS,GACT,aAAa,GACb,iBAAiB,GACjB,mBAAmB,GACnB,qBAAqB,GACrB,aAAa,GACb,cAAc,GACd,OAAO,GACP,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,aAAa,CAAC;AAwNlB,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,cAAc,GACf,EAAE,uBAAuB,GAAG,WAAW,CAuNvC;AAED,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,SAAS,CAAC;CAC5B"}
|
|
@@ -3,8 +3,7 @@ import { json as jsonExtension } from "@codemirror/lang-json";
|
|
|
3
3
|
import { linter, lintGutter } from "@codemirror/lint";
|
|
4
4
|
import { EditorState } from "@codemirror/state";
|
|
5
5
|
import { EditorView } from "@codemirror/view";
|
|
6
|
-
import
|
|
7
|
-
import { tokyoNightDay } from "@uiw/codemirror-theme-tokyo-night-day";
|
|
6
|
+
import * as codeMirrorThemes from "@uiw/codemirror-themes-all";
|
|
8
7
|
import { basicSetup } from "codemirror";
|
|
9
8
|
import { makeJsonTemplate } from "../json/to_json";
|
|
10
9
|
import { enterKeyHandler } from "./enter_key_handler";
|
|
@@ -12,40 +11,187 @@ import { jsonCompletion } from "./json_completion";
|
|
|
12
11
|
import { jsonLinter } from "./json_linter";
|
|
13
12
|
import { debouncedJsonParser } from "./json_state";
|
|
14
13
|
import { statusBar } from "./status_bar";
|
|
15
|
-
|
|
14
|
+
const WHITE_THEME_COLORS = {
|
|
15
|
+
backgroundColor: "#fffdf7",
|
|
16
|
+
lighterBgColor: "#f3eee1",
|
|
17
|
+
borderColor: "#d4d0c4",
|
|
18
|
+
foregroundColor: "#111111",
|
|
19
|
+
accentColor: "#111111",
|
|
20
|
+
errorColor: "#232323",
|
|
21
|
+
selectionColor: "#d9d4c7",
|
|
22
|
+
};
|
|
23
|
+
const TOKYO_NIGHT_THEME_COLORS = {
|
|
24
|
+
backgroundColor: "#1a1b26",
|
|
25
|
+
lighterBgColor: "#1f2335",
|
|
26
|
+
borderColor: "#414868",
|
|
27
|
+
foregroundColor: "#c0caf5",
|
|
28
|
+
accentColor: "#7aa2f7",
|
|
29
|
+
errorColor: "#f7768e",
|
|
30
|
+
selectionColor: "#515c7e40",
|
|
31
|
+
};
|
|
32
|
+
const TOKYO_NIGHT_DAY_THEME_COLORS = {
|
|
33
|
+
backgroundColor: "#d5d6db",
|
|
34
|
+
lighterBgColor: "#e1e2e7",
|
|
35
|
+
borderColor: "#adb0bb",
|
|
36
|
+
foregroundColor: "#3760bf",
|
|
37
|
+
accentColor: "#2e7de9",
|
|
38
|
+
errorColor: "#f52a65",
|
|
39
|
+
selectionColor: "#3760bf33",
|
|
40
|
+
};
|
|
41
|
+
const BUILTIN_THEME_EXTENSIONS = {
|
|
42
|
+
abcdef: codeMirrorThemes.abcdef,
|
|
43
|
+
abyss: codeMirrorThemes.abyss,
|
|
44
|
+
androidstudio: codeMirrorThemes.androidstudio,
|
|
45
|
+
andromeda: codeMirrorThemes.andromeda,
|
|
46
|
+
atomone: codeMirrorThemes.atomone,
|
|
47
|
+
aura: codeMirrorThemes.aura,
|
|
48
|
+
"basic-dark": codeMirrorThemes.basicDark,
|
|
49
|
+
"basic-light": codeMirrorThemes.basicLight,
|
|
50
|
+
bbedit: codeMirrorThemes.bbedit,
|
|
51
|
+
bespin: codeMirrorThemes.bespin,
|
|
52
|
+
"console-dark": codeMirrorThemes.consoleDark,
|
|
53
|
+
"console-light": codeMirrorThemes.consoleLight,
|
|
54
|
+
copilot: codeMirrorThemes.copilot,
|
|
55
|
+
darcula: codeMirrorThemes.darcula,
|
|
56
|
+
dracula: codeMirrorThemes.dracula,
|
|
57
|
+
"duotone-dark": codeMirrorThemes.duotoneDark,
|
|
58
|
+
"duotone-light": codeMirrorThemes.duotoneLight,
|
|
59
|
+
eclipse: codeMirrorThemes.eclipse,
|
|
60
|
+
"github-dark": codeMirrorThemes.githubDark,
|
|
61
|
+
"github-light": codeMirrorThemes.githubLight,
|
|
62
|
+
"gruvbox-dark": codeMirrorThemes.gruvboxDark,
|
|
63
|
+
"gruvbox-light": codeMirrorThemes.gruvboxLight,
|
|
64
|
+
kimbie: codeMirrorThemes.kimbie,
|
|
65
|
+
material: codeMirrorThemes.material,
|
|
66
|
+
"material-dark": codeMirrorThemes.materialDark,
|
|
67
|
+
"material-light": codeMirrorThemes.materialLight,
|
|
68
|
+
monokai: codeMirrorThemes.monokai,
|
|
69
|
+
"monokai-dimmed": codeMirrorThemes.monokaiDimmed,
|
|
70
|
+
"noctis-lilac": codeMirrorThemes.noctisLilac,
|
|
71
|
+
nord: codeMirrorThemes.nord,
|
|
72
|
+
okaidia: codeMirrorThemes.okaidia,
|
|
73
|
+
quietlight: codeMirrorThemes.quietlight,
|
|
74
|
+
red: codeMirrorThemes.red,
|
|
75
|
+
"solarized-dark": codeMirrorThemes.solarizedDark,
|
|
76
|
+
"solarized-light": codeMirrorThemes.solarizedLight,
|
|
77
|
+
sublime: codeMirrorThemes.sublime,
|
|
78
|
+
"tokyo-night": codeMirrorThemes.tokyoNight,
|
|
79
|
+
"tokyo-night-day": codeMirrorThemes.tokyoNightDay,
|
|
80
|
+
"tokyo-night-storm": codeMirrorThemes.tokyoNightStorm,
|
|
81
|
+
"tomorrow-night-blue": codeMirrorThemes.tomorrowNightBlue,
|
|
82
|
+
"vscode-dark": codeMirrorThemes.vscodeDark,
|
|
83
|
+
"vscode-light": codeMirrorThemes.vscodeLight,
|
|
84
|
+
white: codeMirrorThemes.whiteLight,
|
|
85
|
+
"white-dark": codeMirrorThemes.whiteDark,
|
|
86
|
+
"white-light": codeMirrorThemes.whiteLight,
|
|
87
|
+
"xcode-dark": codeMirrorThemes.xcodeDark,
|
|
88
|
+
"xcode-light": codeMirrorThemes.xcodeLight,
|
|
89
|
+
};
|
|
90
|
+
const BUILTIN_THEME_DEFAULTS = {
|
|
91
|
+
abcdef: codeMirrorThemes.defaultSettingsAbcdef,
|
|
92
|
+
abyss: codeMirrorThemes.defaultSettingsAbyss,
|
|
93
|
+
androidstudio: codeMirrorThemes.defaultSettingsAndroidstudio,
|
|
94
|
+
andromeda: codeMirrorThemes.defaultSettingsAndromeda,
|
|
95
|
+
atomone: codeMirrorThemes.defaultSettingsAtomone,
|
|
96
|
+
aura: codeMirrorThemes.defaultSettingsAura,
|
|
97
|
+
"basic-dark": codeMirrorThemes.defaultSettingsBasicDark,
|
|
98
|
+
"basic-light": codeMirrorThemes.defaultSettingsBasicLight,
|
|
99
|
+
bbedit: codeMirrorThemes.defaultSettingsBbedit,
|
|
100
|
+
bespin: codeMirrorThemes.defaultSettingsBespin,
|
|
101
|
+
"console-dark": codeMirrorThemes.defaultSettingsConsoleDark,
|
|
102
|
+
"console-light": codeMirrorThemes.defaultSettingsConsoleLight,
|
|
103
|
+
copilot: codeMirrorThemes.defaultSettingsCopilot,
|
|
104
|
+
darcula: codeMirrorThemes.defaultSettingsDarcula,
|
|
105
|
+
dracula: codeMirrorThemes.defaultSettingsDracula,
|
|
106
|
+
"duotone-dark": codeMirrorThemes.defaultSettingsDuotoneDark,
|
|
107
|
+
"duotone-light": codeMirrorThemes.defaultSettingsDuotoneLight,
|
|
108
|
+
eclipse: codeMirrorThemes.defaultSettingsEclipse,
|
|
109
|
+
"github-dark": codeMirrorThemes.defaultSettingsGithubDark,
|
|
110
|
+
"github-light": codeMirrorThemes.defaultSettingsGithubLight,
|
|
111
|
+
"gruvbox-dark": codeMirrorThemes.defaultSettingsGruvboxDark,
|
|
112
|
+
"gruvbox-light": codeMirrorThemes.defaultSettingsGruvboxLight,
|
|
113
|
+
kimbie: codeMirrorThemes.defaultSettingsKimbie,
|
|
114
|
+
material: codeMirrorThemes.defaultSettingsMaterial,
|
|
115
|
+
"material-dark": codeMirrorThemes.defaultSettingsMaterialDark,
|
|
116
|
+
"material-light": codeMirrorThemes.defaultSettingsMaterialLight,
|
|
117
|
+
monokai: codeMirrorThemes.defaultSettingsMonokai,
|
|
118
|
+
"monokai-dimmed": codeMirrorThemes.defaultSettingsMonokaiDimmed,
|
|
119
|
+
"noctis-lilac": codeMirrorThemes.defaultSettingsNoctisLilac,
|
|
120
|
+
nord: codeMirrorThemes.defaultSettingsNord,
|
|
121
|
+
okaidia: codeMirrorThemes.defaultSettingsOkaidia,
|
|
122
|
+
quietlight: codeMirrorThemes.defaultSettingsQuietlight,
|
|
123
|
+
red: codeMirrorThemes.defaultSettingsRed,
|
|
124
|
+
"solarized-dark": codeMirrorThemes.defaultSettingsSolarizedDark,
|
|
125
|
+
"solarized-light": codeMirrorThemes.defaultSettingsSolarizedLight,
|
|
126
|
+
sublime: codeMirrorThemes.defaultSettingsSublime,
|
|
127
|
+
"tokyo-night": codeMirrorThemes.defaultSettingsTokyoNight,
|
|
128
|
+
"tokyo-night-day": codeMirrorThemes.defaultSettingsTokyoNightDay,
|
|
129
|
+
"tokyo-night-storm": codeMirrorThemes.defaultSettingsTokyoNightStorm,
|
|
130
|
+
"tomorrow-night-blue": codeMirrorThemes.defaultSettingsTomorrowNightBlue,
|
|
131
|
+
"vscode-dark": codeMirrorThemes.defaultSettingsVscodeDark,
|
|
132
|
+
"vscode-light": codeMirrorThemes.defaultSettingsVscodeLight,
|
|
133
|
+
white: codeMirrorThemes.defaultSettingsWhiteLight,
|
|
134
|
+
"white-dark": codeMirrorThemes.defaultSettingsWhiteDark,
|
|
135
|
+
"white-light": codeMirrorThemes.defaultSettingsWhiteLight,
|
|
136
|
+
"xcode-dark": codeMirrorThemes.defaultSettingsXcodeDark,
|
|
137
|
+
"xcode-light": codeMirrorThemes.defaultSettingsXcodeLight,
|
|
138
|
+
};
|
|
139
|
+
function pickColor(...candidates) {
|
|
140
|
+
for (const candidate of candidates) {
|
|
141
|
+
if (candidate && candidate !== "transparent") {
|
|
142
|
+
return candidate;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
function themeFromDefaults(defaults, themeExtension) {
|
|
148
|
+
const background = pickColor(defaults.background, defaults.gutterBackground);
|
|
149
|
+
const foreground = pickColor(defaults.caret, defaults.foreground, defaults.gutterForeground);
|
|
150
|
+
const selection = pickColor(defaults.selection, defaults.selectionMatch, defaults.lineHighlight);
|
|
151
|
+
return {
|
|
152
|
+
backgroundColor: background ?? "#1a1b26",
|
|
153
|
+
lighterBgColor: pickColor(defaults.gutterBackground, defaults.lineHighlight, background) ?? "#1f2335",
|
|
154
|
+
borderColor: pickColor(defaults.gutterBorder, defaults.selectionMatch, defaults.selection, defaults.foreground) ?? "#414868",
|
|
155
|
+
foregroundColor: foreground ?? "#c0caf5",
|
|
156
|
+
accentColor: pickColor(defaults.foreground, defaults.caret) ?? "#7aa2f7",
|
|
157
|
+
errorColor: pickColor(defaults.caret, defaults.foreground) ?? "#f7768e",
|
|
158
|
+
selectionColor: selection ?? "#515c7e40",
|
|
159
|
+
themeExtension,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function resolveBuiltinTheme(themeName) {
|
|
163
|
+
const themeExtension = BUILTIN_THEME_EXTENSIONS[themeName];
|
|
164
|
+
if (themeName === "white") {
|
|
165
|
+
return {
|
|
166
|
+
...WHITE_THEME_COLORS,
|
|
167
|
+
themeExtension,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (themeName === "tokyo-night") {
|
|
171
|
+
return {
|
|
172
|
+
...TOKYO_NIGHT_THEME_COLORS,
|
|
173
|
+
themeExtension,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (themeName === "tokyo-night-day") {
|
|
177
|
+
return {
|
|
178
|
+
...TOKYO_NIGHT_DAY_THEME_COLORS,
|
|
179
|
+
themeExtension,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return themeFromDefaults(BUILTIN_THEME_DEFAULTS[themeName], themeExtension);
|
|
183
|
+
}
|
|
184
|
+
export function createEditorState({ schema, readOnly, json, theme, otherExtension, }) {
|
|
16
185
|
const idToRecordDef = {};
|
|
17
186
|
for (const record of schema.records) {
|
|
18
187
|
idToRecordDef[record.id] = record;
|
|
19
188
|
}
|
|
20
189
|
const content = json ?? makeJsonTemplate(schema.type, idToRecordDef);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
lighterBgColor: "#1f2335",
|
|
27
|
-
borderColor: "#414868",
|
|
28
|
-
foregroundColor: "#c0caf5",
|
|
29
|
-
accentColor: "#7aa2f7",
|
|
30
|
-
errorColor: "#f7768e",
|
|
31
|
-
selectionColor: "#515c7e40",
|
|
32
|
-
themeExtension: tokyoNight,
|
|
33
|
-
};
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "tokyo-night-day": {
|
|
37
|
-
theme = {
|
|
38
|
-
backgroundColor: "#d5d6db",
|
|
39
|
-
lighterBgColor: "#e1e2e7",
|
|
40
|
-
borderColor: "#adb0bb",
|
|
41
|
-
foregroundColor: "#3760bf",
|
|
42
|
-
accentColor: "#2e7de9",
|
|
43
|
-
errorColor: "#f52a65",
|
|
44
|
-
selectionColor: "#3760bf33",
|
|
45
|
-
themeExtension: tokyoNightDay,
|
|
46
|
-
};
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
190
|
+
if (theme === undefined) {
|
|
191
|
+
theme = resolveBuiltinTheme("tokyo-night");
|
|
192
|
+
}
|
|
193
|
+
else if (typeof theme === "string") {
|
|
194
|
+
theme = resolveBuiltinTheme(theme);
|
|
49
195
|
}
|
|
50
196
|
return EditorState.create({
|
|
51
197
|
doc: JSON.stringify(content, null, 2),
|
|
@@ -246,6 +392,7 @@ export function createEditorState({ schema, readOnly, json, theme, }) {
|
|
|
246
392
|
borderTop: "1px solid",
|
|
247
393
|
},
|
|
248
394
|
}),
|
|
395
|
+
otherExtension ?? [],
|
|
249
396
|
],
|
|
250
397
|
});
|
|
251
398
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_editor_state.js","sourceRoot":"","sources":["../../src/codemirror/create_editor_state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,MAAM,UAAU,iBAAiB,CAAC,EAChC,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,KAAK,GACmB;IACxB,MAAM,aAAa,GAAuC,EAAE,CAAC;IAC7D,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;IACpC,CAAC;IACD,MAAM,OAAO,GA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AAS,EAAE,iBAAiB;iBAC7B;gBACD,8BAA8B,EAAE;oBAC9B,QAAQ,EAAE,MAAM;oBAChB,SAAS,EAAE,KAAK;oBAChB,UAAU,EAAE,KAAK;iBAClB;gBACD,qBAAqB,EAAE;oBACrB,OAAO,EAAE,MAAM;oBACf,aAAa,EAAE,QAAQ;oBACvB,GAAG,EAAE,KAAK;oBACV,IAAI,EAAE,GAAG;iBACV;gBACD,iCAAiC,EAAE;oBACjC,OAAO,EAAE,GAAG;oBACZ,SAAS,EAAE,MAAM;oBACjB,UAAU,EAAE,MAAM;iBACnB;gBACD,uCAAuC,EAAE;oBACvC,UAAU,EAAE,MAAM;oBAClB,UAAU,EAAE,MAAM;iBACnB;gBACD,sCAAsC,EAAE;oBACtC,UAAU,EAAE,MAAM;iBACnB;gBACD,mCAAmC,EAAE;oBACnC,SAAS,EAAE,KAAK;oBAChB,UAAU,EAAE,KAAK;oBACjB,SAAS,EAAE,WAAW;iBACvB;aACF,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { autocompletion, closeBrackets } from \"@codemirror/autocomplete\";\nimport { json as jsonExtension } from \"@codemirror/lang-json\";\nimport { linter, lintGutter } from \"@codemirror/lint\";\nimport { EditorState, Extension } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport { tokyoNight } from \"@uiw/codemirror-theme-tokyo-night\";\nimport { tokyoNightDay } from \"@uiw/codemirror-theme-tokyo-night-day\";\nimport { basicSetup } from \"codemirror\";\nimport { makeJsonTemplate } from \"../json/to_json\";\nimport type { Json, RecordDefinition, TypeDefinition } from \"../json/types\";\nimport { enterKeyHandler } from \"./enter_key_handler\";\nimport { jsonCompletion } from \"./json_completion\";\nimport { jsonLinter } from \"./json_linter\";\nimport { debouncedJsonParser } from \"./json_state\";\nimport { statusBar } from \"./status_bar\";\n\nexport type CreateEditorStateParams = {\n schema: TypeDefinition;\n readOnly?: true;\n json?: Json;\n theme?: \"tokyo-night\" | \"tokyo-night-day\" | CustomTheme;\n};\n\nexport function createEditorState({\n schema,\n readOnly,\n json,\n theme,\n}: CreateEditorStateParams): EditorState {\n const idToRecordDef: { [id: string]: RecordDefinition } = {};\n for (const record of schema.records) {\n idToRecordDef[record.id] = record;\n }\n const content = json ?? makeJsonTemplate(schema.type, idToRecordDef);\n\n switch (theme) {\n case undefined:\n case \"tokyo-night\": {\n theme = {\n backgroundColor: \"#1a1b26\",\n lighterBgColor: \"#1f2335\",\n borderColor: \"#414868\",\n foregroundColor: \"#c0caf5\",\n accentColor: \"#7aa2f7\",\n errorColor: \"#f7768e\",\n selectionColor: \"#515c7e40\",\n themeExtension: tokyoNight,\n };\n break;\n }\n case \"tokyo-night-day\": {\n theme = {\n backgroundColor: \"#d5d6db\",\n lighterBgColor: \"#e1e2e7\",\n borderColor: \"#adb0bb\",\n foregroundColor: \"#3760bf\",\n accentColor: \"#2e7de9\",\n errorColor: \"#f52a65\",\n selectionColor: \"#3760bf33\",\n themeExtension: tokyoNightDay,\n };\n break;\n }\n }\n\n return EditorState.create({\n doc: JSON.stringify(content, null, 2),\n extensions: [\n EditorState.readOnly.of(!!readOnly),\n readOnly ? [] : enterKeyHandler(schema),\n basicSetup,\n EditorState.languageData.of(() => [\n {\n closeBrackets: { before: \",]}\" },\n },\n ]),\n closeBrackets(),\n theme.themeExtension ?? [],\n jsonExtension(),\n debouncedJsonParser(schema),\n linter(jsonLinter(readOnly ? \"read-only\" : \"editable\")),\n autocompletion({\n override: [jsonCompletion(schema)],\n }),\n lintGutter(),\n statusBar(),\n EditorView.theme({\n \"&\": {\n fontSize: \"14px\",\n height: \"100%\",\n },\n \".cm-scroller\": {\n fontFamily: \"'JetBrains Mono', monospace\",\n overflow: \"auto\",\n },\n \".cm-lintRange-info\": {\n backgroundImage: \"none\",\n },\n \".cm-lintRange-info:hover\": {\n backgroundColor: theme.selectionColor,\n },\n \".cm-lintRange-error\": {\n backgroundImage: \"none\",\n borderBottom: `3px solid ${theme.errorColor}`,\n },\n \".cm-tooltip-hover\": {\n backgroundColor: theme.lighterBgColor,\n border: `1px solid ${theme.borderColor}`,\n borderRadius: \"4px\",\n padding: \"8px 12px\",\n boxShadow: \"0 4px 12px rgba(0, 0, 0, 0.5)\",\n fontSize: \"14px\",\n lineHeight: \"1.4\",\n color: theme.foregroundColor,\n },\n \".cm-tooltip.cm-tooltip-lint\": {\n backgroundColor: theme.lighterBgColor,\n border: `1px solid ${theme.borderColor}`,\n borderRadius: \"4px\",\n padding: \"8px 12px\",\n boxShadow: \"0 4px 12px rgba(0, 0, 0, 0.5)\",\n fontSize: \"14px\", // Ensure consistency\n color: theme.foregroundColor,\n },\n \".cm-tooltip-lint .cm-diagnostic-error\": {\n fontWeight: \"bold\",\n color: theme.errorColor,\n },\n \".cm-status-bar\": {\n backgroundColor: theme.lighterBgColor,\n borderTopColor: theme.borderColor,\n color: theme.accentColor,\n },\n \".cm-diagnostic-textarea\": {\n backgroundColor: theme.lighterBgColor,\n borderColor: theme.borderColor,\n color: theme.foregroundColor,\n },\n \".cm-diagnostic-textarea[readonly]\": {\n backgroundColor: theme.backgroundColor,\n },\n \".cm-diagnostic-input\": {\n backgroundColor: theme.lighterBgColor,\n borderColor: theme.borderColor,\n color: theme.foregroundColor,\n },\n \".cm-diagnostic-button\": {\n backgroundColor: theme.lighterBgColor,\n borderColor: theme.borderColor,\n color: theme.foregroundColor,\n },\n \".cm-diagnostic-button:hover\": {\n backgroundColor: theme.borderColor,\n },\n \".cm-diagnostic-error-message\": {\n color: theme.errorColor,\n },\n \".diagnostic-row + .diagnostic-row\": {\n borderTopColor: theme.borderColor,\n },\n }),\n EditorView.baseTheme({\n \".cm-lint-marker-info\": {\n display: \"none\",\n },\n \".cm-status-bar\": {\n display: \"flex\",\n flexDirection: \"row-reverse\",\n justifyContent: \"flex-end\",\n padding: \"4px 12px\",\n borderTop: \"1px solid\",\n fontSize: \"12px\",\n height: \"16px\",\n },\n \".cm-status-bar-link\": {\n textDecoration: \"none\",\n cursor: \"pointer\",\n },\n \".cm-status-bar-link:hover\": {\n textDecoration: \"underline\",\n },\n \".cm-status-bar-link:hover ~ .cm-status-bar-link\": {\n textDecoration: \"underline\",\n },\n \".cm-diagnostic-wrapper\": {\n fontSize: \"12px\",\n lineHeight: \"1.3\",\n padding: \"2px\",\n },\n \".cm-diagnostic-controls\": {\n marginTop: \"4px\",\n display: \"flex\",\n gap: \"6px\",\n alignItems: \"center\",\n },\n \".cm-diagnostic-label\": {\n whiteSpace: \"nowrap\",\n fontWeight: \"500\",\n minWidth: \"64px\",\n },\n \".cm-diagnostic-textarea\": {\n flex: \"1\",\n padding: \"3px 6px\",\n border: \"1px solid\",\n borderRadius: \"3px\",\n fontSize: \"12px\",\n fontFamily: \"'JetBrains Mono', monospace\",\n resize: \"none\",\n overflow: \"auto\",\n boxSizing: \"border-box\",\n },\n \".cm-diagnostic-textarea[readonly]\": {\n cursor: \"default\",\n },\n \".cm-diagnostic-input\": {\n padding: \"3px 6px\",\n border: \"1px solid\",\n borderRadius: \"3px\",\n fontSize: \"12px\",\n fontFamily: \"'JetBrains Mono', monospace\",\n boxSizing: \"border-box\",\n width: \"100%\",\n },\n \".cm-diagnostic-button\": {\n padding: \"3px 12px\",\n border: \"1px solid\",\n borderRadius: \"3px\",\n fontSize: \"12px\",\n fontFamily: \"'JetBrains Mono', monospace\",\n cursor: \"pointer\",\n boxSizing: \"border-box\",\n },\n \".cm-diagnostic-button:active\": {\n transform: \"translateY(1px)\",\n },\n \".cm-diagnostic-error-message\": {\n fontSize: \"11px\",\n marginTop: \"2px\",\n fontWeight: \"500\",\n },\n \".cm-timestamp-field\": {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"2px\",\n flex: \"1\",\n },\n \".cm-tooltip-lint .cm-diagnostic\": {\n padding: \"0\",\n borderTop: \"none\",\n borderLeft: \"none\",\n },\n \".cm-tooltip-lint .cm-diagnostic-error\": {\n borderLeft: \"none\",\n fontWeight: \"bold\",\n },\n \".cm-tooltip-lint .cm-diagnostic-info\": {\n borderLeft: \"none\",\n },\n \".diagnostic-row + .diagnostic-row\": {\n marginTop: \"8px\",\n paddingTop: \"8px\",\n borderTop: \"1px solid\",\n },\n }),\n ],\n });\n}\n\nexport interface CustomTheme {\n backgroundColor: string;\n lighterBgColor: string;\n borderColor: string;\n foregroundColor: string;\n accentColor: string;\n errorColor: string;\n selectionColor: string;\n themeExtension?: Extension;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create_editor_state.js","sourceRoot":"","sources":["../../src/codemirror/create_editor_state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA2DzC,MAAM,kBAAkB,GAAwC;IAC9D,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,SAAS;IACzB,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,SAAS;IAC1B,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE,SAAS;IACrB,cAAc,EAAE,SAA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AiC,EAAE;oBACjC,OAAO,EAAE,GAAG;oBACZ,SAAS,EAAE,MAAM;oBACjB,UAAU,EAAE,MAAM;iBACnB;gBACD,uCAAuC,EAAE;oBACvC,UAAU,EAAE,MAAM;oBAClB,UAAU,EAAE,MAAM;iBACnB;gBACD,sCAAsC,EAAE;oBACtC,UAAU,EAAE,MAAM;iBACnB;gBACD,mCAAmC,EAAE;oBACnC,SAAS,EAAE,KAAK;oBAChB,UAAU,EAAE,KAAK;oBACjB,SAAS,EAAE,WAAW;iBACvB;aACF,CAAC;YACF,cAAc,IAAI,EAAE;SACrB;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { autocompletion, closeBrackets } from \"@codemirror/autocomplete\";\nimport { json as jsonExtension } from \"@codemirror/lang-json\";\nimport { linter, lintGutter } from \"@codemirror/lint\";\nimport { EditorState, Extension } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport * as codeMirrorThemes from \"@uiw/codemirror-themes-all\";\nimport { basicSetup } from \"codemirror\";\nimport { makeJsonTemplate } from \"../json/to_json\";\nimport type { Json, RecordDefinition, TypeDefinition } from \"../json/types\";\nimport { enterKeyHandler } from \"./enter_key_handler\";\nimport { jsonCompletion } from \"./json_completion\";\nimport { jsonLinter } from \"./json_linter\";\nimport { debouncedJsonParser } from \"./json_state\";\nimport { statusBar } from \"./status_bar\";\n\nexport type CreateEditorStateParams = {\n schema: TypeDefinition;\n readOnly?: true;\n json?: Json;\n theme?: BuiltinThemeName | CustomTheme;\n otherExtension?: Extension;\n};\n\nexport type BuiltinThemeName =\n | \"abcdef\"\n | \"abyss\"\n | \"androidstudio\"\n | \"andromeda\"\n | \"atomone\"\n | \"aura\"\n | \"basic-dark\"\n | \"basic-light\"\n | \"bbedit\"\n | \"bespin\"\n | \"console-dark\"\n | \"console-light\"\n | \"copilot\"\n | \"darcula\"\n | \"dracula\"\n | \"duotone-dark\"\n | \"duotone-light\"\n | \"eclipse\"\n | \"github-dark\"\n | \"github-light\"\n | \"gruvbox-dark\"\n | \"gruvbox-light\"\n | \"kimbie\"\n | \"material\"\n | \"material-dark\"\n | \"material-light\"\n | \"monokai\"\n | \"monokai-dimmed\"\n | \"noctis-lilac\"\n | \"nord\"\n | \"okaidia\"\n | \"quietlight\"\n | \"red\"\n | \"solarized-dark\"\n | \"solarized-light\"\n | \"sublime\"\n | \"tokyo-night\"\n | \"tokyo-night-day\"\n | \"tokyo-night-storm\"\n | \"tomorrow-night-blue\"\n | \"vscode-dark\"\n | \"vscode-light\"\n | \"white\"\n | \"white-dark\"\n | \"white-light\"\n | \"xcode-dark\"\n | \"xcode-light\";\n\nconst WHITE_THEME_COLORS: Omit<CustomTheme, \"themeExtension\"> = {\n backgroundColor: \"#fffdf7\",\n lighterBgColor: \"#f3eee1\",\n borderColor: \"#d4d0c4\",\n foregroundColor: \"#111111\",\n accentColor: \"#111111\",\n errorColor: \"#232323\",\n selectionColor: \"#d9d4c7\",\n};\n\nconst TOKYO_NIGHT_THEME_COLORS: Omit<CustomTheme, \"themeExtension\"> = {\n backgroundColor: \"#1a1b26\",\n lighterBgColor: \"#1f2335\",\n borderColor: \"#414868\",\n foregroundColor: \"#c0caf5\",\n accentColor: \"#7aa2f7\",\n errorColor: \"#f7768e\",\n selectionColor: \"#515c7e40\",\n};\n\nconst TOKYO_NIGHT_DAY_THEME_COLORS: Omit<CustomTheme, \"themeExtension\"> = {\n backgroundColor: \"#d5d6db\",\n lighterBgColor: \"#e1e2e7\",\n borderColor: \"#adb0bb\",\n foregroundColor: \"#3760bf\",\n accentColor: \"#2e7de9\",\n errorColor: \"#f52a65\",\n selectionColor: \"#3760bf33\",\n};\n\ntype ThemeDefaults = Partial<{\n background: string;\n foreground: string;\n caret: string;\n selection: string;\n selectionMatch: string;\n gutterBackground: string;\n gutterForeground: string;\n gutterBorder: string;\n lineHighlight: string;\n}>;\n\nconst BUILTIN_THEME_EXTENSIONS: Record<BuiltinThemeName, Extension> = {\n abcdef: codeMirrorThemes.abcdef,\n abyss: codeMirrorThemes.abyss,\n androidstudio: codeMirrorThemes.androidstudio,\n andromeda: codeMirrorThemes.andromeda,\n atomone: codeMirrorThemes.atomone,\n aura: codeMirrorThemes.aura,\n \"basic-dark\": codeMirrorThemes.basicDark,\n \"basic-light\": codeMirrorThemes.basicLight,\n bbedit: codeMirrorThemes.bbedit,\n bespin: codeMirrorThemes.bespin,\n \"console-dark\": codeMirrorThemes.consoleDark,\n \"console-light\": codeMirrorThemes.consoleLight,\n copilot: codeMirrorThemes.copilot,\n darcula: codeMirrorThemes.darcula,\n dracula: codeMirrorThemes.dracula,\n \"duotone-dark\": codeMirrorThemes.duotoneDark,\n \"duotone-light\": codeMirrorThemes.duotoneLight,\n eclipse: codeMirrorThemes.eclipse,\n \"github-dark\": codeMirrorThemes.githubDark,\n \"github-light\": codeMirrorThemes.githubLight,\n \"gruvbox-dark\": codeMirrorThemes.gruvboxDark,\n \"gruvbox-light\": codeMirrorThemes.gruvboxLight,\n kimbie: codeMirrorThemes.kimbie,\n material: codeMirrorThemes.material,\n \"material-dark\": codeMirrorThemes.materialDark,\n \"material-light\": codeMirrorThemes.materialLight,\n monokai: codeMirrorThemes.monokai,\n \"monokai-dimmed\": codeMirrorThemes.monokaiDimmed,\n \"noctis-lilac\": codeMirrorThemes.noctisLilac,\n nord: codeMirrorThemes.nord,\n okaidia: codeMirrorThemes.okaidia,\n quietlight: codeMirrorThemes.quietlight,\n red: codeMirrorThemes.red,\n \"solarized-dark\": codeMirrorThemes.solarizedDark,\n \"solarized-light\": codeMirrorThemes.solarizedLight,\n sublime: codeMirrorThemes.sublime,\n \"tokyo-night\": codeMirrorThemes.tokyoNight,\n \"tokyo-night-day\": codeMirrorThemes.tokyoNightDay,\n \"tokyo-night-storm\": codeMirrorThemes.tokyoNightStorm,\n \"tomorrow-night-blue\": codeMirrorThemes.tomorrowNightBlue,\n \"vscode-dark\": codeMirrorThemes.vscodeDark,\n \"vscode-light\": codeMirrorThemes.vscodeLight,\n white: codeMirrorThemes.whiteLight,\n \"white-dark\": codeMirrorThemes.whiteDark,\n \"white-light\": codeMirrorThemes.whiteLight,\n \"xcode-dark\": codeMirrorThemes.xcodeDark,\n \"xcode-light\": codeMirrorThemes.xcodeLight,\n};\n\nconst BUILTIN_THEME_DEFAULTS: Record<BuiltinThemeName, ThemeDefaults> = {\n abcdef: codeMirrorThemes.defaultSettingsAbcdef,\n abyss: codeMirrorThemes.defaultSettingsAbyss,\n androidstudio: codeMirrorThemes.defaultSettingsAndroidstudio,\n andromeda: codeMirrorThemes.defaultSettingsAndromeda,\n atomone: codeMirrorThemes.defaultSettingsAtomone,\n aura: codeMirrorThemes.defaultSettingsAura,\n \"basic-dark\": codeMirrorThemes.defaultSettingsBasicDark,\n \"basic-light\": codeMirrorThemes.defaultSettingsBasicLight,\n bbedit: codeMirrorThemes.defaultSettingsBbedit,\n bespin: codeMirrorThemes.defaultSettingsBespin,\n \"console-dark\": codeMirrorThemes.defaultSettingsConsoleDark,\n \"console-light\": codeMirrorThemes.defaultSettingsConsoleLight,\n copilot: codeMirrorThemes.defaultSettingsCopilot,\n darcula: codeMirrorThemes.defaultSettingsDarcula,\n dracula: codeMirrorThemes.defaultSettingsDracula,\n \"duotone-dark\": codeMirrorThemes.defaultSettingsDuotoneDark,\n \"duotone-light\": codeMirrorThemes.defaultSettingsDuotoneLight,\n eclipse: codeMirrorThemes.defaultSettingsEclipse,\n \"github-dark\": codeMirrorThemes.defaultSettingsGithubDark,\n \"github-light\": codeMirrorThemes.defaultSettingsGithubLight,\n \"gruvbox-dark\": codeMirrorThemes.defaultSettingsGruvboxDark,\n \"gruvbox-light\": codeMirrorThemes.defaultSettingsGruvboxLight,\n kimbie: codeMirrorThemes.defaultSettingsKimbie,\n material: codeMirrorThemes.defaultSettingsMaterial,\n \"material-dark\": codeMirrorThemes.defaultSettingsMaterialDark,\n \"material-light\": codeMirrorThemes.defaultSettingsMaterialLight,\n monokai: codeMirrorThemes.defaultSettingsMonokai,\n \"monokai-dimmed\": codeMirrorThemes.defaultSettingsMonokaiDimmed,\n \"noctis-lilac\": codeMirrorThemes.defaultSettingsNoctisLilac,\n nord: codeMirrorThemes.defaultSettingsNord,\n okaidia: codeMirrorThemes.defaultSettingsOkaidia,\n quietlight: codeMirrorThemes.defaultSettingsQuietlight,\n red: codeMirrorThemes.defaultSettingsRed,\n \"solarized-dark\": codeMirrorThemes.defaultSettingsSolarizedDark,\n \"solarized-light\": codeMirrorThemes.defaultSettingsSolarizedLight,\n sublime: codeMirrorThemes.defaultSettingsSublime,\n \"tokyo-night\": codeMirrorThemes.defaultSettingsTokyoNight,\n \"tokyo-night-day\": codeMirrorThemes.defaultSettingsTokyoNightDay,\n \"tokyo-night-storm\": codeMirrorThemes.defaultSettingsTokyoNightStorm,\n \"tomorrow-night-blue\": codeMirrorThemes.defaultSettingsTomorrowNightBlue,\n \"vscode-dark\": codeMirrorThemes.defaultSettingsVscodeDark,\n \"vscode-light\": codeMirrorThemes.defaultSettingsVscodeLight,\n white: codeMirrorThemes.defaultSettingsWhiteLight,\n \"white-dark\": codeMirrorThemes.defaultSettingsWhiteDark,\n \"white-light\": codeMirrorThemes.defaultSettingsWhiteLight,\n \"xcode-dark\": codeMirrorThemes.defaultSettingsXcodeDark,\n \"xcode-light\": codeMirrorThemes.defaultSettingsXcodeLight,\n};\n\nfunction pickColor(\n ...candidates: Array<string | undefined>\n): string | undefined {\n for (const candidate of candidates) {\n if (candidate && candidate !== \"transparent\") {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction themeFromDefaults(\n defaults: ThemeDefaults,\n themeExtension: Extension,\n): CustomTheme {\n const background = pickColor(defaults.background, defaults.gutterBackground);\n const foreground = pickColor(\n defaults.caret,\n defaults.foreground,\n defaults.gutterForeground,\n );\n const selection = pickColor(\n defaults.selection,\n defaults.selectionMatch,\n defaults.lineHighlight,\n );\n return {\n backgroundColor: background ?? \"#1a1b26\",\n lighterBgColor:\n pickColor(\n defaults.gutterBackground,\n defaults.lineHighlight,\n background,\n ) ?? \"#1f2335\",\n borderColor:\n pickColor(\n defaults.gutterBorder,\n defaults.selectionMatch,\n defaults.selection,\n defaults.foreground,\n ) ?? \"#414868\",\n foregroundColor: foreground ?? \"#c0caf5\",\n accentColor: pickColor(defaults.foreground, defaults.caret) ?? \"#7aa2f7\",\n errorColor: pickColor(defaults.caret, defaults.foreground) ?? \"#f7768e\",\n selectionColor: selection ?? \"#515c7e40\",\n themeExtension,\n };\n}\n\nfunction resolveBuiltinTheme(themeName: BuiltinThemeName): CustomTheme {\n const themeExtension = BUILTIN_THEME_EXTENSIONS[themeName];\n if (themeName === \"white\") {\n return {\n ...WHITE_THEME_COLORS,\n themeExtension,\n };\n }\n if (themeName === \"tokyo-night\") {\n return {\n ...TOKYO_NIGHT_THEME_COLORS,\n themeExtension,\n };\n }\n if (themeName === \"tokyo-night-day\") {\n return {\n ...TOKYO_NIGHT_DAY_THEME_COLORS,\n themeExtension,\n };\n }\n return themeFromDefaults(BUILTIN_THEME_DEFAULTS[themeName], themeExtension);\n}\n\nexport function createEditorState({\n schema,\n readOnly,\n json,\n theme,\n otherExtension,\n}: CreateEditorStateParams): EditorState {\n const idToRecordDef: { [id: string]: RecordDefinition } = {};\n for (const record of schema.records) {\n idToRecordDef[record.id] = record;\n }\n const content = json ?? makeJsonTemplate(schema.type, idToRecordDef);\n\n if (theme === undefined) {\n theme = resolveBuiltinTheme(\"tokyo-night\");\n } else if (typeof theme === \"string\") {\n theme = resolveBuiltinTheme(theme);\n }\n\n return EditorState.create({\n doc: JSON.stringify(content, null, 2),\n extensions: [\n EditorState.readOnly.of(!!readOnly),\n readOnly ? [] : enterKeyHandler(schema),\n basicSetup,\n EditorState.languageData.of(() => [\n {\n closeBrackets: { before: \",]}\" },\n },\n ]),\n closeBrackets(),\n theme.themeExtension ?? [],\n jsonExtension(),\n debouncedJsonParser(schema),\n linter(jsonLinter(readOnly ? \"read-only\" : \"editable\")),\n autocompletion({\n override: [jsonCompletion(schema)],\n }),\n lintGutter(),\n statusBar(),\n EditorView.theme({\n \"&\": {\n fontSize: \"14px\",\n height: \"100%\",\n },\n \".cm-scroller\": {\n fontFamily: \"'JetBrains Mono', monospace\",\n overflow: \"auto\",\n },\n \".cm-lintRange-info\": {\n backgroundImage: \"none\",\n },\n \".cm-lintRange-info:hover\": {\n backgroundColor: theme.selectionColor,\n },\n \".cm-lintRange-error\": {\n backgroundImage: \"none\",\n borderBottom: `3px solid ${theme.errorColor}`,\n },\n \".cm-tooltip-hover\": {\n backgroundColor: theme.lighterBgColor,\n border: `1px solid ${theme.borderColor}`,\n borderRadius: \"4px\",\n padding: \"8px 12px\",\n boxShadow: \"0 4px 12px rgba(0, 0, 0, 0.5)\",\n fontSize: \"14px\",\n lineHeight: \"1.4\",\n color: theme.foregroundColor,\n },\n \".cm-tooltip.cm-tooltip-lint\": {\n backgroundColor: theme.lighterBgColor,\n border: `1px solid ${theme.borderColor}`,\n borderRadius: \"4px\",\n padding: \"8px 12px\",\n boxShadow: \"0 4px 12px rgba(0, 0, 0, 0.5)\",\n fontSize: \"14px\", // Ensure consistency\n color: theme.foregroundColor,\n },\n \".cm-tooltip-lint .cm-diagnostic-error\": {\n fontWeight: \"bold\",\n color: theme.errorColor,\n },\n \".cm-status-bar\": {\n backgroundColor: theme.lighterBgColor,\n borderTopColor: theme.borderColor,\n color: theme.accentColor,\n },\n \".cm-diagnostic-textarea\": {\n backgroundColor: theme.lighterBgColor,\n borderColor: theme.borderColor,\n color: theme.foregroundColor,\n },\n \".cm-diagnostic-textarea[readonly]\": {\n backgroundColor: theme.backgroundColor,\n },\n \".cm-diagnostic-input\": {\n backgroundColor: theme.lighterBgColor,\n borderColor: theme.borderColor,\n color: theme.foregroundColor,\n },\n \".cm-diagnostic-button\": {\n backgroundColor: theme.lighterBgColor,\n borderColor: theme.borderColor,\n color: theme.foregroundColor,\n },\n \".cm-diagnostic-button:hover\": {\n backgroundColor: theme.borderColor,\n },\n \".cm-diagnostic-error-message\": {\n color: theme.errorColor,\n },\n \".diagnostic-row + .diagnostic-row\": {\n borderTopColor: theme.borderColor,\n },\n }),\n EditorView.baseTheme({\n \".cm-lint-marker-info\": {\n display: \"none\",\n },\n \".cm-status-bar\": {\n display: \"flex\",\n flexDirection: \"row-reverse\",\n justifyContent: \"flex-end\",\n padding: \"4px 12px\",\n borderTop: \"1px solid\",\n fontSize: \"12px\",\n height: \"16px\",\n },\n \".cm-status-bar-link\": {\n textDecoration: \"none\",\n cursor: \"pointer\",\n },\n \".cm-status-bar-link:hover\": {\n textDecoration: \"underline\",\n },\n \".cm-status-bar-link:hover ~ .cm-status-bar-link\": {\n textDecoration: \"underline\",\n },\n \".cm-diagnostic-wrapper\": {\n fontSize: \"12px\",\n lineHeight: \"1.3\",\n padding: \"2px\",\n },\n \".cm-diagnostic-controls\": {\n marginTop: \"4px\",\n display: \"flex\",\n gap: \"6px\",\n alignItems: \"center\",\n },\n \".cm-diagnostic-label\": {\n whiteSpace: \"nowrap\",\n fontWeight: \"500\",\n minWidth: \"64px\",\n },\n \".cm-diagnostic-textarea\": {\n flex: \"1\",\n padding: \"3px 6px\",\n border: \"1px solid\",\n borderRadius: \"3px\",\n fontSize: \"12px\",\n fontFamily: \"'JetBrains Mono', monospace\",\n resize: \"none\",\n overflow: \"auto\",\n boxSizing: \"border-box\",\n },\n \".cm-diagnostic-textarea[readonly]\": {\n cursor: \"default\",\n },\n \".cm-diagnostic-input\": {\n padding: \"3px 6px\",\n border: \"1px solid\",\n borderRadius: \"3px\",\n fontSize: \"12px\",\n fontFamily: \"'JetBrains Mono', monospace\",\n boxSizing: \"border-box\",\n width: \"100%\",\n },\n \".cm-diagnostic-button\": {\n padding: \"3px 12px\",\n border: \"1px solid\",\n borderRadius: \"3px\",\n fontSize: \"12px\",\n fontFamily: \"'JetBrains Mono', monospace\",\n cursor: \"pointer\",\n boxSizing: \"border-box\",\n },\n \".cm-diagnostic-button:active\": {\n transform: \"translateY(1px)\",\n },\n \".cm-diagnostic-error-message\": {\n fontSize: \"11px\",\n marginTop: \"2px\",\n fontWeight: \"500\",\n },\n \".cm-timestamp-field\": {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"2px\",\n flex: \"1\",\n },\n \".cm-tooltip-lint .cm-diagnostic\": {\n padding: \"0\",\n borderTop: \"none\",\n borderLeft: \"none\",\n },\n \".cm-tooltip-lint .cm-diagnostic-error\": {\n borderLeft: \"none\",\n fontWeight: \"bold\",\n },\n \".cm-tooltip-lint .cm-diagnostic-info\": {\n borderLeft: \"none\",\n },\n \".diagnostic-row + .diagnostic-row\": {\n marginTop: \"8px\",\n paddingTop: \"8px\",\n borderTop: \"1px solid\",\n },\n }),\n otherExtension ?? [],\n ],\n });\n}\n\nexport interface CustomTheme {\n backgroundColor: string;\n lighterBgColor: string;\n borderColor: string;\n foregroundColor: string;\n accentColor: string;\n errorColor: string;\n selectionColor: string;\n themeExtension?: Extension;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_linter.d.ts","sourceRoot":"","sources":["../../src/codemirror/json_linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"json_linter.d.ts","sourceRoot":"","sources":["../../src/codemirror/json_linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,wBAAgB,UAAU,CACxB,QAAQ,EAAE,UAAU,GAAG,WAAW,GACjC,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAAE,CAuBpC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { makeJsonTemplate } from "../json/to_json";
|
|
2
|
+
import { jsonStateField } from "./json_state";
|
|
2
3
|
export function jsonLinter(editable) {
|
|
3
4
|
function lintJson(view) {
|
|
4
5
|
const jsonState = view.state.field(jsonStateField, false);
|
|
@@ -168,7 +169,6 @@ function getTimestampControlRows(view, typeHint) {
|
|
|
168
169
|
insert: newJsonString,
|
|
169
170
|
},
|
|
170
171
|
});
|
|
171
|
-
ensureJsonState(view, view.schema);
|
|
172
172
|
};
|
|
173
173
|
// Enter key handler for unix_millis input
|
|
174
174
|
unixMillisInput.addEventListener("keydown", (e) => {
|
|
@@ -231,6 +231,64 @@ function getTimestampControlRows(view, typeHint) {
|
|
|
231
231
|
controlsRow.appendChild(row3);
|
|
232
232
|
return [headerRow, controlsRow];
|
|
233
233
|
}
|
|
234
|
+
function getEnumDropdown(view, typeHint, enumDefinition) {
|
|
235
|
+
const controlsRow = document.createElement("div");
|
|
236
|
+
controlsRow.className = "cm-diagnostic-controls";
|
|
237
|
+
const label = document.createElement("span");
|
|
238
|
+
label.className = "cm-diagnostic-label";
|
|
239
|
+
label.textContent = "Variant:";
|
|
240
|
+
const select = document.createElement("select");
|
|
241
|
+
select.className = "cm-diagnostic-input";
|
|
242
|
+
{
|
|
243
|
+
// Add the UNKNOWN variant
|
|
244
|
+
const option = document.createElement("option");
|
|
245
|
+
option.value = "UNKNOWN";
|
|
246
|
+
option.textContent = "UNKNOWN";
|
|
247
|
+
select.appendChild(option);
|
|
248
|
+
}
|
|
249
|
+
for (const variant of enumDefinition.variants) {
|
|
250
|
+
const option = document.createElement("option");
|
|
251
|
+
option.value = variant.name;
|
|
252
|
+
option.textContent = variant.name;
|
|
253
|
+
select.appendChild(option);
|
|
254
|
+
}
|
|
255
|
+
const currentValue = typeHint.valueContext?.value;
|
|
256
|
+
if (currentValue &&
|
|
257
|
+
currentValue.kind === "literal" &&
|
|
258
|
+
currentValue.type === "string") {
|
|
259
|
+
try {
|
|
260
|
+
select.value = JSON.parse(currentValue.jsonCode);
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
// Ignore invalid value and keep the default selection.
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
select.addEventListener("change", () => {
|
|
267
|
+
const variant = enumDefinition.variants.find((variant) => variant.name === select.value);
|
|
268
|
+
let newJsonString;
|
|
269
|
+
if (variant.type) {
|
|
270
|
+
const jsonState = view.state.field(jsonStateField, false);
|
|
271
|
+
const valueJson = makeJsonTemplate(variant.type, jsonState.recordIdToDefinition);
|
|
272
|
+
newJsonString = JSON.stringify({
|
|
273
|
+
kind: variant.name,
|
|
274
|
+
value: valueJson,
|
|
275
|
+
}, null, 2).replaceAll("\n", "\n" + " ".repeat(typeHint.valueContext.value.indent));
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
newJsonString = JSON.stringify(variant.name);
|
|
279
|
+
}
|
|
280
|
+
view.dispatch({
|
|
281
|
+
changes: {
|
|
282
|
+
from: typeHint.segment.start,
|
|
283
|
+
to: typeHint.segment.end,
|
|
284
|
+
insert: newJsonString,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
controlsRow.appendChild(label);
|
|
289
|
+
controlsRow.appendChild(select);
|
|
290
|
+
return controlsRow;
|
|
291
|
+
}
|
|
234
292
|
function hintToDiagnostic(typeHint, editable) {
|
|
235
293
|
const { message } = typeHint;
|
|
236
294
|
return {
|
|
@@ -257,13 +315,19 @@ function hintToDiagnostic(typeHint, editable) {
|
|
|
257
315
|
rows = getTimestampControlRows(view, typeHint);
|
|
258
316
|
}
|
|
259
317
|
else {
|
|
260
|
-
// Display the message
|
|
318
|
+
// Display the message.
|
|
261
319
|
const pieces = typeof message === "string" ? [message] : message;
|
|
262
320
|
rows = pieces.map((piece) => {
|
|
263
321
|
const row = document.createElement("div");
|
|
264
322
|
row.textContent = piece;
|
|
265
323
|
return row;
|
|
266
324
|
});
|
|
325
|
+
if (typeHint.valueContext &&
|
|
326
|
+
typeHint.enumDefinition &&
|
|
327
|
+
editable === "editable") {
|
|
328
|
+
// Render a dropdown for selecting a different variant.
|
|
329
|
+
rows.push(getEnumDropdown(view, typeHint, typeHint.enumDefinition));
|
|
330
|
+
}
|
|
267
331
|
}
|
|
268
332
|
for (const row of rows) {
|
|
269
333
|
row.classList.add("diagnostic-row");
|