@luck-design-biz/luckda 1.0.2-2 → 1.0.2-4
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/lowcode/constants/event-topics.js +2 -0
- package/es/lowcode/engine/meta/box.props.default.json +1 -1
- package/es/lowcode/engine/meta/box.props.json +1 -1
- package/es/lowcode/engine/meta/fielddatadic.props.default.json +16 -0
- package/es/lowcode/engine/meta/fielddatadic.props.json +73 -0
- package/es/lowcode/engine/meta/layout.props.default.json +1 -1
- package/es/lowcode/engine/meta/layout.props.json +1 -1
- package/es/lowcode/painter/DesignOperator.js +8 -3
- package/es/lowcode/painter/DesignToolbar.js +27 -28
- package/es/lowcode/painter/Panel.js +1 -1
- package/es/lowcode/painter/components/DragDrop/DragDropContext.js +10 -3
- package/es/lowcode/painter/components/TreeEditor.js +76 -8
- package/es/lowcode/painter/components/code-editor/BaseEditor.js +10 -6
- package/es/lowcode/painter/panel-section/JSEditor.js +55 -33
- package/es/lowcode/painter/panel-section/StylePanel/MainPanel.js +37 -26
- package/es/lowcode/painter/style/components.less +1 -1
- package/es/lowcode/view/{errorBoundary.js → ErrorBoundary.js} +24 -6
- package/es/lowcode/view/Page.js +3 -3
- package/es/lowcode/view/lc-components/Box/FunctionDesign.js +4 -2
- package/es/lowcode/view/lc-components/Box/index.less +2 -2
- package/es/lowcode/view/lc-components/Box/meta.json +1 -1
- package/es/lowcode/view/lc-components/JSX/RuntimeComp.js +32 -16
- package/es/lowcode/view/lc-components/Layout/meta.json +1 -1
- package/lib/lowcode/constants/event-topics.js +3 -1
- package/lib/lowcode/engine/meta/box.props.default.json +1 -1
- package/lib/lowcode/engine/meta/box.props.json +1 -1
- package/lib/lowcode/engine/meta/fielddatadic.props.default.json +16 -0
- package/lib/lowcode/engine/meta/fielddatadic.props.json +73 -0
- package/lib/lowcode/engine/meta/layout.props.default.json +1 -1
- package/lib/lowcode/engine/meta/layout.props.json +1 -1
- package/lib/lowcode/painter/DesignOperator.js +8 -3
- package/lib/lowcode/painter/DesignToolbar.js +27 -28
- package/lib/lowcode/painter/Panel.js +1 -1
- package/lib/lowcode/painter/components/DragDrop/DragDropContext.js +10 -3
- package/lib/lowcode/painter/components/TreeEditor.js +76 -8
- package/lib/lowcode/painter/components/code-editor/BaseEditor.js +10 -6
- package/lib/lowcode/painter/panel-section/JSEditor.js +54 -32
- package/lib/lowcode/painter/panel-section/StylePanel/MainPanel.js +37 -26
- package/lib/lowcode/painter/style/components.less +1 -1
- package/lib/lowcode/view/{errorBoundary.js → ErrorBoundary.js} +23 -5
- package/lib/lowcode/view/Page.js +4 -4
- package/lib/lowcode/view/lc-components/Box/FunctionDesign.js +4 -2
- package/lib/lowcode/view/lc-components/Box/index.less +2 -2
- package/lib/lowcode/view/lc-components/Box/meta.json +1 -1
- package/lib/lowcode/view/lc-components/JSX/RuntimeComp.js +31 -16
- package/lib/lowcode/view/lc-components/Layout/meta.json +1 -1
- package/package.json +1 -1
|
@@ -2,9 +2,14 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
import React, {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import React, { PureComponent } from 'react';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
var Wrapper = styled.div.withConfig({
|
|
8
|
+
displayName: "Wrapper",
|
|
9
|
+
componentId: "luckda-6530__sc-1ge5tx6-0"
|
|
10
|
+
})(["width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;"]);
|
|
11
|
+
var ErrorBoundary = /*#__PURE__*/function (_PureComponent) {
|
|
12
|
+
_inherits(ErrorBoundary, _PureComponent);
|
|
8
13
|
var _super = _createSuper(ErrorBoundary);
|
|
9
14
|
function ErrorBoundary(props) {
|
|
10
15
|
var _this;
|
|
@@ -18,11 +23,24 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
18
23
|
return _this;
|
|
19
24
|
}
|
|
20
25
|
_createClass(ErrorBoundary, [{
|
|
26
|
+
key: "componentDidUpdate",
|
|
27
|
+
value: function componentDidUpdate(prevProps) {
|
|
28
|
+
if (this.props.children !== prevProps.children && this.state.hasError) {
|
|
29
|
+
// 重置 hasError 为 false 以便重新渲染子组件
|
|
30
|
+
this.setState({
|
|
31
|
+
hasError: false,
|
|
32
|
+
error: '',
|
|
33
|
+
errorInfo: ''
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
21
38
|
key: "componentDidCatch",
|
|
22
39
|
value: function componentDidCatch(error, errorInfo) {
|
|
40
|
+
var _this$props$onErrorCa, _this$props;
|
|
23
41
|
// 在此处记录错误信息
|
|
24
42
|
console.error(error);
|
|
25
|
-
this.props.
|
|
43
|
+
(_this$props$onErrorCa = (_this$props = this.props).onErrorCatch) === null || _this$props$onErrorCa === void 0 || _this$props$onErrorCa.call(_this$props, error, errorInfo);
|
|
26
44
|
this.setState({
|
|
27
45
|
hasError: true,
|
|
28
46
|
error: error,
|
|
@@ -34,7 +52,7 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
34
52
|
value: function render() {
|
|
35
53
|
if (this.state.hasError) {
|
|
36
54
|
// 如果有错误,显示备用 UI
|
|
37
|
-
return /*#__PURE__*/React.createElement(
|
|
55
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement("h3", {
|
|
38
56
|
style: {
|
|
39
57
|
whiteSpace: 'pre-line',
|
|
40
58
|
color: 'var(--luck-color-danger)',
|
|
@@ -57,5 +75,5 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
57
75
|
}
|
|
58
76
|
}]);
|
|
59
77
|
return ErrorBoundary;
|
|
60
|
-
}(
|
|
78
|
+
}(PureComponent);
|
|
61
79
|
export default ErrorBoundary;
|
package/es/lowcode/view/Page.js
CHANGED
|
@@ -14,7 +14,7 @@ import Wrapper from "./lc-components/Wrapper";
|
|
|
14
14
|
import Canvas from "./Canvas";
|
|
15
15
|
import { LC_BUILDIN_UNIT_KEY } from "../constants";
|
|
16
16
|
import useCombinedRefs from "../engine/tools/useCombinedRefs";
|
|
17
|
-
import ErrorBoundary from "./
|
|
17
|
+
import ErrorBoundary from "./ErrorBoundary";
|
|
18
18
|
import styles from "./style/page.less";
|
|
19
19
|
var LCPage = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
20
20
|
var className = _ref.className,
|
|
@@ -38,11 +38,11 @@ var LCPage = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
38
38
|
var getTargetDom = useMemoizedFn(function () {
|
|
39
39
|
return _rootRef.current;
|
|
40
40
|
});
|
|
41
|
-
var
|
|
41
|
+
var handleErrorCatch = useMemoizedFn(function () {
|
|
42
42
|
ctx.$publisher(ctx.topics.COMPONENT_ACTIVE, null);
|
|
43
43
|
});
|
|
44
44
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
45
|
-
|
|
45
|
+
onErrorCatch: handleErrorCatch
|
|
46
46
|
}, /*#__PURE__*/React.createElement(Wrapper, {
|
|
47
47
|
id: LC_BUILDIN_UNIT_KEY.PAGE_ROOT,
|
|
48
48
|
getTargetDom: getTargetDom
|
|
@@ -17,10 +17,12 @@ var FunctionDesign = function FunctionDesign(_ref) {
|
|
|
17
17
|
return !children || React.Children.count(children) === 0;
|
|
18
18
|
}, [children]);
|
|
19
19
|
return /*#__PURE__*/React.createElement(Index, _extends({
|
|
20
|
-
className: classNames(styles['lc-component-box-design'], _defineProperty(
|
|
20
|
+
className: classNames(styles['lc-component-box-design'], _defineProperty({}, className, !!className)),
|
|
21
21
|
style: _objectSpread({
|
|
22
22
|
minHeight: 60
|
|
23
23
|
}, style)
|
|
24
|
-
}, props), isEmpty ?
|
|
24
|
+
}, props), isEmpty ? /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: styles.placeholder
|
|
26
|
+
}, "\u70B9\u51FB\u7EC4\u4EF6\u5E93\u7684\u7EC4\u4EF6\u6216\u62D6\u62FD\u7EC4\u4EF6\u5230\u8FD9\u91CC") : children);
|
|
25
27
|
};
|
|
26
28
|
export default FunctionDesign;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["children"];
|
|
4
|
+
var _excluded = ["children", "onErrorCatch"];
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import * as Babel from '@babel/standalone';
|
|
7
7
|
import * as LuckAntd from 'luck-design/antd';
|
|
8
8
|
import * as LuckDesign from 'luck-design';
|
|
9
9
|
import * as AHooks from 'ahooks';
|
|
10
|
+
import styled from 'styled-components';
|
|
10
11
|
import { keys } from 'lodash';
|
|
11
12
|
import { useContext } from "../../../engine/provider/ContextProvider";
|
|
12
13
|
import { executeCode } from "../../../engine/tools/helper";
|
|
14
|
+
import ErrorBoundary from "../../ErrorBoundary";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* 实时代码渲染组件
|
|
@@ -18,27 +22,39 @@ import { executeCode } from "../../../engine/tools/helper";
|
|
|
18
22
|
*/
|
|
19
23
|
var RuntimeCom = function RuntimeCom(_ref) {
|
|
20
24
|
var children = _ref.children,
|
|
25
|
+
onErrorCatch = _ref.onErrorCatch,
|
|
21
26
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
22
27
|
var ctx = useContext();
|
|
23
28
|
var Component = AHooks.useCreation(function () {
|
|
24
29
|
var code = React.Children.toArray(children).join('').trim();
|
|
25
30
|
if (!code) return Fragment;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
try {
|
|
32
|
+
// 使用Babel转换代码
|
|
33
|
+
var transformedCode = Babel.transform(code, {
|
|
34
|
+
presets: ['react']
|
|
35
|
+
}).code;
|
|
36
|
+
var functionNameMatch = transformedCode.match(/function\s+([^\s(]+)/);
|
|
37
|
+
if (functionNameMatch && functionNameMatch.length > 1) {
|
|
38
|
+
var functionName = functionNameMatch[1];
|
|
39
|
+
var argsName = keys(rest);
|
|
40
|
+
var _args = argsName.map(function (n) {
|
|
41
|
+
return rest[n];
|
|
42
|
+
});
|
|
43
|
+
return executeCode.apply(void 0, [ctx, "function() {".concat(transformedCode, "; return ").concat(functionName, ";}"), ['React', 'Antd', 'Luckd', 'styled', 'libs'].concat(_toConsumableArray(argsName)), React, LuckAntd, LuckDesign, styled, _objectSpread({}, AHooks)].concat(_toConsumableArray(_args)));
|
|
44
|
+
}
|
|
45
|
+
return Fragment;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return function () {
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
style: {
|
|
50
|
+
color: 'red'
|
|
51
|
+
}
|
|
52
|
+
}, e.message);
|
|
53
|
+
};
|
|
39
54
|
}
|
|
40
|
-
return Fragment;
|
|
41
55
|
}, [children]);
|
|
42
|
-
return /*#__PURE__*/React.createElement(
|
|
56
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
57
|
+
onErrorCatch: onErrorCatch
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Component, null));
|
|
43
59
|
};
|
|
44
60
|
export default RuntimeCom;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.PAGE_LOAD_MOUNT = exports.LANG_SETTING_SELECT = exports.COMPONENT_UNMOUNT = exports.COMPONENT_SETTING_CLICK = exports.COMPONENT_REPOSITIONING = exports.COMPONENT_MOUNT = exports.COMPONENT_MODIFY = exports.COMPONENT_MODAL_TOGGLE = exports.COMPONENT_HOVER = exports.COMPONENT_DRAG_OVER = exports.COMPONENT_DRAG_END = exports.COMPONENT_DELETE = exports.COMPONENT_APPEND = exports.COMPONENT_ACTIVE = void 0;
|
|
6
|
+
exports.PAGE_LOAD_MOUNT = exports.LANG_SETTING_SELECT = exports.DESIGN_OPERATE_SAVE = exports.COMPONENT_UNMOUNT = exports.COMPONENT_SETTING_CLICK = exports.COMPONENT_REPOSITIONING = exports.COMPONENT_MOUNT = exports.COMPONENT_MODIFY = exports.COMPONENT_MODAL_TOGGLE = exports.COMPONENT_HOVER = exports.COMPONENT_DRAG_OVER = exports.COMPONENT_DRAG_END = exports.COMPONENT_DELETE = exports.COMPONENT_APPEND = exports.COMPONENT_ACTIVE = void 0;
|
|
7
7
|
/******************************** 通用Topic开始 ********************************/
|
|
8
8
|
|
|
9
9
|
var PAGE_LOAD_MOUNT = exports.PAGE_LOAD_MOUNT = 'page-load-mount';
|
|
@@ -36,6 +36,8 @@ var COMPONENT_MODAL_TOGGLE = exports.COMPONENT_MODAL_TOGGLE = 'component-modal-t
|
|
|
36
36
|
var COMPONENT_DRAG_OVER = exports.COMPONENT_DRAG_OVER = 'component-drag-over';
|
|
37
37
|
// 组件拖放完成时的事件
|
|
38
38
|
var COMPONENT_DRAG_END = exports.COMPONENT_DRAG_END = 'component-drag-end';
|
|
39
|
+
// 保存事件
|
|
40
|
+
var DESIGN_OPERATE_SAVE = exports.DESIGN_OPERATE_SAVE = 'design-operate-save';
|
|
39
41
|
|
|
40
42
|
/******************************* Design Topic结束 *******************************/
|
|
41
43
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"component": "FieldDatadic",
|
|
3
|
+
"name": "数据字典",
|
|
4
|
+
"group": "field",
|
|
5
|
+
"desc": "数据字典类型表单项",
|
|
6
|
+
"icon": "icon-fieldstring",
|
|
7
|
+
"groupName": "表单项",
|
|
8
|
+
"order": 1,
|
|
9
|
+
"display": "select",
|
|
10
|
+
"multiple": false,
|
|
11
|
+
"isTree": false,
|
|
12
|
+
"allowClear": false,
|
|
13
|
+
"advance": {
|
|
14
|
+
"events": {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"component": "FieldDatadic",
|
|
3
|
+
"name": "数据字典",
|
|
4
|
+
"group": "field",
|
|
5
|
+
"desc": "数据字典类型表单项",
|
|
6
|
+
"icon": "icon-fieldstring",
|
|
7
|
+
"groupName": "表单项",
|
|
8
|
+
"order": 1,
|
|
9
|
+
"props": [
|
|
10
|
+
{
|
|
11
|
+
"key": "alias",
|
|
12
|
+
"name": "字典key",
|
|
13
|
+
"type": "string"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"key": "valueField",
|
|
17
|
+
"name": "实际值字段",
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"key": "labelField",
|
|
22
|
+
"name": "翻译值字段",
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"key": "display",
|
|
27
|
+
"name": "展现形式",
|
|
28
|
+
"type": "segmented",
|
|
29
|
+
"options": [
|
|
30
|
+
{
|
|
31
|
+
"label": "Select",
|
|
32
|
+
"value": "select"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"label": "Radio",
|
|
36
|
+
"value": "radio"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"default": "select"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"key": "multiple",
|
|
43
|
+
"name": "多选",
|
|
44
|
+
"desc": "仅在展现形式为Select时有效",
|
|
45
|
+
"type": "switch",
|
|
46
|
+
"default": false
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"key": "isTree",
|
|
50
|
+
"name": "树形结构",
|
|
51
|
+
"desc": "用于规定树形结构的数据字典,仅在展现形式为Select时有效",
|
|
52
|
+
"type": "switch",
|
|
53
|
+
"default": false
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"key": "allowClear",
|
|
57
|
+
"name": "允许清除",
|
|
58
|
+
"desc": "仅在展现形式为Select时有效",
|
|
59
|
+
"type": "switch",
|
|
60
|
+
"default": false
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"advance": {
|
|
64
|
+
"events": [
|
|
65
|
+
{
|
|
66
|
+
"key": "onChange",
|
|
67
|
+
"name": "数据变化事件",
|
|
68
|
+
"desc": "在数据变化事件时,执行方法",
|
|
69
|
+
"func": "function onChange(data) {\n\t\n}"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"groupName": "布局",
|
|
7
7
|
"desc": "布局容器是一种提供列比例、列间距、行间距和样式等配置选项的元素,用于创建灵活的页面布局。它使用户能够轻松组织和排列组件,并实现各种复杂的布局需求。",
|
|
8
8
|
"order": 1,
|
|
9
|
-
"css": "background-color: transparent;",
|
|
9
|
+
"css": "height:auto; background-color: transparent;",
|
|
10
10
|
"columnRatio": "12:3:9",
|
|
11
11
|
"columnSpacing": 16,
|
|
12
12
|
"lineSpacing": 16,
|
|
@@ -121,10 +121,10 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
121
121
|
};
|
|
122
122
|
}, [operatorId.selector]);
|
|
123
123
|
var activeDomPosition = (0, _ahooks.useCreation)(function () {
|
|
124
|
-
var _getElement;
|
|
124
|
+
var _getElement, _canvas$current;
|
|
125
125
|
if (!operatorId.selector && !operatorId.selectorTarget) return null;
|
|
126
126
|
var targetTop = (_getElement = getElement((0, _lodash.isNil)(operatorId.selectorTarget) ? operatorId.selector : operatorId.selectorTarget.element)) === null || _getElement === void 0 ? void 0 : _getElement.getBoundingClientRect().top;
|
|
127
|
-
var delat = targetTop - canvas.current.getBoundingClientRect().top;
|
|
127
|
+
var delat = targetTop - (((_canvas$current = canvas.current) === null || _canvas$current === void 0 ? void 0 : _canvas$current.getBoundingClientRect().top) || 0);
|
|
128
128
|
return {
|
|
129
129
|
top: delat > 24 ? -24 : 0
|
|
130
130
|
};
|
|
@@ -142,6 +142,10 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
142
142
|
}, {
|
|
143
143
|
target: canvas
|
|
144
144
|
});
|
|
145
|
+
(0, _ahooks.useKeyPress)('ctrl.s', function (e) {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
|
|
148
|
+
});
|
|
145
149
|
(0, _ahooks.useEventListener)('mousemove', function (event) {
|
|
146
150
|
var elem = event.target;
|
|
147
151
|
var targetFormItem = elem.closest("[".concat(_constants.LC_COMPONENT_UNIT_KEY, "=\"").concat(_constants.LC_FORMITEM_UNIT, "\"]"));
|
|
@@ -275,7 +279,8 @@ var DesignOperator = function DesignOperator(_ref) {
|
|
|
275
279
|
_modal.api.doOpen();
|
|
276
280
|
currentModal.current = id;
|
|
277
281
|
} else if (!toggle) {
|
|
278
|
-
|
|
282
|
+
var _canvas$current2;
|
|
283
|
+
(_canvas$current2 = canvas.current) === null || _canvas$current2 === void 0 || _canvas$current2.style.removeProperty('overflow');
|
|
279
284
|
var _id = id || currentModal.current;
|
|
280
285
|
if (_id) {
|
|
281
286
|
var _modal2 = context.componentMap.get(_id);
|
|
@@ -94,20 +94,6 @@ var DesignToolbar = function DesignToolbar(_ref) {
|
|
|
94
94
|
}),
|
|
95
95
|
updatePageDataLoading = _useRequest2.loading,
|
|
96
96
|
runAsync = _useRequest2.runAsync;
|
|
97
|
-
(0, _react.useEffect)(function () {
|
|
98
|
-
var topicId = context.$subscriber(context.topics.LANG_SETTING_SELECT).on(function (_ref2) {
|
|
99
|
-
var _langList = _ref2.langList;
|
|
100
|
-
return setLangList(_langList);
|
|
101
|
-
}).watch();
|
|
102
|
-
return function () {
|
|
103
|
-
return context.$unsubscriber(context.topics.LANG_SETTING_SELECT, topicId);
|
|
104
|
-
};
|
|
105
|
-
}, []);
|
|
106
|
-
(0, _react.useEffect)(function () {
|
|
107
|
-
if (!showPreview) {
|
|
108
|
-
setUserId(void 0);
|
|
109
|
-
}
|
|
110
|
-
}, [showPreview]);
|
|
111
97
|
var handleSave = (0, _ahooks.useMemoizedFn)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
|
|
112
98
|
var _yield$runAsync, code;
|
|
113
99
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
@@ -152,6 +138,23 @@ var DesignToolbar = function DesignToolbar(_ref) {
|
|
|
152
138
|
}
|
|
153
139
|
}, _callee);
|
|
154
140
|
})), []);
|
|
141
|
+
(0, _react.useEffect)(function () {
|
|
142
|
+
var lssid = context.$subscriber(context.topics.LANG_SETTING_SELECT).on(function (_ref3) {
|
|
143
|
+
var _langList = _ref3.langList;
|
|
144
|
+
setLangList(_langList);
|
|
145
|
+
console.log(11111, _langList);
|
|
146
|
+
}).watch();
|
|
147
|
+
var dasid = context.$subscriber(context.topics.DESIGN_OPERATE_SAVE).on(handleSave).watch();
|
|
148
|
+
return function () {
|
|
149
|
+
context.$unsubscriber(context.topics.LANG_SETTING_SELECT, lssid);
|
|
150
|
+
context.$unsubscriber(context.topics.DESIGN_OPERATE_SAVE, dasid);
|
|
151
|
+
};
|
|
152
|
+
}, []);
|
|
153
|
+
(0, _react.useEffect)(function () {
|
|
154
|
+
if (!showPreview) {
|
|
155
|
+
setUserId(void 0);
|
|
156
|
+
}
|
|
157
|
+
}, [showPreview]);
|
|
155
158
|
var handleClearCache = (0, _ahooks.useMemoizedFn)(function () {
|
|
156
159
|
_antd.Modal.confirm({
|
|
157
160
|
title: (0, _utils.formatMessage)({
|
|
@@ -333,20 +336,14 @@ var DesignToolbar = function DesignToolbar(_ref) {
|
|
|
333
336
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
|
334
337
|
while (1) switch (_context3.prev = _context3.next) {
|
|
335
338
|
case 0:
|
|
336
|
-
if (updatePageDataLoading) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
break;
|
|
339
|
+
if (!updatePageDataLoading) {
|
|
340
|
+
if ((0, _ContextProvider.getNeedPrompt)()) {
|
|
341
|
+
context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
|
|
342
|
+
}
|
|
343
|
+
context.$publisher(context.topics.COMPONENT_ACTIVE, null);
|
|
344
|
+
setShowPreview(true);
|
|
343
345
|
}
|
|
344
|
-
|
|
345
|
-
return handleSave();
|
|
346
|
-
case 4:
|
|
347
|
-
context.$publisher(context.topics.COMPONENT_ACTIVE, null);
|
|
348
|
-
setShowPreview(true);
|
|
349
|
-
case 6:
|
|
346
|
+
case 1:
|
|
350
347
|
case "end":
|
|
351
348
|
return _context3.stop();
|
|
352
349
|
}
|
|
@@ -385,7 +382,9 @@ var DesignToolbar = function DesignToolbar(_ref) {
|
|
|
385
382
|
fontSize: 14,
|
|
386
383
|
margin: '0 11px 0 5px'
|
|
387
384
|
},
|
|
388
|
-
onClick:
|
|
385
|
+
onClick: function onClick() {
|
|
386
|
+
return context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
|
|
387
|
+
}
|
|
389
388
|
})), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
|
|
390
389
|
visible: show,
|
|
391
390
|
width: 1024,
|
|
@@ -117,7 +117,7 @@ var Panel = function Panel() {
|
|
|
117
117
|
oldValue: oldValue,
|
|
118
118
|
newValue: newValue
|
|
119
119
|
});
|
|
120
|
-
if (repositioning) context.$publisher(context.topics.COMPONENT_REPOSITIONING, {
|
|
120
|
+
if (repositioning || field === 'css') context.$publisher(context.topics.COMPONENT_REPOSITIONING, {
|
|
121
121
|
id: _id
|
|
122
122
|
});
|
|
123
123
|
});
|
|
@@ -54,9 +54,16 @@ function _default(_ref) {
|
|
|
54
54
|
break;
|
|
55
55
|
case 'add':
|
|
56
56
|
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
ctx.$subscriber(ctx.topics.COMPONENT_ACTIVE).once(function () {
|
|
58
|
+
var compName = fromComp.component.toLowerCase();
|
|
59
|
+
var json = require("../../../engine/meta/".concat(compName, ".props.default.json"));
|
|
60
|
+
ctx.$publisher(ctx.topics.COMPONENT_SETTING_CLICK, {
|
|
61
|
+
data: json
|
|
62
|
+
});
|
|
63
|
+
}).watch();
|
|
64
|
+
ctx.$publisher(ctx.topics.COMPONENT_ACTIVE, {
|
|
65
|
+
target: id
|
|
66
|
+
});
|
|
60
67
|
}
|
|
61
68
|
break;
|
|
62
69
|
}
|
|
@@ -1,20 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = _default;
|
|
8
|
-
var
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
var _TreeDragDropWrapper = _interopRequireDefault(require("./DragDrop/TreeDragDropWrapper"));
|
|
12
|
+
var _antd = require("luck-design/antd");
|
|
13
|
+
var _ContextProvider = require("../../engine/provider/ContextProvider");
|
|
14
|
+
/**
|
|
15
|
+
* 树节点组件
|
|
16
|
+
* @param {Object} props - 组件属性
|
|
17
|
+
* @param {Object} props.item - 代表树节点的对象
|
|
18
|
+
* @returns {React.Component} 返回包裹在拖拽功能中的节点编辑组件
|
|
19
|
+
*/
|
|
10
20
|
function _default(_ref) {
|
|
11
21
|
var item = _ref.item;
|
|
12
|
-
var EditorNode = function EditorNode() {
|
|
13
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
14
|
-
className: "item"
|
|
15
|
-
}, item.name);
|
|
16
|
-
};
|
|
17
22
|
return /*#__PURE__*/_react.default.createElement(_TreeDragDropWrapper.default, {
|
|
18
23
|
item: item
|
|
19
|
-
}, /*#__PURE__*/_react.default.createElement(EditorNode,
|
|
20
|
-
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement(EditorNode, {
|
|
25
|
+
item: item
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 编辑节点组件,提供查看和编辑树节点名称的功能
|
|
31
|
+
* @param {Object} props - 组件属性
|
|
32
|
+
* @param {Object} props.item - 代表树节点的对象
|
|
33
|
+
* @returns {React.Component} 根据编辑状态渲染输入框或仅文本
|
|
34
|
+
*/
|
|
35
|
+
var EditorNode = function EditorNode(_ref2) {
|
|
36
|
+
var item = _ref2.item;
|
|
37
|
+
// console.log('item', item)
|
|
38
|
+
var _useState = (0, _react.useState)(false),
|
|
39
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
40
|
+
edited = _useState2[0],
|
|
41
|
+
setEdited = _useState2[1];
|
|
42
|
+
var _useState3 = (0, _react.useState)(item.name),
|
|
43
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
44
|
+
editedValue = _useState4[0],
|
|
45
|
+
setEditedValue = _useState4[1];
|
|
46
|
+
var inputRef = (0, _react.useRef)(null); // 创建一个 ref 来引用输入框
|
|
47
|
+
|
|
48
|
+
var handleDoubleClick = (0, _react.useCallback)(function () {
|
|
49
|
+
if (!item.buildIn) setEdited(true);
|
|
50
|
+
}, []);
|
|
51
|
+
var handleBlur = (0, _react.useCallback)(function () {
|
|
52
|
+
setEdited(false);
|
|
53
|
+
}, []);
|
|
54
|
+
var handPressEnter = (0, _react.useCallback)(function (e) {
|
|
55
|
+
(0, _ContextProvider.modifyNode)(item.id, {
|
|
56
|
+
name: e.target.value
|
|
57
|
+
});
|
|
58
|
+
setEdited(false);
|
|
59
|
+
});
|
|
60
|
+
var handleInputChange = (0, _react.useCallback)(function (e) {
|
|
61
|
+
setEditedValue(e.target.value);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// 使用 useEffect 钩子来处理聚焦逻辑
|
|
65
|
+
(0, _react.useEffect)(function () {
|
|
66
|
+
if (edited) {
|
|
67
|
+
// 如果 edited 为 true,聚焦到输入框
|
|
68
|
+
inputRef.current && inputRef.current.focus();
|
|
69
|
+
}
|
|
70
|
+
}, [edited]); // 依赖 edited 状态变化
|
|
71
|
+
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
73
|
+
className: "item",
|
|
74
|
+
onDoubleClick: handleDoubleClick
|
|
75
|
+
}, edited ? /*#__PURE__*/_react.default.createElement("div", {
|
|
76
|
+
className: "treenode-editor"
|
|
77
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Input, {
|
|
78
|
+
ref: inputRef // 将 ref 应用到 Input 组件
|
|
79
|
+
,
|
|
80
|
+
onChange: handleInputChange,
|
|
81
|
+
value: editedValue,
|
|
82
|
+
size: "small",
|
|
83
|
+
onBlur: handleBlur,
|
|
84
|
+
onPressEnter: handPressEnter
|
|
85
|
+
})) : /*#__PURE__*/_react.default.createElement("div", {
|
|
86
|
+
className: "treenode-info"
|
|
87
|
+
}, item.name));
|
|
88
|
+
};
|
|
@@ -11,7 +11,7 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var monaco = _interopRequireWildcard(require("monaco-editor"));
|
|
14
|
-
var _excluded = ["onChange", "
|
|
14
|
+
var _excluded = ["onChange", "isFullscreen", "style", "onLoad"],
|
|
15
15
|
_excluded2 = ["children", "language", "options"];
|
|
16
16
|
/**
|
|
17
17
|
* BaseEditor 组件是一个封装了 monaco 编辑器的 React 组件,支持前向 ref 引用。
|
|
@@ -48,9 +48,9 @@ var _excluded = ["onChange", "onLayoutChange", "isFullscreen", "style"],
|
|
|
48
48
|
*/
|
|
49
49
|
var BaseEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
50
50
|
var onChange = _ref.onChange,
|
|
51
|
-
onLayoutChange = _ref.onLayoutChange,
|
|
52
51
|
isFullscreen = _ref.isFullscreen,
|
|
53
52
|
style = _ref.style,
|
|
53
|
+
onLoad = _ref.onLoad,
|
|
54
54
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
55
55
|
var children = props.children,
|
|
56
56
|
_props$language = props.language,
|
|
@@ -60,6 +60,9 @@ var BaseEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
60
60
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded2);
|
|
61
61
|
var editorRef = (0, _react.useRef)(null);
|
|
62
62
|
var editorInstance = (0, _react.useRef)(null);
|
|
63
|
+
(0, _react.useEffect)(function () {
|
|
64
|
+
if (onLoad) onLoad();
|
|
65
|
+
}, []);
|
|
63
66
|
|
|
64
67
|
// 初始化编辑器实例
|
|
65
68
|
(0, _react.useEffect)(function () {
|
|
@@ -87,10 +90,11 @@ var BaseEditor = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
87
90
|
editorInstance.current.onDidChangeModelContent(function (event) {
|
|
88
91
|
if (onChange) onChange(editorInstance.current.getValue(), event);
|
|
89
92
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
|
|
94
|
+
// 监听布局变化,重新赋值,解决编辑器全屏切换时,编辑器空白的问题
|
|
95
|
+
// editorInstance.current.onDidLayoutChange((event) => {
|
|
96
|
+
// if (onChange) onChange(editorInstance.current.getValue(), event);
|
|
97
|
+
// });
|
|
94
98
|
}
|
|
95
99
|
return function () {
|
|
96
100
|
var _editorInstance$curre;
|