@darajs/components 1.16.5 → 1.16.6-alpha.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/dist/dara_components-1.16.6a1-py3-none-any.whl +0 -0
- package/dist/smart/code-editor.d.ts.map +1 -1
- package/dist/smart/code-editor.js +27 -2
- package/dist/smart/code-editor.js.map +1 -1
- package/dist/smart/index.d.ts +1 -0
- package/dist/smart/index.d.ts.map +1 -1
- package/dist/smart/index.js +1 -0
- package/dist/smart/index.js.map +1 -1
- package/dist/smart/ui-code-editor/code-editor.d.ts +119 -0
- package/dist/smart/ui-code-editor/code-editor.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/code-editor.js +358 -0
- package/dist/smart/ui-code-editor/code-editor.js.map +1 -0
- package/dist/smart/ui-code-editor/codemirror-context.d.ts +18 -0
- package/dist/smart/ui-code-editor/codemirror-context.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/codemirror-context.js +10 -0
- package/dist/smart/ui-code-editor/codemirror-context.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/argument-hints.d.ts +21 -0
- package/dist/smart/ui-code-editor/extensions/argument-hints.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/argument-hints.js +250 -0
- package/dist/smart/ui-code-editor/extensions/argument-hints.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/code-folding.d.ts +3 -0
- package/dist/smart/ui-code-editor/extensions/code-folding.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/code-folding.js +69 -0
- package/dist/smart/ui-code-editor/extensions/code-folding.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/json.d.ts +16 -0
- package/dist/smart/ui-code-editor/extensions/json.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/json.js +29 -0
- package/dist/smart/ui-code-editor/extensions/json.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/lsp-utils.d.ts +39 -0
- package/dist/smart/ui-code-editor/extensions/lsp-utils.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/lsp-utils.js +299 -0
- package/dist/smart/ui-code-editor/extensions/lsp-utils.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/markdown.d.ts +13 -0
- package/dist/smart/ui-code-editor/extensions/markdown.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/markdown.js +19 -0
- package/dist/smart/ui-code-editor/extensions/markdown.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/python.d.ts +15 -0
- package/dist/smart/ui-code-editor/extensions/python.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/python.js +21 -0
- package/dist/smart/ui-code-editor/extensions/python.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/shared.d.ts +48 -0
- package/dist/smart/ui-code-editor/extensions/shared.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/shared.js +166 -0
- package/dist/smart/ui-code-editor/extensions/shared.js.map +1 -0
- package/dist/smart/ui-code-editor/extensions/sql.d.ts +14 -0
- package/dist/smart/ui-code-editor/extensions/sql.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/extensions/sql.js +23 -0
- package/dist/smart/ui-code-editor/extensions/sql.js.map +1 -0
- package/dist/smart/ui-code-editor/index.d.ts +25 -0
- package/dist/smart/ui-code-editor/index.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/index.js +25 -0
- package/dist/smart/ui-code-editor/index.js.map +1 -0
- package/dist/smart/ui-code-editor/types.d.ts +65 -0
- package/dist/smart/ui-code-editor/types.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/types.js +5 -0
- package/dist/smart/ui-code-editor/types.js.map +1 -0
- package/dist/smart/ui-code-editor/utils.d.ts +16 -0
- package/dist/smart/ui-code-editor/utils.d.ts.map +1 -0
- package/dist/smart/ui-code-editor/utils.js +33 -0
- package/dist/smart/ui-code-editor/utils.js.map +1 -0
- package/dist/umd/dara.components.umd.js +35044 -31126
- package/dist/umd/style.css +749 -0
- package/package.json +27 -14
- package/dist/dara_components-1.16.5-py3-none-any.whl +0 -0
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-editor.d.ts","sourceRoot":"","sources":["../../js/smart/code-editor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-editor.d.ts","sourceRoot":"","sources":["../../js/smart/code-editor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAA8C,MAAM,cAAc,CAAC;AAQ1G,UAAU,eAAgB,SAAQ,oBAAoB;IAClD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC;CACrD;AAID;;;GAGG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAsCvD;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import { injectCss, useComponentStyles, useVariable } from '@darajs/core';
|
|
3
|
-
import { CodeEditor as UICodeEditor } from '
|
|
4
|
+
import { CodeEditor as UICodeEditor } from './ui-code-editor';
|
|
5
|
+
import { getJSONExtensions } from './ui-code-editor/extensions/json';
|
|
6
|
+
import { getMarkdownExtensions } from './ui-code-editor/extensions/markdown';
|
|
7
|
+
import { getPythonExtensions } from './ui-code-editor/extensions/python';
|
|
8
|
+
import { getSQLExtensions } from './ui-code-editor/extensions/sql';
|
|
4
9
|
const StyledCodeEditor = injectCss(UICodeEditor);
|
|
5
10
|
/**
|
|
6
11
|
* A component that creates a CodeEditor. The script is stored in a variable and is updated
|
|
@@ -9,7 +14,27 @@ const StyledCodeEditor = injectCss(UICodeEditor);
|
|
|
9
14
|
function CodeEditor(props) {
|
|
10
15
|
const [style, css] = useComponentStyles(props);
|
|
11
16
|
const [script, setScript] = useVariable(props.script);
|
|
12
|
-
|
|
17
|
+
const onChange = React.useCallback((update) => {
|
|
18
|
+
if (update.docChanged) {
|
|
19
|
+
setScript(update.state.doc.toString());
|
|
20
|
+
}
|
|
21
|
+
}, [setScript]);
|
|
22
|
+
const extensions = React.useMemo(() => {
|
|
23
|
+
if (props.language === 'json') {
|
|
24
|
+
return getJSONExtensions();
|
|
25
|
+
}
|
|
26
|
+
if (props.language === 'python') {
|
|
27
|
+
return getPythonExtensions();
|
|
28
|
+
}
|
|
29
|
+
if (props.language === 'markdown') {
|
|
30
|
+
return getMarkdownExtensions();
|
|
31
|
+
}
|
|
32
|
+
if (props.language === 'sql') {
|
|
33
|
+
return getSQLExtensions();
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}, [props.language]);
|
|
37
|
+
return (_jsx(StyledCodeEditor, { "$rawCss": css, initialValue: script, onChange: onChange, style: style, extensions: extensions }));
|
|
13
38
|
}
|
|
14
39
|
export default CodeEditor;
|
|
15
40
|
//# sourceMappingURL=code-editor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-editor.js","sourceRoot":"","sources":["../../js/smart/code-editor.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"code-editor.js","sourceRoot":"","sources":["../../js/smart/code-editor.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAkC,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE1G,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAA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,CAAC;AACN,CAAC;AAED,eAAe,UAAU,CAAC"}
|
package/dist/smart/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export { default as FilterStatusButton } from './filter-status-button/filter-sta
|
|
|
3
3
|
export { default as HierarchySelector } from './hierarchy-selector/hierarchy-selector';
|
|
4
4
|
export { default as HierarchyViewer } from './hierarchy-viewer/hierarchy-viewer';
|
|
5
5
|
export { default as CodeEditor } from './code-editor';
|
|
6
|
+
export { CodeEditor as UiCodeEditor, argumentHints, closeArgumentsHintsTooltip, getDefaultExtensions, goToDefinitionExtension, getJSONExtensions, getMarkdownExtensions, getPythonExtensions, getSQLExtensions, } from './ui-code-editor';
|
|
6
7
|
export { default as Chat } from './chat/chat';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../js/smart/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../js/smart/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACH,UAAU,IAAI,YAAY,EAC1B,aAAa,EACb,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/smart/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { default as FilterStatusButton } from './filter-status-button/filter-sta
|
|
|
4
4
|
export { default as HierarchySelector } from './hierarchy-selector/hierarchy-selector';
|
|
5
5
|
export { default as HierarchyViewer } from './hierarchy-viewer/hierarchy-viewer';
|
|
6
6
|
export { default as CodeEditor } from './code-editor';
|
|
7
|
+
export { CodeEditor as UiCodeEditor, argumentHints, closeArgumentsHintsTooltip, getDefaultExtensions, goToDefinitionExtension, getJSONExtensions, getMarkdownExtensions, getPythonExtensions, getSQLExtensions, } from './ui-code-editor';
|
|
7
8
|
export { default as Chat } from './chat/chat';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/smart/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../js/smart/index.tsx"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../js/smart/index.tsx"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACH,UAAU,IAAI,YAAY,EAC1B,aAAa,EACb,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { Extension } from '@codemirror/state';
|
|
2
|
+
import type { KeyBinding, ViewUpdate } from '@codemirror/view';
|
|
3
|
+
import { EditorView } from '@codemirror/view';
|
|
4
|
+
import '@vscode/codicons/dist/codicon.css';
|
|
5
|
+
import type { FunctionComponent } from 'react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import type { Range } from 'vscode-languageserver-types';
|
|
8
|
+
import './index.css';
|
|
9
|
+
import type { LSPDefinition, LspHoverResponse } from './types';
|
|
10
|
+
export interface ConfigurableHotkeys {
|
|
11
|
+
hotkeyBindings?: {
|
|
12
|
+
[key: string]: (e: KeyboardEvent, view: EditorView) => void;
|
|
13
|
+
};
|
|
14
|
+
focusMiddlewares?: (() => boolean)[];
|
|
15
|
+
allowInputs?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TooltipRenderProps {
|
|
18
|
+
lineNumber: number;
|
|
19
|
+
characterPos: number;
|
|
20
|
+
inspectedSubstring: string;
|
|
21
|
+
source?: string;
|
|
22
|
+
contents: LspHoverResponse['contents'];
|
|
23
|
+
}
|
|
24
|
+
type FocusState = 'soft' | 'hard';
|
|
25
|
+
export interface CodeEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onBlur'> {
|
|
26
|
+
/**
|
|
27
|
+
* The URI of the file being edited.
|
|
28
|
+
* Should be in the format `file:///path/to/file#cellId`, cellId being optional
|
|
29
|
+
*/
|
|
30
|
+
uri?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The class name to apply to the editor wrapper
|
|
33
|
+
*/
|
|
34
|
+
className?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The extensions to apply to the editor
|
|
37
|
+
*/
|
|
38
|
+
extensions?: Extension;
|
|
39
|
+
/**
|
|
40
|
+
* Styles to apply directly to the editor rather than the wrapper around it
|
|
41
|
+
*/
|
|
42
|
+
editorStyle?: React.CSSProperties;
|
|
43
|
+
/**
|
|
44
|
+
* The initial text value of the editor
|
|
45
|
+
*/
|
|
46
|
+
initialValue?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the editor should be disabled
|
|
49
|
+
*/
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether to disable the LSP features
|
|
53
|
+
*/
|
|
54
|
+
enableLsp?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the editor should be read-only
|
|
57
|
+
*/
|
|
58
|
+
readOnly?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The type of focus on the editor, hard is editable mode, soft just browseable
|
|
61
|
+
*/
|
|
62
|
+
focusType?: FocusState;
|
|
63
|
+
/**
|
|
64
|
+
* The style to apply to the editor wrapper
|
|
65
|
+
*/
|
|
66
|
+
style?: React.CSSProperties;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the editor should be focused on load
|
|
69
|
+
*/
|
|
70
|
+
focusOnLoad?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The onFocus handler
|
|
73
|
+
*/
|
|
74
|
+
onFocus?: () => void;
|
|
75
|
+
/**
|
|
76
|
+
* The onBlur handler
|
|
77
|
+
*/
|
|
78
|
+
onBlur?: (ev: FocusEvent, view: EditorView) => void;
|
|
79
|
+
/**
|
|
80
|
+
* The onChange handler
|
|
81
|
+
*/
|
|
82
|
+
onChange?: (update: ViewUpdate) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Callback to handle go to definition
|
|
85
|
+
*/
|
|
86
|
+
onGoToDefinition?: (defs: LSPDefinition[]) => void;
|
|
87
|
+
/**
|
|
88
|
+
* The initial position in the document to select
|
|
89
|
+
*/
|
|
90
|
+
initialPosition?: Range;
|
|
91
|
+
/**
|
|
92
|
+
* The configurable hotkeys to apply to the editor wrapper
|
|
93
|
+
*/
|
|
94
|
+
configurableHotkeys?: ConfigurableHotkeys;
|
|
95
|
+
/**
|
|
96
|
+
* The data-testid to apply to the editor wrapper
|
|
97
|
+
*/
|
|
98
|
+
dataTestId?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The keymap precedence to apply to the editor
|
|
101
|
+
*/
|
|
102
|
+
keymapPrecedence?: KeyBinding[];
|
|
103
|
+
/**
|
|
104
|
+
* Render props for the tooltip
|
|
105
|
+
*/
|
|
106
|
+
tooltipRenderer?: (props: TooltipRenderProps) => React.ReactNode;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the editor should be updated if initial value changes
|
|
109
|
+
*/
|
|
110
|
+
shouldSyncInitialValue?: boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Base CodeEditor component.
|
|
114
|
+
* Should not depend on studio-specific contexts or hooks as it will eventually be moved into Dara.
|
|
115
|
+
* Studio-specific functionality should be implemented as extensions or configured via props, injected in StudioEditor.
|
|
116
|
+
*/
|
|
117
|
+
declare const CodeEditor: FunctionComponent<CodeEditorProps>;
|
|
118
|
+
export default CodeEditor;
|
|
119
|
+
//# sourceMappingURL=code-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.d.ts","sourceRoot":"","sources":["../../../js/smart/ui-code-editor/code-editor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAgC,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAkC,MAAM,kBAAkB,CAAC;AAC9E,OAAO,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAA+C,MAAM,OAAO,CAAC;AAGpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAWzD,OAAO,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAsC/D,MAAM,WAAW,mBAAmB;IAChC,cAAc,CAAC,EAAE;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;KAC/D,CAAC;IACF,gBAAgB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAElC,MAAM,WAAW,eAAgB,SAAQ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AAK,KAAK,CAAC,SAAS,CAAC;IACjE;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AAKD;;;;GAIG;AACH,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAiYlD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { autocompletion } from '@codemirror/autocomplete';
|
|
23
|
+
import { EditorState, Prec } from '@codemirror/state';
|
|
24
|
+
import { EditorView, hoverTooltip, keymap, tooltips } from '@codemirror/view';
|
|
25
|
+
import '@vscode/codicons/dist/codicon.css';
|
|
26
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
27
|
+
import ReactDOM from 'react-dom';
|
|
28
|
+
import { WebSocketCtx } from '@darajs/core';
|
|
29
|
+
import styled, { useTheme } from '@darajs/styled-components';
|
|
30
|
+
import { useFocusTinykeys, useLatestCallback, useLatestRef, useOnClickOutside } from '@darajs/ui-utils';
|
|
31
|
+
import { useCodeMirrorContext } from './codemirror-context';
|
|
32
|
+
import { argumentHints, closeArgumentsHintsTooltip } from './extensions/argument-hints';
|
|
33
|
+
import { getLspCompletion, getLspDefinition, getLspInspection } from './extensions/lsp-utils';
|
|
34
|
+
import { getDefaultExtensions, goToDefinitionExtension } from './extensions/shared';
|
|
35
|
+
import './index.css';
|
|
36
|
+
import { EXTERNAL_UPDATE } from './utils';
|
|
37
|
+
const TooltipWrapper = styled.div `
|
|
38
|
+
position: relative;
|
|
39
|
+
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
|
|
44
|
+
max-width: 550px;
|
|
45
|
+
max-height: 300px;
|
|
46
|
+
margin: -1px;
|
|
47
|
+
|
|
48
|
+
color: ${(props) => props.theme.colors.text};
|
|
49
|
+
word-break: break-word;
|
|
50
|
+
|
|
51
|
+
background-color: ${({ theme }) => theme.colors.background} !important;
|
|
52
|
+
border-radius: 0.25rem;
|
|
53
|
+
box-shadow:
|
|
54
|
+
rgb(0 0 0 / 10%) 0 1px 3px 0,
|
|
55
|
+
rgb(0 0 0 / 6%) 0 1px 2px 0;
|
|
56
|
+
|
|
57
|
+
pre {
|
|
58
|
+
margin: 0;
|
|
59
|
+
padding: 0.75rem 1rem;
|
|
60
|
+
font-size: 0.9rem;
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
function Tooltip({ content }) {
|
|
64
|
+
return ReactDOM.createPortal(content, document.body);
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line no-empty-function
|
|
67
|
+
const noop = () => { };
|
|
68
|
+
/**
|
|
69
|
+
* Base CodeEditor component.
|
|
70
|
+
* Should not depend on studio-specific contexts or hooks as it will eventually be moved into Dara.
|
|
71
|
+
* Studio-specific functionality should be implemented as extensions or configured via props, injected in StudioEditor.
|
|
72
|
+
*/
|
|
73
|
+
const CodeEditor = (_a) => {
|
|
74
|
+
var _b;
|
|
75
|
+
var { className, uri, extensions, editorStyle, enableLsp, initialValue, focusType, disabled, readOnly = false, style, focusOnLoad = false, onFocus, onBlur, onChange, initialPosition, configurableHotkeys, dataTestId, keymapPrecedence, tooltipRenderer, onGoToDefinition, shouldSyncInitialValue = true } = _a, rest = __rest(_a, ["className", "uri", "extensions", "editorStyle", "enableLsp", "initialValue", "focusType", "disabled", "readOnly", "style", "focusOnLoad", "onFocus", "onBlur", "onChange", "initialPosition", "configurableHotkeys", "dataTestId", "keymapPrecedence", "tooltipRenderer", "onGoToDefinition", "shouldSyncInitialValue"]);
|
|
76
|
+
if (enableLsp && !uri) {
|
|
77
|
+
throw new Error('Must provide URI when LSP is enabled');
|
|
78
|
+
}
|
|
79
|
+
const { client } = React.useContext(WebSocketCtx);
|
|
80
|
+
const ref = useRef(null);
|
|
81
|
+
const viewRef = useRef(null);
|
|
82
|
+
const onBlurStable = useLatestRef(onBlur);
|
|
83
|
+
const theme = useTheme();
|
|
84
|
+
const [tooltipContent, setTooltipContent] = useState();
|
|
85
|
+
const tooltipRef = useRef(null);
|
|
86
|
+
const [signatureTooltipContent, setSignatureTooltipContent] = useState();
|
|
87
|
+
const signatureTooltipRef = useRef(null);
|
|
88
|
+
// We use refs to prevent the editor from re-initializing when the script changes, updates to the editor on script
|
|
89
|
+
// changes are handled in a dedicated useEffect More info: https://stackoverflow.com/a/70616581
|
|
90
|
+
const initialThemeType = useLatestRef(theme.themeType);
|
|
91
|
+
const initialValueRef = useLatestRef(initialValue !== null && initialValue !== void 0 ? initialValue : '');
|
|
92
|
+
const initialIsFocused = useLatestRef(focusOnLoad);
|
|
93
|
+
const focusTypeRef = useLatestRef(focusType);
|
|
94
|
+
const onChangeRef = useLatestRef((update) => {
|
|
95
|
+
initialValueRef.current = update.state.doc.toString();
|
|
96
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(update);
|
|
97
|
+
});
|
|
98
|
+
const onFocusRef = useLatestRef(onFocus);
|
|
99
|
+
const [prevIsFocused, setPrevIsFocused] = useState(focusOnLoad);
|
|
100
|
+
// remap the hotkeys to pass it the viewRef
|
|
101
|
+
const hotkeys = useMemo(() => {
|
|
102
|
+
return (configurableHotkeys === null || configurableHotkeys === void 0 ? void 0 : configurableHotkeys.hotkeyBindings) ?
|
|
103
|
+
Object.keys(configurableHotkeys.hotkeyBindings).reduce((acc, key) => {
|
|
104
|
+
acc[key] = (e) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
(_b = (_a = configurableHotkeys.hotkeyBindings) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.call(_a, e, viewRef.current);
|
|
107
|
+
};
|
|
108
|
+
return acc;
|
|
109
|
+
}, {})
|
|
110
|
+
: {};
|
|
111
|
+
}, [configurableHotkeys === null || configurableHotkeys === void 0 ? void 0 : configurableHotkeys.hotkeyBindings, viewRef]);
|
|
112
|
+
// These shortcuts are specifically for when the code editor is in focus
|
|
113
|
+
useFocusTinykeys(hotkeys, ref, {
|
|
114
|
+
middlewares: configurableHotkeys === null || configurableHotkeys === void 0 ? void 0 : configurableHotkeys.focusMiddlewares,
|
|
115
|
+
allowInputs: configurableHotkeys === null || configurableHotkeys === void 0 ? void 0 : configurableHotkeys.allowInputs,
|
|
116
|
+
});
|
|
117
|
+
if (focusOnLoad !== prevIsFocused) {
|
|
118
|
+
if (focusOnLoad) {
|
|
119
|
+
(_b = viewRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
120
|
+
}
|
|
121
|
+
if (focusType === 'soft' && onBlur) {
|
|
122
|
+
onBlur(new FocusEvent('blur'), viewRef.current);
|
|
123
|
+
}
|
|
124
|
+
setPrevIsFocused(focusOnLoad);
|
|
125
|
+
}
|
|
126
|
+
const { setEditorView } = useCodeMirrorContext();
|
|
127
|
+
const enableGoToDef = React.useMemo(() => onGoToDefinition !== undefined, [onGoToDefinition]);
|
|
128
|
+
const goToDef = useLatestCallback(onGoToDefinition !== null && onGoToDefinition !== void 0 ? onGoToDefinition : noop);
|
|
129
|
+
useOnClickOutside(ref.current, () => {
|
|
130
|
+
closeArgumentsHintsTooltip(viewRef.current);
|
|
131
|
+
});
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
var _a;
|
|
134
|
+
// client is required for LSP features
|
|
135
|
+
if (!ref.current || (!client && enableLsp)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const signatureHelp = argumentHints(client, uri, signatureTooltipRef, setSignatureTooltipContent);
|
|
139
|
+
const startState = EditorState.create({
|
|
140
|
+
doc: initialValueRef.current,
|
|
141
|
+
selection: {
|
|
142
|
+
anchor: initialValueRef.current.length,
|
|
143
|
+
},
|
|
144
|
+
extensions: [
|
|
145
|
+
extensions !== null && extensions !== void 0 ? extensions : [],
|
|
146
|
+
...getDefaultExtensions(initialThemeType.current),
|
|
147
|
+
EditorView.clickAddsSelectionRange.of((evt) => evt.altKey && !evt.ctrlKey && !evt.metaKey),
|
|
148
|
+
EditorView.editable.of(!disabled),
|
|
149
|
+
EditorState.readOnly.of(readOnly),
|
|
150
|
+
EditorView.updateListener.of((update) => {
|
|
151
|
+
onChangeRef.current(update);
|
|
152
|
+
if (update.focusChanged && update.view.hasFocus && onFocusRef.current) {
|
|
153
|
+
onFocusRef.current();
|
|
154
|
+
}
|
|
155
|
+
}),
|
|
156
|
+
// This block of extensions is only applied if LSP is enabled
|
|
157
|
+
enableLsp ?
|
|
158
|
+
[
|
|
159
|
+
// signature help
|
|
160
|
+
signatureHelp,
|
|
161
|
+
// completion
|
|
162
|
+
autocompletion({
|
|
163
|
+
override: [(ctx) => getLspCompletion(client, ctx, uri)],
|
|
164
|
+
// use original sorting order from the LSP
|
|
165
|
+
compareCompletions: () => 1,
|
|
166
|
+
// reactivate completion when completing paths
|
|
167
|
+
activateOnCompletion: (completion) => completion.type === 'file' &&
|
|
168
|
+
typeof completion.apply === 'string' &&
|
|
169
|
+
completion.apply.endsWith('/'),
|
|
170
|
+
}),
|
|
171
|
+
// go-to-definition
|
|
172
|
+
enableGoToDef ?
|
|
173
|
+
goToDefinitionExtension((ch, line) => __awaiter(void 0, void 0, void 0, function* () {
|
|
174
|
+
const res = yield getLspDefinition(client, uri, line, ch);
|
|
175
|
+
if (res) {
|
|
176
|
+
goToDef(res.definitions);
|
|
177
|
+
}
|
|
178
|
+
}))
|
|
179
|
+
: [],
|
|
180
|
+
tooltips({
|
|
181
|
+
parent: document.body,
|
|
182
|
+
}),
|
|
183
|
+
// inspect
|
|
184
|
+
hoverTooltip((view, pos) => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
+
// TODO: when this is moved to base Dara it should have a default implementation
|
|
186
|
+
if (!tooltipRenderer) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
const wordRange = view.state.wordAt(pos);
|
|
190
|
+
if (!wordRange) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
const inspectedSubstring = view.state.doc.sliceString(wordRange.from, wordRange.to);
|
|
194
|
+
const linePosInfo = view.state.doc.lineAt(pos);
|
|
195
|
+
const ch = pos - linePosInfo.from;
|
|
196
|
+
const line = linePosInfo.number - 1;
|
|
197
|
+
const inspection = yield getLspInspection(client, uri, line, ch);
|
|
198
|
+
if (!inspection) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
above: true,
|
|
203
|
+
create: () => {
|
|
204
|
+
const dom = tooltipRef.current;
|
|
205
|
+
setTooltipContent(tooltipRenderer({
|
|
206
|
+
characterPos: ch,
|
|
207
|
+
lineNumber: line,
|
|
208
|
+
inspectedSubstring,
|
|
209
|
+
contents: inspection.contents,
|
|
210
|
+
source: inspection.source,
|
|
211
|
+
}));
|
|
212
|
+
setSignatureTooltipContent(null);
|
|
213
|
+
return {
|
|
214
|
+
dom,
|
|
215
|
+
overlap: true,
|
|
216
|
+
destroy: () => {
|
|
217
|
+
setTooltipContent(null);
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
end: wordRange.to,
|
|
222
|
+
pos: wordRange.from,
|
|
223
|
+
};
|
|
224
|
+
})),
|
|
225
|
+
]
|
|
226
|
+
: [],
|
|
227
|
+
keymap.of([
|
|
228
|
+
{
|
|
229
|
+
key: 'Escape',
|
|
230
|
+
run: () => {
|
|
231
|
+
if (!signatureHelp || !enableLsp) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
// if the tooltip is not currently showing, skip
|
|
235
|
+
const signatureHelpState = signatureHelp[0];
|
|
236
|
+
if (viewRef.current.state.field(signatureHelpState) === null) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
// tooltip is showing, close and return true to stop propagation
|
|
240
|
+
// so Escape doesn't trigger other events
|
|
241
|
+
closeArgumentsHintsTooltip(viewRef.current);
|
|
242
|
+
return true;
|
|
243
|
+
},
|
|
244
|
+
stopPropagation: true,
|
|
245
|
+
},
|
|
246
|
+
]),
|
|
247
|
+
Prec.highest(keymap.of((_a = keymapPrecedence === null || keymapPrecedence === void 0 ? void 0 : keymapPrecedence.map((binding) => {
|
|
248
|
+
return Object.assign(Object.assign({}, binding), { run: () => { var _a, _b; return (_b = (_a = binding.run) === null || _a === void 0 ? void 0 : _a.call(binding, viewRef.current)) !== null && _b !== void 0 ? _b : false; } });
|
|
249
|
+
})) !== null && _a !== void 0 ? _a : [])),
|
|
250
|
+
EditorView.domEventHandlers({
|
|
251
|
+
blur: (ev, view) => {
|
|
252
|
+
var _a;
|
|
253
|
+
(_a = onBlurStable.current) === null || _a === void 0 ? void 0 : _a.call(onBlurStable, ev, view);
|
|
254
|
+
},
|
|
255
|
+
}),
|
|
256
|
+
],
|
|
257
|
+
});
|
|
258
|
+
viewRef.current = new EditorView({
|
|
259
|
+
parent: ref.current,
|
|
260
|
+
state: startState,
|
|
261
|
+
});
|
|
262
|
+
if (initialIsFocused.current && focusTypeRef.current !== 'soft') {
|
|
263
|
+
viewRef.current.focus();
|
|
264
|
+
// focus on last character
|
|
265
|
+
viewRef.current.dispatch({
|
|
266
|
+
selection: {
|
|
267
|
+
anchor: viewRef.current.state.doc.length,
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (setEditorView) {
|
|
272
|
+
setEditorView(viewRef.current);
|
|
273
|
+
}
|
|
274
|
+
// If an initial position in the document is set then scroll to it and set the cursor
|
|
275
|
+
if (initialPosition) {
|
|
276
|
+
const view = viewRef.current;
|
|
277
|
+
// +1 due to lsp being zero indexed and code mirror being 1 indexed
|
|
278
|
+
const line = view.state.doc.line((initialPosition === null || initialPosition === void 0 ? void 0 : initialPosition.start.line) + 1);
|
|
279
|
+
const pos = line.from + (initialPosition === null || initialPosition === void 0 ? void 0 : initialPosition.start.character);
|
|
280
|
+
const endPos = line.from + (initialPosition === null || initialPosition === void 0 ? void 0 : initialPosition.end.character);
|
|
281
|
+
view.focus();
|
|
282
|
+
view.dispatch({
|
|
283
|
+
effects: EditorView.scrollIntoView(line.from, { y: 'start' }),
|
|
284
|
+
selection: {
|
|
285
|
+
anchor: pos,
|
|
286
|
+
head: endPos,
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
return () => {
|
|
291
|
+
var _a;
|
|
292
|
+
(_a = viewRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
293
|
+
};
|
|
294
|
+
}, [
|
|
295
|
+
client,
|
|
296
|
+
initialPosition,
|
|
297
|
+
initialValueRef,
|
|
298
|
+
extensions,
|
|
299
|
+
keymapPrecedence,
|
|
300
|
+
initialIsFocused,
|
|
301
|
+
focusTypeRef,
|
|
302
|
+
setEditorView,
|
|
303
|
+
onFocusRef,
|
|
304
|
+
onChangeRef,
|
|
305
|
+
initialThemeType,
|
|
306
|
+
uri,
|
|
307
|
+
goToDef,
|
|
308
|
+
disabled,
|
|
309
|
+
readOnly,
|
|
310
|
+
tooltipRenderer,
|
|
311
|
+
enableLsp,
|
|
312
|
+
enableGoToDef,
|
|
313
|
+
onBlurStable,
|
|
314
|
+
]);
|
|
315
|
+
// keep the editor in sync with the script variable in case it changes from the outside
|
|
316
|
+
React.useEffect(() => {
|
|
317
|
+
// https://github.com/causalens/decision-studio/pull/394
|
|
318
|
+
// First check if there is a difference, if there isn't then there's definitely nothing to do so don't bother
|
|
319
|
+
// with the next step at all.
|
|
320
|
+
if (shouldSyncInitialValue && viewRef.current && viewRef.current.state.doc.toString() !== initialValue) {
|
|
321
|
+
// Rather than forcing the update immediately we set it in a timeout that will get wiped on any other
|
|
322
|
+
// changes to initialValue coming through. If the content is still different after 100ms then we push the
|
|
323
|
+
// update through as we are now sure that the difference was intentional and not due to race condition.
|
|
324
|
+
const timeoutID = setTimeout(() => {
|
|
325
|
+
var _a;
|
|
326
|
+
if (viewRef.current.state.doc.toString() !== initialValue) {
|
|
327
|
+
viewRef.current.dispatch({
|
|
328
|
+
annotations: EXTERNAL_UPDATE.of(true),
|
|
329
|
+
changes: {
|
|
330
|
+
from: 0,
|
|
331
|
+
insert: initialValue,
|
|
332
|
+
to: viewRef.current.state.doc.length,
|
|
333
|
+
},
|
|
334
|
+
selection: { anchor: (_a = initialValue === null || initialValue === void 0 ? void 0 : initialValue.length) !== null && _a !== void 0 ? _a : 0 },
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}, 100);
|
|
338
|
+
return () => clearTimeout(timeoutID);
|
|
339
|
+
}
|
|
340
|
+
// Just in case the editor gets recreated then make sure the initialContent ref is up to date
|
|
341
|
+
initialValueRef.current = initialValue !== null && initialValue !== void 0 ? initialValue : '';
|
|
342
|
+
}, [initialValue, initialValueRef, shouldSyncInitialValue]);
|
|
343
|
+
return (_jsxs("div", Object.assign({ className: className, style: style }, rest, { children: [_jsx(Tooltip, { content: _jsx("div", { children: _jsx(TooltipWrapper, { ref: tooltipRef, role: "tooltip", style: {
|
|
344
|
+
display: tooltipContent ? 'flex' : 'none',
|
|
345
|
+
}, children: tooltipContent }) }) }), _jsx(Tooltip, { content: _jsx("div", { children: _jsx(TooltipWrapper, { ref: signatureTooltipRef, role: "tooltip", style: {
|
|
346
|
+
display: signatureTooltipContent ? 'flex' : 'none',
|
|
347
|
+
}, children: signatureTooltipContent }) }) }), _jsx("div", { onBlur: () => {
|
|
348
|
+
if (enableLsp) {
|
|
349
|
+
closeArgumentsHintsTooltip(viewRef.current);
|
|
350
|
+
}
|
|
351
|
+
// if not using focus types and just a plain editor, call onBlur
|
|
352
|
+
if (focusType === undefined) {
|
|
353
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(new FocusEvent('blur'), viewRef.current);
|
|
354
|
+
}
|
|
355
|
+
}, "data-testid": dataTestId, ref: ref, style: editorStyle })] })));
|
|
356
|
+
};
|
|
357
|
+
export default CodeEditor;
|
|
358
|
+
//# sourceMappingURL=code-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.js","sourceRoot":"","sources":["../../../js/smart/ui-code-editor/code-editor.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,mCAAmC,CAAC;AAE3C,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,QAAQ,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,YAA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,OAAO,CAAC,OAAO,CAAC,CAAC;oBAChD,CAAC;oBACD,gEAAgE;oBAChE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;wBAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;oBACtD,CAAC;gBACL,CAAC,iBACY,UAAU,EACvB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,WAAW,GACpB,KACA,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EditorView } from '@codemirror/view';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface CodeMirrorContextInterface {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* The current editor view.
|
|
7
|
+
*/
|
|
8
|
+
editorView: EditorView;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* Set the editor view
|
|
12
|
+
*/
|
|
13
|
+
setEditorView: (editorView: EditorView) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare const CodeMirrorContext: React.Context<CodeMirrorContextInterface>;
|
|
16
|
+
export declare function useCodeMirrorContext(): CodeMirrorContextInterface;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=codemirror-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemirror-context.d.ts","sourceRoot":"","sources":["../../../js/smart/ui-code-editor/codemirror-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,UAAU,0BAA0B;IAChC;;;OAGG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;;OAGG;IACH,aAAa,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;CACnD;AAID,eAAO,MAAM,iBAAiB,2CAG5B,CAAC;AAEH,wBAAgB,oBAAoB,IAAI,0BAA0B,CAEjE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
const noop = () => { };
|
|
3
|
+
export const CodeMirrorContext = React.createContext({
|
|
4
|
+
editorView: null,
|
|
5
|
+
setEditorView: noop,
|
|
6
|
+
});
|
|
7
|
+
export function useCodeMirrorContext() {
|
|
8
|
+
return React.useContext(CodeMirrorContext);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=codemirror-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemirror-context.js","sourceRoot":"","sources":["../../../js/smart/ui-code-editor/codemirror-context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AAE5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAA6B;IAC7E,UAAU,EAAE,IAA6B;IACzC,aAAa,EAAE,IAAI;CACtB,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB;IAChC,OAAO,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAC/C,CAAC"}
|