skir-codemirror-plugin 1.0.0 → 1.0.2
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/LICENSE +21 -0
- package/README.md +39 -1
- package/dist/codemirror/create_editor_state.js +1 -1
- package/dist/codemirror/create_editor_state.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/codemirror/create_editor_state.ts +1 -1
- package/src/index.ts +4 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tyler Fibonacci
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -28,9 +28,12 @@ npm install skir-codemirror-plugin
|
|
|
28
28
|
The package root exports:
|
|
29
29
|
|
|
30
30
|
- `createEditorState`
|
|
31
|
+
- `ensureJsonState`
|
|
32
|
+
- `toJson`
|
|
31
33
|
- `CreateEditorStateParams` (type)
|
|
32
34
|
- `CustomTheme` (type)
|
|
33
|
-
- `
|
|
35
|
+
- `JsonState` (type)
|
|
36
|
+
- all types from `./json/types`
|
|
34
37
|
|
|
35
38
|
## Usage
|
|
36
39
|
|
|
@@ -60,6 +63,41 @@ new EditorView({
|
|
|
60
63
|
});
|
|
61
64
|
```
|
|
62
65
|
|
|
66
|
+
## Read Current JSON Value
|
|
67
|
+
|
|
68
|
+
Use `ensureJsonState(view, schema)` to force parse/validation against the current
|
|
69
|
+
document and retrieve the latest state. Then call `toJson(...)` on
|
|
70
|
+
`parseResult.value` when it exists.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { EditorView } from "@codemirror/view";
|
|
74
|
+
import {
|
|
75
|
+
createEditorState,
|
|
76
|
+
ensureJsonState,
|
|
77
|
+
toJson,
|
|
78
|
+
type TypeDefinition,
|
|
79
|
+
} from "skir-codemirror-plugin";
|
|
80
|
+
|
|
81
|
+
const schema: TypeDefinition = {
|
|
82
|
+
type: { kind: "primitive", value: "string" },
|
|
83
|
+
records: [],
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const view = new EditorView({
|
|
87
|
+
state: createEditorState({ schema }),
|
|
88
|
+
parent: document.getElementById("editor")!,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const jsonState = ensureJsonState(view, schema);
|
|
92
|
+
|
|
93
|
+
if (jsonState.parseResult.value) {
|
|
94
|
+
const jsonValue = toJson(jsonState.parseResult.value);
|
|
95
|
+
console.log("Current JSON value:", jsonValue);
|
|
96
|
+
} else {
|
|
97
|
+
console.log("Cannot convert to JSON:", jsonState.parseResult.errors);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
63
101
|
## createEditorState Parameters
|
|
64
102
|
|
|
65
103
|
```ts
|
|
@@ -51,7 +51,7 @@ export function createEditorState({ schema, readOnly, json, theme, }) {
|
|
|
51
51
|
doc: JSON.stringify(content, null, 2),
|
|
52
52
|
extensions: [
|
|
53
53
|
EditorState.readOnly.of(!!readOnly),
|
|
54
|
-
enterKeyHandler(schema),
|
|
54
|
+
readOnly ? [] : enterKeyHandler(schema),
|
|
55
55
|
basicSetup,
|
|
56
56
|
EditorState.languageData.of(() => [
|
|
57
57
|
{
|
|
@@ -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;AAS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EAAE;oBACvB,OAAO,EAAE,UAAU;oBACnB,MAAM,EAAE,WAAW;oBACnB,YAAY,EAAE,KAAK;oBACnB,QAAQ,EAAE,MAAM;oBAChB,UAAU,EAAE,6BAA6B;oBACzC,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,YAAY;iBACxB;gBACD,8BAA8B,EAAE;oBAC9B,SAAS,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 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,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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,QAAQ,EAAE,MAAM;oBAChB,UAAU,EAAE,6BAA6B;oBACzC,SAAS,EAAE,YAAY;oBACvB,KAAK,EAAE,MAAM;iBACd;gBACD,uBAAuB,EAAE;oBACvB,OAAO,EAAE,UAAU;oBACnB,MAAM,EAAE,WAAW;oBACnB,YAAY,EAAE,KAAK;oBACnB,QAAQ,EAAE,MAAM;oBAChB,UAAU,EAAE,6BAA6B;oBACzC,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,YAAY;iBACxB;gBACD,8BAA8B,EAAE;oBAC9B,SAAS,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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { createEditorState } from "./codemirror/create_editor_state";
|
|
2
2
|
export type { CreateEditorStateParams, CustomTheme, } from "./codemirror/create_editor_state";
|
|
3
|
-
export
|
|
3
|
+
export { ensureJsonState } from "./codemirror/json_state";
|
|
4
|
+
export type { JsonState } from "./codemirror/json_state";
|
|
5
|
+
export { toJson } from "./json/to_json";
|
|
6
|
+
export type * from "./json/types";
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,YAAY,EACV,uBAAuB,EACvB,WAAW,GACZ,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,YAAY,EACV,uBAAuB,EACvB,WAAW,GACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,mBAAmB,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["export { createEditorState } from \"./codemirror/create_editor_state\";\nexport type {\n CreateEditorStateParams,\n CustomTheme,\n} from \"./codemirror/create_editor_state\";\nexport type {
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAKrE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { createEditorState } from \"./codemirror/create_editor_state\";\nexport type {\n CreateEditorStateParams,\n CustomTheme,\n} from \"./codemirror/create_editor_state\";\nexport { ensureJsonState } from \"./codemirror/json_state\";\nexport type { JsonState } from \"./codemirror/json_state\";\nexport { toJson } from \"./json/to_json\";\nexport type * from \"./json/types\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skir-codemirror-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/gepheum/skir-codemirror-plugin#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"src/",
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
|
-
"license": "
|
|
18
|
+
"license": "MIT",
|
|
19
19
|
"author": "Tyler Fibonacci <gepheum@gmail.com>",
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"module": "./dist/index.js",
|
|
@@ -67,7 +67,7 @@ export function createEditorState({
|
|
|
67
67
|
doc: JSON.stringify(content, null, 2),
|
|
68
68
|
extensions: [
|
|
69
69
|
EditorState.readOnly.of(!!readOnly),
|
|
70
|
-
enterKeyHandler(schema),
|
|
70
|
+
readOnly ? [] : enterKeyHandler(schema),
|
|
71
71
|
basicSetup,
|
|
72
72
|
EditorState.languageData.of(() => [
|
|
73
73
|
{
|
package/src/index.ts
CHANGED
|
@@ -3,4 +3,7 @@ export type {
|
|
|
3
3
|
CreateEditorStateParams,
|
|
4
4
|
CustomTheme,
|
|
5
5
|
} from "./codemirror/create_editor_state";
|
|
6
|
-
export
|
|
6
|
+
export { ensureJsonState } from "./codemirror/json_state";
|
|
7
|
+
export type { JsonState } from "./codemirror/json_state";
|
|
8
|
+
export { toJson } from "./json/to_json";
|
|
9
|
+
export type * from "./json/types";
|