@mongodb-js/compass-editor 0.6.0 → 0.8.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/actions.d.ts +11 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/{multiline-editor.js → actions.js} +8 -57
- package/dist/actions.js.map +1 -0
- package/dist/autocompleter.d.ts +22 -7
- package/dist/autocompleter.d.ts.map +1 -1
- package/dist/autocompleter.js +28 -8
- package/dist/autocompleter.js.map +1 -1
- package/dist/codemirror/ace-compat-autocompleter.d.ts +26 -0
- package/dist/codemirror/ace-compat-autocompleter.d.ts.map +1 -0
- package/dist/codemirror/ace-compat-autocompleter.js +67 -0
- package/dist/codemirror/ace-compat-autocompleter.js.map +1 -0
- package/dist/codemirror/aggregation-autocompleter.d.ts +3 -0
- package/dist/codemirror/aggregation-autocompleter.d.ts.map +1 -0
- package/dist/codemirror/aggregation-autocompleter.js +58 -0
- package/dist/codemirror/aggregation-autocompleter.js.map +1 -0
- package/dist/codemirror/document-autocompleter.d.ts +3 -0
- package/dist/codemirror/document-autocompleter.d.ts.map +1 -0
- package/dist/codemirror/document-autocompleter.js +50 -0
- package/dist/codemirror/document-autocompleter.js.map +1 -0
- package/dist/codemirror/query-autocompleter.d.ts +4 -0
- package/dist/codemirror/query-autocompleter.d.ts.map +1 -0
- package/dist/codemirror/query-autocompleter.js +22 -0
- package/dist/codemirror/query-autocompleter.js.map +1 -0
- package/dist/codemirror/stage-autocompleter.d.ts +6 -0
- package/dist/codemirror/stage-autocompleter.d.ts.map +1 -0
- package/dist/codemirror/stage-autocompleter.js +58 -0
- package/dist/codemirror/stage-autocompleter.js.map +1 -0
- package/dist/codemirror/utils.d.ts +14 -0
- package/dist/codemirror/utils.d.ts.map +1 -0
- package/dist/codemirror/utils.js +80 -0
- package/dist/codemirror/utils.js.map +1 -0
- package/dist/codemirror/validation-autocompleter.d.ts +4 -0
- package/dist/codemirror/validation-autocompleter.d.ts.map +1 -0
- package/dist/codemirror/validation-autocompleter.js +123 -0
- package/dist/codemirror/validation-autocompleter.js.map +1 -0
- package/dist/index.d.ts +7 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -31
- package/dist/index.js.map +1 -1
- package/dist/json-editor.d.ts +101 -16
- package/dist/json-editor.d.ts.map +1 -1
- package/dist/json-editor.js +440 -76
- package/dist/json-editor.js.map +1 -1
- package/dist/prettify.d.ts +1 -1
- package/dist/prettify.d.ts.map +1 -1
- package/dist/types.d.ts +4 -36
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -14
- 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 -108
- 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.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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStageAutocompleter = void 0;
|
|
4
|
+
const autocompleter_1 = require("../autocompleter");
|
|
5
|
+
const ace_compat_autocompleter_1 = require("./ace-compat-autocompleter");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const query_autocompleter_1 = require("./query-autocompleter");
|
|
8
|
+
const createStageAutocompleter = ({ stageOperator, ...options } = {}) => {
|
|
9
|
+
const queryAutocompleter = (0, query_autocompleter_1.createQueryAutocompleter)(options);
|
|
10
|
+
const fieldsReferenceCompletions = (0, autocompleter_1.completer)('', {
|
|
11
|
+
...options,
|
|
12
|
+
meta: ['field:reference'],
|
|
13
|
+
});
|
|
14
|
+
const stageCompletions = (0, autocompleter_1.completer)('', {
|
|
15
|
+
...options,
|
|
16
|
+
meta: [
|
|
17
|
+
'expr:*',
|
|
18
|
+
'conv',
|
|
19
|
+
'bson',
|
|
20
|
+
'field:identifier',
|
|
21
|
+
...(['$project', '$group'].includes(stageOperator !== null && stageOperator !== void 0 ? stageOperator : '')
|
|
22
|
+
? ['accumulator', 'accumulator:*']
|
|
23
|
+
: []),
|
|
24
|
+
],
|
|
25
|
+
}).map((completion) => {
|
|
26
|
+
var _a;
|
|
27
|
+
if ((_a = completion.meta) === null || _a === void 0 ? void 0 : _a.startsWith('expr:')) {
|
|
28
|
+
return {
|
|
29
|
+
...completion,
|
|
30
|
+
description: `<p>${(0, utils_1.aggLink)(completion.value)} pipeline operator</p>`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return completion;
|
|
34
|
+
});
|
|
35
|
+
return (0, ace_compat_autocompleter_1.createAceCompatAutocompleter)({
|
|
36
|
+
String({ prefix, context }) {
|
|
37
|
+
if (prefix.text.startsWith('$')) {
|
|
38
|
+
return (0, ace_compat_autocompleter_1.createCompletionResultForIdPrefix)({
|
|
39
|
+
prefix,
|
|
40
|
+
completions: fieldsReferenceCompletions,
|
|
41
|
+
escape: 'never',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return (0, utils_1.completeWordsInString)(context);
|
|
45
|
+
},
|
|
46
|
+
IdentifierLike({ prefix, context }) {
|
|
47
|
+
if (stageOperator === '$match') {
|
|
48
|
+
return queryAutocompleter(context);
|
|
49
|
+
}
|
|
50
|
+
return (0, ace_compat_autocompleter_1.createCompletionResultForIdPrefix)({
|
|
51
|
+
prefix,
|
|
52
|
+
completions: stageCompletions,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
exports.createStageAutocompleter = createStageAutocompleter;
|
|
58
|
+
//# sourceMappingURL=stage-autocompleter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/stage-autocompleter.ts"],"names":[],"mappings":";;;AAEA,oDAA6C;AAC7C,yEAGoC;AACpC,mCAAyD;AACzD,+DAAiE;AAE1D,MAAM,wBAAwB,GAAG,CAAC,EACvC,aAAa,EACb,GAAG,OAAO,KAGR,EAAE,EAAoB,EAAE;IAC1B,MAAM,kBAAkB,GAAG,IA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AC9B,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;aACpC;YACD,OAAO,IAAA,4DAAiC,EAAC;gBACvC,MAAM;gBACN,WAAW,EAAE,gBAAgB;aAC9B,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA1DW,QAAA,wBAAwB,4BA0DnC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CompletionContext } from '@codemirror/autocomplete';
|
|
2
|
+
import type { EditorState } from '@codemirror/state';
|
|
3
|
+
export declare const completeWordsInString: import("@codemirror/autocomplete").CompletionSource;
|
|
4
|
+
export declare function resolveTokenAtCursor(context: CompletionContext): import("@lezer/common").SyntaxNode;
|
|
5
|
+
export type Token = ReturnType<typeof resolveTokenAtCursor>;
|
|
6
|
+
export declare function aggLink(op: string): string;
|
|
7
|
+
export declare function padLines(str: string, pad?: string): string;
|
|
8
|
+
export declare function parents(token: Token): Generator<import("@lezer/common").SyntaxNode, void, unknown>;
|
|
9
|
+
export declare function removeQuotes(str: string): string;
|
|
10
|
+
export declare function isTokenEqual(a: Token, b: Token): boolean;
|
|
11
|
+
export declare function getPropertyNameFromPropertyToken(editorState: EditorState, propertyToken: Token): string;
|
|
12
|
+
export declare function getTokenText(editorState: EditorState, token: Token): string;
|
|
13
|
+
export declare function getAncestryOfToken(token: Token, document: string): string[];
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/codemirror/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,qBAAqB,qDAAoC,CAAC;AAEvE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,sCAE9D;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5D,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG1C;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAO,UAK/C;AAED,wBAAiB,OAAO,CAAC,KAAK,EAAE,KAAK,gEAKpC;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,UAEvC;AAID,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,WAE9C;AAED,wBAAgB,gCAAgC,CAC9C,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,KAAK,GACnB,MAAM,CAKR;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,UAElE;AA0CD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAY3E"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAncestryOfToken = exports.getTokenText = exports.getPropertyNameFromPropertyToken = exports.isTokenEqual = exports.removeQuotes = exports.parents = exports.padLines = exports.aggLink = exports.resolveTokenAtCursor = exports.completeWordsInString = void 0;
|
|
4
|
+
const autocomplete_1 = require("@codemirror/autocomplete");
|
|
5
|
+
const language_1 = require("@codemirror/language");
|
|
6
|
+
exports.completeWordsInString = (0, autocomplete_1.ifIn)(['String'], autocomplete_1.completeAnyWord);
|
|
7
|
+
function resolveTokenAtCursor(context) {
|
|
8
|
+
return (0, language_1.syntaxTree)(context.state).resolveInner(context.pos, -1);
|
|
9
|
+
}
|
|
10
|
+
exports.resolveTokenAtCursor = resolveTokenAtCursor;
|
|
11
|
+
function aggLink(op) {
|
|
12
|
+
op = op.replace(/^\$/, '');
|
|
13
|
+
return `<a target="_blank" href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/${op}/">$${op}</a>`;
|
|
14
|
+
}
|
|
15
|
+
exports.aggLink = aggLink;
|
|
16
|
+
function padLines(str, pad = ' ') {
|
|
17
|
+
return str
|
|
18
|
+
.split('\n')
|
|
19
|
+
.map((line) => `${pad}${line}`)
|
|
20
|
+
.join('\n');
|
|
21
|
+
}
|
|
22
|
+
exports.padLines = padLines;
|
|
23
|
+
function* parents(token) {
|
|
24
|
+
let parent = token;
|
|
25
|
+
while ((parent = parent.parent)) {
|
|
26
|
+
yield parent;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.parents = parents;
|
|
30
|
+
function removeQuotes(str) {
|
|
31
|
+
return str.replace(/(^('|")|('|")$)/g, '');
|
|
32
|
+
}
|
|
33
|
+
exports.removeQuotes = removeQuotes;
|
|
34
|
+
function isTokenEqual(a, b) {
|
|
35
|
+
return a.from === b.from && a.to === b.to;
|
|
36
|
+
}
|
|
37
|
+
exports.isTokenEqual = isTokenEqual;
|
|
38
|
+
function getPropertyNameFromPropertyToken(editorState, propertyToken) {
|
|
39
|
+
if (!propertyToken.firstChild) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
return removeQuotes(getTokenText(editorState, propertyToken.firstChild));
|
|
43
|
+
}
|
|
44
|
+
exports.getPropertyNameFromPropertyToken = getPropertyNameFromPropertyToken;
|
|
45
|
+
function getTokenText(editorState, token) {
|
|
46
|
+
return editorState.sliceDoc(token.from, token.to);
|
|
47
|
+
}
|
|
48
|
+
exports.getTokenText = getTokenText;
|
|
49
|
+
const getAncestorList = (node, doc) => {
|
|
50
|
+
const ancestors = [];
|
|
51
|
+
if (!(node === null || node === void 0 ? void 0 : node.parent)) {
|
|
52
|
+
return ancestors;
|
|
53
|
+
}
|
|
54
|
+
if (['ArrayExpression', 'Array'].includes(node.parent.name)) {
|
|
55
|
+
let prevSibling = node.prevSibling;
|
|
56
|
+
let index = 0;
|
|
57
|
+
while (prevSibling) {
|
|
58
|
+
if (![':', ',', '['].includes(prevSibling.name)) {
|
|
59
|
+
index++;
|
|
60
|
+
}
|
|
61
|
+
prevSibling = prevSibling.prevSibling;
|
|
62
|
+
}
|
|
63
|
+
ancestors.push(`[${index}]`);
|
|
64
|
+
}
|
|
65
|
+
if (node.name === 'Property' && node.firstChild) {
|
|
66
|
+
const { from, to } = node.firstChild;
|
|
67
|
+
const ancestor = doc.slice(from, to).replace(/"/g, '').replace(/'/g, '');
|
|
68
|
+
ancestors.push(ancestor);
|
|
69
|
+
}
|
|
70
|
+
return ancestors.concat(getAncestorList(node.parent, doc));
|
|
71
|
+
};
|
|
72
|
+
function getAncestryOfToken(token, document) {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
const isAutocompletingPropertyName = ['ObjectExpression', 'PropertyDefinition'].includes(token.name) ||
|
|
75
|
+
(((_b = (_a = token.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.name) === 'ObjectExpression' && !token.prevSibling);
|
|
76
|
+
const list = getAncestorList(isAutocompletingPropertyName ? (_c = token.parent) === null || _c === void 0 ? void 0 : _c.parent : token, document).reverse();
|
|
77
|
+
return list;
|
|
78
|
+
}
|
|
79
|
+
exports.getAncestryOfToken = getAncestryOfToken;
|
|
80
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/codemirror/utils.ts"],"names":[],"mappings":";;;AAAA,2DAAiE;AAEjE,mDAAkD;AAGrC,QAAA,qBAAqB,GAAG,IAAA,mBAAI,EAAC,CAAC,QAAQ,CAAC,EAAE,8BAAe,CAAC,CAAC;AAEvE,SAAgB,oBAAoB,CAAC,OAA0B;IAC7D,OAAO,IAAA,qBAAU,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAFD,oDAEC;AAID,SAAg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AOF,SAAgB,kBAAkB,CAAC,KAAY,EAAE,QAAgB;;IAG/D,MAAM,4BAA4B,GAChC,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAC/D,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,MAAM,0CAAE,MAAM,0CAAE,IAAI,MAAK,kBAAkB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE5E,MAAM,IAAI,GAAG,eAAe,CAC1B,4BAA4B,CAAC,CAAC,CAAC,MAAA,KAAK,CAAC,MAAM,0CAAE,MAAM,CAAC,CAAC,CAAC,KAAK,EAC3D,QAAQ,CACT,CAAC,OAAO,EAAE,CAAC;IACZ,OAAO,IAAI,CAAC;AACd,CAAC;AAZD,gDAYC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CompletionSource } from '@codemirror/autocomplete';
|
|
2
|
+
import type { CompleteOptions } from '../autocompleter';
|
|
3
|
+
export declare const createValidationAutocompleter: (options?: Pick<CompleteOptions, 'fields' | 'serverVersion'>) => CompletionSource;
|
|
4
|
+
//# sourceMappingURL=validation-autocompleter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-autocompleter.d.ts","sourceRoot":"","sources":["../../src/codemirror/validation-autocompleter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA6F1E,eAAO,MAAM,6BAA6B,aAC/B,KAAK,eAAe,EAAE,QAAQ,GAAG,eAAe,CAAC,KACzD,gBAqEF,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createValidationAutocompleter = void 0;
|
|
4
|
+
const autocomplete_1 = require("@codemirror/autocomplete");
|
|
5
|
+
const autocompleter_1 = require("../autocompleter");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const ace_compat_autocompleter_1 = require("./ace-compat-autocompleter");
|
|
8
|
+
const query_autocompleter_1 = require("./query-autocompleter");
|
|
9
|
+
const rootJsonSchemaCompletion = (from, to) => ({
|
|
10
|
+
filter: false,
|
|
11
|
+
from,
|
|
12
|
+
to,
|
|
13
|
+
options: [
|
|
14
|
+
(0, autocomplete_1.snippetCompletion)('{\n\t$jsonSchema: {\n\t\t${}\n\t}\n}', {
|
|
15
|
+
label: '$jsonSchema',
|
|
16
|
+
info: 'json-schema validation object',
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
const isCompletingRequired = (ancestors) => {
|
|
21
|
+
return ancestors[ancestors.length - 2] === 'required';
|
|
22
|
+
};
|
|
23
|
+
const isCompletingProperties = (ancestors) => {
|
|
24
|
+
return ancestors[ancestors.length - 1] === 'properties';
|
|
25
|
+
};
|
|
26
|
+
const isCompletingBsonType = (ancestors) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const immediateParent = (_a = ancestors[ancestors.length - 1]) !== null && _a !== void 0 ? _a : '';
|
|
29
|
+
return (immediateParent === 'bsonType' ||
|
|
30
|
+
ancestors[ancestors.length - 2] === 'bsonType');
|
|
31
|
+
};
|
|
32
|
+
const isCompletingQueryOperator = (ancestors, operators) => {
|
|
33
|
+
return ancestors
|
|
34
|
+
.filter((x) => x !== '$jsonSchema')
|
|
35
|
+
.some((x) => operators.includes(x));
|
|
36
|
+
};
|
|
37
|
+
const getNestingAncestor = (ancestors) => {
|
|
38
|
+
return (ancestors
|
|
39
|
+
.filter((x) => !['$jsonSchema'].includes(x))
|
|
40
|
+
.map((x, i, a) => {
|
|
41
|
+
if (['required', 'properties'].includes(x)) {
|
|
42
|
+
return a[i - 1];
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join('.'));
|
|
47
|
+
};
|
|
48
|
+
const filterFieldsByAncestor = (fields, ancestor) => {
|
|
49
|
+
if (ancestor === '') {
|
|
50
|
+
return fields;
|
|
51
|
+
}
|
|
52
|
+
return fields
|
|
53
|
+
.filter((x) => x.value !== ancestor && x.value.startsWith(ancestor))
|
|
54
|
+
.map((x) => {
|
|
55
|
+
const value = x.value.replace(`${ancestor}.`, '');
|
|
56
|
+
return {
|
|
57
|
+
...x,
|
|
58
|
+
value,
|
|
59
|
+
};
|
|
60
|
+
})
|
|
61
|
+
.filter((x) => x.value);
|
|
62
|
+
};
|
|
63
|
+
const createValidationAutocompleter = (options = {}) => {
|
|
64
|
+
const defaultCompletions = (0, autocompleter_1.completer)('', {
|
|
65
|
+
meta: ['json-schema', 'bson', 'query'],
|
|
66
|
+
...options,
|
|
67
|
+
});
|
|
68
|
+
const fieldCompletions = (0, autocompleter_1.completer)('', {
|
|
69
|
+
meta: ['field:identifier'],
|
|
70
|
+
...options,
|
|
71
|
+
});
|
|
72
|
+
const bsonTypeCompletions = (0, autocompleter_1.completer)('', {
|
|
73
|
+
meta: ['bson-type-aliases'],
|
|
74
|
+
...options,
|
|
75
|
+
});
|
|
76
|
+
const queryAutocompleter = (0, query_autocompleter_1.createQueryAutocompleter)(options);
|
|
77
|
+
const queryCompletions = (0, autocompleter_1.completer)('', {
|
|
78
|
+
meta: ['query'],
|
|
79
|
+
...options,
|
|
80
|
+
});
|
|
81
|
+
const queryOperators = queryCompletions.map((x) => x.value);
|
|
82
|
+
return (context) => {
|
|
83
|
+
const token = (0, utils_1.resolveTokenAtCursor)(context);
|
|
84
|
+
const document = context.state.sliceDoc(0);
|
|
85
|
+
const prefix = context.matchBefore(ace_compat_autocompleter_1.ID_REGEX);
|
|
86
|
+
if (token.type.isTop) {
|
|
87
|
+
return rootJsonSchemaCompletion(0, document.length);
|
|
88
|
+
}
|
|
89
|
+
if (!prefix) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const ancestors = (0, utils_1.getAncestryOfToken)(token, document);
|
|
93
|
+
if (ancestors.length === 0) {
|
|
94
|
+
return (0, ace_compat_autocompleter_1.createCompletionResultForIdPrefix)({
|
|
95
|
+
prefix,
|
|
96
|
+
completions: queryCompletions,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (isCompletingQueryOperator(ancestors, queryOperators)) {
|
|
100
|
+
return queryAutocompleter(context);
|
|
101
|
+
}
|
|
102
|
+
if (isCompletingRequired(ancestors) || isCompletingProperties(ancestors)) {
|
|
103
|
+
const ancestor = getNestingAncestor(ancestors);
|
|
104
|
+
return (0, ace_compat_autocompleter_1.createCompletionResultForIdPrefix)({
|
|
105
|
+
prefix,
|
|
106
|
+
completions: filterFieldsByAncestor(fieldCompletions, ancestor),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (isCompletingBsonType(ancestors)) {
|
|
110
|
+
return (0, ace_compat_autocompleter_1.createCompletionResultForIdPrefix)({
|
|
111
|
+
prefix,
|
|
112
|
+
completions: bsonTypeCompletions,
|
|
113
|
+
escape: 'always',
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return (0, ace_compat_autocompleter_1.createCompletionResultForIdPrefix)({
|
|
117
|
+
prefix,
|
|
118
|
+
completions: defaultCompletions,
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
exports.createValidationAutocompleter = createValidationAutocompleter;
|
|
123
|
+
//# sourceMappingURL=validation-autocompleter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-autocompleter.js","sourceRoot":"","sources":["../../src/codemirror/validation-autocompleter.ts"],"names":[],"mappings":";;;AACA,2DAA6D;AAC7D,oDAA6C;AAG7C,mCAAmE;AACnE,yEAGoC;AACpC,+DAAiE;AAEjE,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,EAAE,KAAK;IACb,IAAI;IACJ,EA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AAC,EAAE;YACxE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAC/C,OAAO,IAAA,4DAAiC,EAAC;gBACvC,MAAM;gBACN,WAAW,EAAE,sBAAsB,CAAC,gBAAgB,EAAE,QAAQ,CAAC;aAChE,CAAC,CAAC;SACJ;QAED,IAAI,oBAAoB,CAAC,SAAS,CAAC,EAAE;YACnC,OAAO,IAAA,4DAAiC,EAAC;gBACvC,MAAM;gBACN,WAAW,EAAE,mBAAmB;gBAChC,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAC;SACJ;QAED,OAAO,IAAA,4DAAiC,EAAC;YACvC,MAAM;YACN,WAAW,EAAE,kBAAkB;SAChC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAvEW,QAAA,6BAA6B,iCAuExC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
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 declare type AceEditor = Ace.Editor;
|
|
8
|
-
export declare 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
|
|
16
|
-
export {
|
|
4
|
+
export { CodemirrorInlineEditor, CodemirrorMultilineEditor, setCodemirrorEditorValue, } from './json-editor';
|
|
5
|
+
export type { EditorView, Command, Annotation, Action, EditorRef, Completer, } from './json-editor';
|
|
6
|
+
export { createDocumentAutocompleter } from './codemirror/document-autocompleter';
|
|
7
|
+
export { createValidationAutocompleter } from './codemirror/validation-autocompleter';
|
|
8
|
+
export { createQueryAutocompleter } from './codemirror/query-autocompleter';
|
|
9
|
+
export { createStageAutocompleter } from './codemirror/stage-autocompleter';
|
|
10
|
+
export { createAggregationAutocompleter } from './codemirror/aggregation-autocompleter';
|
|
17
11
|
//# 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,
|
|
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,37 +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.
|
|
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
|
-
Object.defineProperty(exports, "
|
|
35
|
-
|
|
36
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "CodemirrorInlineEditor", { enumerable: true, get: function () { return json_editor_1.CodemirrorInlineEditor; } });
|
|
8
|
+
Object.defineProperty(exports, "CodemirrorMultilineEditor", { enumerable: true, get: function () { return json_editor_1.CodemirrorMultilineEditor; } });
|
|
9
|
+
Object.defineProperty(exports, "setCodemirrorEditorValue", { enumerable: true, get: function () { return json_editor_1.setCodemirrorEditorValue; } });
|
|
10
|
+
var document_autocompleter_1 = require("./codemirror/document-autocompleter");
|
|
11
|
+
Object.defineProperty(exports, "createDocumentAutocompleter", { enumerable: true, get: function () { return document_autocompleter_1.createDocumentAutocompleter; } });
|
|
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; } });
|
|
37
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
|
@@ -1,39 +1,124 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { KeyBinding } from '@codemirror/view';
|
|
3
3
|
import { EditorView } from '@codemirror/view';
|
|
4
|
-
import { unfoldAll } from '@codemirror/language';
|
|
5
4
|
import type { Diagnostic } from '@codemirror/lint';
|
|
6
5
|
import type { CompletionSource } from '@codemirror/autocomplete';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import type { IconGlyph } from '@mongodb-js/compass-components';
|
|
7
|
+
import { Facet } from '@codemirror/state';
|
|
8
|
+
import { LanguageSupport } from '@codemirror/language';
|
|
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';
|
|
56
|
+
export type Annotation = Pick<Diagnostic, 'from' | 'to' | 'severity' | 'message'>;
|
|
57
|
+
type EditorProps = {
|
|
10
58
|
language?: EditorLanguage;
|
|
11
59
|
onChangeText?: (text: string, event?: any) => void;
|
|
12
60
|
onLoad?: (editor: EditorView) => void;
|
|
13
61
|
darkMode?: boolean;
|
|
14
62
|
showLineNumbers?: boolean;
|
|
15
63
|
showFoldGutter?: boolean;
|
|
64
|
+
showAnnotationsGutter?: boolean;
|
|
65
|
+
showScroll?: boolean;
|
|
66
|
+
highlightActiveLine?: boolean;
|
|
16
67
|
readOnly?: boolean;
|
|
17
|
-
className?: string;
|
|
18
68
|
'data-testid'?: string;
|
|
19
69
|
annotations?: Annotation[];
|
|
20
70
|
completer?: CompletionSource;
|
|
71
|
+
minLines?: number;
|
|
72
|
+
maxLines?: number;
|
|
73
|
+
lineHeight?: number;
|
|
74
|
+
placeholder?: string;
|
|
75
|
+
commands?: readonly KeyBinding[];
|
|
76
|
+
initialJSONFoldAll?: boolean;
|
|
21
77
|
} & ({
|
|
22
78
|
text: string;
|
|
23
79
|
initialText?: never;
|
|
24
80
|
} | {
|
|
25
81
|
text?: never;
|
|
26
82
|
initialText: string;
|
|
83
|
+
}) & Pick<React.HTMLProps<HTMLDivElement>, 'id' | 'className' | 'onFocus' | 'onBlur'>;
|
|
84
|
+
export declare const languages: Record<EditorLanguage, () => LanguageSupport>;
|
|
85
|
+
export declare const languageName: Facet<EditorLanguage, readonly EditorLanguage[]>;
|
|
86
|
+
export type EditorRef = {
|
|
87
|
+
foldAll: () => boolean;
|
|
88
|
+
unfoldAll: () => boolean;
|
|
89
|
+
copyAll: () => boolean;
|
|
90
|
+
prettify: () => boolean;
|
|
91
|
+
applySnippet: (template: string) => boolean;
|
|
92
|
+
focus: () => boolean;
|
|
93
|
+
readonly editor: EditorView | null;
|
|
94
|
+
};
|
|
95
|
+
declare const BaseEditor: React.ForwardRefExoticComponent<EditorProps & React.RefAttributes<EditorRef>>;
|
|
96
|
+
export type { EditorView, KeyBinding as Command };
|
|
97
|
+
type InlineEditorProps = Omit<EditorProps, 'text' | 'showLineNumbers' | 'showFoldGutter' | 'showAnnotationsGutter' | 'showScroll' | 'highlightActiveLine' | 'minLines' | 'annotations'> & ({
|
|
98
|
+
text: string;
|
|
99
|
+
initialText?: never;
|
|
100
|
+
} | {
|
|
101
|
+
text?: never;
|
|
102
|
+
initialText: string;
|
|
27
103
|
});
|
|
28
|
-
declare const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
104
|
+
declare const InlineEditor: React.ForwardRefExoticComponent<InlineEditorProps & React.RefAttributes<EditorRef>>;
|
|
105
|
+
export type Action = {
|
|
106
|
+
icon: IconGlyph;
|
|
107
|
+
label: string;
|
|
108
|
+
action: (editor: EditorView) => boolean | void;
|
|
109
|
+
};
|
|
110
|
+
type MultilineEditorProps = EditorProps & {
|
|
111
|
+
customActions?: Action[];
|
|
112
|
+
copyable?: boolean;
|
|
113
|
+
formattable?: boolean;
|
|
114
|
+
editorClassName?: string;
|
|
115
|
+
actionsClassName?: string;
|
|
33
116
|
};
|
|
34
|
-
declare const
|
|
35
|
-
declare
|
|
36
|
-
|
|
37
|
-
export
|
|
38
|
-
export {
|
|
117
|
+
declare const MultilineEditor: React.ForwardRefExoticComponent<MultilineEditorProps & React.RefAttributes<EditorRef>>;
|
|
118
|
+
declare function setCodemirrorEditorValue(element: HTMLElement | string | null, text: string): Promise<void>;
|
|
119
|
+
export { BaseEditor };
|
|
120
|
+
export { InlineEditor as CodemirrorInlineEditor };
|
|
121
|
+
export { MultilineEditor as CodemirrorMultilineEditor };
|
|
122
|
+
export { setCodemirrorEditorValue };
|
|
123
|
+
export type { CompletionSource as Completer };
|
|
39
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,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,O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