@tmagic/editor 1.5.0-beta.1 → 1.5.0-beta.11

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 (79) hide show
  1. package/dist/style.css +276 -3
  2. package/dist/tmagic-editor.js +268 -218
  3. package/dist/tmagic-editor.umd.cjs +496 -421
  4. package/package.json +13 -14
  5. package/src/Editor.vue +18 -4
  6. package/src/components/CodeBlockEditor.vue +5 -5
  7. package/src/components/SearchInput.vue +1 -0
  8. package/src/components/Tree.vue +10 -2
  9. package/src/components/TreeNode.vue +4 -2
  10. package/src/editorProps.ts +6 -3
  11. package/src/fields/CodeLink.vue +2 -2
  12. package/src/fields/CodeSelect.vue +1 -1
  13. package/src/fields/CodeSelectCol.vue +1 -1
  14. package/src/fields/CondOpSelect.vue +1 -1
  15. package/src/fields/DataSourceFieldSelect/FieldSelect.vue +2 -8
  16. package/src/fields/DataSourceFieldSelect/Index.vue +2 -2
  17. package/src/fields/DataSourceFields.vue +1 -1
  18. package/src/fields/DataSourceInput.vue +4 -4
  19. package/src/fields/DataSourceMethodSelect.vue +1 -1
  20. package/src/fields/DataSourceMethods.vue +1 -1
  21. package/src/fields/DataSourceMocks.vue +1 -1
  22. package/src/fields/DisplayConds.vue +1 -1
  23. package/src/fields/EventSelect.vue +4 -4
  24. package/src/fields/PageFragmentSelect.vue +1 -1
  25. package/src/fields/UISelect.vue +1 -1
  26. package/src/hooks/use-code-block-edit.ts +1 -1
  27. package/src/hooks/use-data-source-edit.ts +1 -1
  28. package/src/hooks/use-data-source-method.ts +3 -3
  29. package/src/hooks/use-filter.ts +2 -2
  30. package/src/hooks/use-node-status.ts +3 -3
  31. package/src/hooks/use-stage.ts +2 -2
  32. package/src/index.ts +28 -8
  33. package/src/initService.ts +17 -10
  34. package/src/layouts/AddPageBox.vue +1 -1
  35. package/src/layouts/CodeEditor.vue +5 -5
  36. package/src/layouts/Framework.vue +2 -2
  37. package/src/layouts/NavMenu.vue +1 -1
  38. package/src/layouts/PropsPanel.vue +1 -1
  39. package/src/layouts/page-bar/AddButton.vue +1 -1
  40. package/src/layouts/page-bar/PageBar.vue +8 -2
  41. package/src/layouts/page-bar/PageBarScrollContainer.vue +1 -1
  42. package/src/layouts/page-bar/PageList.vue +8 -2
  43. package/src/layouts/page-bar/SwitchTypeButton.vue +1 -1
  44. package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
  45. package/src/layouts/sidebar/Sidebar.vue +13 -1
  46. package/src/layouts/sidebar/code-block/CodeBlockList.vue +11 -3
  47. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +11 -2
  48. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +1 -1
  49. package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -3
  50. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +19 -2
  51. package/src/layouts/sidebar/layer/LayerNodeTool.vue +1 -1
  52. package/src/layouts/sidebar/layer/LayerPanel.vue +5 -1
  53. package/src/layouts/sidebar/layer/use-click.ts +1 -1
  54. package/src/layouts/sidebar/layer/use-drag.ts +1 -1
  55. package/src/layouts/sidebar/layer/use-node-status.ts +3 -4
  56. package/src/layouts/workspace/Breadcrumb.vue +1 -1
  57. package/src/layouts/workspace/viewer/NodeListMenu.vue +2 -2
  58. package/src/layouts/workspace/viewer/Stage.vue +9 -5
  59. package/src/layouts/workspace/viewer/StageOverlay.vue +9 -4
  60. package/src/layouts/workspace/viewer/ViewerMenu.vue +1 -1
  61. package/src/services/codeBlock.ts +7 -7
  62. package/src/services/dataSource.ts +3 -4
  63. package/src/services/dep.ts +2 -2
  64. package/src/services/editor.ts +10 -11
  65. package/src/services/history.ts +1 -1
  66. package/src/services/props.ts +3 -3
  67. package/src/services/stageOverlay.ts +15 -7
  68. package/src/services/storage.ts +2 -2
  69. package/src/theme/index.scss +3 -0
  70. package/src/theme/page-bar.scss +2 -1
  71. package/src/type.ts +14 -11
  72. package/src/utils/config.ts +5 -5
  73. package/src/utils/content-menu.ts +3 -3
  74. package/src/utils/data-source/index.ts +1 -1
  75. package/src/utils/editor.ts +13 -35
  76. package/src/utils/operator.ts +2 -1
  77. package/src/utils/props.ts +1 -1
  78. package/src/utils/tree.ts +1 -1
  79. package/types/index.d.ts +1554 -3130
@@ -1,7 +1,16 @@
1
1
  import { onBeforeUnmount, reactive, toRaw, watch } from 'vue';
2
- import { cloneDeep } from 'lodash-es';
3
-
4
- import type { EventOption } from '@tmagic/core';
2
+ import { cloneDeep, debounce } from 'lodash-es';
3
+
4
+ import type {
5
+ CodeBlockContent,
6
+ DataSourceSchema,
7
+ EventOption,
8
+ Id,
9
+ MApp,
10
+ MNode,
11
+ MPage,
12
+ MPageFragment,
13
+ } from '@tmagic/core';
5
14
  import {
6
15
  createCodeBlockTarget,
7
16
  createDataSourceCondTarget,
@@ -9,14 +18,12 @@ import {
9
18
  createDataSourceTarget,
10
19
  DepTargetType,
11
20
  Target,
12
- } from '@tmagic/dep';
13
- import type { CodeBlockContent, DataSourceSchema, Id, MApp, MNode, MPage, MPageFragment } from '@tmagic/schema';
14
- import { isPage } from '@tmagic/utils';
21
+ } from '@tmagic/core';
22
+ import { isPage, traverseNode } from '@tmagic/utils';
15
23
 
16
24
  import PropsPanel from './layouts/PropsPanel.vue';
17
25
  import { EditorProps } from './editorProps';
18
26
  import { Services } from './type';
19
- import { traverseNode } from './utils';
20
27
 
21
28
  export declare type LooseRequired<T> = {
22
29
  [P in string & keyof T]: T[P];
@@ -242,7 +249,7 @@ export const initServiceEvents = (
242
249
 
243
250
  const getApp = () => {
244
251
  const stage = editorService.get('stage');
245
- return stage?.renderer.runtime?.getApp?.();
252
+ return stage?.renderer?.runtime?.getApp?.();
246
253
  };
247
254
 
248
255
  const updateDataSourceSchema = () => {
@@ -284,7 +291,7 @@ export const initServiceEvents = (
284
291
  }
285
292
  };
286
293
 
287
- const collectedHandler = (nodes: MNode[], deep: boolean) => {
294
+ const collectedHandler = debounce((nodes: MNode[], deep: boolean) => {
288
295
  const root = editorService.get('root');
289
296
  const stage = editorService.get('stage');
290
297
 
@@ -328,7 +335,7 @@ export const initServiceEvents = (
328
335
  });
329
336
  });
330
337
  });
331
- };
338
+ }, 300);
332
339
 
333
340
  depService.on('add-target', targetAddHandler);
334
341
  depService.on('remove-target', targetRemoveHandler);
@@ -22,7 +22,7 @@
22
22
  import { inject, toRaw } from 'vue';
23
23
  import { Plus } from '@element-plus/icons-vue';
24
24
 
25
- import { NodeType } from '@tmagic/schema';
25
+ import { NodeType } from '@tmagic/core';
26
26
 
27
27
  import MIcon from '@editor/components/Icon.vue';
28
28
  import type { Services } from '@editor/type';
@@ -23,7 +23,7 @@ import serialize from 'serialize-javascript';
23
23
  import { TMagicButton } from '@tmagic/design';
24
24
 
25
25
  import MIcon from '@editor/components/Icon.vue';
26
- import { getConfig } from '@editor/utils/config';
26
+ import { getEditorConfig } from '@editor/utils/config';
27
27
  import monaco from '@editor/utils/monaco-editor';
28
28
 
29
29
  defineOptions({
@@ -76,7 +76,7 @@ const toString = (v: string | any, language: string): string => {
76
76
  return value;
77
77
  };
78
78
 
79
- const parse = (v: string | any, language: string): any => {
79
+ const parseCode = (v: string | any, language: string): any => {
80
80
  if (typeof v !== 'string') {
81
81
  return v;
82
82
  }
@@ -85,7 +85,7 @@ const parse = (v: string | any, language: string): any => {
85
85
  return JSON.parse(v);
86
86
  }
87
87
 
88
- return getConfig('parseDSL')(v);
88
+ return getEditorConfig('parseDSL')(v);
89
89
  };
90
90
 
91
91
  let vsEditor: monaco.editor.IStandaloneCodeEditor | null = null;
@@ -149,7 +149,7 @@ const init = async () => {
149
149
  e.stopPropagation();
150
150
  const newValue = getEditorValue();
151
151
  values.value = newValue;
152
- emit('save', props.parse ? parse(newValue, props.language) : newValue);
152
+ emit('save', props.parse ? parseCode(newValue, props.language) : newValue);
153
153
  }
154
154
  });
155
155
 
@@ -158,7 +158,7 @@ const init = async () => {
158
158
  const newValue = getEditorValue();
159
159
  if (values.value !== newValue) {
160
160
  values.value = newValue;
161
- emit('save', props.parse ? parse(newValue, props.language) : newValue);
161
+ emit('save', props.parse ? parseCode(newValue, props.language) : newValue);
162
162
  }
163
163
  });
164
164
  }
@@ -65,7 +65,7 @@ import { TMagicScrollbar } from '@tmagic/design';
65
65
 
66
66
  import SplitView from '@editor/components/SplitView.vue';
67
67
  import type { FrameworkSlots, GetColumnWidth, PageBarSortOptions, Services } from '@editor/type';
68
- import { getConfig } from '@editor/utils/config';
68
+ import { getEditorConfig } from '@editor/utils/config';
69
69
 
70
70
  import PageBar from './page-bar/PageBar.vue';
71
71
  import AddPageBox from './AddPageBox.vue';
@@ -156,7 +156,7 @@ onBeforeUnmount(() => {
156
156
 
157
157
  const saveCode = (value: string) => {
158
158
  try {
159
- const parseDSL = getConfig('parseDSL');
159
+ const parseDSL = getEditorConfig('parseDSL');
160
160
  editorService?.set('root', parseDSL(value));
161
161
  } catch (e: any) {
162
162
  console.error(e);
@@ -10,7 +10,7 @@
10
10
  import { computed, inject, markRaw, onBeforeUnmount, onMounted, ref } from 'vue';
11
11
  import { Back, Delete, FullScreen, Grid, Memo, Right, ScaleToOriginal, ZoomIn, ZoomOut } from '@element-plus/icons-vue';
12
12
 
13
- import { NodeType } from '@tmagic/schema';
13
+ import { NodeType } from '@tmagic/core';
14
14
 
15
15
  import ToolButton from '@editor/components/ToolButton.vue';
16
16
  import { ColumnLayout, MenuBarData, MenuButton, MenuComponent, MenuItem, Services } from '@editor/type';
@@ -41,10 +41,10 @@
41
41
  import { computed, getCurrentInstance, inject, onBeforeUnmount, onMounted, ref, watchEffect } from 'vue';
42
42
  import { Document as DocumentIcon } from '@element-plus/icons-vue';
43
43
 
44
+ import type { MNode } from '@tmagic/core';
44
45
  import { TMagicButton } from '@tmagic/design';
45
46
  import type { FormState, FormValue } from '@tmagic/form';
46
47
  import { MForm } from '@tmagic/form';
47
- import type { MNode } from '@tmagic/schema';
48
48
 
49
49
  import MIcon from '@editor/components/Icon.vue';
50
50
  import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
@@ -14,7 +14,7 @@
14
14
  import { computed, inject, toRaw } from 'vue';
15
15
  import { Plus } from '@element-plus/icons-vue';
16
16
 
17
- import { NodeType } from '@tmagic/schema';
17
+ import { NodeType } from '@tmagic/core';
18
18
 
19
19
  import Icon from '@editor/components/Icon.vue';
20
20
  import type { Services } from '@editor/type';
@@ -24,7 +24,13 @@
24
24
  </slot>
25
25
  </div>
26
26
 
27
- <TMagicPopover popper-class="page-bar-popover" placement="top" :width="160" trigger="hover">
27
+ <TMagicPopover
28
+ popper-class="page-bar-popover"
29
+ placement="top"
30
+ trigger="hover"
31
+ :width="160"
32
+ :destroy-on-close="true"
33
+ >
28
34
  <div>
29
35
  <slot name="page-bar-popover" :page="item">
30
36
  <ToolButton
@@ -60,8 +66,8 @@
60
66
  import { computed, inject, ref, watch } from 'vue';
61
67
  import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
62
68
 
69
+ import { type Id, type MPage, type MPageFragment, NodeType } from '@tmagic/core';
63
70
  import { TMagicIcon, TMagicPopover } from '@tmagic/design';
64
- import { Id, type MPage, type MPageFragment, NodeType } from '@tmagic/schema';
65
71
  import { isPage, isPageFragment } from '@tmagic/utils';
66
72
 
67
73
  import ToolButton from '@editor/components/ToolButton.vue';
@@ -36,7 +36,7 @@ import {
36
36
  import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
37
37
  import Sortable, { SortableEvent } from 'sortablejs';
38
38
 
39
- import { Id, NodeType } from '@tmagic/schema';
39
+ import { Id, NodeType } from '@tmagic/core';
40
40
 
41
41
  import Icon from '@editor/components/Icon.vue';
42
42
  import type { PageBarSortOptions, Services } from '@editor/type';
@@ -4,7 +4,13 @@
4
4
  id="m-editor-page-bar-list-icon"
5
5
  class="m-editor-page-bar-item m-editor-page-bar-item-icon"
6
6
  >
7
- <TMagicPopover popper-class="page-bar-popover" placement="top" :width="160" trigger="hover">
7
+ <TMagicPopover
8
+ popper-class="page-bar-popover"
9
+ placement="top"
10
+ trigger="hover"
11
+ :width="160"
12
+ :destroy-on-close="true"
13
+ >
8
14
  <div>
9
15
  <slot name="page-list-popover" :list="list">
10
16
  <ToolButton
@@ -31,8 +37,8 @@
31
37
  import { computed, inject } from 'vue';
32
38
  import { Files } from '@element-plus/icons-vue';
33
39
 
40
+ import { Id, MPage, MPageFragment } from '@tmagic/core';
34
41
  import { TMagicIcon, TMagicPopover } from '@tmagic/design';
35
- import { Id, MPage, MPageFragment } from '@tmagic/schema';
36
42
 
37
43
  import ToolButton from '@editor/components/ToolButton.vue';
38
44
  import type { Services } from '@editor/type';
@@ -13,8 +13,8 @@
13
13
  </template>
14
14
 
15
15
  <script setup lang="ts">
16
+ import { NodeType } from '@tmagic/core';
16
17
  import { TMagicButton } from '@tmagic/design';
17
- import { NodeType } from '@tmagic/schema';
18
18
 
19
19
  defineOptions({
20
20
  name: 'MEditorPageBarSwitchTypeButton',
@@ -111,7 +111,7 @@ const dragendHandler = () => {
111
111
  globalThis.clearTimeout(timeout);
112
112
  timeout = undefined;
113
113
  }
114
- const doc = stage.value?.renderer.getDocument();
114
+ const doc = stage.value?.renderer?.getDocument();
115
115
  if (doc && stageOptions?.containerHighlightClassName) {
116
116
  removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
117
117
  }
@@ -180,8 +180,10 @@ defineOptions({
180
180
 
181
181
  const props = withDefaults(
182
182
  defineProps<{
183
- data: SideBarData;
183
+ data?: SideBarData;
184
184
  layerContentMenu: (MenuButton | MenuComponent)[];
185
+ indent?: number;
186
+ nextLevelIndentIncrement?: number;
185
187
  customContentMenu?: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
186
188
  }>(),
187
189
  {
@@ -234,6 +236,8 @@ const getItemConfig = (data: SideItem): SideComponent => {
234
236
  props: {
235
237
  layerContentMenu: props.layerContentMenu,
236
238
  customContentMenu: props.customContentMenu,
239
+ indent: props.indent,
240
+ nextLevelIndentIncrement: props.nextLevelIndentIncrement,
237
241
  },
238
242
  component: LayerPanel,
239
243
  slots: {},
@@ -244,6 +248,10 @@ const getItemConfig = (data: SideItem): SideComponent => {
244
248
  icon: EditPen,
245
249
  text: '代码编辑',
246
250
  component: CodeBlockListPanel,
251
+ props: {
252
+ indent: props.indent,
253
+ nextLevelIndentIncrement: props.nextLevelIndentIncrement,
254
+ },
247
255
  slots: {},
248
256
  },
249
257
  [SideItemKey.DATA_SOURCE]: {
@@ -252,6 +260,10 @@ const getItemConfig = (data: SideItem): SideComponent => {
252
260
  icon: Coin,
253
261
  text: '数据源',
254
262
  component: DataSourceListPanel,
263
+ props: {
264
+ indent: props.indent,
265
+ nextLevelIndentIncrement: props.nextLevelIndentIncrement,
266
+ },
255
267
  slots: {},
256
268
  },
257
269
  };
@@ -1,5 +1,11 @@
1
1
  <template>
2
- <Tree :data="codeList" :node-status-map="nodeStatusMap" @node-click="clickHandler">
2
+ <Tree
3
+ :data="codeList"
4
+ :node-status-map="nodeStatusMap"
5
+ :indent="indent"
6
+ :next-level-indent-increment="nextLevelIndentIncrement"
7
+ @node-click="clickHandler"
8
+ >
3
9
  <template #tree-node-label="{ data }">
4
10
  <div
5
11
  :class="{
@@ -28,9 +34,9 @@
28
34
  import { computed, inject } from 'vue';
29
35
  import { Close, Edit, View } from '@element-plus/icons-vue';
30
36
 
31
- import { DepTargetType } from '@tmagic/dep';
37
+ import type { Id, MNode } from '@tmagic/core';
38
+ import { DepTargetType } from '@tmagic/core';
32
39
  import { tMagicMessage, tMagicMessageBox, TMagicTooltip } from '@tmagic/design';
33
- import type { Id, MNode } from '@tmagic/schema';
34
40
 
35
41
  import Icon from '@editor/components/Icon.vue';
36
42
  import Tree from '@editor/components/Tree.vue';
@@ -45,6 +51,8 @@ defineOptions({
45
51
  });
46
52
 
47
53
  const props = defineProps<{
54
+ indent?: number;
55
+ nextLevelIndentIncrement?: number;
48
56
  customError?: (id: Id, errorType: CodeDeleteErrorType) => any;
49
57
  }>();
50
58
 
@@ -11,7 +11,14 @@
11
11
  </slot>
12
12
 
13
13
  <!-- 代码块列表 -->
14
- <CodeBlockList ref="codeBlockList" :custom-error="customError" @edit="editCode" @remove="deleteCode">
14
+ <CodeBlockList
15
+ ref="codeBlockList"
16
+ :custom-error="customError"
17
+ :indent="indent"
18
+ :next-level-indent-increment="nextLevelIndentIncrement"
19
+ @edit="editCode"
20
+ @remove="deleteCode"
21
+ >
15
22
  <template #code-block-panel-tool="{ id, data }">
16
23
  <slot name="code-block-panel-tool" :id="id" :data="data"></slot>
17
24
  </template>
@@ -30,8 +37,8 @@
30
37
  <script setup lang="ts">
31
38
  import { computed, inject, ref } from 'vue';
32
39
 
40
+ import type { Id } from '@tmagic/core';
33
41
  import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
34
- import type { Id } from '@tmagic/schema';
35
42
 
36
43
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
37
44
  import SearchInput from '@editor/components/SearchInput.vue';
@@ -47,6 +54,8 @@ defineOptions({
47
54
  });
48
55
 
49
56
  defineProps<{
57
+ indent?: number;
58
+ nextLevelIndentIncrement?: number;
50
59
  customError?: (id: Id, errorType: CodeDeleteErrorType) => any;
51
60
  }>();
52
61
 
@@ -24,9 +24,9 @@
24
24
  <script setup lang="ts">
25
25
  import { inject, Ref, ref, watchEffect } from 'vue';
26
26
 
27
+ import { DataSourceSchema } from '@tmagic/core';
27
28
  import { tMagicMessage } from '@tmagic/design';
28
29
  import { FormConfig, MFormBox } from '@tmagic/form';
29
- import { DataSourceSchema } from '@tmagic/schema';
30
30
 
31
31
  import FloatingBox from '@editor/components/FloatingBox.vue';
32
32
  import { useEditorContentHeight } from '@editor/hooks';
@@ -1,5 +1,11 @@
1
1
  <template>
2
- <Tree :data="list" :node-status-map="nodeStatusMap" @node-click="clickHandler">
2
+ <Tree
3
+ :data="list"
4
+ :node-status-map="nodeStatusMap"
5
+ :indent="indent"
6
+ :next-level-indent-increment="nextLevelIndentIncrement"
7
+ @node-click="clickHandler"
8
+ >
3
9
  <template #tree-node-label="{ data }">
4
10
  <div
5
11
  :class="{
@@ -27,9 +33,8 @@
27
33
  import { computed, inject } from 'vue';
28
34
  import { Close, Edit, View } from '@element-plus/icons-vue';
29
35
 
30
- import { DepTargetType } from '@tmagic/dep';
36
+ import { DepData, DepTargetType, Id, MNode } from '@tmagic/core';
31
37
  import { tMagicMessageBox, TMagicTooltip } from '@tmagic/design';
32
- import { DepData, Id, MNode } from '@tmagic/schema';
33
38
 
34
39
  import Icon from '@editor/components/Icon.vue';
35
40
  import Tree from '@editor/components/Tree.vue';
@@ -43,6 +48,11 @@ defineOptions({
43
48
  name: 'MEditorDataSourceList',
44
49
  });
45
50
 
51
+ defineProps<{
52
+ indent?: number;
53
+ nextLevelIndentIncrement?: number;
54
+ }>();
55
+
46
56
  const emit = defineEmits<{
47
57
  edit: [id: string];
48
58
  remove: [id: string];
@@ -2,7 +2,13 @@
2
2
  <TMagicScrollbar class="data-source-list-panel m-editor-layer-panel">
3
3
  <div class="search-wrapper">
4
4
  <SearchInput @search="filterTextChangeHandler"></SearchInput>
5
- <TMagicPopover v-if="editable" placement="right" trigger="hover" popper-class="data-source-list-panel-add-menu">
5
+ <TMagicPopover
6
+ v-if="editable"
7
+ placement="right"
8
+ trigger="hover"
9
+ popper-class="data-source-list-panel-add-menu"
10
+ :destroy-on-close="true"
11
+ >
6
12
  <template #reference>
7
13
  <TMagicButton type="primary" size="small">新增</TMagicButton>
8
14
  </template>
@@ -23,7 +29,13 @@
23
29
  </div>
24
30
 
25
31
  <!-- 数据源列表 -->
26
- <DataSourceList ref="dataSourceList" @edit="editHandler" @remove="removeHandler"></DataSourceList>
32
+ <DataSourceList
33
+ ref="dataSourceList"
34
+ :indent="indent"
35
+ :next-level-indent-increment="nextLevelIndentIncrement"
36
+ @edit="editHandler"
37
+ @remove="removeHandler"
38
+ ></DataSourceList>
27
39
  </TMagicScrollbar>
28
40
 
29
41
  <DataSourceConfigPanel
@@ -55,6 +67,11 @@ defineOptions({
55
67
  name: 'MEditorDataSourceListPanel',
56
68
  });
57
69
 
70
+ defineProps<{
71
+ indent?: number;
72
+ nextLevelIndentIncrement?: number;
73
+ }>();
74
+
58
75
  const eventBus = inject<EventBus>('eventBus');
59
76
  const { dataSourceService } = inject<Services>('services') || {};
60
77
 
@@ -9,7 +9,7 @@
9
9
  import { inject } from 'vue';
10
10
  import { Hide, View } from '@element-plus/icons-vue';
11
11
 
12
- import type { MNode } from '@tmagic/schema';
12
+ import type { MNode } from '@tmagic/core';
13
13
 
14
14
  import MIcon from '@editor/components/Icon.vue';
15
15
  import { Services } from '@editor/type';
@@ -10,6 +10,8 @@
10
10
  ref="tree"
11
11
  :data="nodeData"
12
12
  :node-status-map="nodeStatusMap"
13
+ :indent="indent"
14
+ :next-level-indent-increment="nextLevelIndentIncrement"
13
15
  @node-dragover="handleDragOver"
14
16
  @node-dragstart="handleDragStart"
15
17
  @node-dragleave="handleDragLeave"
@@ -47,8 +49,8 @@
47
49
  <script setup lang="ts">
48
50
  import { computed, inject, ref } from 'vue';
49
51
 
52
+ import type { MNode } from '@tmagic/core';
50
53
  import { TMagicScrollbar } from '@tmagic/design';
51
- import type { MNode } from '@tmagic/schema';
52
54
 
53
55
  import SearchInput from '@editor/components/SearchInput.vue';
54
56
  import Tree from '@editor/components/Tree.vue';
@@ -70,6 +72,8 @@ defineOptions({
70
72
 
71
73
  defineProps<{
72
74
  layerContentMenu: (MenuButton | MenuComponent)[];
75
+ indent?: number;
76
+ nextLevelIndentIncrement?: number;
73
77
  customContentMenu?: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
74
78
  }>();
75
79
 
@@ -1,7 +1,7 @@
1
1
  import { computed, type ComputedRef, nextTick, type Ref, ref } from 'vue';
2
2
  import { throttle } from 'lodash-es';
3
3
 
4
- import { Id, MNode } from '@tmagic/schema';
4
+ import { Id, MNode } from '@tmagic/core';
5
5
  import { isPage, isPageFragment } from '@tmagic/utils';
6
6
 
7
7
  import { LayerNodeStatus, Services, TreeNodeData, UI_SELECT_MODE_EVENT_NAME } from '@editor/type';
@@ -1,4 +1,4 @@
1
- import type { Id, MContainer, MNode } from '@tmagic/schema';
1
+ import type { Id, MContainer, MNode } from '@tmagic/core';
2
2
  import { addClassName, removeClassName } from '@tmagic/utils';
3
3
 
4
4
  import { DragType, type Services } from '@editor/type';
@@ -1,10 +1,9 @@
1
1
  import { computed, ref, watch } from 'vue';
2
2
 
3
- import type { Id, MNode, MPage, MPageFragment } from '@tmagic/schema';
4
- import { getNodePath, isPage, isPageFragment } from '@tmagic/utils';
3
+ import type { Id, MNode, MPage, MPageFragment } from '@tmagic/core';
4
+ import { getNodePath, isPage, isPageFragment, traverseNode } from '@tmagic/utils';
5
5
 
6
- import { LayerNodeStatus, Services } from '@editor/type';
7
- import { traverseNode } from '@editor/utils';
6
+ import type { LayerNodeStatus, Services } from '@editor/type';
8
7
  import { updateStatus } from '@editor/utils/tree';
9
8
 
10
9
  const createPageNodeStatus = (page: MPage | MPageFragment, initialLayerNodeStatus?: Map<Id, LayerNodeStatus>) => {
@@ -10,8 +10,8 @@
10
10
  <script setup lang="ts">
11
11
  import { computed, inject } from 'vue';
12
12
 
13
+ import type { MNode } from '@tmagic/core';
13
14
  import { TMagicButton } from '@tmagic/design';
14
- import type { MNode } from '@tmagic/schema';
15
15
  import { getNodePath } from '@tmagic/utils';
16
16
 
17
17
  import type { Services } from '@editor/type';
@@ -24,8 +24,8 @@
24
24
  <script lang="ts" setup>
25
25
  import { computed, inject, nextTick, ref, watch } from 'vue';
26
26
 
27
+ import type { MNode } from '@tmagic/core';
27
28
  import { TMagicTooltip } from '@tmagic/design';
28
- import type { MNode } from '@tmagic/schema';
29
29
  import { getIdFromEl } from '@tmagic/utils';
30
30
 
31
31
  import FloatingBox from '@editor/components/FloatingBox.vue';
@@ -61,7 +61,7 @@ const unWatch = watch(
61
61
  nextTick(() => unWatch());
62
62
 
63
63
  stage.on('select', (el: HTMLElement, event: MouseEvent) => {
64
- const els = stage.renderer.getElementsFromPoint(event) || [];
64
+ const els = stage.renderer?.getElementsFromPoint(event) || [];
65
65
  const ids = els.map((el) => getIdFromEl()(el)).filter((id) => Boolean(id)) as string[];
66
66
 
67
67
  buttonVisible.value = ids.length > 3;
@@ -44,14 +44,14 @@
44
44
  import { computed, inject, markRaw, nextTick, onBeforeUnmount, onMounted, ref, toRaw, watch, watchEffect } from 'vue';
45
45
  import { cloneDeep } from 'lodash-es';
46
46
 
47
- import type { MApp, MContainer } from '@tmagic/schema';
47
+ import type { MApp, MContainer } from '@tmagic/core';
48
48
  import StageCore, { getOffset, Runtime } from '@tmagic/stage';
49
49
  import { calcValueByFontsize, getIdFromEl } from '@tmagic/utils';
50
50
 
51
51
  import ScrollViewer from '@editor/components/ScrollViewer.vue';
52
52
  import { useStage } from '@editor/hooks/use-stage';
53
53
  import { DragType, Layout, type MenuButton, type MenuComponent, type Services, type StageOptions } from '@editor/type';
54
- import { getConfig } from '@editor/utils/config';
54
+ import { getEditorConfig } from '@editor/utils/config';
55
55
  import { KeyBindingContainerKey } from '@editor/utils/keybinding-config';
56
56
 
57
57
  import NodeListMenu from './NodeListMenu.vue';
@@ -123,6 +123,10 @@ watchEffect(() => {
123
123
  });
124
124
  });
125
125
 
126
+ onBeforeUnmount(() => {
127
+ stage?.destroy();
128
+ });
129
+
126
130
  watch(zoom, (zoom) => {
127
131
  if (!stage || !zoom) return;
128
132
  stage.setZoom(zoom);
@@ -170,7 +174,7 @@ onBeforeUnmount(() => {
170
174
  services?.editorService.off('root-change', rootChangeHandler);
171
175
  });
172
176
 
173
- const parseDSL = getConfig('parseDSL');
177
+ const parseDSL = getEditorConfig('parseDSL');
174
178
 
175
179
  const contextmenuHandler = (e: MouseEvent) => {
176
180
  e.preventDefault();
@@ -196,7 +200,7 @@ const dropHandler = async (e: DragEvent) => {
196
200
 
197
201
  e.preventDefault();
198
202
 
199
- const doc = stage?.renderer.contentWindow?.document;
203
+ const doc = stage?.renderer?.contentWindow?.document;
200
204
  const parentEl: HTMLElement | null | undefined = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
201
205
 
202
206
  let parent: MContainer | undefined | null = page.value;
@@ -209,7 +213,7 @@ const dropHandler = async (e: DragEvent) => {
209
213
  const layout = await services?.editorService.getLayout(parent);
210
214
 
211
215
  const containerRect = stageContainer.value.getBoundingClientRect();
212
- const { scrollTop, scrollLeft } = stage.mask;
216
+ const { scrollTop, scrollLeft } = stage.mask!;
213
217
  const { style = {} } = config.data;
214
218
 
215
219
  let top = 0;
@@ -8,7 +8,7 @@
8
8
  </template>
9
9
 
10
10
  <script setup lang="ts">
11
- import { computed, inject, ref, watch } from 'vue';
11
+ import { computed, inject, onBeforeUnmount, ref, watch } from 'vue';
12
12
  import { CloseBold } from '@element-plus/icons-vue';
13
13
 
14
14
  import { TMagicIcon } from '@tmagic/design';
@@ -34,7 +34,7 @@ const style = computed(() => ({
34
34
  watch(stage, (stage) => {
35
35
  if (stage) {
36
36
  stage.on('dblclick', async (event: MouseEvent) => {
37
- const el = await stage.actionManager.getElementFromPoint(event);
37
+ const el = (await stage.actionManager?.getElementFromPoint(event)) || null;
38
38
  services?.stageOverlayService.openOverlay(el);
39
39
  });
40
40
  } else {
@@ -53,8 +53,8 @@ watch(stageOverlay, (stageOverlay) => {
53
53
 
54
54
  const { mask, renderer } = subStage;
55
55
 
56
- const { contentWindow } = renderer;
57
- mask.showRule(false);
56
+ const { contentWindow } = renderer!;
57
+ mask?.showRule(false);
58
58
 
59
59
  services?.stageOverlayService.updateOverlay();
60
60
 
@@ -62,6 +62,11 @@ watch(stageOverlay, (stageOverlay) => {
62
62
  }
63
63
  });
64
64
 
65
+ onBeforeUnmount(() => {
66
+ services?.stageOverlayService.get('stage')?.destroy();
67
+ services?.stageOverlayService.set('stage', null);
68
+ });
69
+
65
70
  const closeOverlayHandler = () => {
66
71
  services?.stageOverlayService.closeOverlay();
67
72
  };
@@ -6,7 +6,7 @@
6
6
  import { computed, inject, markRaw, ref, watch } from 'vue';
7
7
  import { Bottom, Top } from '@element-plus/icons-vue';
8
8
 
9
- import { NodeType } from '@tmagic/schema';
9
+ import { NodeType } from '@tmagic/core';
10
10
  import { isPage, isPageFragment } from '@tmagic/utils';
11
11
 
12
12
  import ContentMenu from '@editor/components/ContentMenu.vue';