@mongodb-js/compass-editor 0.7.0 → 0.9.0
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/dist/autocompleter.d.ts +12 -0
- package/dist/autocompleter.d.ts.map +1 -1
- package/dist/index.d.ts +2 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -38
- package/dist/index.js.map +1 -1
- package/dist/json-editor.d.ts +52 -2
- package/dist/json-editor.d.ts.map +1 -1
- package/dist/json-editor.js +99 -58
- package/dist/json-editor.js.map +1 -1
- package/dist/types.d.ts +3 -36
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -10
- package/dist/ace/aggregation-autocompleter.d.ts +0 -15
- package/dist/ace/aggregation-autocompleter.d.ts.map +0 -1
- package/dist/ace/aggregation-autocompleter.js +0 -109
- package/dist/ace/aggregation-autocompleter.js.map +0 -1
- package/dist/ace/index.d.ts +0 -2
- package/dist/ace/index.d.ts.map +0 -1
- package/dist/ace/index.js +0 -37
- package/dist/ace/index.js.map +0 -1
- package/dist/ace/mode.d.ts +0 -2
- package/dist/ace/mode.d.ts.map +0 -1
- package/dist/ace/mode.js +0 -67
- package/dist/ace/mode.js.map +0 -1
- package/dist/ace/query-autocompleter.d.ts +0 -12
- package/dist/ace/query-autocompleter.d.ts.map +0 -1
- package/dist/ace/query-autocompleter.js +0 -38
- package/dist/ace/query-autocompleter.js.map +0 -1
- package/dist/ace/stage-autocompleter.d.ts +0 -16
- package/dist/ace/stage-autocompleter.d.ts.map +0 -1
- package/dist/ace/stage-autocompleter.js +0 -70
- package/dist/ace/stage-autocompleter.js.map +0 -1
- package/dist/ace/theme.d.ts +0 -4
- package/dist/ace/theme.d.ts.map +0 -1
- package/dist/ace/theme.js +0 -297
- package/dist/ace/theme.js.map +0 -1
- package/dist/ace/util.d.ts +0 -3
- package/dist/ace/util.d.ts.map +0 -1
- package/dist/ace/util.js +0 -12
- package/dist/ace/util.js.map +0 -1
- package/dist/ace/validation-autocompleter.d.ts +0 -12
- package/dist/ace/validation-autocompleter.d.ts.map +0 -1
- package/dist/ace/validation-autocompleter.js +0 -36
- package/dist/ace/validation-autocompleter.js.map +0 -1
- package/dist/base-editor.d.ts +0 -36
- package/dist/base-editor.d.ts.map +0 -1
- package/dist/base-editor.js +0 -156
- package/dist/base-editor.js.map +0 -1
- package/dist/inline-editor.d.ts +0 -8
- package/dist/inline-editor.d.ts.map +0 -1
- package/dist/inline-editor.js +0 -21
- package/dist/inline-editor.js.map +0 -1
- package/dist/multiline-editor.d.ts +0 -18
- package/dist/multiline-editor.d.ts.map +0 -1
- package/dist/multiline-editor.js +0 -83
- package/dist/multiline-editor.js.map +0 -1
- package/dist/syntax-highlight.d.ts +0 -10
- package/dist/syntax-highlight.d.ts.map +0 -1
- package/dist/syntax-highlight.js +0 -26
- package/dist/syntax-highlight.js.map +0 -1
package/dist/autocompleter.d.ts
CHANGED
|
@@ -114,6 +114,12 @@ declare const ALL_COMPLETIONS: ({
|
|
|
114
114
|
readonly score: 1;
|
|
115
115
|
readonly meta: "accumulator";
|
|
116
116
|
readonly version: "5.2.0";
|
|
117
|
+
} | {
|
|
118
|
+
readonly name: "$median";
|
|
119
|
+
readonly value: "$median";
|
|
120
|
+
readonly score: 1;
|
|
121
|
+
readonly meta: "accumulator";
|
|
122
|
+
readonly version: "7.0.0";
|
|
117
123
|
} | {
|
|
118
124
|
readonly name: "$min";
|
|
119
125
|
readonly value: "$min";
|
|
@@ -127,6 +133,12 @@ declare const ALL_COMPLETIONS: ({
|
|
|
127
133
|
readonly score: 1;
|
|
128
134
|
readonly meta: "accumulator";
|
|
129
135
|
readonly version: "5.2.0";
|
|
136
|
+
} | {
|
|
137
|
+
readonly name: "$percentile";
|
|
138
|
+
readonly value: "$percentile";
|
|
139
|
+
readonly score: 1;
|
|
140
|
+
readonly meta: "accumulator";
|
|
141
|
+
readonly version: "7.0.0";
|
|
130
142
|
} | {
|
|
131
143
|
readonly name: "$push";
|
|
132
144
|
readonly value: "$push";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocompleter.d.ts","sourceRoot":"","sources":["../src/autocompleter.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"autocompleter.d.ts","sourceRoot":"","sources":["../src/autocompleter.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,EAAE,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAE7B,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAsBF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,UAAQ,UAIrD;AAaD,wBAAgB,SAAS,CACvB,MAAM,SAAK,EACX,OAAO,GAAE,eAAoB,EAC7B,WAAW,GAAE,UAAU,EAAoB,GAC1C,gBAAgB,EAAE,CAsCpB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import type { Ace } from 'ace-builds';
|
|
2
|
-
export * from './base-editor';
|
|
3
|
-
export { ValidationAutoCompleter } from './ace/validation-autocompleter';
|
|
4
|
-
export { QueryAutoCompleter } from './ace/query-autocompleter';
|
|
5
|
-
export { StageAutoCompleter } from './ace/stage-autocompleter';
|
|
6
|
-
export { AggregationAutoCompleter } from './ace/aggregation-autocompleter';
|
|
7
|
-
export type AceEditor = Ace.Editor;
|
|
8
|
-
export type AceAnnotation = Ace.Annotation;
|
|
9
1
|
export type { CompletionWithServerInfo } from './types';
|
|
10
|
-
export { InlineEditor } from './inline-editor';
|
|
11
2
|
export { prettify } from './prettify';
|
|
12
3
|
export type { FormatOptions } from './prettify';
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export type { EditorView, Command, Annotation, Action, EditorRef, } from './json-editor';
|
|
16
|
-
export { SyntaxHighlight } from './syntax-highlight';
|
|
4
|
+
export { CodemirrorInlineEditor, CodemirrorMultilineEditor, setCodemirrorEditorValue, } from './json-editor';
|
|
5
|
+
export type { EditorView, Command, Annotation, Action, EditorRef, Completer, } from './json-editor';
|
|
17
6
|
export { createDocumentAutocompleter } from './codemirror/document-autocompleter';
|
|
18
7
|
export { createValidationAutocompleter } from './codemirror/validation-autocompleter';
|
|
19
8
|
export { createQueryAutocompleter } from './codemirror/query-autocompleter';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,48 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createAggregationAutocompleter = exports.createStageAutocompleter = exports.createQueryAutocompleter = exports.createValidationAutocompleter = exports.createDocumentAutocompleter = exports.
|
|
18
|
-
__exportStar(require("./base-editor"), exports);
|
|
19
|
-
var validation_autocompleter_1 = require("./ace/validation-autocompleter");
|
|
20
|
-
Object.defineProperty(exports, "ValidationAutoCompleter", { enumerable: true, get: function () { return validation_autocompleter_1.ValidationAutoCompleter; } });
|
|
21
|
-
var query_autocompleter_1 = require("./ace/query-autocompleter");
|
|
22
|
-
Object.defineProperty(exports, "QueryAutoCompleter", { enumerable: true, get: function () { return query_autocompleter_1.QueryAutoCompleter; } });
|
|
23
|
-
var stage_autocompleter_1 = require("./ace/stage-autocompleter");
|
|
24
|
-
Object.defineProperty(exports, "StageAutoCompleter", { enumerable: true, get: function () { return stage_autocompleter_1.StageAutoCompleter; } });
|
|
25
|
-
var aggregation_autocompleter_1 = require("./ace/aggregation-autocompleter");
|
|
26
|
-
Object.defineProperty(exports, "AggregationAutoCompleter", { enumerable: true, get: function () { return aggregation_autocompleter_1.AggregationAutoCompleter; } });
|
|
27
|
-
var inline_editor_1 = require("./inline-editor");
|
|
28
|
-
Object.defineProperty(exports, "InlineEditor", { enumerable: true, get: function () { return inline_editor_1.InlineEditor; } });
|
|
3
|
+
exports.createAggregationAutocompleter = exports.createStageAutocompleter = exports.createQueryAutocompleter = exports.createValidationAutocompleter = exports.createDocumentAutocompleter = exports.setCodemirrorEditorValue = exports.CodemirrorMultilineEditor = exports.CodemirrorInlineEditor = exports.prettify = void 0;
|
|
29
4
|
var prettify_1 = require("./prettify");
|
|
30
5
|
Object.defineProperty(exports, "prettify", { enumerable: true, get: function () { return prettify_1.prettify; } });
|
|
31
|
-
var multiline_editor_1 = require("./multiline-editor");
|
|
32
|
-
Object.defineProperty(exports, "Editor", { enumerable: true, get: function () { return multiline_editor_1.Editor; } });
|
|
33
6
|
var json_editor_1 = require("./json-editor");
|
|
34
7
|
Object.defineProperty(exports, "CodemirrorInlineEditor", { enumerable: true, get: function () { return json_editor_1.CodemirrorInlineEditor; } });
|
|
35
8
|
Object.defineProperty(exports, "CodemirrorMultilineEditor", { enumerable: true, get: function () { return json_editor_1.CodemirrorMultilineEditor; } });
|
|
36
|
-
|
|
37
|
-
Object.defineProperty(exports, "SyntaxHighlight", { enumerable: true, get: function () { return syntax_highlight_1.SyntaxHighlight; } });
|
|
9
|
+
Object.defineProperty(exports, "setCodemirrorEditorValue", { enumerable: true, get: function () { return json_editor_1.setCodemirrorEditorValue; } });
|
|
38
10
|
var document_autocompleter_1 = require("./codemirror/document-autocompleter");
|
|
39
11
|
Object.defineProperty(exports, "createDocumentAutocompleter", { enumerable: true, get: function () { return document_autocompleter_1.createDocumentAutocompleter; } });
|
|
40
|
-
var
|
|
41
|
-
Object.defineProperty(exports, "createValidationAutocompleter", { enumerable: true, get: function () { return
|
|
42
|
-
var
|
|
43
|
-
Object.defineProperty(exports, "createQueryAutocompleter", { enumerable: true, get: function () { return
|
|
44
|
-
var
|
|
45
|
-
Object.defineProperty(exports, "createStageAutocompleter", { enumerable: true, get: function () { return
|
|
46
|
-
var
|
|
47
|
-
Object.defineProperty(exports, "createAggregationAutocompleter", { enumerable: true, get: function () { return
|
|
12
|
+
var validation_autocompleter_1 = require("./codemirror/validation-autocompleter");
|
|
13
|
+
Object.defineProperty(exports, "createValidationAutocompleter", { enumerable: true, get: function () { return validation_autocompleter_1.createValidationAutocompleter; } });
|
|
14
|
+
var query_autocompleter_1 = require("./codemirror/query-autocompleter");
|
|
15
|
+
Object.defineProperty(exports, "createQueryAutocompleter", { enumerable: true, get: function () { return query_autocompleter_1.createQueryAutocompleter; } });
|
|
16
|
+
var stage_autocompleter_1 = require("./codemirror/stage-autocompleter");
|
|
17
|
+
Object.defineProperty(exports, "createStageAutocompleter", { enumerable: true, get: function () { return stage_autocompleter_1.createStageAutocompleter; } });
|
|
18
|
+
var aggregation_autocompleter_1 = require("./codemirror/aggregation-autocompleter");
|
|
19
|
+
Object.defineProperty(exports, "createAggregationAutocompleter", { enumerable: true, get: function () { return aggregation_autocompleter_1.createAggregationAutocompleter; } });
|
|
48
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAEjB,6CAIuB;AAHrB,qHAAA,sBAAsB,OAAA;AACtB,wHAAA,yBAAyB,OAAA;AACzB,uHAAA,wBAAwB,OAAA;AAU1B,8EAAkF;AAAzE,qIAAA,2BAA2B,OAAA;AACpC,kFAAsF;AAA7E,yIAAA,6BAA6B,OAAA;AACtC,wEAA4E;AAAnE,+HAAA,wBAAwB,OAAA;AACjC,wEAA4E;AAAnE,+HAAA,wBAAwB,OAAA;AACjC,oFAAwF;AAA/E,2IAAA,8BAA8B,OAAA"}
|
package/dist/json-editor.d.ts
CHANGED
|
@@ -6,7 +6,53 @@ import type { CompletionSource } from '@codemirror/autocomplete';
|
|
|
6
6
|
import type { IconGlyph } from '@mongodb-js/compass-components';
|
|
7
7
|
import { Facet } from '@codemirror/state';
|
|
8
8
|
import { LanguageSupport } from '@codemirror/language';
|
|
9
|
-
|
|
9
|
+
export declare const editorPalette: {
|
|
10
|
+
readonly light: {
|
|
11
|
+
readonly color: string;
|
|
12
|
+
readonly backgroundColor: string;
|
|
13
|
+
readonly gutterColor: string;
|
|
14
|
+
readonly gutterBackgroundColor: string;
|
|
15
|
+
readonly gutterActiveLineBackgroundColor: string;
|
|
16
|
+
readonly gutterFoldButtonColor: string;
|
|
17
|
+
readonly cursorColor: "#889397";
|
|
18
|
+
readonly activeLineBackgroundColor: string;
|
|
19
|
+
readonly selectionBackgroundColor: "#C3E7FE";
|
|
20
|
+
readonly bracketBorderColor: "#C1C7C6";
|
|
21
|
+
readonly infoGutterIconColor: string;
|
|
22
|
+
readonly warningGutterIconColor: string;
|
|
23
|
+
readonly errorGutterIconColor: string;
|
|
24
|
+
readonly foldPlaceholderColor: "#889397";
|
|
25
|
+
readonly foldPlaceholderBackgroundColor: "#F9FBFA";
|
|
26
|
+
readonly autocompleteColor: string;
|
|
27
|
+
readonly autocompleteBackgroundColor: "#F9FBFA";
|
|
28
|
+
readonly autocompleteBorderColor: "#E8EDEB";
|
|
29
|
+
readonly autocompleteMatchColor: "#00A35C";
|
|
30
|
+
readonly autocompleteSelectedBackgroundColor: "#E8EDEB";
|
|
31
|
+
};
|
|
32
|
+
readonly dark: {
|
|
33
|
+
readonly color: string;
|
|
34
|
+
readonly backgroundColor: string;
|
|
35
|
+
readonly gutterColor: string;
|
|
36
|
+
readonly gutterBackgroundColor: string;
|
|
37
|
+
readonly gutterActiveLineBackgroundColor: string;
|
|
38
|
+
readonly gutterFoldButtonColor: string;
|
|
39
|
+
readonly cursorColor: "#00ED64";
|
|
40
|
+
readonly activeLineBackgroundColor: string;
|
|
41
|
+
readonly selectionBackgroundColor: "#5C6C75";
|
|
42
|
+
readonly bracketBorderColor: "#C1C7C6";
|
|
43
|
+
readonly infoGutterIconColor: string;
|
|
44
|
+
readonly warningGutterIconColor: string;
|
|
45
|
+
readonly errorGutterIconColor: string;
|
|
46
|
+
readonly foldPlaceholderColor: "#889397";
|
|
47
|
+
readonly foldPlaceholderBackgroundColor: "#1C2D38";
|
|
48
|
+
readonly autocompleteColor: "#C1C7C6";
|
|
49
|
+
readonly autocompleteBackgroundColor: "#112733";
|
|
50
|
+
readonly autocompleteBorderColor: "#5C6C75";
|
|
51
|
+
readonly autocompleteMatchColor: "#F9FBFA";
|
|
52
|
+
readonly autocompleteSelectedBackgroundColor: "#3D4F58";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type EditorLanguage = 'json' | 'javascript' | 'javascript-expression';
|
|
10
56
|
export type Annotation = Pick<Diagnostic, 'from' | 'to' | 'severity' | 'message'>;
|
|
11
57
|
type EditorProps = {
|
|
12
58
|
language?: EditorLanguage;
|
|
@@ -27,6 +73,7 @@ type EditorProps = {
|
|
|
27
73
|
lineHeight?: number;
|
|
28
74
|
placeholder?: string;
|
|
29
75
|
commands?: readonly KeyBinding[];
|
|
76
|
+
initialJSONFoldAll?: boolean;
|
|
30
77
|
} & ({
|
|
31
78
|
text: string;
|
|
32
79
|
initialText?: never;
|
|
@@ -47,7 +94,7 @@ export type EditorRef = {
|
|
|
47
94
|
};
|
|
48
95
|
declare const BaseEditor: React.ForwardRefExoticComponent<EditorProps & React.RefAttributes<EditorRef>>;
|
|
49
96
|
export type { EditorView, KeyBinding as Command };
|
|
50
|
-
type InlineEditorProps = Omit<EditorProps, 'text' | 'showLineNumbers' | 'showFoldGutter' | 'showAnnotationsGutter' | 'showScroll' | 'highlightActiveLine' | 'minLines' | '
|
|
97
|
+
type InlineEditorProps = Omit<EditorProps, 'text' | 'showLineNumbers' | 'showFoldGutter' | 'showAnnotationsGutter' | 'showScroll' | 'highlightActiveLine' | 'minLines' | 'annotations'> & ({
|
|
51
98
|
text: string;
|
|
52
99
|
initialText?: never;
|
|
53
100
|
} | {
|
|
@@ -68,7 +115,10 @@ type MultilineEditorProps = EditorProps & {
|
|
|
68
115
|
actionsClassName?: string;
|
|
69
116
|
};
|
|
70
117
|
declare const MultilineEditor: React.ForwardRefExoticComponent<MultilineEditorProps & React.RefAttributes<EditorRef>>;
|
|
118
|
+
declare function setCodemirrorEditorValue(element: HTMLElement | string | null, text: string): Promise<void>;
|
|
71
119
|
export { BaseEditor };
|
|
72
120
|
export { InlineEditor as CodemirrorInlineEditor };
|
|
73
121
|
export { MultilineEditor as CodemirrorMultilineEditor };
|
|
122
|
+
export { setCodemirrorEditorValue };
|
|
123
|
+
export type { CompletionSource as Completer };
|
|
74
124
|
//# sourceMappingURL=json-editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-editor.d.ts","sourceRoot":"","sources":["../src/json-editor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-editor.d.ts","sourceRoot":"","sources":["../src/json-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAW,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAOL,UAAU,EACX,MAAM,kBAAkB,CAAC;AAoB1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AASjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAchE,OAAO,EAAE,KAAK,EAA4B,MAAM,mBAAmB,CAAC;AACpE,OAAO,EACL,eAAe,EAGhB,MAAM,sBAAsB,CAAC;AAiD9B,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+ChB,CAAC;AAkOX,KAAK,cAAc,GAAG,MAAM,GAAG,YAAY,GAAG,uBAAuB,CAAC;AAEtE,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,UAAU,EACV,MAAM,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CACvC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE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G,IAAI,EACpC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAef;AAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,OAAO,EAAE,YAAY,IAAI,sBAAsB,EAAE,CAAC;AAClD,OAAO,EAAE,eAAe,IAAI,yBAAyB,EAAE,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,CAAC;AACpC,YAAY,EAAE,gBAAgB,IAAI,SAAS,EAAE,CAAC"}
|
package/dist/json-editor.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CodemirrorMultilineEditor = exports.CodemirrorInlineEditor = exports.BaseEditor = exports.languageName = exports.languages = void 0;
|
|
26
|
+
exports.setCodemirrorEditorValue = exports.CodemirrorMultilineEditor = exports.CodemirrorInlineEditor = exports.BaseEditor = exports.languageName = exports.languages = exports.editorPalette = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const view_1 = require("@codemirror/view");
|
|
29
29
|
const language_1 = require("@codemirror/language");
|
|
@@ -52,9 +52,15 @@ const hiddenScrollStyle = (0, compass_components_1.css)({
|
|
|
52
52
|
display: 'none',
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
|
+
function isReadOnly(state) {
|
|
56
|
+
return state.facet(state_1.EditorState.readOnly);
|
|
57
|
+
}
|
|
55
58
|
const breakFocusOutBinding = {
|
|
56
59
|
...commands_1.indentWithTab,
|
|
57
60
|
run({ state, dispatch }) {
|
|
61
|
+
if (isReadOnly(state)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
58
64
|
dispatch(state.update(state.replaceSelection('\t'), {
|
|
59
65
|
scrollIntoView: true,
|
|
60
66
|
userEvent: 'input',
|
|
@@ -62,12 +68,12 @@ const breakFocusOutBinding = {
|
|
|
62
68
|
return true;
|
|
63
69
|
},
|
|
64
70
|
};
|
|
65
|
-
|
|
71
|
+
exports.editorPalette = {
|
|
66
72
|
light: {
|
|
67
73
|
color: compass_components_1.codePalette.light[3],
|
|
68
74
|
backgroundColor: compass_components_1.codePalette.light[0],
|
|
69
|
-
gutterColor: compass_components_1.
|
|
70
|
-
gutterBackgroundColor: compass_components_1.
|
|
75
|
+
gutterColor: compass_components_1.codePalette.light[3],
|
|
76
|
+
gutterBackgroundColor: compass_components_1.codePalette.light[0],
|
|
71
77
|
gutterActiveLineBackgroundColor: (0, polished_1.rgba)(compass_components_1.palette.gray.light2, 0.5),
|
|
72
78
|
gutterFoldButtonColor: compass_components_1.palette.black,
|
|
73
79
|
cursorColor: compass_components_1.palette.gray.base,
|
|
@@ -88,8 +94,8 @@ const editorPalette = {
|
|
|
88
94
|
dark: {
|
|
89
95
|
color: compass_components_1.codePalette.dark[3],
|
|
90
96
|
backgroundColor: compass_components_1.codePalette.dark[0],
|
|
91
|
-
gutterColor: compass_components_1.
|
|
92
|
-
gutterBackgroundColor: compass_components_1.
|
|
97
|
+
gutterColor: compass_components_1.codePalette.dark[3],
|
|
98
|
+
gutterBackgroundColor: compass_components_1.codePalette.dark[0],
|
|
93
99
|
gutterActiveLineBackgroundColor: (0, polished_1.rgba)(compass_components_1.palette.gray.dark2, 0.5),
|
|
94
100
|
gutterFoldButtonColor: compass_components_1.palette.white,
|
|
95
101
|
cursorColor: compass_components_1.palette.green.base,
|
|
@@ -111,8 +117,8 @@ const editorPalette = {
|
|
|
111
117
|
function getStylesForTheme(theme) {
|
|
112
118
|
return view_1.EditorView.theme({
|
|
113
119
|
'&': {
|
|
114
|
-
color: editorPalette[theme].color,
|
|
115
|
-
backgroundColor: editorPalette[theme].backgroundColor,
|
|
120
|
+
color: exports.editorPalette[theme].color,
|
|
121
|
+
backgroundColor: exports.editorPalette[theme].backgroundColor,
|
|
116
122
|
maxHeight: '100%',
|
|
117
123
|
},
|
|
118
124
|
'& .cm-scroller': {
|
|
@@ -125,17 +131,17 @@ function getStylesForTheme(theme) {
|
|
|
125
131
|
'& .cm-content': {
|
|
126
132
|
paddingTop: `${compass_components_1.spacing[1]}px`,
|
|
127
133
|
paddingBottom: `${compass_components_1.spacing[1]}px`,
|
|
128
|
-
caretColor: editorPalette[theme].cursorColor,
|
|
134
|
+
caretColor: exports.editorPalette[theme].cursorColor,
|
|
129
135
|
},
|
|
130
136
|
'& .cm-activeLine': {
|
|
131
137
|
background: 'none',
|
|
132
138
|
},
|
|
133
139
|
'&.cm-focused .cm-activeLine': {
|
|
134
|
-
backgroundColor: editorPalette[theme].activeLineBackgroundColor,
|
|
140
|
+
backgroundColor: exports.editorPalette[theme].activeLineBackgroundColor,
|
|
135
141
|
},
|
|
136
142
|
'& .cm-gutters': {
|
|
137
|
-
color: editorPalette[theme].gutterColor,
|
|
138
|
-
backgroundColor: editorPalette[theme].gutterBackgroundColor,
|
|
143
|
+
color: exports.editorPalette[theme].gutterColor,
|
|
144
|
+
backgroundColor: exports.editorPalette[theme].gutterBackgroundColor,
|
|
139
145
|
border: 'none',
|
|
140
146
|
},
|
|
141
147
|
'& .cm-gutter-lint': {
|
|
@@ -150,26 +156,26 @@ function getStylesForTheme(theme) {
|
|
|
150
156
|
padding: '2px',
|
|
151
157
|
},
|
|
152
158
|
'& .cm-gutter-lint .cm-lint-marker-info': {
|
|
153
|
-
content: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath fill='${editorPalette[theme].infoGutterIconColor}' fill-rule='evenodd' d='M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM9 4a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM8 6a1 1 0 0 1 1 1v4h.5a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1H7V7h-.5a.5.5 0 0 1 0-1H8Z' clip-rule='evenodd'/%3E%3C/svg%3E%0A")`,
|
|
159
|
+
content: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath fill='${exports.editorPalette[theme].infoGutterIconColor}' fill-rule='evenodd' d='M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM9 4a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM8 6a1 1 0 0 1 1 1v4h.5a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1H7V7h-.5a.5.5 0 0 1 0-1H8Z' clip-rule='evenodd'/%3E%3C/svg%3E%0A")`,
|
|
154
160
|
},
|
|
155
161
|
'& .cm-gutter-lint .cm-lint-marker-warning': {
|
|
156
|
-
content: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath fill='${editorPalette[theme].warningGutterIconColor}' fill-rule='evenodd' d='M8.864 2.514a.983.983 0 0 0-1.728 0L1.122 13.539A.987.987 0 0 0 1.986 15h12.028a.987.987 0 0 0 .864-1.461L8.864 2.514ZM7 6a1 1 0 0 1 2 0v4a1 1 0 1 1-2 0V6Zm2 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z' clip-rule='evenodd'/%3E%3C/svg%3E%0A")`,
|
|
162
|
+
content: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath fill='${exports.editorPalette[theme].warningGutterIconColor}' fill-rule='evenodd' d='M8.864 2.514a.983.983 0 0 0-1.728 0L1.122 13.539A.987.987 0 0 0 1.986 15h12.028a.987.987 0 0 0 .864-1.461L8.864 2.514ZM7 6a1 1 0 0 1 2 0v4a1 1 0 1 1-2 0V6Zm2 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z' clip-rule='evenodd'/%3E%3C/svg%3E%0A")`,
|
|
157
163
|
},
|
|
158
164
|
'& .cm-gutter-lint .cm-lint-marker-error': {
|
|
159
|
-
content: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath fill='${editorPalette[theme].errorGutterIconColor}' fill-rule='evenodd' d='M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14zm1.414-9.828a1 1 0 1 1 1.414 1.414L9.414 8l1.414 1.414a1 1 0 1 1-1.414 1.414L8 9.414l-1.414 1.414a1 1 0 1 1-1.414-1.414L6.586 8 5.172 6.586a1 1 0 0 1 1.414-1.414L8 6.586l1.414-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E%0A")`,
|
|
165
|
+
content: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath fill='${exports.editorPalette[theme].errorGutterIconColor}' fill-rule='evenodd' d='M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14zm1.414-9.828a1 1 0 1 1 1.414 1.414L9.414 8l1.414 1.414a1 1 0 1 1-1.414 1.414L8 9.414l-1.414 1.414a1 1 0 1 1-1.414-1.414L6.586 8 5.172 6.586a1 1 0 0 1 1.414-1.414L8 6.586l1.414-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E%0A")`,
|
|
160
166
|
},
|
|
161
167
|
'& .cm-activeLineGutter': {
|
|
162
168
|
background: 'none',
|
|
163
169
|
},
|
|
164
170
|
'&.cm-focused .cm-activeLineGutter': {
|
|
165
|
-
backgroundColor: editorPalette[theme].gutterActiveLineBackgroundColor,
|
|
171
|
+
backgroundColor: exports.editorPalette[theme].gutterActiveLineBackgroundColor,
|
|
166
172
|
},
|
|
167
173
|
'& .cm-foldPlaceholder': {
|
|
168
174
|
display: 'inline-block',
|
|
169
175
|
border: 'none',
|
|
170
|
-
color: editorPalette[theme].foldPlaceholderColor,
|
|
171
|
-
backgroundColor: editorPalette[theme].foldPlaceholderBackgroundColor,
|
|
172
|
-
boxShadow: `inset 0 0 0 1px ${editorPalette[theme].foldPlaceholderColor}`,
|
|
176
|
+
color: exports.editorPalette[theme].foldPlaceholderColor,
|
|
177
|
+
backgroundColor: exports.editorPalette[theme].foldPlaceholderBackgroundColor,
|
|
178
|
+
boxShadow: `inset 0 0 0 1px ${exports.editorPalette[theme].foldPlaceholderColor}`,
|
|
173
179
|
padding: '0 2px',
|
|
174
180
|
},
|
|
175
181
|
'& .foldMarker': {
|
|
@@ -184,14 +190,14 @@ function getStylesForTheme(theme) {
|
|
|
184
190
|
width: '12px',
|
|
185
191
|
height: '12px',
|
|
186
192
|
display: 'block',
|
|
187
|
-
color: editorPalette[theme].gutterFoldButtonColor,
|
|
193
|
+
color: exports.editorPalette[theme].gutterFoldButtonColor,
|
|
188
194
|
},
|
|
189
195
|
'& .cm-selectionBackground': {
|
|
190
|
-
backgroundColor: editorPalette[theme].selectionBackgroundColor,
|
|
196
|
+
backgroundColor: exports.editorPalette[theme].selectionBackgroundColor,
|
|
191
197
|
},
|
|
192
198
|
'&.cm-focused .cm-matchingBracket': {
|
|
193
199
|
background: 'none',
|
|
194
|
-
boxShadow: `0 0 0 1px ${editorPalette[theme].bracketBorderColor}`,
|
|
200
|
+
boxShadow: `0 0 0 1px ${exports.editorPalette[theme].bracketBorderColor}`,
|
|
195
201
|
borderRadius: '2px',
|
|
196
202
|
},
|
|
197
203
|
'& .cm-selectionBackground:first-child': {
|
|
@@ -204,31 +210,31 @@ function getStylesForTheme(theme) {
|
|
|
204
210
|
},
|
|
205
211
|
'& .cm-cursor': {
|
|
206
212
|
borderLeft: '2px solid',
|
|
207
|
-
borderColor: editorPalette[theme].cursorColor,
|
|
213
|
+
borderColor: exports.editorPalette[theme].cursorColor,
|
|
208
214
|
marginLeft: '-1px',
|
|
209
215
|
},
|
|
210
216
|
'& .cm-tooltip': {
|
|
211
|
-
color: editorPalette[theme].autocompleteColor,
|
|
212
|
-
backgroundColor: editorPalette[theme].autocompleteBackgroundColor,
|
|
213
|
-
border: `1px solid ${editorPalette[theme].autocompleteBorderColor}`,
|
|
217
|
+
color: exports.editorPalette[theme].autocompleteColor,
|
|
218
|
+
backgroundColor: exports.editorPalette[theme].autocompleteBackgroundColor,
|
|
219
|
+
border: `1px solid ${exports.editorPalette[theme].autocompleteBorderColor}`,
|
|
214
220
|
},
|
|
215
221
|
'& .cm-tooltip.cm-tooltip-autocomplete > ul': {
|
|
216
222
|
fontFamily: compass_components_1.fontFamilies.code,
|
|
217
223
|
},
|
|
218
224
|
'& .cm-tooltip-autocomplete ul li[aria-selected]': {
|
|
219
|
-
color: editorPalette[theme].autocompleteColor,
|
|
220
|
-
backgroundColor: editorPalette[theme].autocompleteSelectedBackgroundColor,
|
|
225
|
+
color: exports.editorPalette[theme].autocompleteColor,
|
|
226
|
+
backgroundColor: exports.editorPalette[theme].autocompleteSelectedBackgroundColor,
|
|
221
227
|
},
|
|
222
228
|
'& .cm-completionIcon': {
|
|
223
229
|
display: 'none',
|
|
224
230
|
},
|
|
225
231
|
'& .cm-completionDetail': {
|
|
226
|
-
color: (0, polished_1.rgba)(editorPalette[theme].autocompleteColor, 0.5),
|
|
232
|
+
color: (0, polished_1.rgba)(exports.editorPalette[theme].autocompleteColor, 0.5),
|
|
227
233
|
fontStyle: 'normal',
|
|
228
234
|
marginRight: '1em',
|
|
229
235
|
},
|
|
230
236
|
'& .cm-completionMatchedText': {
|
|
231
|
-
color: editorPalette[theme].autocompleteMatchColor,
|
|
237
|
+
color: exports.editorPalette[theme].autocompleteMatchColor,
|
|
232
238
|
fontWeight: 'bold',
|
|
233
239
|
textDecoration: 'none',
|
|
234
240
|
},
|
|
@@ -332,24 +338,27 @@ const javascriptExpression = lang_javascript_1.javascriptLanguage.configure({
|
|
|
332
338
|
});
|
|
333
339
|
exports.languages = {
|
|
334
340
|
json: lang_json_1.json,
|
|
335
|
-
javascript
|
|
341
|
+
javascript: lang_javascript_1.javascript,
|
|
342
|
+
'javascript-expression': () => {
|
|
336
343
|
return new language_2.LanguageSupport(javascriptExpression);
|
|
337
344
|
},
|
|
338
345
|
};
|
|
339
346
|
exports.languageName = state_1.Facet.define({});
|
|
340
|
-
function
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
editorView.dispatch(...transactions);
|
|
347
|
+
async function wait(ms) {
|
|
348
|
+
return new Promise((resolve) => {
|
|
349
|
+
setTimeout(resolve, ms);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
async function sheduleDispatch(editorView, transactions, signal) {
|
|
353
|
+
while (editorView.updateState != 0) {
|
|
354
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
await wait();
|
|
352
358
|
}
|
|
359
|
+
transactions = Array.isArray(transactions) ? transactions : [transactions];
|
|
360
|
+
editorView.dispatch(...transactions);
|
|
361
|
+
return true;
|
|
353
362
|
}
|
|
354
363
|
function useCodemirrorExtensionCompartment(fn, value, editorViewRef) {
|
|
355
364
|
var _a, _b;
|
|
@@ -365,7 +374,7 @@ function useCodemirrorExtensionCompartment(fn, value, editorViewRef) {
|
|
|
365
374
|
return;
|
|
366
375
|
}
|
|
367
376
|
const controller = new AbortController();
|
|
368
|
-
sheduleDispatch(editorViewRef.current, {
|
|
377
|
+
void sheduleDispatch(editorViewRef.current, {
|
|
369
378
|
effects: (_a = compartmentRef.current) === null || _a === void 0 ? void 0 : _a.reconfigure(extensionCreatorRef.current()),
|
|
370
379
|
}, controller.signal);
|
|
371
380
|
return () => {
|
|
@@ -375,7 +384,7 @@ function useCodemirrorExtensionCompartment(fn, value, editorViewRef) {
|
|
|
375
384
|
return initialExtensionRef.current;
|
|
376
385
|
}
|
|
377
386
|
const BaseEditor = react_1.default.forwardRef(function BaseEditor({ initialText: _initialText, text, onChangeText, language = 'json', showLineNumbers = true, showFoldGutter = true, showAnnotationsGutter = true, showScroll = true, highlightActiveLine: shouldHighlightActiveLine = true, annotations, completer, darkMode: _darkMode, className, readOnly = false, onLoad = () => {
|
|
378
|
-
}, minLines, maxLines, lineHeight = 16, placeholder: placeholderString, commands, ...props }, ref) {
|
|
387
|
+
}, minLines, maxLines, lineHeight = 16, placeholder: placeholderString, commands, initialJSONFoldAll: _initialJSONFoldAll = true, ...props }, ref) {
|
|
379
388
|
const darkMode = (0, compass_components_1.useDarkMode)(_darkMode);
|
|
380
389
|
const onChangeTextRef = (0, react_1.useRef)(onChangeText);
|
|
381
390
|
const onLoadRef = (0, react_1.useRef)(onLoad);
|
|
@@ -389,6 +398,7 @@ const BaseEditor = react_1.default.forwardRef(function BaseEditor({ initialText:
|
|
|
389
398
|
height: 0,
|
|
390
399
|
hasScroll: false,
|
|
391
400
|
});
|
|
401
|
+
const initialJSONFoldAll = (0, react_1.useRef)(_initialJSONFoldAll);
|
|
392
402
|
onChangeTextRef.current = onChangeText;
|
|
393
403
|
onLoadRef.current = onLoad;
|
|
394
404
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
@@ -454,7 +464,8 @@ const BaseEditor = react_1.default.forwardRef(function BaseEditor({ initialText:
|
|
|
454
464
|
return view_1.EditorView.theme({
|
|
455
465
|
'& .cm-scroller': {
|
|
456
466
|
lineHeight: `${lineHeight}px`,
|
|
457
|
-
...(maxLines &&
|
|
467
|
+
...(maxLines &&
|
|
468
|
+
maxLines < Infinity && {
|
|
458
469
|
maxHeight: `${maxLines * lineHeight}px`,
|
|
459
470
|
}),
|
|
460
471
|
height: '100%',
|
|
@@ -537,7 +548,12 @@ const BaseEditor = react_1.default.forwardRef(function BaseEditor({ initialText:
|
|
|
537
548
|
view_1.keymap.of([
|
|
538
549
|
{
|
|
539
550
|
key: 'Tab',
|
|
540
|
-
run
|
|
551
|
+
run(context) {
|
|
552
|
+
if (isReadOnly(context.state)) {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
return (0, autocomplete_1.acceptCompletion)(context);
|
|
556
|
+
},
|
|
541
557
|
},
|
|
542
558
|
{
|
|
543
559
|
key: 'Ctrl-Shift-b',
|
|
@@ -572,7 +588,7 @@ const BaseEditor = react_1.default.forwardRef(function BaseEditor({ initialText:
|
|
|
572
588
|
const docLength = editor.state.doc.length;
|
|
573
589
|
const isSyntaxTreeAvailable = (0, language_1.syntaxTreeAvailable)(editor.state, docLength) ||
|
|
574
590
|
(0, language_1.forceParsing)(editor, docLength, 150);
|
|
575
|
-
if (isSyntaxTreeAvailable) {
|
|
591
|
+
if (initialJSONFoldAll.current && isSyntaxTreeAvailable) {
|
|
576
592
|
foldAll(editor);
|
|
577
593
|
}
|
|
578
594
|
else {
|
|
@@ -605,7 +621,7 @@ const BaseEditor = react_1.default.forwardRef(function BaseEditor({ initialText:
|
|
|
605
621
|
if (editorViewRef.current &&
|
|
606
622
|
text !== ((_a = editorViewRef.current.state.sliceDoc()) !== null && _a !== void 0 ? _a : '')) {
|
|
607
623
|
const controller = new AbortController();
|
|
608
|
-
sheduleDispatch(editorViewRef.current, {
|
|
624
|
+
void sheduleDispatch(editorViewRef.current, {
|
|
609
625
|
changes: {
|
|
610
626
|
from: 0,
|
|
611
627
|
to: editorViewRef.current.state.doc.length,
|
|
@@ -622,7 +638,7 @@ const BaseEditor = react_1.default.forwardRef(function BaseEditor({ initialText:
|
|
|
622
638
|
return;
|
|
623
639
|
}
|
|
624
640
|
const controller = new AbortController();
|
|
625
|
-
sheduleDispatch(editorViewRef.current, {
|
|
641
|
+
void sheduleDispatch(editorViewRef.current, {
|
|
626
642
|
effects: lint_1.setDiagnosticsEffect.of(annotations !== null && annotations !== void 0 ? annotations : []),
|
|
627
643
|
}, controller.signal);
|
|
628
644
|
return () => {
|
|
@@ -660,6 +676,9 @@ function isTopNode(node) {
|
|
|
660
676
|
: isTopNode(node.parent);
|
|
661
677
|
}
|
|
662
678
|
const applySnippet = (editor, template) => {
|
|
679
|
+
if (isReadOnly(editor.state)) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
663
682
|
const completion = (0, autocomplete_1.snippetCompletion)(template, { label: template });
|
|
664
683
|
if (typeof completion.apply === 'function') {
|
|
665
684
|
completion.apply(editor, completion, 0, editor.state.doc.length);
|
|
@@ -688,7 +707,7 @@ const foldAll = (editor) => {
|
|
|
688
707
|
},
|
|
689
708
|
});
|
|
690
709
|
if (foldableProperties.length > 0) {
|
|
691
|
-
sheduleDispatch(editor, {
|
|
710
|
+
void sheduleDispatch(editor, {
|
|
692
711
|
effects: foldableProperties.map((range) => {
|
|
693
712
|
return language_1.foldEffect.of(range);
|
|
694
713
|
}),
|
|
@@ -701,15 +720,15 @@ const copyAll = (editorView) => {
|
|
|
701
720
|
return true;
|
|
702
721
|
};
|
|
703
722
|
const prettify = (editorView) => {
|
|
704
|
-
if (editorView.state
|
|
723
|
+
if (isReadOnly(editorView.state)) {
|
|
705
724
|
return false;
|
|
706
725
|
}
|
|
707
726
|
const language = editorView.state.facet(exports.languageName)[0];
|
|
708
727
|
const doc = editorView.state.sliceDoc();
|
|
709
728
|
try {
|
|
710
|
-
const formatted = (0, prettify_1.prettify)(doc, language
|
|
729
|
+
const formatted = (0, prettify_1.prettify)(doc, language);
|
|
711
730
|
if (formatted !== doc) {
|
|
712
|
-
sheduleDispatch(editorView, {
|
|
731
|
+
void sheduleDispatch(editorView, {
|
|
713
732
|
changes: {
|
|
714
733
|
from: 0,
|
|
715
734
|
to: editorView.state.doc.length,
|
|
@@ -730,17 +749,21 @@ const inlineStyles = (0, compass_components_1.css)({
|
|
|
730
749
|
},
|
|
731
750
|
});
|
|
732
751
|
const InlineEditor = react_1.default.forwardRef(function InlineEditor({ className, ...props }, forwardRef) {
|
|
733
|
-
return (react_1.default.createElement(BaseEditor, { ref: forwardRef, maxLines: 10, showFoldGutter: false, showLineNumbers: false, showAnnotationsGutter: false, showScroll: false, highlightActiveLine: false, className: (0, compass_components_1.cx)(inlineStyles, className), language: "javascript", ...props }));
|
|
752
|
+
return (react_1.default.createElement(BaseEditor, { ref: forwardRef, maxLines: 10, showFoldGutter: false, showLineNumbers: false, showAnnotationsGutter: false, showScroll: false, highlightActiveLine: false, className: (0, compass_components_1.cx)(inlineStyles, className), language: "javascript-expression", ...props }));
|
|
734
753
|
});
|
|
735
754
|
exports.CodemirrorInlineEditor = InlineEditor;
|
|
736
755
|
const multilineEditorContainerStyle = (0, compass_components_1.css)({
|
|
737
756
|
position: 'relative',
|
|
738
757
|
height: '100%',
|
|
758
|
+
backgroundColor: exports.editorPalette.light.backgroundColor,
|
|
739
759
|
[`&:focus-within > .multiline-editor-actions,
|
|
740
760
|
&:hover > .multiline-editor-actions`]: {
|
|
741
761
|
display: 'flex',
|
|
742
762
|
},
|
|
743
763
|
});
|
|
764
|
+
const multilineEditorContainerDarkModeStyle = (0, compass_components_1.css)({
|
|
765
|
+
backgroundColor: exports.editorPalette.dark.backgroundColor,
|
|
766
|
+
});
|
|
744
767
|
const actionsContainerStyle = (0, compass_components_1.css)({
|
|
745
768
|
position: 'absolute',
|
|
746
769
|
top: compass_components_1.spacing[1],
|
|
@@ -748,7 +771,8 @@ const actionsContainerStyle = (0, compass_components_1.css)({
|
|
|
748
771
|
display: 'none',
|
|
749
772
|
gap: compass_components_1.spacing[2],
|
|
750
773
|
});
|
|
751
|
-
const MultilineEditor = react_1.default.forwardRef(function MultilineEditor({ customActions, copyable = true, formattable = true, className, editorClassName, actionsClassName, ...props }, ref) {
|
|
774
|
+
const MultilineEditor = react_1.default.forwardRef(function MultilineEditor({ customActions, copyable = true, formattable = true, className, editorClassName, actionsClassName, darkMode: _darkMode, ...props }, ref) {
|
|
775
|
+
const darkMode = (0, compass_components_1.useDarkMode)(_darkMode);
|
|
752
776
|
const containerRef = (0, react_1.useRef)(null);
|
|
753
777
|
const editorRef = (0, react_1.useRef)(null);
|
|
754
778
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
@@ -804,14 +828,31 @@ const MultilineEditor = react_1.default.forwardRef(function MultilineEditor({ cu
|
|
|
804
828
|
}),
|
|
805
829
|
];
|
|
806
830
|
}, [copyable, formattable, customActions]);
|
|
807
|
-
return (react_1.default.createElement("div", { ref: containerRef, className: (0, compass_components_1.cx)(multilineEditorContainerStyle, className), onClick: (evt) => {
|
|
831
|
+
return (react_1.default.createElement("div", { ref: containerRef, className: (0, compass_components_1.cx)(multilineEditorContainerStyle, darkMode && multilineEditorContainerDarkModeStyle, className), onClick: (evt) => {
|
|
808
832
|
var _a;
|
|
809
833
|
if (evt.target === containerRef.current) {
|
|
810
834
|
(_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
811
835
|
}
|
|
812
836
|
} },
|
|
813
|
-
react_1.default.createElement(BaseEditor, { ref: editorRef, className: editorClassName, language: "javascript", minLines: 10, ...props }),
|
|
837
|
+
react_1.default.createElement(BaseEditor, { ref: editorRef, className: editorClassName, language: "javascript-expression", minLines: 10, ...props }),
|
|
814
838
|
actions.length > 0 && (react_1.default.createElement("div", { className: (0, compass_components_1.cx)('multiline-editor-actions', actionsContainerStyle, actionsClassName) }, actions))));
|
|
815
839
|
});
|
|
816
840
|
exports.CodemirrorMultilineEditor = MultilineEditor;
|
|
841
|
+
async function setCodemirrorEditorValue(element, text) {
|
|
842
|
+
if (typeof element === 'string') {
|
|
843
|
+
element = document.querySelector(`[data-testid="${element}"]`);
|
|
844
|
+
}
|
|
845
|
+
if (!element || !element.hasAttribute('data-codemirror')) {
|
|
846
|
+
throw new Error('Cannot find editor container');
|
|
847
|
+
}
|
|
848
|
+
const editorView = element._cm;
|
|
849
|
+
await sheduleDispatch(editorView, {
|
|
850
|
+
changes: {
|
|
851
|
+
from: 0,
|
|
852
|
+
to: editorView.state.doc.length,
|
|
853
|
+
insert: text,
|
|
854
|
+
},
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
exports.setCodemirrorEditorValue = setCodemirrorEditorValue;
|
|
817
858
|
//# sourceMappingURL=json-editor.js.map
|