@yuntijs/ui 1.0.0-beta.8 → 1.0.0-beta.80
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/es/Alert/index.d.ts +13 -0
- package/es/Alert/index.js +25 -0
- package/es/Alert/style.d.ts +4 -0
- package/es/Alert/style.js +13 -0
- package/es/App/index.d.ts +7 -0
- package/es/App/index.js +19 -0
- package/es/ButtonGroup/index.d.ts +24 -0
- package/es/ButtonGroup/index.js +66 -0
- package/es/Card/index.d.ts +1 -0
- package/es/Card/index.js +1 -0
- package/es/CardList/Item/index.d.ts +4 -0
- package/es/CardList/Item/index.js +43 -0
- package/es/CardList/Item/style.d.ts +0 -0
- package/es/CardList/Item/style.js +0 -0
- package/es/CardList/index.d.ts +2 -0
- package/es/CardList/index.js +39 -0
- package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
- package/es/ChatInputArea/desktop/ChatInputArea.js +72 -0
- package/es/ChatInputArea/index.d.ts +6 -0
- package/es/ChatInputArea/index.js +6 -0
- package/es/ChatItem/components/MessageContent.d.ts +21 -0
- package/es/ChatItem/components/MessageContent.js +59 -0
- package/es/ChatItem/index.d.ts +4 -0
- package/es/ChatItem/index.js +120 -0
- package/es/ChatItem/style.d.ts +24 -0
- package/es/ChatItem/style.js +38 -0
- package/es/ChatItem/type.d.ts +82 -0
- package/es/ChatItem/type.js +1 -0
- package/es/CollapseGroup/index.d.ts +4 -0
- package/es/CollapseGroup/index.js +23 -0
- package/es/CollapseGroup/style.d.ts +3 -0
- package/es/CollapseGroup/style.js +11 -0
- package/es/ConfigProvider/index.d.ts +3 -0
- package/es/ConfigProvider/index.js +17 -11
- package/es/Descriptions/index.d.ts +14 -0
- package/es/Descriptions/index.js +31 -0
- package/es/Descriptions/style.d.ts +4 -0
- package/es/Descriptions/style.js +24 -0
- package/es/Divider/index.d.ts +38 -0
- package/es/Divider/index.js +66 -0
- package/es/Divider/style.d.ts +3 -0
- package/es/Divider/style.js +12 -0
- package/es/DragPanel/index.d.ts +10 -0
- package/es/DragPanel/index.js +97 -0
- package/es/DragPanel/style.d.ts +7 -0
- package/es/DragPanel/style.js +15 -0
- package/es/Drawer/index.d.ts +13 -0
- package/es/Drawer/index.js +20 -0
- package/es/Drawer/style.d.ts +4 -0
- package/es/Drawer/style.js +16 -0
- package/es/Dropdown/index.d.ts +14 -0
- package/es/Dropdown/index.js +59 -0
- package/es/Dropdown/style.d.ts +7 -0
- package/es/Dropdown/style.js +13 -0
- package/es/EditableMessage/index.d.ts +75 -0
- package/es/EditableMessage/index.js +99 -0
- package/es/Form/collapse-list/index.d.ts +40 -0
- package/es/Form/collapse-list/index.js +209 -0
- package/es/Form/collapse-list/style.d.ts +5 -0
- package/es/Form/collapse-list/style.js +13 -0
- package/es/Form/index.d.ts +8 -0
- package/es/Form/index.js +5 -0
- package/es/FormHelper/autoFocus.d.ts +10 -0
- package/es/FormHelper/autoFocus.js +38 -0
- package/es/FormHelper/index.d.ts +13 -0
- package/es/FormHelper/index.js +41 -0
- package/es/Highlighter/FullFeatured.d.ts +18 -0
- package/es/Highlighter/FullFeatured.js +102 -0
- package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -0
- package/es/Highlighter/SyntaxHighlighter/index.js +51 -0
- package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
- package/es/Highlighter/SyntaxHighlighter/style.js +16 -0
- package/es/Highlighter/index.d.ts +50 -0
- package/es/Highlighter/index.js +77 -0
- package/es/Highlighter/style.d.ts +9 -0
- package/es/Highlighter/style.js +23 -0
- package/es/Highlighter/theme.d.ts +1 -0
- package/es/Highlighter/theme.js +1661 -0
- package/es/LogViewer/index.d.ts +10 -0
- package/es/LogViewer/index.js +141 -0
- package/es/LogViewer/style.d.ts +6 -0
- package/es/LogViewer/style.js +16 -0
- package/es/LogViewer/types.d.ts +235 -0
- package/es/LogViewer/types.js +1 -0
- package/es/Mentions/constants.d.ts +6 -0
- package/es/Mentions/constants.js +28 -0
- package/es/Mentions/hooks.d.ts +20 -0
- package/es/Mentions/hooks.js +133 -0
- package/es/Mentions/index.d.ts +19 -0
- package/es/Mentions/index.js +136 -0
- package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
- package/es/Mentions/plugins/custom-text/node.js +72 -0
- package/es/Mentions/plugins/mention-node/component.d.ts +6 -0
- package/es/Mentions/plugins/mention-node/component.js +64 -0
- package/es/Mentions/plugins/mention-node/index.d.ts +9 -0
- package/es/Mentions/plugins/mention-node/index.js +32 -0
- package/es/Mentions/plugins/mention-node/node.d.ts +23 -0
- package/es/Mentions/plugins/mention-node/node.js +97 -0
- package/es/Mentions/plugins/mention-node/replacement.d.ts +5 -0
- package/es/Mentions/plugins/mention-node/replacement.js +42 -0
- package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
- package/es/Mentions/plugins/mention-node/style.js +47 -0
- package/es/Mentions/plugins/mention-node/utils.d.ts +4 -0
- package/es/Mentions/plugins/mention-node/utils.js +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.js +39 -0
- package/es/Mentions/plugins/mention-picker/index.d.ts +36 -0
- package/es/Mentions/plugins/mention-picker/index.js +87 -0
- package/es/Mentions/plugins/mention-picker/menu-item.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/menu-item.js +71 -0
- package/es/Mentions/plugins/mention-picker/menu.d.ts +9 -0
- package/es/Mentions/plugins/mention-picker/menu.js +30 -0
- package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/style.js +19 -0
- package/es/Mentions/plugins/mention-picker/utils.d.ts +22 -0
- package/es/Mentions/plugins/mention-picker/utils.js +39 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.d.ts +7 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.js +36 -0
- package/es/Mentions/provider.d.ts +12 -0
- package/es/Mentions/provider.js +15 -0
- package/es/Mentions/style.d.ts +11 -0
- package/es/Mentions/style.js +22 -0
- package/es/Mentions/types.d.ts +17 -0
- package/es/Mentions/types.js +1 -0
- package/es/Mentions/utils.d.ts +9 -0
- package/es/Mentions/utils.js +95 -0
- package/es/Modal/index.d.ts +19 -0
- package/es/Modal/index.js +36 -0
- package/es/Modal/style.d.ts +4 -0
- package/es/Modal/style.js +17 -0
- package/es/MonacoEditor/base/controller.d.ts +17 -0
- package/es/MonacoEditor/base/controller.js +49 -0
- package/es/MonacoEditor/base/helper.d.ts +65 -0
- package/es/MonacoEditor/base/helper.js +324 -0
- package/es/MonacoEditor/base/index.d.ts +35 -0
- package/es/MonacoEditor/base/index.js +236 -0
- package/es/MonacoEditor/base/monaco.d.ts +6 -0
- package/es/MonacoEditor/base/monaco.js +64 -0
- package/es/MonacoEditor/base/style.d.ts +12 -0
- package/es/MonacoEditor/base/style.js +26 -0
- package/es/MonacoEditor/index.d.ts +2 -4
- package/es/MonacoEditor/index.js +26 -62
- package/es/MonacoEditor/style.js +3 -2
- package/es/Page/Breadcrumb/index.d.ts +9 -0
- package/es/Page/Breadcrumb/index.js +56 -0
- package/es/Page/Content/index.d.ts +4 -0
- package/es/Page/Content/index.js +59 -0
- package/es/Page/Content/style.d.ts +3 -0
- package/es/Page/Content/style.js +12 -0
- package/es/Page/Footer/index.d.ts +2 -0
- package/es/Page/Footer/index.js +6 -0
- package/es/Page/Header/Icon.d.ts +17 -0
- package/es/Page/Header/Icon.js +42 -0
- package/es/Page/Header/index.d.ts +43 -0
- package/es/Page/Header/index.js +202 -0
- package/es/Page/Header/style.d.ts +12 -0
- package/es/Page/Header/style.js +21 -0
- package/es/Page/Page.d.ts +9 -0
- package/es/Page/Page.js +49 -0
- package/es/Page/PageContext.d.ts +15 -0
- package/es/Page/PageContext.js +21 -0
- package/es/Page/Title/index.d.ts +5 -0
- package/es/Page/Title/index.js +18 -0
- package/es/Page/Title/style.d.ts +3 -0
- package/es/Page/Title/style.js +10 -0
- package/es/Page/index.d.ts +18 -0
- package/es/Page/index.js +15 -0
- package/es/Page/style.d.ts +3 -0
- package/es/Page/style.js +10 -0
- package/es/ProCard/Card/index.d.ts +6 -0
- package/es/ProCard/Card/index.js +25 -0
- package/es/ProCard/Card/style.d.ts +7 -0
- package/es/ProCard/Card/style.js +15 -0
- package/es/ProCard/Content/index.d.ts +4 -0
- package/es/ProCard/Content/index.js +24 -0
- package/es/ProCard/Content/style.d.ts +3 -0
- package/es/ProCard/Content/style.js +10 -0
- package/es/ProCard/Descriptions/index.d.ts +4 -0
- package/es/ProCard/Descriptions/index.js +28 -0
- package/es/ProCard/Descriptions/style.d.ts +3 -0
- package/es/ProCard/Descriptions/style.js +12 -0
- package/es/ProCard/Header/index.d.ts +15 -0
- package/es/ProCard/Header/index.js +86 -0
- package/es/ProCard/Header/style.d.ts +12 -0
- package/es/ProCard/Header/style.js +21 -0
- package/es/ProCard/index.d.ts +13 -0
- package/es/ProCard/index.js +8 -0
- package/es/Radio/index.d.ts +36 -0
- package/es/Radio/index.js +26 -0
- package/es/Radio/style.d.ts +4 -0
- package/es/Radio/style.js +66 -0
- package/es/SelectCard/index.d.ts +33 -0
- package/es/SelectCard/index.js +132 -0
- package/es/SelectCard/style.d.ts +10 -0
- package/es/SelectCard/style.js +42 -0
- package/es/SliderInput/index.js +2 -2
- package/es/Status/index.d.ts +7 -0
- package/es/Status/index.js +39 -0
- package/es/Status/style.d.ts +4 -0
- package/es/Status/style.js +14 -0
- package/es/Table/collapse/index.d.ts +8 -0
- package/es/Table/collapse/index.js +39 -0
- package/es/Table/collapse/style.d.ts +3 -0
- package/es/Table/collapse/style.js +11 -0
- package/es/Table/index.d.ts +20 -0
- package/es/Table/index.js +56 -0
- package/es/Typography/index.d.ts +32 -0
- package/es/Typography/index.js +77 -0
- package/es/WaveformIcon/index.d.ts +9 -0
- package/es/WaveformIcon/index.js +51 -0
- package/es/hooks/languageMap.d.ts +1 -0
- package/es/hooks/languageMap.js +1 -0
- package/es/hooks/useHighlight.d.ts +5 -0
- package/es/hooks/useHighlight.js +78 -0
- package/es/index.d.ts +38 -1
- package/es/index.js +52 -1
- package/es/notification/index.d.ts +24 -0
- package/es/notification/index.js +237 -0
- package/es/notification/style.d.ts +2 -0
- package/es/notification/style.js +28 -0
- package/es/styles/colors/colors.d.ts +39 -0
- package/es/styles/colors/colors.js +86 -0
- package/es/styles/colors/generateColorPalette.d.ts +11 -0
- package/es/styles/colors/generateColorPalette.js +31 -0
- package/es/styles/colors/neutralColors.d.ts +9 -0
- package/es/styles/colors/neutralColors.js +32 -0
- package/es/styles/index.d.ts +4 -0
- package/es/styles/index.js +4 -0
- package/es/useSpeechSynthes/const/polyfill.d.ts +3 -0
- package/es/useSpeechSynthes/const/polyfill.js +21 -0
- package/es/useSpeechSynthes/index.d.ts +13 -0
- package/es/useSpeechSynthes/index.js +69 -0
- package/es/utils/constants.d.ts +1 -0
- package/es/utils/constants.js +1 -0
- package/es/utils/tools.d.ts +1 -0
- package/es/utils/tools.js +1 -0
- package/package.json +30 -9
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Icon } from '@lobehub/ui';
|
|
2
|
+
import { Button } from 'antd';
|
|
3
|
+
import { Maximize2, Minimize2 } from 'lucide-react';
|
|
4
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
5
|
+
import { INITIAL_OPTIONS, WORD_EDITOR_INITIALIZING, useEditor, useFullScreen } from "./helper";
|
|
6
|
+
import { useStyles } from "./style";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export * from "./controller";
|
|
10
|
+
export * from "./monaco";
|
|
11
|
+
function noop() {}
|
|
12
|
+
var SingleMonacoEditor = function SingleMonacoEditor(props) {
|
|
13
|
+
var _props$options;
|
|
14
|
+
var onChange = props.onChange,
|
|
15
|
+
enableOutline = props.enableOutline,
|
|
16
|
+
width = props.width,
|
|
17
|
+
height = props.height,
|
|
18
|
+
language = props.language,
|
|
19
|
+
supportFullScreen = props.supportFullScreen;
|
|
20
|
+
var onChangeRef = useRef(onChange);
|
|
21
|
+
var _useEditor = useEditor('single', props),
|
|
22
|
+
isEditorReady = _useEditor.isEditorReady,
|
|
23
|
+
focused = _useEditor.focused,
|
|
24
|
+
loading = _useEditor.loading,
|
|
25
|
+
containerRef = _useEditor.containerRef,
|
|
26
|
+
monacoRef = _useEditor.monacoRef,
|
|
27
|
+
editorRef = _useEditor.editorRef,
|
|
28
|
+
valueRef = _useEditor.valueRef;
|
|
29
|
+
var subscriptionRef = useRef();
|
|
30
|
+
var _useFullScreen = useFullScreen(editorRef === null || editorRef === void 0 ? void 0 : editorRef.current),
|
|
31
|
+
isFullScreen = _useFullScreen.isFullScreen,
|
|
32
|
+
fullScreen = _useFullScreen.fullScreen;
|
|
33
|
+
var _useStyles = useStyles({
|
|
34
|
+
isFullScreen: isFullScreen,
|
|
35
|
+
minimapEnabled: (_props$options = props.options) === null || _props$options === void 0 || (_props$options = _props$options.minimap) === null || _props$options === void 0 ? void 0 : _props$options.enabled
|
|
36
|
+
}),
|
|
37
|
+
cx = _useStyles.cx,
|
|
38
|
+
styles = _useStyles.styles;
|
|
39
|
+
var className = cx(styles.base, props.className, {
|
|
40
|
+
've-focused': focused,
|
|
41
|
+
've-outline': enableOutline
|
|
42
|
+
});
|
|
43
|
+
var style = useMemo(function () {
|
|
44
|
+
return {
|
|
45
|
+
width: width,
|
|
46
|
+
height: height
|
|
47
|
+
};
|
|
48
|
+
}, [width, height]);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
onChangeRef.current = onChange;
|
|
51
|
+
}, [onChange]);
|
|
52
|
+
useEffect(function () {
|
|
53
|
+
if (isEditorReady) {
|
|
54
|
+
var _subscriptionRef$curr;
|
|
55
|
+
var editorInstance = editorRef.current;
|
|
56
|
+
(_subscriptionRef$curr = subscriptionRef.current) === null || _subscriptionRef$curr === void 0 || _subscriptionRef$curr.dispose();
|
|
57
|
+
subscriptionRef.current = editorInstance === null || editorInstance === void 0 ? void 0 : editorInstance.onDidChangeModelContent(function (event) {
|
|
58
|
+
var _editorInstance$getMo;
|
|
59
|
+
var editorValue = editorInstance === null || editorInstance === void 0 || (_editorInstance$getMo = editorInstance.getModel()) === null || _editorInstance$getMo === void 0 ? void 0 : _editorInstance$getMo.getValue();
|
|
60
|
+
if (valueRef.current !== editorValue) {
|
|
61
|
+
var _onChangeRef$current;
|
|
62
|
+
(_onChangeRef$current = onChangeRef.current) === null || _onChangeRef$current === void 0 || _onChangeRef$current.call(onChangeRef, editorValue, event);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, [editorRef, isEditorReady, subscriptionRef, valueRef]);
|
|
67
|
+
useEffect(function () {
|
|
68
|
+
return function () {
|
|
69
|
+
var _subscriptionRef$curr2, _editorInstance$getMo2, _editorRef$current;
|
|
70
|
+
var editorInstance = editorRef.current;
|
|
71
|
+
(_subscriptionRef$curr2 = subscriptionRef.current) === null || _subscriptionRef$curr2 === void 0 || _subscriptionRef$curr2.dispose();
|
|
72
|
+
editorInstance === null || editorInstance === void 0 || (_editorInstance$getMo2 = editorInstance.getModel()) === null || _editorInstance$getMo2 === void 0 || _editorInstance$getMo2.dispose();
|
|
73
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
+
(_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || _editorRef$current.dispose();
|
|
75
|
+
};
|
|
76
|
+
}, [editorRef]);
|
|
77
|
+
useEffect(function () {
|
|
78
|
+
var _editorRef$current2;
|
|
79
|
+
if (!isEditorReady) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var model = (_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 ? void 0 : _editorRef$current2.getModel();
|
|
83
|
+
if (model) {
|
|
84
|
+
var _monacoRef$current;
|
|
85
|
+
(_monacoRef$current = monacoRef.current) === null || _monacoRef$current === void 0 || _monacoRef$current.editor.setModelLanguage(model, language);
|
|
86
|
+
}
|
|
87
|
+
}, [editorRef, isEditorReady, language, monacoRef]);
|
|
88
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
89
|
+
className: className,
|
|
90
|
+
style: props.style,
|
|
91
|
+
children: [loading && /*#__PURE__*/_jsx("span", {
|
|
92
|
+
className: cx(styles.loading, 'loading'),
|
|
93
|
+
children: WORD_EDITOR_INITIALIZING
|
|
94
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
95
|
+
className: "react-monaco-editor-container",
|
|
96
|
+
ref: containerRef,
|
|
97
|
+
style: style,
|
|
98
|
+
children: supportFullScreen && /*#__PURE__*/_jsx(Button, {
|
|
99
|
+
className: styles.fullScreenBtn,
|
|
100
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
|
101
|
+
icon: isFullScreen ? Minimize2 : Maximize2
|
|
102
|
+
}),
|
|
103
|
+
onClick: fullScreen,
|
|
104
|
+
size: "small",
|
|
105
|
+
type: "text"
|
|
106
|
+
})
|
|
107
|
+
})]
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
var DiffMonacoEditor = function DiffMonacoEditor(props) {
|
|
111
|
+
var enableOutline = props.enableOutline,
|
|
112
|
+
width = props.width,
|
|
113
|
+
height = props.height,
|
|
114
|
+
language = props.language,
|
|
115
|
+
onChange = props.onChange,
|
|
116
|
+
original = props.original,
|
|
117
|
+
supportFullScreen = props.supportFullScreen;
|
|
118
|
+
var onChangeRef = useRef(onChange);
|
|
119
|
+
var _useEditor2 = useEditor('diff', props),
|
|
120
|
+
isEditorReady = _useEditor2.isEditorReady,
|
|
121
|
+
focused = _useEditor2.focused,
|
|
122
|
+
loading = _useEditor2.loading,
|
|
123
|
+
containerRef = _useEditor2.containerRef,
|
|
124
|
+
monacoRef = _useEditor2.monacoRef,
|
|
125
|
+
editorRef = _useEditor2.editorRef,
|
|
126
|
+
valueRef = _useEditor2.valueRef;
|
|
127
|
+
var _useFullScreen2 = useFullScreen(),
|
|
128
|
+
isFullScreen = _useFullScreen2.isFullScreen,
|
|
129
|
+
fullScreen = _useFullScreen2.fullScreen;
|
|
130
|
+
var _useStyles2 = useStyles({
|
|
131
|
+
isFullScreen: isFullScreen,
|
|
132
|
+
diff: true
|
|
133
|
+
}),
|
|
134
|
+
cx = _useStyles2.cx,
|
|
135
|
+
styles = _useStyles2.styles;
|
|
136
|
+
var className = cx(styles.base, props.className, {
|
|
137
|
+
've-focused': focused,
|
|
138
|
+
've-outline': enableOutline
|
|
139
|
+
});
|
|
140
|
+
var style = useMemo(function () {
|
|
141
|
+
return {
|
|
142
|
+
width: width,
|
|
143
|
+
height: height
|
|
144
|
+
};
|
|
145
|
+
}, [width, height]);
|
|
146
|
+
useEffect(function () {
|
|
147
|
+
onChangeRef.current = onChange;
|
|
148
|
+
}, [onChange]);
|
|
149
|
+
useEffect(function () {
|
|
150
|
+
var _editorRef$current$ge;
|
|
151
|
+
if (!isEditorReady) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
(_editorRef$current$ge = editorRef.current.getModel()) === null || _editorRef$current$ge === void 0 || _editorRef$current$ge.original.setValue(original !== null && original !== void 0 ? original : '');
|
|
155
|
+
var _ref = editorRef.current.getModel() || {},
|
|
156
|
+
modified = _ref.modified;
|
|
157
|
+
modified === null || modified === void 0 || modified.onDidChangeContent(function (event) {
|
|
158
|
+
var editorValue = modified.getValue();
|
|
159
|
+
if (valueRef.current !== editorValue) {
|
|
160
|
+
var _onChangeRef$current2;
|
|
161
|
+
(_onChangeRef$current2 = onChangeRef.current) === null || _onChangeRef$current2 === void 0 || _onChangeRef$current2.call(onChangeRef, editorValue, event);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}, [editorRef, isEditorReady, original, valueRef]);
|
|
165
|
+
useEffect(function () {
|
|
166
|
+
return function () {
|
|
167
|
+
var _editorRef$current3, _editorRef$current4, _editorRef$current5;
|
|
168
|
+
(_editorRef$current3 = editorRef.current) === null || _editorRef$current3 === void 0 || (_editorRef$current3 = _editorRef$current3.getModel()) === null || _editorRef$current3 === void 0 || (_editorRef$current3 = _editorRef$current3.original) === null || _editorRef$current3 === void 0 || _editorRef$current3.dispose();
|
|
169
|
+
(_editorRef$current4 = editorRef.current) === null || _editorRef$current4 === void 0 || (_editorRef$current4 = _editorRef$current4.getModel()) === null || _editorRef$current4 === void 0 || (_editorRef$current4 = _editorRef$current4.modified) === null || _editorRef$current4 === void 0 || _editorRef$current4.dispose();
|
|
170
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
171
|
+
(_editorRef$current5 = editorRef.current) === null || _editorRef$current5 === void 0 || _editorRef$current5.dispose();
|
|
172
|
+
};
|
|
173
|
+
}, [editorRef]);
|
|
174
|
+
useEffect(function () {
|
|
175
|
+
var _editorRef$current6, _monacoRef$current2, _monacoRef$current3;
|
|
176
|
+
if (!isEditorReady) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
var _ref2 = ((_editorRef$current6 = editorRef.current) === null || _editorRef$current6 === void 0 ? void 0 : _editorRef$current6.getModel()) || {},
|
|
180
|
+
originalModel = _ref2.original,
|
|
181
|
+
modifiedModel = _ref2.modified;
|
|
182
|
+
(_monacoRef$current2 = monacoRef.current) === null || _monacoRef$current2 === void 0 || _monacoRef$current2.editor.setModelLanguage(originalModel, language);
|
|
183
|
+
(_monacoRef$current3 = monacoRef.current) === null || _monacoRef$current3 === void 0 || _monacoRef$current3.editor.setModelLanguage(modifiedModel, language);
|
|
184
|
+
}, [editorRef, isEditorReady, language, monacoRef]);
|
|
185
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
186
|
+
className: className,
|
|
187
|
+
style: props.style,
|
|
188
|
+
children: [loading && /*#__PURE__*/_jsx("span", {
|
|
189
|
+
className: cx(styles.loading, 'loading'),
|
|
190
|
+
children: WORD_EDITOR_INITIALIZING
|
|
191
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
192
|
+
className: "react-monaco-editor-container react-monaco-editor-diff-container",
|
|
193
|
+
ref: containerRef,
|
|
194
|
+
style: style,
|
|
195
|
+
children: supportFullScreen && /*#__PURE__*/_jsx(Button, {
|
|
196
|
+
className: styles.fullScreenBtn,
|
|
197
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
|
198
|
+
icon: isFullScreen ? Minimize2 : Maximize2
|
|
199
|
+
}),
|
|
200
|
+
onClick: fullScreen,
|
|
201
|
+
size: "small",
|
|
202
|
+
type: "text"
|
|
203
|
+
})
|
|
204
|
+
})]
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
var DiffMonacoEditorComponent = Object.assign(DiffMonacoEditor, {
|
|
208
|
+
displayName: 'DiffMonacoEditor',
|
|
209
|
+
defaultProps: {
|
|
210
|
+
width: '100%',
|
|
211
|
+
height: 150,
|
|
212
|
+
defaultValue: '',
|
|
213
|
+
language: 'javascript',
|
|
214
|
+
options: INITIAL_OPTIONS,
|
|
215
|
+
editorDidMount: noop,
|
|
216
|
+
editorWillMount: noop,
|
|
217
|
+
onChange: noop,
|
|
218
|
+
requireConfig: {}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
export var SingleMonacoEditorComponent = Object.assign(SingleMonacoEditor, {
|
|
222
|
+
displayName: 'SingleMonacoEditor',
|
|
223
|
+
defaultProps: {
|
|
224
|
+
width: '100%',
|
|
225
|
+
height: 150,
|
|
226
|
+
defaultValue: '',
|
|
227
|
+
language: 'javascript',
|
|
228
|
+
options: INITIAL_OPTIONS,
|
|
229
|
+
editorDidMount: noop,
|
|
230
|
+
editorWillMount: noop,
|
|
231
|
+
onChange: noop,
|
|
232
|
+
requireConfig: {}
|
|
233
|
+
},
|
|
234
|
+
MonacoDiffEditor: DiffMonacoEditorComponent
|
|
235
|
+
});
|
|
236
|
+
export default SingleMonacoEditorComponent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Monaco } from '@monaco-editor/loader';
|
|
2
|
+
import { EditorMeta } from './controller';
|
|
3
|
+
export declare const getSingletonMonaco: (options?: any) => Promise<typeof import("monaco-editor")>;
|
|
4
|
+
export declare const getCommonMonaco: (config: any) => Promise<Monaco>;
|
|
5
|
+
export declare function getMonaco(config?: any): Promise<typeof import("monaco-editor")>;
|
|
6
|
+
export declare function configure(config: EditorMeta): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import loader from '@monaco-editor/loader';
|
|
4
|
+
import { isEqual } from 'lodash-es';
|
|
5
|
+
import { controller } from "./controller";
|
|
6
|
+
export var getSingletonMonaco = function () {
|
|
7
|
+
var monaco;
|
|
8
|
+
var prevOptions;
|
|
9
|
+
return /*#__PURE__*/function () {
|
|
10
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
11
|
+
var hasConfig;
|
|
12
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13
|
+
while (1) switch (_context.prev = _context.next) {
|
|
14
|
+
case 0:
|
|
15
|
+
if (!(!monaco || !isEqual(prevOptions, options))) {
|
|
16
|
+
_context.next = 7;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
hasConfig = Object.keys(options || {}).length > 0;
|
|
20
|
+
loader.config(hasConfig ? options : {
|
|
21
|
+
paths: {
|
|
22
|
+
vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.33.0/min/vs'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
// eslint-disable-next-line require-atomic-updates
|
|
26
|
+
_context.next = 5;
|
|
27
|
+
return loader.init();
|
|
28
|
+
case 5:
|
|
29
|
+
monaco = _context.sent;
|
|
30
|
+
// eslint-disable-next-line require-atomic-updates
|
|
31
|
+
prevOptions = options;
|
|
32
|
+
case 7:
|
|
33
|
+
return _context.abrupt("return", monaco);
|
|
34
|
+
case 8:
|
|
35
|
+
case "end":
|
|
36
|
+
return _context.stop();
|
|
37
|
+
}
|
|
38
|
+
}, _callee);
|
|
39
|
+
}));
|
|
40
|
+
return function (_x) {
|
|
41
|
+
return _ref.apply(this, arguments);
|
|
42
|
+
};
|
|
43
|
+
}();
|
|
44
|
+
}();
|
|
45
|
+
export var getCommonMonaco = function getCommonMonaco(config) {
|
|
46
|
+
if (config) {
|
|
47
|
+
loader.config(config);
|
|
48
|
+
} else {
|
|
49
|
+
loader.config({
|
|
50
|
+
paths: {
|
|
51
|
+
vs: 'https://g.alicdn.com/code/lib/monaco-editor/0.31.1/min/vs'
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return loader.init();
|
|
56
|
+
};
|
|
57
|
+
export function getMonaco(config) {
|
|
58
|
+
var hasConfig = Object.keys(config || {}).length > 0;
|
|
59
|
+
var monacoConfig = hasConfig ? config : undefined;
|
|
60
|
+
return controller.getMeta().singleton ? getSingletonMonaco(monacoConfig) : getCommonMonaco(monacoConfig);
|
|
61
|
+
}
|
|
62
|
+
export function configure(config) {
|
|
63
|
+
controller.updateMeta(config);
|
|
64
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* styles from https://github.com/alibaba/lowcode-plugins/blob/main/packages/base-monaco-editor/src/index.scss
|
|
3
|
+
*/
|
|
4
|
+
export declare const useStyles: (props?: {
|
|
5
|
+
minimapEnabled?: boolean | undefined;
|
|
6
|
+
isFullScreen?: boolean | undefined;
|
|
7
|
+
diff?: boolean | undefined;
|
|
8
|
+
} | undefined) => import("antd-style").ReturnStyles<{
|
|
9
|
+
base: import("antd-style").SerializedStyles;
|
|
10
|
+
fullScreenBtn: import("antd-style").SerializedStyles;
|
|
11
|
+
loading: import("antd-style").SerializedStyles;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
3
|
+
import { createStyles, keyframes } from 'antd-style';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* styles from https://github.com/alibaba/lowcode-plugins/blob/main/packages/base-monaco-editor/src/index.scss
|
|
7
|
+
*/
|
|
8
|
+
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
9
|
+
var css = _ref.css,
|
|
10
|
+
token = _ref.token,
|
|
11
|
+
prefixCls = _ref.prefixCls;
|
|
12
|
+
var _ref2$minimapEnabled = _ref2.minimapEnabled,
|
|
13
|
+
minimapEnabled = _ref2$minimapEnabled === void 0 ? false : _ref2$minimapEnabled,
|
|
14
|
+
_ref2$isFullScreen = _ref2.isFullScreen,
|
|
15
|
+
isFullScreen = _ref2$isFullScreen === void 0 ? false : _ref2$isFullScreen,
|
|
16
|
+
_ref2$diff = _ref2.diff,
|
|
17
|
+
diff = _ref2$diff === void 0 ? false : _ref2$diff;
|
|
18
|
+
var dots = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { content: '.'; }\n 20% { content: '..'; }\n 40% { content: '...'; }\n 60% { content: '....'; }\n 80% { content: '.....'; }\n "])));
|
|
19
|
+
return {
|
|
20
|
+
base: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n box-sizing: content-box;\n min-height: 100px;\n\n border: 1px solid transparent;\n border-radius: 3px;\n &:hover {\n border-color: var(--color-field-border-hover, rgba(31, 56, 88, 0.1));\n }\n\n &.ve-focused {\n border-color: var(--color-field-border-active, rgba(31, 56, 88, 0.15));\n }\n\n &.ve-outline {\n border: 1px solid var(--color-field-border, rgba(31, 56, 88, 0.05)) !important;\n }\n\n & > .react-monaco-editor-container {\n width: 100%;\n height: 100%;\n min-height: 100px;\n background: transparent;\n\n ", "\n\n & > .monaco-editor {\n border-radius: ", "px;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n .monaco-scrollable-element {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n .monaco-diff-editor {\n border-radius: ", "px;\n & > .original > .monaco-editor {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n }\n .diffViewport {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n\n ..syntaxTips {\n position: absolute;\n bottom: 0;\n left: 0;\n\n box-sizing: border-box;\n width: 100%;\n max-height: 0;\n margin: 0;\n padding: 10px 30px;\n\n color: red;\n\n background: rgba(255, 234, 234, 0.8);\n\n transition: 0.2s ease max-height;\n }\n\n .syntaxTips:hover {\n overflow: auto;\n max-height: 50%;\n }\n\n .syntaxTips .infoIcon {\n position: absolute;\n top: 2px;\n right: 5px;\n transform: rotateY(180deg);\n\n width: 20px;\n height: 16px;\n }\n "])), isFullScreen && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: fixed;\n z-index: 9998;\n inset: 0;\n\n width: auto !important;\n height: auto !important;\n "]))), token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius - 1, token.borderRadius - 1),
|
|
21
|
+
fullScreenBtn: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n &.", "-btn {\n position: absolute;\n color: ", ";\n top: 20px;\n transition: none;\n ", "\n }\n "])), prefixCls, token.colorTextSecondary, isFullScreen ? css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n z-index: 9999;\n right: ", "px;\n "])), diff ? 64 : 138) : css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n right: ", "px;\n "])), minimapEnabled || diff ? 64 : 20)),
|
|
22
|
+
loading: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: absolute;\n inset: 0;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n font-size: ", "px;\n color: ", ";\n\n background-color: transparent;\n\n &::after {\n content: '';\n /* width: 20px; */\n display: inline;\n animation: ", " steps(3) 1s infinite;\n }\n "])), token.fontSizeSM, token.colorTextTertiary, dots)
|
|
23
|
+
};
|
|
24
|
+
}, {
|
|
25
|
+
hashPriority: 'low'
|
|
26
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IDiffMonacoEditorProps, IGeneralManacoEditorProps, ISingleMonacoEditorProps } from '@alilc/lowcode-plugin-base-monaco-editor/lib/helper';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
|
|
2
|
+
import type { IDiffMonacoEditorProps, IGeneralManacoEditorProps, ISingleMonacoEditorProps } from './base/helper';
|
|
3
|
+
export { type EditorMeta, Controller as MonacoController } from './base/controller';
|
|
4
4
|
export interface BaseMonacoEditorProps extends IGeneralManacoEditorProps {
|
|
5
5
|
/** Should the editor be read only. See also domReadOnly. Defaults to false. */
|
|
6
6
|
readOnly?: boolean;
|
|
@@ -22,8 +22,6 @@ export declare const BaseMonacoEditor: React.FC<BaseMonacoEditorProps & {
|
|
|
22
22
|
type?: 'single' | 'diff';
|
|
23
23
|
/** Is show fullscreen button */
|
|
24
24
|
supportFullScreen?: boolean;
|
|
25
|
-
/** className of diff editor wrapper */
|
|
26
|
-
diffEditorWrapperClassName?: boolean;
|
|
27
25
|
}>;
|
|
28
26
|
export type MonacoEditorProps = ISingleMonacoEditorProps & BaseMonacoEditorProps;
|
|
29
27
|
export declare const MonacoEditor: React.FC<MonacoEditorProps>;
|
package/es/MonacoEditor/index.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["type", "editorDidMount", "readOnly", "lineNumbers", "wordWrap", "contextmenu", "theme", "minimapEnabled", "version", "requireConfig", "options", "
|
|
4
|
+
var _excluded = ["type", "editorDidMount", "readOnly", "lineNumbers", "wordWrap", "contextmenu", "theme", "minimapEnabled", "version", "requireConfig", "options", "className", "supportFullScreen"],
|
|
5
5
|
_excluded2 = ["inlineView", "options"];
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
-
import { SingleMonacoEditorComponent } from '@alilc/lowcode-plugin-base-monaco-editor';
|
|
9
8
|
import { useThemeMode } from 'antd-style';
|
|
10
|
-
import React, { useMemo, useState } from 'react';
|
|
11
|
-
import { useCdnFn } from
|
|
12
|
-
import {
|
|
9
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
|
+
import { useCdnFn } from "../ConfigProvider";
|
|
11
|
+
import { SingleMonacoEditorComponent } from "./base";
|
|
13
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
|
|
15
|
-
export { Controller as MonacoController } from
|
|
13
|
+
// @Todo: Controller SSR error: https://github.com/alibaba/lowcode-plugins/blob/main/packages/base-monaco-editor/src/controller.ts#L33
|
|
14
|
+
export { Controller as MonacoController } from "./base/controller";
|
|
16
15
|
export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
17
16
|
var _props$type = props.type,
|
|
18
17
|
type = _props$type === void 0 ? 'single' : _props$type,
|
|
@@ -33,13 +32,13 @@ export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
|
33
32
|
_props$requireConfig = props.requireConfig,
|
|
34
33
|
requireConfigFromProps = _props$requireConfig === void 0 ? {} : _props$requireConfig,
|
|
35
34
|
options = props.options,
|
|
36
|
-
onChange = props.onChange,
|
|
37
35
|
className = props.className,
|
|
38
|
-
diffEditorWrapperClassName = props.diffEditorWrapperClassName,
|
|
39
36
|
supportFullScreen = props.supportFullScreen,
|
|
40
|
-
width = props.width,
|
|
41
|
-
height = props.height,
|
|
42
37
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
38
|
+
var editorDidMountRef = useRef(editorDidMount);
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
editorDidMountRef.current = editorDidMount;
|
|
41
|
+
}, [editorDidMount]);
|
|
43
42
|
var _useThemeMode = useThemeMode(),
|
|
44
43
|
isDarkMode = _useThemeMode.isDarkMode;
|
|
45
44
|
var theme = useMemo(function () {
|
|
@@ -52,18 +51,11 @@ export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
|
52
51
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
52
|
editorInstance = _useState2[0],
|
|
54
53
|
setEditorInstance = _useState2[1];
|
|
55
|
-
var handleEditorDidMount = function
|
|
54
|
+
var handleEditorDidMount = useCallback(function (monaco, editor) {
|
|
55
|
+
var _editorDidMountRef$cu;
|
|
56
56
|
setEditorInstance(editor);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (type === 'diff') {
|
|
60
|
-
var _ref = editor.getModel(),
|
|
61
|
-
modified = _ref.modified;
|
|
62
|
-
modified.onDidChangeContent(function (event) {
|
|
63
|
-
onChange === null || onChange === void 0 || onChange(modified.getValue(), event);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
};
|
|
57
|
+
(_editorDidMountRef$cu = editorDidMountRef.current) === null || _editorDidMountRef$cu === void 0 || _editorDidMountRef$cu.call(editorDidMountRef, monaco, editor);
|
|
58
|
+
}, []);
|
|
67
59
|
var editorOptions = useMemo(function () {
|
|
68
60
|
var newOps = Object.assign({}, options, {
|
|
69
61
|
readOnly: readOnly,
|
|
@@ -76,7 +68,7 @@ export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
|
76
68
|
});
|
|
77
69
|
editorInstance === null || editorInstance === void 0 || editorInstance.updateOptions(newOps);
|
|
78
70
|
return newOps;
|
|
79
|
-
}, [readOnly, lineNumbers, wordWrap, contextmenu, minimapEnabled,
|
|
71
|
+
}, [options, readOnly, lineNumbers, wordWrap, contextmenu, minimapEnabled, editorInstance]);
|
|
80
72
|
var genCdnUrl = useCdnFn();
|
|
81
73
|
var requireConfig = useMemo(function () {
|
|
82
74
|
return Object.assign({}, requireConfigFromProps, {
|
|
@@ -88,53 +80,25 @@ export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
|
88
80
|
})
|
|
89
81
|
}, requireConfigFromProps.paths)
|
|
90
82
|
});
|
|
91
|
-
}, [requireConfigFromProps, version]);
|
|
92
|
-
var _useState3 = useState(false),
|
|
93
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
94
|
-
isFullScreen = _useState4[0],
|
|
95
|
-
setIsFullScreen = _useState4[1];
|
|
96
|
-
var _useStyles = useStyles({
|
|
97
|
-
minimapEnabled: minimapEnabled,
|
|
98
|
-
isFullScreen: isFullScreen
|
|
99
|
-
}),
|
|
100
|
-
styles = _useStyles.styles,
|
|
101
|
-
cx = _useStyles.cx;
|
|
83
|
+
}, [genCdnUrl, requireConfigFromProps, version]);
|
|
102
84
|
if (type !== 'diff') {
|
|
103
85
|
return /*#__PURE__*/_jsx(SingleMonacoEditorComponent, _objectSpread({
|
|
104
|
-
className:
|
|
86
|
+
className: className,
|
|
105
87
|
editorDidMount: handleEditorDidMount,
|
|
106
|
-
height: height,
|
|
107
|
-
onChange: onChange,
|
|
108
88
|
options: editorOptions,
|
|
109
89
|
requireConfig: requireConfig,
|
|
110
90
|
supportFullScreen: editorInstance && supportFullScreen,
|
|
111
|
-
theme: theme
|
|
112
|
-
width: width
|
|
91
|
+
theme: theme
|
|
113
92
|
}, otherProps));
|
|
114
93
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
124
|
-
className: cx(styles.diff, diffEditorWrapperClassName),
|
|
125
|
-
children: [/*#__PURE__*/_jsx(SingleMonacoEditorComponent.MonacoDiffEditor, _objectSpread({
|
|
126
|
-
className: cx(styles.base, className),
|
|
127
|
-
editorDidMount: handleEditorDidMount,
|
|
128
|
-
height: isFullScreen ? 'auto' : height,
|
|
129
|
-
options: editorOptions,
|
|
130
|
-
requireConfig: requireConfig,
|
|
131
|
-
theme: theme,
|
|
132
|
-
width: isFullScreen ? 'auto' : width
|
|
133
|
-
}, otherProps)), editorInstance && supportFullScreen && /*#__PURE__*/_jsx("div", {
|
|
134
|
-
className: fullScreenClassName,
|
|
135
|
-
onClick: fullScreen
|
|
136
|
-
})]
|
|
137
|
-
});
|
|
94
|
+
return /*#__PURE__*/_jsx(SingleMonacoEditorComponent.MonacoDiffEditor, _objectSpread({
|
|
95
|
+
className: className,
|
|
96
|
+
editorDidMount: handleEditorDidMount,
|
|
97
|
+
options: editorOptions,
|
|
98
|
+
requireConfig: requireConfig,
|
|
99
|
+
supportFullScreen: editorInstance && supportFullScreen,
|
|
100
|
+
theme: theme
|
|
101
|
+
}, otherProps));
|
|
138
102
|
};
|
|
139
103
|
export var MonacoEditor = function MonacoEditor(props) {
|
|
140
104
|
return /*#__PURE__*/_jsx(BaseMonacoEditor, _objectSpread(_objectSpread({}, props), {}, {
|
package/es/MonacoEditor/style.js
CHANGED
|
@@ -8,7 +8,8 @@ import fullScreenIcon from "./assets/img/full-screen-icon.png";
|
|
|
8
8
|
* styles from https://github.com/alibaba/lowcode-plugins/blob/main/packages/base-monaco-editor/src/index.scss
|
|
9
9
|
*/
|
|
10
10
|
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
11
|
-
var css = _ref.css
|
|
11
|
+
var css = _ref.css,
|
|
12
|
+
token = _ref.token;
|
|
12
13
|
var _ref2$minimapEnabled = _ref2.minimapEnabled,
|
|
13
14
|
minimapEnabled = _ref2$minimapEnabled === void 0 ? false : _ref2$minimapEnabled,
|
|
14
15
|
_ref2$isFullScreen = _ref2.isFullScreen,
|
|
@@ -16,7 +17,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
16
17
|
var dots = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { content: '.'; }\n 20% { content: '..'; }\n 40% { content: '...'; }\n 60% { content: '....'; }\n 80% { content: '.....'; }\n "])));
|
|
17
18
|
var fullScreenStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .base-monaco-full-screen-icon,\n .base-monaco-full-screen-icon-cancel {\n cursor: pointer;\n\n position: absolute;\n\n width: 20px;\n height: 20px;\n\n background-size: 20px 20px;\n }\n\n .base-monaco-full-screen-icon {\n top: 40px;\n right: ", ";\n background-image: url(", ");\n }\n\n .base-monaco-full-screen-icon-cancel {\n z-index: 9999;\n top: 10px;\n right: 138px;\n background-image: url(", ");\n }\n "])), minimapEnabled ? '64px' : '20px', fullScreenIcon, fullScreenCancelIcon);
|
|
18
19
|
return {
|
|
19
|
-
base: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n\n box-sizing: content-box;\n min-height: 100px;\n\n border: 1px solid
|
|
20
|
+
base: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n\n box-sizing: content-box;\n width: 100%;\n min-height: 100px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n &:hover {\n border-color: var(--color-field-border-hover, rgba(31, 56, 88, 0.1));\n }\n &.ve-focused {\n border-color: var(--color-field-border-active, rgba(31, 56, 88, 0.15));\n }\n &.ve-outline {\n border: 1px solid var(--color-field-border, rgba(31, 56, 88, 0.05)) !important;\n }\n\n .react-monaco-editor-container {\n width: 100%;\n height: 100%;\n min-height: 100px;\n background: transparent;\n & > .monaco-editor {\n border-radius: ", "px;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n .monaco-scrollable-element {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n .monaco-diff-editor {\n border-radius: ", "px;\n & > .original > .monaco-editor {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n }\n .diffViewport {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n\n ", "\n\n .loading {\n position: absolute;\n inset: 0;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n color: var(--color-text, rgba(0, 0, 0, 0.3));\n\n background-color: transparent;\n\n &::after {\n content: '';\n display: inline;\n animation: ", " steps(3) 1s infinite;\n }\n }\n\n .syntaxTips {\n position: absolute;\n bottom: 0;\n left: 0;\n\n box-sizing: border-box;\n width: 100%;\n max-height: 0;\n margin: 0;\n padding: 10px 30px;\n\n color: red;\n\n background: rgba(255, 234, 234, 0.8);\n\n transition: 0.2s ease max-height;\n }\n\n .syntaxTips:hover {\n overflow: auto;\n max-height: 50%;\n }\n\n .syntaxTips .infoIcon {\n position: absolute;\n top: 2px;\n right: 5px;\n transform: rotateY(180deg);\n\n width: 20px;\n height: 16px;\n }\n "])), token.colorBorder, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius - 1, token.borderRadius - 1, fullScreenStyle, dots),
|
|
20
21
|
diff: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n box-sizing: content-box;\n\n .react-monaco-editor-container {\n ", "\n }\n\n ", "\n\n .base-monaco-full-screen-icon {\n right: 64px;\n }\n\n .base-monaco-full-screen-icon-cancel {\n position: fixed;\n right: 64px;\n }\n "])), isFullScreen && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: fixed;\n z-index: 9998;\n inset: 0;\n\n width: auto;\n height: auto;\n "]))), fullScreenStyle)
|
|
21
22
|
};
|
|
22
23
|
}, {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BreadcrumbProps } from '../../Breadcrumb';
|
|
3
|
+
import { PageContextValue } from '../PageContext';
|
|
4
|
+
export type PageBreadcrumbProps = BreadcrumbProps;
|
|
5
|
+
export interface BreadcrumbLinkProps extends React.HtmlHTMLAttributes<HTMLElement> {
|
|
6
|
+
to: string;
|
|
7
|
+
Link?: PageContextValue['Link'];
|
|
8
|
+
}
|
|
9
|
+
export declare const PageBreadcrumb: React.FC<PageBreadcrumbProps>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["to", "Link", "children"];
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import React, { useCallback, useContext, useEffect } from 'react';
|
|
7
|
+
import { Breadcrumb } from "../../Breadcrumb";
|
|
8
|
+
import { PageContext } from "../PageContext";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
var BreadcrumbLink = function BreadcrumbLink(props) {
|
|
11
|
+
var to = props.to,
|
|
12
|
+
Link = props.Link,
|
|
13
|
+
children = props.children,
|
|
14
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
15
|
+
if (Link) {
|
|
16
|
+
return /*#__PURE__*/_jsx(Link, _objectSpread(_objectSpread({
|
|
17
|
+
to: to
|
|
18
|
+
}, otherProps), {}, {
|
|
19
|
+
children: children
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/_jsx("a", _objectSpread(_objectSpread({
|
|
23
|
+
href: "#".concat(to)
|
|
24
|
+
}, otherProps), {}, {
|
|
25
|
+
children: children
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
export var PageBreadcrumb = function PageBreadcrumb(props) {
|
|
29
|
+
var _useContext = useContext(PageContext),
|
|
30
|
+
Link = _useContext.Link,
|
|
31
|
+
breadcrumb = _useContext.breadcrumb;
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
var _breadcrumb$setItems;
|
|
34
|
+
breadcrumb === null || breadcrumb === void 0 || (_breadcrumb$setItems = breadcrumb.setItems) === null || _breadcrumb$setItems === void 0 || _breadcrumb$setItems.call(breadcrumb, props.items);
|
|
35
|
+
}, [breadcrumb, props.items]);
|
|
36
|
+
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
var itemRender = useCallback(function (currentRoute, params, items, paths) {
|
|
39
|
+
var _items$at, _items$at2;
|
|
40
|
+
var isLast = currentRoute.href ? currentRoute.href === ((_items$at = items.at(-1)) === null || _items$at === void 0 ? void 0 : _items$at.href) : currentRoute.path === ((_items$at2 = items.at(-1)) === null || _items$at2 === void 0 ? void 0 : _items$at2.path);
|
|
41
|
+
if (isLast) {
|
|
42
|
+
return /*#__PURE__*/_jsx("span", {
|
|
43
|
+
children: currentRoute.title
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
var to = currentRoute.href ? currentRoute.href : "/".concat(paths.join('/'));
|
|
47
|
+
return /*#__PURE__*/_jsx(BreadcrumbLink, {
|
|
48
|
+
Link: Link,
|
|
49
|
+
to: to,
|
|
50
|
+
children: currentRoute.title
|
|
51
|
+
});
|
|
52
|
+
}, [Link]);
|
|
53
|
+
return /*#__PURE__*/_jsx(Breadcrumb, _objectSpread({
|
|
54
|
+
itemRender: itemRender
|
|
55
|
+
}, props));
|
|
56
|
+
};
|