@yuntijs/ui 1.0.0-beta.5 → 1.0.0-beta.7
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/MonacoEditor/assets/img/full-screen-cancel-icon.png +0 -0
- package/es/MonacoEditor/assets/img/full-screen-icon.png +0 -0
- package/es/MonacoEditor/index.d.ts +4 -0
- package/es/MonacoEditor/index.js +59 -14
- package/es/MonacoEditor/style.d.ts +10 -0
- package/es/MonacoEditor/style.js +24 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +4 -1
- package/es/typings.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
|
Binary file
|
|
Binary file
|
|
@@ -20,6 +20,10 @@ export interface BaseMonacoEditorProps extends IGeneralManacoEditorProps {
|
|
|
20
20
|
export declare const BaseMonacoEditor: React.FC<BaseMonacoEditorProps & {
|
|
21
21
|
/** Only for BaseMonacoEditor. */
|
|
22
22
|
type?: 'single' | 'diff';
|
|
23
|
+
/** Is show fullscreen button */
|
|
24
|
+
supportFullScreen?: boolean;
|
|
25
|
+
/** className of diff editor wrapper */
|
|
26
|
+
diffEditorWrapperClassName?: boolean;
|
|
23
27
|
}>;
|
|
24
28
|
export type MonacoEditorProps = ISingleMonacoEditorProps & BaseMonacoEditorProps;
|
|
25
29
|
export declare const MonacoEditor: React.FC<MonacoEditorProps>;
|
package/es/MonacoEditor/index.js
CHANGED
|
@@ -1,16 +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", "onChange"],
|
|
4
|
+
var _excluded = ["type", "editorDidMount", "readOnly", "lineNumbers", "wordWrap", "contextmenu", "theme", "minimapEnabled", "version", "requireConfig", "options", "onChange", "className", "diffEditorWrapperClassName", "supportFullScreen", "width", "height"],
|
|
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
8
|
import { SingleMonacoEditorComponent } from '@alilc/lowcode-plugin-base-monaco-editor';
|
|
9
|
-
import {
|
|
9
|
+
import { useThemeMode } from 'antd-style';
|
|
10
10
|
import React, { useMemo, useState } from 'react';
|
|
11
11
|
import { useCdnFn } from '..';
|
|
12
|
+
import { useStyles } from "./style";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
export { Controller as MonacoController } from '@alilc/lowcode-plugin-base-monaco-editor/es/controller';
|
|
15
16
|
export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
16
17
|
var _props$type = props.type,
|
|
@@ -33,14 +34,20 @@ export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
|
33
34
|
requireConfigFromProps = _props$requireConfig === void 0 ? {} : _props$requireConfig,
|
|
34
35
|
options = props.options,
|
|
35
36
|
onChange = props.onChange,
|
|
37
|
+
className = props.className,
|
|
38
|
+
diffEditorWrapperClassName = props.diffEditorWrapperClassName,
|
|
39
|
+
supportFullScreen = props.supportFullScreen,
|
|
40
|
+
width = props.width,
|
|
41
|
+
height = props.height,
|
|
36
42
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
37
|
-
var
|
|
43
|
+
var _useThemeMode = useThemeMode(),
|
|
44
|
+
isDarkMode = _useThemeMode.isDarkMode;
|
|
38
45
|
var theme = useMemo(function () {
|
|
39
46
|
if (themeFromProps) {
|
|
40
47
|
return themeFromProps;
|
|
41
48
|
}
|
|
42
|
-
return
|
|
43
|
-
}, [
|
|
49
|
+
return isDarkMode ? 'vs-dark' : 'vs';
|
|
50
|
+
}, [isDarkMode, themeFromProps]);
|
|
44
51
|
var _useState = useState(),
|
|
45
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
46
53
|
editorInstance = _useState2[0],
|
|
@@ -82,14 +89,52 @@ export var BaseMonacoEditor = function BaseMonacoEditor(props) {
|
|
|
82
89
|
}, requireConfigFromProps.paths)
|
|
83
90
|
});
|
|
84
91
|
}, [requireConfigFromProps, version]);
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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;
|
|
102
|
+
if (type !== 'diff') {
|
|
103
|
+
return /*#__PURE__*/_jsx(SingleMonacoEditorComponent, _objectSpread({
|
|
104
|
+
className: cx(styles.base, className),
|
|
105
|
+
editorDidMount: handleEditorDidMount,
|
|
106
|
+
height: height,
|
|
107
|
+
onChange: onChange,
|
|
108
|
+
options: editorOptions,
|
|
109
|
+
requireConfig: requireConfig,
|
|
110
|
+
supportFullScreen: editorInstance && supportFullScreen,
|
|
111
|
+
theme: theme,
|
|
112
|
+
width: width
|
|
113
|
+
}, otherProps));
|
|
114
|
+
}
|
|
115
|
+
var fullScreen = function fullScreen() {
|
|
116
|
+
setIsFullScreen(!isFullScreen);
|
|
117
|
+
editorInstance === null || editorInstance === void 0 || editorInstance.layout();
|
|
118
|
+
};
|
|
119
|
+
var fullScreenClassName = cx({
|
|
120
|
+
'base-monaco-full-screen-icon': !isFullScreen,
|
|
121
|
+
'base-monaco-full-screen-icon-cancel': isFullScreen
|
|
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
|
+
});
|
|
93
138
|
};
|
|
94
139
|
export var MonacoEditor = function MonacoEditor(props) {
|
|
95
140
|
return /*#__PURE__*/_jsx(BaseMonacoEditor, _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
} | undefined) => import("antd-style").ReturnStyles<{
|
|
8
|
+
base: import("antd-style").SerializedStyles;
|
|
9
|
+
diff: import("antd-style").SerializedStyles;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
|
+
import { createStyles, keyframes } from 'antd-style';
|
|
4
|
+
import fullScreenCancelIcon from "./assets/img/full-screen-cancel-icon.png";
|
|
5
|
+
import fullScreenIcon from "./assets/img/full-screen-icon.png";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* styles from https://github.com/alibaba/lowcode-plugins/blob/main/packages/base-monaco-editor/src/index.scss
|
|
9
|
+
*/
|
|
10
|
+
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
11
|
+
var css = _ref.css;
|
|
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
|
+
var dots = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { content: '.'; }\n 20% { content: '..'; }\n 40% { content: '...'; }\n 60% { content: '....'; }\n 80% { content: '.....'; }\n "])));
|
|
17
|
+
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 z-index: 9999;\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 top: 10px;\n right: 138px;\n background-image: url(", ");\n }\n "])), minimapEnabled ? '64px' : '20px', fullScreenIcon, fullScreenCancelIcon);
|
|
18
|
+
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 transparent;\n border-radius: 3px;\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 }\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 "])), fullScreenStyle, dots),
|
|
20
|
+
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
|
+
}, {
|
|
23
|
+
hashPriority: 'low'
|
|
24
|
+
});
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/typings.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.png';
|