@luck-design-biz/luckda 1.0.6-13tl → 1.0.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.
Files changed (169) hide show
  1. package/es/components/Builder/index.js +37 -27
  2. package/es/components/ComplexItem/index.js +5 -3
  3. package/es/components/ComplexItem/service.js +6 -3
  4. package/es/components/LdAutoForm/index.js +25 -12
  5. package/es/components/LdCard/index.js +10 -8
  6. package/es/components/LdCom/index.js +3 -2
  7. package/es/components/LdFormList/index.js +5 -4
  8. package/es/components/LdGrid/index.js +29 -20
  9. package/es/components/LdGridForm/index.js +16 -7
  10. package/es/components/LdInfoPanel/index.js +16 -10
  11. package/es/helper/FromItems.js +64 -5
  12. package/es/helper/form.js +8 -2
  13. package/es/helper/ldBuilder.js +9 -5
  14. package/es/helper/ldComBuild.js +16 -11
  15. package/es/locales/zh-CN.js +40 -4
  16. package/es/lowcode/constants/api-url.js +202 -175
  17. package/es/lowcode/constants/event-topics.js +2 -0
  18. package/es/lowcode/constants/index.js +5 -4
  19. package/es/lowcode/engine/meta/components-list.json +6 -0
  20. package/es/lowcode/engine/meta/fielddate.props.default.json +1 -0
  21. package/es/lowcode/engine/meta/fielddate.props.json +48 -0
  22. package/es/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
  23. package/es/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
  24. package/es/lowcode/engine/meta/pagecomponent.props.json +41 -0
  25. package/es/lowcode/engine/meta/proxy.props.default.json +15 -0
  26. package/es/lowcode/engine/meta/proxy.props.json +66 -0
  27. package/es/lowcode/engine/provider/ContextProvider/index.js +45 -9
  28. package/es/lowcode/engine/provider/ContextProvider/usePageDataStore.js +36 -30
  29. package/es/lowcode/engine/provider/ContextProvider/usePageVar.js +11 -5
  30. package/es/lowcode/engine/provider/ContextProvider/useTodo.js +2 -4
  31. package/es/lowcode/engine/provider/EventBusProvider.js +14 -4
  32. package/es/lowcode/engine/provider/PageProxyProvider.js +95 -0
  33. package/es/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
  34. package/es/lowcode/engine/tools/helper.js +44 -5
  35. package/es/lowcode/engine/tools/initDS.js +4 -4
  36. package/es/lowcode/painter/Design.js +1 -0
  37. package/es/lowcode/painter/DesignOperator.js +129 -27
  38. package/es/lowcode/painter/DesignToolbar.js +88 -173
  39. package/es/lowcode/painter/components/AdvancePanel.js +28 -10
  40. package/es/lowcode/painter/components/TipIcon.js +12 -4
  41. package/es/lowcode/painter/components/field-setting/SettingUI.js +56 -4
  42. package/es/lowcode/painter/components/field-setting/index.js +24 -1
  43. package/es/lowcode/painter/components/shortcut-modal/KeyIcon.js +11 -0
  44. package/es/lowcode/painter/components/shortcut-modal/index.js +208 -0
  45. package/es/lowcode/painter/panel-section/BlockEditor/index.js +10 -19
  46. package/es/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
  47. package/es/lowcode/painter/panel-section/ConditionCheck.js +0 -1
  48. package/es/lowcode/painter/panel-section/DataSetSelector.js +6 -3
  49. package/es/lowcode/painter/panel-section/FieldsSetting.js +1 -1
  50. package/es/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
  51. package/es/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
  52. package/es/lowcode/painter/panel-section/JSEditor/index.js +15 -5
  53. package/es/lowcode/painter/panel-section/JSEditor/index.less +4 -0
  54. package/es/lowcode/painter/panel-section/ProxyLinker.js +137 -0
  55. package/es/lowcode/painter/panel-section/ProxyParams.js +28 -0
  56. package/es/lowcode/painter/panel-section/ProxyParamsSetter.js +240 -0
  57. package/es/lowcode/painter/style/panel-item.less +1 -0
  58. package/es/lowcode/preview/DebugTool.js +78 -0
  59. package/es/lowcode/preview/DebugToolDetail.js +103 -0
  60. package/es/lowcode/preview/index.js +10 -17
  61. package/es/lowcode/preview/useDebugSettings.js +62 -0
  62. package/es/lowcode/view/Canvas.js +5 -1
  63. package/es/lowcode/view/Page.js +8 -3
  64. package/es/lowcode/view/lc-components/CardList/index.js +3 -0
  65. package/es/lowcode/view/lc-components/Dialog/index.js +9 -7
  66. package/es/lowcode/view/lc-components/Drawer/index.js +2 -0
  67. package/es/lowcode/view/lc-components/FieldDate/meta.json +48 -0
  68. package/es/lowcode/view/lc-components/Form/index.js +3 -0
  69. package/es/lowcode/view/lc-components/Proxy/FunctionDesign.js +17 -0
  70. package/es/lowcode/view/lc-components/Proxy/FunctionLive.js +23 -0
  71. package/es/lowcode/view/lc-components/Proxy/FunctionPreview.js +23 -0
  72. package/es/lowcode/view/lc-components/Proxy/index.js +42 -0
  73. package/es/lowcode/view/lc-components/Proxy/index.less +5 -0
  74. package/es/lowcode/view/lc-components/Proxy/meta.json +66 -0
  75. package/es/lowcode/view/lc-components/Table/components/TopImex.js +5 -23
  76. package/es/lowcode/view/lc-components/Table/index.js +12 -6
  77. package/es/lowcode/view/lc-components/Tabs/index.js +6 -2
  78. package/es/lowcode/view/lc-components/Tree/index.js +3 -0
  79. package/es/lowcode/view/lc-components/Wrapper.js +7 -1
  80. package/es/services.js +25 -7
  81. package/es/utils/action.js +3 -2
  82. package/es/utils/form.js +37 -4
  83. package/es/utils/grid.js +2 -1
  84. package/lib/components/Builder/index.js +36 -26
  85. package/lib/components/ComplexItem/index.js +5 -3
  86. package/lib/components/ComplexItem/service.js +6 -3
  87. package/lib/components/LdAutoForm/index.js +22 -9
  88. package/lib/components/LdCard/index.js +10 -8
  89. package/lib/components/LdCom/index.js +3 -2
  90. package/lib/components/LdFormList/index.js +4 -3
  91. package/lib/components/LdGrid/index.js +29 -20
  92. package/lib/components/LdGridForm/index.js +13 -4
  93. package/lib/components/LdInfoPanel/index.js +15 -9
  94. package/lib/helper/FromItems.js +64 -5
  95. package/lib/helper/form.js +8 -2
  96. package/lib/helper/ldBuilder.js +8 -5
  97. package/lib/helper/ldComBuild.js +14 -9
  98. package/lib/locales/zh-CN.js +40 -4
  99. package/lib/lowcode/constants/api-url.js +204 -175
  100. package/lib/lowcode/constants/event-topics.js +3 -1
  101. package/lib/lowcode/constants/index.js +6 -5
  102. package/lib/lowcode/engine/meta/components-list.json +6 -0
  103. package/lib/lowcode/engine/meta/fielddate.props.default.json +1 -0
  104. package/lib/lowcode/engine/meta/fielddate.props.json +48 -0
  105. package/lib/lowcode/engine/meta/js-editor/auto-complete.json +5 -0
  106. package/lib/lowcode/engine/meta/pagecomponent.props.default.json +8 -0
  107. package/lib/lowcode/engine/meta/pagecomponent.props.json +41 -0
  108. package/lib/lowcode/engine/meta/proxy.props.default.json +15 -0
  109. package/lib/lowcode/engine/meta/proxy.props.json +66 -0
  110. package/lib/lowcode/engine/provider/ContextProvider/index.js +50 -13
  111. package/lib/lowcode/engine/provider/ContextProvider/usePageDataStore.js +37 -31
  112. package/lib/lowcode/engine/provider/ContextProvider/usePageVar.js +10 -4
  113. package/lib/lowcode/engine/provider/ContextProvider/useTodo.js +1 -3
  114. package/lib/lowcode/engine/provider/EventBusProvider.js +14 -4
  115. package/lib/lowcode/engine/provider/PageProxyProvider.js +103 -0
  116. package/lib/lowcode/engine/provider/RemoteSourceProvider.js +10 -12
  117. package/lib/lowcode/engine/tools/helper.js +44 -4
  118. package/lib/lowcode/engine/tools/initDS.js +4 -4
  119. package/lib/lowcode/painter/Design.js +1 -0
  120. package/lib/lowcode/painter/DesignOperator.js +126 -24
  121. package/lib/lowcode/painter/DesignToolbar.js +84 -169
  122. package/lib/lowcode/painter/components/AdvancePanel.js +27 -9
  123. package/lib/lowcode/painter/components/TipIcon.js +12 -4
  124. package/lib/lowcode/painter/components/field-setting/SettingUI.js +55 -3
  125. package/lib/lowcode/painter/components/field-setting/index.js +24 -1
  126. package/lib/lowcode/painter/components/shortcut-modal/KeyIcon.js +18 -0
  127. package/lib/lowcode/painter/components/shortcut-modal/index.js +215 -0
  128. package/lib/lowcode/painter/panel-section/BlockEditor/index.js +9 -18
  129. package/lib/lowcode/painter/panel-section/BlocksEditor/index.js +4 -1
  130. package/lib/lowcode/painter/panel-section/ConditionCheck.js +0 -1
  131. package/lib/lowcode/painter/panel-section/DataSetSelector.js +6 -3
  132. package/lib/lowcode/painter/panel-section/FieldsSetting.js +1 -1
  133. package/lib/lowcode/painter/panel-section/IconConditionSelector.js +2 -1
  134. package/lib/lowcode/painter/panel-section/JSEditor/ToolBar.js +7 -4
  135. package/lib/lowcode/painter/panel-section/JSEditor/index.js +14 -4
  136. package/lib/lowcode/painter/panel-section/JSEditor/index.less +4 -0
  137. package/lib/lowcode/painter/panel-section/ProxyLinker.js +145 -0
  138. package/lib/lowcode/painter/panel-section/ProxyParams.js +35 -0
  139. package/lib/lowcode/painter/panel-section/ProxyParamsSetter.js +248 -0
  140. package/lib/lowcode/painter/style/panel-item.less +1 -0
  141. package/lib/lowcode/preview/DebugTool.js +86 -0
  142. package/lib/lowcode/preview/DebugToolDetail.js +111 -0
  143. package/lib/lowcode/preview/index.js +10 -18
  144. package/lib/lowcode/preview/useDebugSettings.js +69 -0
  145. package/lib/lowcode/view/Canvas.js +5 -1
  146. package/lib/lowcode/view/Page.js +8 -3
  147. package/lib/lowcode/view/lc-components/CardList/index.js +3 -0
  148. package/lib/lowcode/view/lc-components/Dialog/index.js +9 -7
  149. package/lib/lowcode/view/lc-components/Drawer/index.js +2 -0
  150. package/lib/lowcode/view/lc-components/FieldDate/meta.json +48 -0
  151. package/lib/lowcode/view/lc-components/Form/index.js +3 -0
  152. package/lib/lowcode/view/lc-components/Proxy/FunctionDesign.js +24 -0
  153. package/lib/lowcode/view/lc-components/Proxy/FunctionLive.js +30 -0
  154. package/lib/lowcode/view/lc-components/Proxy/FunctionPreview.js +30 -0
  155. package/lib/lowcode/view/lc-components/Proxy/index.js +50 -0
  156. package/lib/lowcode/view/lc-components/Proxy/index.less +5 -0
  157. package/lib/lowcode/view/lc-components/Proxy/meta.json +66 -0
  158. package/lib/lowcode/view/lc-components/Table/components/TopImex.js +4 -22
  159. package/lib/lowcode/view/lc-components/Table/index.js +12 -6
  160. package/lib/lowcode/view/lc-components/Tabs/index.js +5 -1
  161. package/lib/lowcode/view/lc-components/Tree/index.js +3 -0
  162. package/lib/lowcode/view/lc-components/Wrapper.js +6 -0
  163. package/lib/services.js +26 -7
  164. package/lib/utils/action.js +6 -0
  165. package/lib/utils/form.js +38 -4
  166. package/lib/utils/grid.js +2 -1
  167. package/package.json +1 -1
  168. package/es/lowcode/engine/meta/button.api.json +0 -0
  169. package/lib/lowcode/engine/meta/button.api.json +0 -0
@@ -1,11 +1,13 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
6
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
7
  import React, { createContext } from 'react';
7
8
  import { useRequest, useSetState, useAsyncEffect, useMemoizedFn, useCreation, useUnmount } from 'ahooks';
8
9
  import { history } from 'umi';
10
+ import { values } from 'lodash';
9
11
  import launcher from "../launcher";
10
12
  import { LuckDaContext } from "../../../components/Builder";
11
13
  import { doAction as doActionUtils } from "../../../helper/action";
@@ -23,12 +25,10 @@ export default (function (_ref) {
23
25
  var _usePageDataStore = usePageDataStore(function (state) {
24
26
  return {
25
27
  initialize: state.initialize,
26
- initializeModule: state.initializeModule,
27
28
  reset: state.reset
28
29
  };
29
30
  }),
30
31
  initialize = _usePageDataStore.initialize,
31
- initializeModule = _usePageDataStore.initializeModule,
32
32
  reset = _usePageDataStore.reset;
33
33
  var _useTemporalStore = useTemporalStore(function (state) {
34
34
  return {
@@ -70,7 +70,6 @@ export default (function (_ref) {
70
70
  setRemoteSource({
71
71
  module: data
72
72
  });
73
- initializeModule(data);
74
73
  }
75
74
  }
76
75
  }),
@@ -153,7 +152,7 @@ export default (function (_ref) {
153
152
  }),
154
153
  runFetchAllBehaviorExport = _useRequest6.run;
155
154
  useAsyncEffect( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
156
- var fetchPageDataRes, data, list, detail, source;
155
+ var fetchPageDataRes, data, list, detail, source, _pageData;
157
156
  return _regeneratorRuntime().wrap(function _callee$(_context) {
158
157
  while (1) switch (_context.prev = _context.next) {
159
158
  case 0:
@@ -173,16 +172,17 @@ export default (function (_ref) {
173
172
  break;
174
173
  }
175
174
  history.replace('/404');
176
- _context.next = 20;
175
+ _context.next = 21;
177
176
  break;
178
177
  case 9:
179
- source = detail[list[0]].source;
180
178
  setMetaAttrs(META_TAG_NAME, data);
181
- _context.next = 13;
179
+ source = detail[list[0]].source;
180
+ _pageData = decompress(source);
181
+ _context.next = 14;
182
182
  return runFetchModlueData(data.dataModelKey, {
183
- moduleCode: data.moduleCode
183
+ moduleCode: [data.moduleCode].concat(_toConsumableArray(values(_pageData.props.proxy))).join(',')
184
184
  });
185
- case 13:
185
+ case 14:
186
186
  runFetchAllBehaviorImport({
187
187
  behaviorMode: 'IMPORT',
188
188
  moduleCode: data.moduleCode
@@ -197,11 +197,9 @@ export default (function (_ref) {
197
197
  runFetchAllSerials({
198
198
  uid: data.moduleId
199
199
  });
200
- initialize(decompress(source));
200
+ initialize(_pageData);
201
201
  resume();
202
202
  eventBus.$publisher(PAGE_LOAD_MOUNT);
203
- case 20:
204
- ;
205
203
  case 21:
206
204
  case "end":
207
205
  return _context.stop();
@@ -1,9 +1,10 @@
1
1
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
3
  import _construct from "@babel/runtime/helpers/esm/construct";
3
4
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
5
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
6
  import _typeof from "@babel/runtime/helpers/esm/typeof";
6
- import { omit, isNil, isString, isArray, has, get } from 'lodash';
7
+ import { omit, isNil, isString, isArray, has, get, cloneDeep, groupBy, keyBy, each } from 'lodash';
7
8
  import postcss from 'postcss';
8
9
  import { META_TAG_NAME } from "../../constants";
9
10
  export function isPromise(value) {
@@ -166,22 +167,36 @@ export function setMetaAttrs(name, data) {
166
167
  meta.content = isString(data) ? data : new URLSearchParams(data).toString().replaceAll('&', ',');
167
168
  document.head.appendChild(meta);
168
169
  }
170
+ function normalize(val) {
171
+ if (val === 'null') return null;
172
+ if (val === 'undefined') return undefined;
173
+ if (val === 'true') return true;
174
+ if (val === 'false') return false;
175
+ if (/^-?\d+(\.\d+)?$/.test(val)) return Number(val);
176
+ return val;
177
+ }
169
178
  export function getMetaAttr(name, _) {
170
179
  if (isNil(name)) return void 0;
171
180
  var meta = document.querySelector("meta[name=\"".concat(name, "\"]"));
181
+ if (isNil(meta)) return void 0;
172
182
  if (meta.content.includes(',')) {
173
183
  var data = new URLSearchParams(meta.content.replaceAll(',', '&'));
174
184
  if (isNil(_)) {
175
- return Object.fromEntries(data.entries());
185
+ return Object.fromEntries(Array.from(data.entries()).map(function (_ref) {
186
+ var _ref2 = _slicedToArray(_ref, 2),
187
+ k = _ref2[0],
188
+ v = _ref2[1];
189
+ return [k, normalize(v)];
190
+ }));
176
191
  }
177
192
  if (isArray(_)) {
178
193
  return _.map(function (n) {
179
- return data.get(n);
194
+ return normalize(data.get(n));
180
195
  });
181
196
  }
182
- return data.get(_);
197
+ return normalize(data.get(_));
183
198
  }
184
- return meta.content;
199
+ return normalize(meta.content);
185
200
  }
186
201
  export function getLDMetaAttr(_) {
187
202
  return getMetaAttr(META_TAG_NAME, _);
@@ -262,4 +277,28 @@ export function findFirstLeafNode(node) {
262
277
  _iterator2.f();
263
278
  }
264
279
  return null;
280
+ }
281
+ export function dataToTree(data, params) {
282
+ var _ref3 = params || {},
283
+ _ref3$parentKey = _ref3.parentKey,
284
+ parentKey = _ref3$parentKey === void 0 ? 'parentId' : _ref3$parentKey,
285
+ _ref3$childKey = _ref3.childKey,
286
+ childKey = _ref3$childKey === void 0 ? 'children' : _ref3$childKey,
287
+ _ref3$rootId = _ref3.rootId,
288
+ rootId = _ref3$rootId === void 0 ? '0' : _ref3$rootId,
289
+ _ref3$id = _ref3.id,
290
+ id = _ref3$id === void 0 ? 'id' : _ref3$id,
291
+ _ref3$stain = _ref3.stain,
292
+ stain = _ref3$stain === void 0 ? false : _ref3$stain;
293
+ var _data = stain ? data : cloneDeep(data);
294
+ var groupedByParents = groupBy(_data, parentKey);
295
+ var itemsById = keyBy(_data, id);
296
+ try {
297
+ each(omit(groupedByParents, rootId), function (children, parentId) {
298
+ itemsById[parentId][childKey] = children;
299
+ });
300
+ } catch (e) {
301
+ console.error('helper.dataToTree error', e);
302
+ }
303
+ return groupedByParents[rootId];
265
304
  }
@@ -140,8 +140,8 @@ var wrapPromise = function wrapPromise(promise) {
140
140
  }
141
141
  };
142
142
  };
143
- export default function initialize(ctx) {
144
- var pageVars = usePageDataStore.getState().pageData.props.vars;
143
+ export default function initialize(ctx, proxyCode) {
144
+ var pageVars = usePageDataStore.getState()[proxyCode || 'pageData'].props.vars;
145
145
  if (isNil(pageVars)) return null;
146
146
  var remoteApis = new Map();
147
147
  var _reduce = reduce(pageVars, function (ret, val) {
@@ -170,8 +170,8 @@ export default function initialize(ctx) {
170
170
  _reduce2 = _toArray(_reduce),
171
171
  variables = _reduce2[0],
172
172
  autoTasks = _reduce2.slice(1);
173
- useStateStore.getState().initialize(variables);
174
- ctx._initRemoteApiMap(remoteApis);
173
+ useStateStore.getState().initialize(variables, !!proxyCode);
174
+ ctx._initRemoteApiMap(remoteApis, !!proxyCode);
175
175
  function run() {
176
176
  return _run2.apply(this, arguments);
177
177
  }
@@ -65,6 +65,7 @@ var Design = function Design() {
65
65
  return /*#__PURE__*/React.createElement("div", {
66
66
  className: styles['lc-painter-design']
67
67
  }, /*#__PURE__*/React.createElement(DesignToolbar, {
68
+ canvas: simulatorRef,
68
69
  locale: locale,
69
70
  onLangChange: handleLangChange
70
71
  }), /*#__PURE__*/React.createElement("div", {
@@ -1,12 +1,13 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import React, { useRef, useEffect, useState } from 'react';
3
+ import { getCreateHistoryOptions } from 'umi';
3
4
  import { last, initial } from 'lodash';
4
- import { useEventListener, useSetState, useMemoizedFn, useCreation, useSize, useLatest, useKeyPress } from 'ahooks';
5
+ import { useEventListener, useSetState, useMemoizedFn, useCreation, useSize, useLatest } from 'ahooks';
5
6
  import { Icon, Dropdown, message } from 'luck-design/antd';
6
- import { reverse, isString, isNil } from 'lodash';
7
+ import { reverse, isString, isNil, omit } from 'lodash';
7
8
  import classNames from 'classnames';
8
9
  import { suid } from '@luck-design-biz/base/utils';
9
- import { useContext, addNode, deleteNode } from "../engine/provider/ContextProvider";
10
+ import { useContext, addNode, deleteNode, moveNode, useTemporalStore } from "../engine/provider/ContextProvider";
10
11
  import { LC_BUILDIN_UNIT_KEY, LC_COMPONENT_UNIT_KEY, LC_COMPONENT_UNIT, LC_FORMITEM_UNIT, CONTAINER_UNITS } from "../constants";
11
12
  import styles from "./style/design.less";
12
13
  var _MODAL_COMPONENT_ = ['Dialog', 'Drawer'];
@@ -43,6 +44,18 @@ var DesignOperator = function DesignOperator(_ref) {
43
44
  setOperatorId = _useSetState2[1];
44
45
  var lastSelectorId = useLatest(operatorId.selector);
45
46
  var currentModal = useRef(null);
47
+ var _useTemporalStore = useTemporalStore(function (state) {
48
+ return {
49
+ undo: state.undo,
50
+ redo: state.redo,
51
+ pastStates: state.pastStates,
52
+ futureStates: state.futureStates
53
+ };
54
+ }),
55
+ canUndo = _useTemporalStore.canUndo,
56
+ canRedo = _useTemporalStore.canRedo,
57
+ undo = _useTemporalStore.undo,
58
+ redo = _useTemporalStore.redo;
46
59
  var getElement = useMemoizedFn(function (_target) {
47
60
  var _context$componentMap;
48
61
  return isString(_target) ? (_context$componentMap = context.componentMap.get(_target)) === null || _context$componentMap === void 0 ? void 0 : _context$componentMap.api.getSelfDom() : _target;
@@ -63,9 +76,109 @@ var DesignOperator = function DesignOperator(_ref) {
63
76
  id: id
64
77
  });
65
78
  });
79
+ var handleShortcutEmit = useMemoizedFn(function (_ref3) {
80
+ var key = _ref3.key;
81
+ switch (key) {
82
+ case 'meta.s':
83
+ case 'ctrl.s':
84
+ context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
85
+ break;
86
+ case 'meta.p':
87
+ case 'ctrl.p':
88
+ {
89
+ var _getCreateHistoryOpti = getCreateHistoryOptions(),
90
+ basename = _getCreateHistoryOpti.basename;
91
+ var previewUrl = "".concat(basename === '/' ? '' : basename, "/byteman/preview/").concat(context.router.getQuery('code'));
92
+ window.open(previewUrl, '_blank');
93
+ }
94
+ break;
95
+ case 'meta.z':
96
+ case 'ctrl.z':
97
+ canUndo && undo();
98
+ break;
99
+ case 'meta.shift.z':
100
+ case 'ctrl.shift.z':
101
+ canRedo && redo();
102
+ break;
103
+ case 'meta.c':
104
+ case 'ctrl.c':
105
+ if (operatorId.selector) {
106
+ var _context$$$api$getSel = context.$(operatorId.selector).api.getSelfAndParentData(),
107
+ node = _context$$$api$getSel.node,
108
+ parent = _context$$$api$getSel.parent;
109
+ if (CONTAINER_UNITS.includes(parent === null || parent === void 0 ? void 0 : parent.props.component)) {
110
+ addComponent(omit(node.props), parent.props.id);
111
+ }
112
+ }
113
+ break;
114
+ case 'backspace':
115
+ if (operatorId.selector && operatorId.deletable) {
116
+ handleDelete({
117
+ id: operatorId.selector
118
+ });
119
+ }
120
+ break;
121
+ case 'uparrow':
122
+ if (operatorId.selector) {
123
+ var _context$$$api$getSel2 = context.$(operatorId.selector).api.getSelfAndParentData(),
124
+ _parent = _context$$$api$getSel2.parent;
125
+ if (_parent) {
126
+ handleSelect(_parent.props.id);
127
+ }
128
+ }
129
+ break;
130
+ case 'downarrow':
131
+ if (operatorId.selector) {
132
+ var _node$children;
133
+ var _node = context.$(operatorId.selector).api.getSelfData();
134
+ if (_node !== null && _node !== void 0 && (_node$children = _node.children) !== null && _node$children !== void 0 && _node$children.length) {
135
+ handleSelect(_node.children[0]);
136
+ }
137
+ }
138
+ break;
139
+ case 'leftarrow':
140
+ case 'rightarrow':
141
+ if (operatorId.selector) {
142
+ var _parent2$children;
143
+ var _context$$$api$getSel3 = context.$(operatorId.selector).api.getSelfAndParentData(),
144
+ _parent2 = _context$$$api$getSel3.parent;
145
+ if (_parent2 !== null && _parent2 !== void 0 && (_parent2$children = _parent2.children) !== null && _parent2$children !== void 0 && _parent2$children.length) {
146
+ var index = _parent2.children.findIndex(function (c) {
147
+ return c === operatorId.selector;
148
+ });
149
+ if (key === 'leftarrow' && index > 0) {
150
+ handleSelect(_parent2.children[index - 1]);
151
+ } else if (key === 'rightarrow' && index < _parent2.children.length - 1) {
152
+ handleSelect(_parent2.children[index + 1]);
153
+ }
154
+ }
155
+ }
156
+ break;
157
+ case 'alt.leftarrow':
158
+ case 'alt.rightarrow':
159
+ if (operatorId.selector) {
160
+ var _parent3$children;
161
+ var _context$$$api$getSel4 = context.$(operatorId.selector).api.getSelfAndParentData(),
162
+ _parent3 = _context$$$api$getSel4.parent;
163
+ if (_parent3 !== null && _parent3 !== void 0 && (_parent3$children = _parent3.children) !== null && _parent3$children !== void 0 && _parent3$children.length) {
164
+ var _index = _parent3.children.findIndex(function (c) {
165
+ return c === operatorId.selector;
166
+ });
167
+ if (key === 'alt.leftarrow' && _index > 0) {
168
+ moveNode(_parent3.children[_index], _parent3.children[_index - 1], 'left');
169
+ } else if (key === 'alt.rightarrow' && _index < _parent3.children.length - 1) {
170
+ moveNode(_parent3.children[_index], _parent3.children[_index + 1], 'right');
171
+ }
172
+ }
173
+ }
174
+ break;
175
+ default:
176
+ break;
177
+ }
178
+ });
66
179
  var addComponent = useMemoizedFn(function (data, targetId) {
67
- context.$subscriber(context.topics.COMPONENT_MOUNT).once(function (_ref3) {
68
- var mountCompId = _ref3.id;
180
+ context.$subscriber(context.topics.COMPONENT_MOUNT).once(function (_ref4) {
181
+ var mountCompId = _ref4.id;
69
182
  if (mountCompId === _id) {
70
183
  context.$publisher(context.topics.COMPONENT_APPEND, {
71
184
  id: _id
@@ -126,19 +239,6 @@ var DesignOperator = function DesignOperator(_ref) {
126
239
  var _last;
127
240
  return operatorId.detector && isString(operatorId.detector) ? (_last = last(context.componentMap.get(operatorId.detector).api.getLevelNodes())) === null || _last === void 0 ? void 0 : _last.name : void 0;
128
241
  }, [operatorId.detector]);
129
- useKeyPress('backspace', function () {
130
- if (operatorId.selector && operatorId.deletable) {
131
- handleDelete({
132
- id: operatorId.selector
133
- });
134
- }
135
- }, {
136
- target: canvas
137
- });
138
- useKeyPress('ctrl.s', function (e) {
139
- e.preventDefault();
140
- context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
141
- });
142
242
  useEventListener('mousemove', function (event) {
143
243
  var elem = event.target;
144
244
  var targetFormItem = elem.closest("[".concat(LC_COMPONENT_UNIT_KEY, "=\"").concat(LC_FORMITEM_UNIT, "\"]"));
@@ -201,11 +301,11 @@ var DesignOperator = function DesignOperator(_ref) {
201
301
  target: canvas
202
302
  });
203
303
  useEffect(function () {
204
- var csid = context.$subscriber(context.topics.COMPONENT_SETTING_CLICK).on(function (_ref4) {
205
- var data = _ref4.data;
304
+ var csid = context.$subscriber(context.topics.COMPONENT_SETTING_CLICK).on(function (_ref5) {
305
+ var data = _ref5.data;
206
306
  if (_MODAL_COMPONENT_.includes(data.component)) {
207
- context.$subscriber(context.topics.COMPONENT_APPEND).once(function (_ref5) {
208
- var compId = _ref5.id;
307
+ context.$subscriber(context.topics.COMPONENT_APPEND).once(function (_ref6) {
308
+ var compId = _ref6.id;
209
309
  context.$publisher(context.topics.COMPONENT_MODAL_TOGGLE, {
210
310
  toggle: true,
211
311
  id: compId
@@ -261,9 +361,9 @@ var DesignOperator = function DesignOperator(_ref) {
261
361
  });
262
362
  }
263
363
  }).watch();
264
- var cmtid = context.$subscriber(context.topics.COMPONENT_MODAL_TOGGLE).on(function (_ref6) {
265
- var toggle = _ref6.toggle,
266
- id = _ref6.id;
364
+ var cmtid = context.$subscriber(context.topics.COMPONENT_MODAL_TOGGLE).on(function (_ref7) {
365
+ var toggle = _ref7.toggle,
366
+ id = _ref7.id;
267
367
  if (toggle && id !== currentModal.current) {
268
368
  var _canvas$current2;
269
369
  (_canvas$current2 = canvas.current) === null || _canvas$current2 === void 0 || _canvas$current2.style.setProperty('overflow', 'hidden');
@@ -283,19 +383,21 @@ var DesignOperator = function DesignOperator(_ref) {
283
383
  }
284
384
  }
285
385
  }).watch();
286
- var cdid = context.$subscriber(context.topics.COMPONENT_DELETE).on(function (_ref7) {
287
- var id = _ref7.id;
386
+ var cdid = context.$subscriber(context.topics.COMPONENT_DELETE).on(function (_ref8) {
387
+ var id = _ref8.id;
288
388
  if (lastSelectorId.current === id) {
289
389
  handleSelect();
290
390
  }
291
391
  deleteNode(id);
292
392
  });
393
+ var dseid = context.$subscriber(context.topics.DESIGN_SHORTCUT_EMIT).on(handleShortcutEmit);
293
394
  return function () {
294
395
  context.$unsubscriber(context.topics.COMPONENT_SETTING_CLICK, csid);
295
396
  context.$unsubscriber(context.topics.COMPONENT_HOVER, hcid);
296
397
  context.$unsubscriber(context.topics.COMPONENT_ACTIVE, acid);
297
398
  context.$unsubscriber(context.topics.MODAL_OPEN, cmtid);
298
399
  context.$unsubscriber(context.topics.COMPONENT_DELETE, cdid);
400
+ context.$unsubscriber(context.topics.COMPONENT_DELETE, dseid);
299
401
  };
300
402
  }, []);
301
403
  useEffect(function () {