react-codemirror-editor 0.2.1 → 0.3.1
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 +16 -26
- package/dist/core/diagnostics/json/index.d.ts +3 -0
- package/dist/core/diagnostics/json/index.d.ts.map +1 -1
- package/dist/core/diagnostics/json/index.js +3 -0
- package/dist/core/diagnostics/json/jsonDiagnostics.d.ts.map +1 -1
- package/dist/core/diagnostics/json/jsonDiagnostics.js +4 -5
- package/dist/core/diagnostics/json/jsonValidationLinter.d.ts +4 -0
- package/dist/core/diagnostics/json/jsonValidationLinter.d.ts.map +1 -0
- package/dist/core/diagnostics/json/jsonValidationLinter.js +8 -0
- package/dist/core/diagnostics/json/jsonValidationState.d.ts +12 -0
- package/dist/core/diagnostics/json/jsonValidationState.d.ts.map +1 -0
- package/dist/core/diagnostics/json/jsonValidationState.js +37 -0
- package/dist/core/editor/editorController.d.ts.map +1 -1
- package/dist/core/editor/editorController.js +10 -0
- package/dist/core/languages/buildExtensions.d.ts.map +1 -1
- package/dist/core/languages/buildExtensions.js +2 -1
- package/dist/types/editor.d.ts +5 -1
- package/dist/types/editor.d.ts.map +1 -1
- package/package.json +63 -63
- package/dist/core/diagnostics/json/jsonValidation.d.ts +0 -4
- package/dist/core/diagnostics/json/jsonValidation.d.ts.map +0 -1
- package/dist/core/diagnostics/json/jsonValidation.js +0 -8
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
# React Code Editor
|
|
2
|
+
|
|
1
3
|

|
|
2
4
|

|
|
3
5
|

|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
A modern, extensible **CodeMirror 6–based React code editor** featuring first-class TypeScript support, language-aware configuration, optional diagnostics, and search/validation support.
|
|
7
|
+
A modern, extensible **CodeMirror 6–based React code editor** featuring first-class TypeScript support, language-aware configuration, optional diagnostics, search, and validation support.
|
|
8
8
|
|
|
9
9
|
This library is designed to scale from a simple embedded editor to a **multi-language, schema-aware editing platform**.
|
|
10
10
|
|
|
@@ -105,6 +105,7 @@ This keeps the editor **language-agnostic** and flexible.
|
|
|
105
105
|
- `findPrev()`
|
|
106
106
|
- `replace(replacement: string)`
|
|
107
107
|
- `replaceAll(replacement: string)`
|
|
108
|
+
- `getValidation()`
|
|
108
109
|
|
|
109
110
|
### 🧠 Format API (Callback-Based)
|
|
110
111
|
|
|
@@ -157,9 +158,7 @@ controllerRef.current?.format((code) =>
|
|
|
157
158
|
);
|
|
158
159
|
```
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
## 📋 Why Callback-Based Formatting?
|
|
161
|
+
### 📋 Why Callback-Based Formatting?
|
|
163
162
|
|
|
164
163
|
- Keeps core editor **small**
|
|
165
164
|
- Avoids hard dependency on Prettier
|
|
@@ -168,9 +167,7 @@ controllerRef.current?.format((code) =>
|
|
|
168
167
|
|
|
169
168
|
This is a library-level design decision, not a limitation.
|
|
170
169
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
## 🔍 Search & Replace
|
|
170
|
+
### 🔍 Search & Replace
|
|
174
171
|
|
|
175
172
|
The editor includes **search & replace functionality** via a controller API:
|
|
176
173
|
|
|
@@ -193,27 +190,20 @@ You can pass **search configuration**:
|
|
|
193
190
|
/>
|
|
194
191
|
```
|
|
195
192
|
|
|
196
|
-
|
|
193
|
+
### ✅ Validation State
|
|
197
194
|
|
|
198
|
-
|
|
195
|
+
```ts
|
|
196
|
+
const state: {
|
|
197
|
+
isValid: boolean;
|
|
198
|
+
errorCount: number;
|
|
199
|
+
warningCount: number;
|
|
200
|
+
} | null = controllerRef.current?.getValidation();
|
|
199
201
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<CodeEditor
|
|
204
|
-
language="json"
|
|
205
|
-
languageOptions={{
|
|
206
|
-
json: {
|
|
207
|
-
schema: myJsonSchema,
|
|
208
|
-
onValidationChange: (isValid) => console.log('Valid:', isValid),
|
|
209
|
-
},
|
|
210
|
-
}}
|
|
211
|
-
/>
|
|
202
|
+
if (state) {
|
|
203
|
+
const { isValid, errorCount, warningCount } = state;
|
|
204
|
+
}
|
|
212
205
|
```
|
|
213
206
|
|
|
214
|
-
- `isValid` is `true` if there are no syntax or schema errors
|
|
215
|
-
- Useful for enabling/disabling Save buttons or warnings in your UI
|
|
216
|
-
|
|
217
207
|
---
|
|
218
208
|
|
|
219
209
|
## 🌍 Languages
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { jsonDiagnosticsExtension } from './jsonDiagnostics';
|
|
2
|
+
export { safeJsonCompletion } from './safeJsonCompletion';
|
|
3
|
+
export { jsonValidationState, computeValidationState, dispatchValidationState, } from './jsonValidationState';
|
|
4
|
+
export { jsonValidationLinter } from './jsonValidationLinter';
|
|
2
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/diagnostics/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/diagnostics/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export { jsonDiagnosticsExtension } from './jsonDiagnostics';
|
|
2
|
+
export { safeJsonCompletion } from './safeJsonCompletion';
|
|
3
|
+
export { jsonValidationState, computeValidationState, dispatchValidationState, } from './jsonValidationState';
|
|
4
|
+
export { jsonValidationLinter } from './jsonValidationLinter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonDiagnostics.d.ts","sourceRoot":"","sources":["../../../../src/core/diagnostics/json/jsonDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"jsonDiagnostics.d.ts","sourceRoot":"","sources":["../../../../src/core/diagnostics/json/jsonDiagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAY9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,wBAAwB,aACxB,gBAAgB,KAC1B,SA0CF,CAAC"}
|
|
@@ -2,14 +2,13 @@ import { hoverTooltip } from '@codemirror/view';
|
|
|
2
2
|
import { linter, lintGutter } from '@codemirror/lint';
|
|
3
3
|
import { autocompletion } from '@codemirror/autocomplete';
|
|
4
4
|
import { jsonSchemaLinter, jsonSchemaHover, stateExtensions, } from 'codemirror-json-schema';
|
|
5
|
-
import { validation } from './jsonValidation';
|
|
6
5
|
import { jsonLinter } from './jsonLinter';
|
|
7
|
-
import { safeJsonCompletion } from './
|
|
6
|
+
import { safeJsonCompletion, jsonValidationLinter } from './';
|
|
8
7
|
export const jsonDiagnosticsExtension = (options = {}) => {
|
|
9
|
-
const { diagnostics = true, gutter = true, schema, schemaLint = !!schema, hover = !!schema, autocomplete = !!schema,
|
|
8
|
+
const { diagnostics = true, gutter = true, schema, schemaLint = !!schema, hover = !!schema, autocomplete = !!schema, } = options;
|
|
10
9
|
const extensions = [];
|
|
11
10
|
if (diagnostics) {
|
|
12
|
-
extensions.push(linter(
|
|
11
|
+
extensions.push(linter(jsonValidationLinter(jsonLinter)));
|
|
13
12
|
if (gutter) {
|
|
14
13
|
extensions.push(lintGutter());
|
|
15
14
|
}
|
|
@@ -17,7 +16,7 @@ export const jsonDiagnosticsExtension = (options = {}) => {
|
|
|
17
16
|
if (schema) {
|
|
18
17
|
extensions.push(stateExtensions(schema));
|
|
19
18
|
if (schemaLint) {
|
|
20
|
-
extensions.push(linter(
|
|
19
|
+
extensions.push(linter(jsonValidationLinter(jsonSchemaLinter(schema))));
|
|
21
20
|
}
|
|
22
21
|
if (hover) {
|
|
23
22
|
extensions.push(hoverTooltip(jsonSchemaHover(schema)));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EditorView } from '@codemirror/view';
|
|
2
|
+
import type { Diagnostic } from '@codemirror/lint';
|
|
3
|
+
export declare const jsonValidationLinter: (linterFn: (view: EditorView) => Diagnostic[]) => (view: EditorView) => Diagnostic[];
|
|
4
|
+
//# sourceMappingURL=jsonValidationLinter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonValidationLinter.d.ts","sourceRoot":"","sources":["../../../../src/core/diagnostics/json/jsonValidationLinter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,eAAO,MAAM,oBAAoB,aAClB,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAAE,YACtC,UAAU,KAAG,UAAU,EAQ7B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StateEffect, StateField } from '@codemirror/state';
|
|
2
|
+
import type { Diagnostic } from '@codemirror/lint';
|
|
3
|
+
export interface ValidationState {
|
|
4
|
+
isValid: boolean;
|
|
5
|
+
errorCount: number;
|
|
6
|
+
warningCount: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const setValidationState: import("@codemirror/state").StateEffectType<ValidationState>;
|
|
9
|
+
export declare function computeValidationState(diagnostics: readonly Diagnostic[]): ValidationState;
|
|
10
|
+
export declare function dispatchValidationState(diagnostics: readonly Diagnostic[]): StateEffect<ValidationState>;
|
|
11
|
+
export declare const jsonValidationState: StateField<ValidationState>;
|
|
12
|
+
//# sourceMappingURL=jsonValidationState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonValidationState.d.ts","sourceRoot":"","sources":["../../../../src/core/diagnostics/json/jsonValidationState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,kBAAkB,8DAAwC,CAAC;AAExE,wBAAgB,sBAAsB,CAClC,WAAW,EAAE,SAAS,UAAU,EAAE,GACnC,eAAe,CAcjB;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,gCAEzE;AAED,eAAO,MAAM,mBAAmB,6BAgB9B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StateEffect, StateField } from '@codemirror/state';
|
|
2
|
+
export const setValidationState = StateEffect.define();
|
|
3
|
+
export function computeValidationState(diagnostics) {
|
|
4
|
+
let errorCount = 0;
|
|
5
|
+
let warningCount = 0;
|
|
6
|
+
for (const d of diagnostics) {
|
|
7
|
+
if (d.severity === 'error')
|
|
8
|
+
errorCount++;
|
|
9
|
+
else if (d.severity === 'warning')
|
|
10
|
+
warningCount++;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
isValid: errorCount === 0,
|
|
14
|
+
errorCount,
|
|
15
|
+
warningCount,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function dispatchValidationState(diagnostics) {
|
|
19
|
+
return setValidationState.of(computeValidationState(diagnostics));
|
|
20
|
+
}
|
|
21
|
+
export const jsonValidationState = StateField.define({
|
|
22
|
+
create() {
|
|
23
|
+
return {
|
|
24
|
+
isValid: true,
|
|
25
|
+
errorCount: 0,
|
|
26
|
+
warningCount: 0,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
update(value, tr) {
|
|
30
|
+
for (const e of tr.effects) {
|
|
31
|
+
if (e.is(setValidationState)) {
|
|
32
|
+
return e.value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorController.d.ts","sourceRoot":"","sources":["../../../src/core/editor/editorController.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editorController.d.ts","sourceRoot":"","sources":["../../../src/core/editor/editorController.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,sBAAsB,IAAI,gBAAgB,CAoDzD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { copyToClipboard, foldAllCode, unfoldAllCode, formatCode, openSearch, closeSearch, replace, replaceAllOccurrences, searchNext, searchPrevious, } from '../extensions';
|
|
2
|
+
import { jsonValidationState } from '../diagnostics/json';
|
|
2
3
|
export function createEditorController() {
|
|
3
4
|
let view = null;
|
|
4
5
|
return {
|
|
@@ -38,5 +39,14 @@ export function createEditorController() {
|
|
|
38
39
|
replaceAll() {
|
|
39
40
|
replaceAllOccurrences(view);
|
|
40
41
|
},
|
|
42
|
+
getValidation() {
|
|
43
|
+
if (!view)
|
|
44
|
+
return null;
|
|
45
|
+
return (view.state.field(jsonValidationState, false) ?? {
|
|
46
|
+
isValid: true,
|
|
47
|
+
errorCount: 0,
|
|
48
|
+
warningCount: 0,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
41
51
|
};
|
|
42
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildExtensions.d.ts","sourceRoot":"","sources":["../../../src/core/languages/buildExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"buildExtensions.d.ts","sourceRoot":"","sources":["../../../src/core/languages/buildExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9D,eAAO,MAAM,uBAAuB,aACtB,cAAc,WACf,eAAe,GAAG,SAAS,KACrC,SAAS,EAWX,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsonLanguage } from '.';
|
|
2
|
-
import { jsonDiagnosticsExtension } from '../diagnostics/json';
|
|
2
|
+
import { jsonDiagnosticsExtension, jsonValidationState, } from '../diagnostics/json';
|
|
3
3
|
export const buildLanguageExtensions = (language, options) => {
|
|
4
4
|
switch (language) {
|
|
5
5
|
case 'json':
|
|
6
6
|
return [
|
|
7
7
|
jsonLanguage(),
|
|
8
|
+
jsonValidationState,
|
|
8
9
|
jsonDiagnosticsExtension(options?.[language] ?? {}),
|
|
9
10
|
];
|
|
10
11
|
default:
|
package/dist/types/editor.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export interface EditorController {
|
|
|
17
17
|
searchPrevious(): void;
|
|
18
18
|
replace(): void;
|
|
19
19
|
replaceAll(): void;
|
|
20
|
+
getValidation(): {
|
|
21
|
+
isValid: boolean;
|
|
22
|
+
errorCount: number;
|
|
23
|
+
warningCount: number;
|
|
24
|
+
} | null;
|
|
20
25
|
}
|
|
21
26
|
export interface CreateEditorOptions {
|
|
22
27
|
parent: HTMLElement;
|
|
@@ -68,7 +73,6 @@ export interface JsonEditorConfig {
|
|
|
68
73
|
schemaLint?: boolean;
|
|
69
74
|
hover?: boolean;
|
|
70
75
|
autocomplete?: boolean;
|
|
71
|
-
onValidationChange?: (isValid: boolean) => void;
|
|
72
76
|
}
|
|
73
77
|
export interface SearchOptions {
|
|
74
78
|
enabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/types/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,SAAS,GACf,OAAO,GACP,MAAM,GACN,WAAW,GACX,cAAc,GACd,gBAAgB,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,eAAe,GACf,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,gBAAgB,GAChB,cAAc,CAAC;AAErB,MAAM,MAAM,cAAc,GAAG,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC5B,IAAI,CAAC,EAAE,gBAAgB,CAAC;CAQ3B;AAED,MAAM,WAAW,gBAAgB;IAC7B,OAAO,IAAI,UAAU,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;IACvC,IAAI,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IACrC,OAAO,IAAI,OAAO,CAAC;IACnB,SAAS,IAAI,OAAO,CAAC;IACrB,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC;IACrD,UAAU,IAAI,IAAI,CAAC;IACnB,WAAW,IAAI,IAAI,CAAC;IACpB,UAAU,IAAI,IAAI,CAAC;IACnB,cAAc,IAAI,IAAI,CAAC;IACvB,OAAO,IAAI,IAAI,CAAC;IAChB,UAAU,IAAI,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../src/types/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,SAAS,GACf,OAAO,GACP,MAAM,GACN,WA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M,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-codemirror-editor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "A modular, extensible React code editor built on CodeMirror 6 with first-class JSON support.",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"module": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"sideEffects": false,
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "https://github.com/mihirmistry2/react-code-editor.git"
|
|
17
|
-
},
|
|
18
|
-
"homepage": "https://github.com/mihirmistry2/react-code-editor#readme",
|
|
19
|
-
"bugs": {
|
|
20
|
-
"url": "https://github.com/mihirmistry2/react-code-editor/issues"
|
|
21
|
-
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc",
|
|
24
|
-
"lint": "eslint .",
|
|
25
|
-
"prepublishOnly": "npm run build"
|
|
26
|
-
},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"react": ">=18",
|
|
29
|
-
"react-dom": ">=18"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@codemirror/lang-json": "^6.0.2",
|
|
33
|
-
"@codemirror/state": "^6.5.3",
|
|
34
|
-
"@codemirror/view": "^6.39.8",
|
|
35
|
-
"codemirror": "^6.0.2",
|
|
36
|
-
"codemirror-json-schema": "^0.8.1"
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@eslint/js": "^9.17.0",
|
|
40
|
-
"@types/node": "^20.0.0",
|
|
41
|
-
"@types/react": "^19.0.0",
|
|
42
|
-
"@types/react-dom": "^19.0.0",
|
|
43
|
-
"eslint": "^9.17.0",
|
|
44
|
-
"eslint-plugin-react-hooks": "^5.0.0",
|
|
45
|
-
"eslint-plugin-react-refresh": "^0.4.16",
|
|
46
|
-
"globals": "^15.14.0",
|
|
47
|
-
"react": "^19.0.0",
|
|
48
|
-
"react-dom": "^19.0.0",
|
|
49
|
-
"typescript": "~5.7.2",
|
|
50
|
-
"typescript-eslint": "^8.18.2"
|
|
51
|
-
},
|
|
52
|
-
"keywords": [
|
|
53
|
-
"react",
|
|
54
|
-
"codemirror",
|
|
55
|
-
"codemirror6",
|
|
56
|
-
"editor",
|
|
57
|
-
"code-editor",
|
|
58
|
-
"react-editor",
|
|
59
|
-
"react-codemirror",
|
|
60
|
-
"ide"
|
|
61
|
-
],
|
|
62
|
-
"license": "MIT"
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "react-codemirror-editor",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "A modular, extensible React code editor built on CodeMirror 6 with first-class JSON support.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/mihirmistry2/react-code-editor.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/mihirmistry2/react-code-editor#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/mihirmistry2/react-code-editor/issues"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"lint": "eslint .",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": ">=18",
|
|
29
|
+
"react-dom": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@codemirror/lang-json": "^6.0.2",
|
|
33
|
+
"@codemirror/state": "^6.5.3",
|
|
34
|
+
"@codemirror/view": "^6.39.8",
|
|
35
|
+
"codemirror": "^6.0.2",
|
|
36
|
+
"codemirror-json-schema": "^0.8.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@eslint/js": "^9.17.0",
|
|
40
|
+
"@types/node": "^20.0.0",
|
|
41
|
+
"@types/react": "^19.0.0",
|
|
42
|
+
"@types/react-dom": "^19.0.0",
|
|
43
|
+
"eslint": "^9.17.0",
|
|
44
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
45
|
+
"eslint-plugin-react-refresh": "^0.4.16",
|
|
46
|
+
"globals": "^15.14.0",
|
|
47
|
+
"react": "^19.0.0",
|
|
48
|
+
"react-dom": "^19.0.0",
|
|
49
|
+
"typescript": "~5.7.2",
|
|
50
|
+
"typescript-eslint": "^8.18.2"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"react",
|
|
54
|
+
"codemirror",
|
|
55
|
+
"codemirror6",
|
|
56
|
+
"editor",
|
|
57
|
+
"code-editor",
|
|
58
|
+
"react-editor",
|
|
59
|
+
"react-codemirror",
|
|
60
|
+
"ide"
|
|
61
|
+
],
|
|
62
|
+
"license": "MIT"
|
|
63
|
+
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { EditorView } from '@codemirror/view';
|
|
2
|
-
import { Diagnostic } from '@codemirror/lint';
|
|
3
|
-
export declare const validation: (linterFn: (view: EditorView) => Diagnostic[], onValidationChange?: (isValid: boolean) => void) => (view: EditorView) => Diagnostic[];
|
|
4
|
-
//# sourceMappingURL=jsonValidation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonValidation.d.ts","sourceRoot":"","sources":["../../../../src/core/diagnostics/json/jsonValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,eAAO,MAAM,UAAU,aAEL,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAAE,uBACvB,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,YAE5C,UAAU,KAAG,UAAU,EAS7B,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const validation = (linterFn, onValidationChange) => (view) => {
|
|
2
|
-
const diagnostics = linterFn(view);
|
|
3
|
-
if (onValidationChange) {
|
|
4
|
-
const isValid = diagnostics.every((d) => d.severity !== 'error');
|
|
5
|
-
onValidationChange(isValid);
|
|
6
|
-
}
|
|
7
|
-
return diagnostics;
|
|
8
|
-
};
|