@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
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
- "version": "1.5.0-beta.1",
2
+ "version": "1.5.0-beta.11",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
+ "dist/style.css",
6
7
  "src/theme/*"
7
8
  ],
8
9
  "main": "dist/tmagic-editor.umd.cjs",
@@ -55,8 +56,11 @@
55
56
  "moveable": "^0.53.0",
56
57
  "serialize-javascript": "^6.0.0",
57
58
  "sortablejs": "^1.15.2",
58
- "@tmagic/table": "1.5.0-beta.1",
59
- "@tmagic/dep": "1.5.0-beta.1"
59
+ "@tmagic/design": "1.5.0-beta.11",
60
+ "@tmagic/stage": "1.5.0-beta.11",
61
+ "@tmagic/form": "1.5.0-beta.11",
62
+ "@tmagic/table": "1.5.0-beta.11",
63
+ "@tmagic/utils": "1.5.0-beta.11"
60
64
  },
61
65
  "devDependencies": {
62
66
  "@types/events": "^3.0.0",
@@ -64,25 +68,20 @@
64
68
  "@types/node": "^18.19.0",
65
69
  "@types/serialize-javascript": "^5.0.1",
66
70
  "@types/sortablejs": "^1.15.8",
67
- "@vitejs/plugin-vue": "^5.1.1",
68
- "@vue/compiler-sfc": "^3.4.27",
71
+ "@vitejs/plugin-vue": "^5.1.3",
72
+ "@vue/compiler-sfc": "^3.5.0",
69
73
  "@vue/test-utils": "^2.4.6",
70
74
  "rimraf": "^3.0.2",
71
- "sass": "^1.77.0",
75
+ "sass": "^1.78.0",
72
76
  "tsc-alias": "^1.8.5",
73
77
  "type-fest": "^4.10.3",
74
- "vite": "^5.3.5"
78
+ "vite": "^5.4.3"
75
79
  },
76
80
  "peerDependencies": {
77
81
  "monaco-editor": "^0.48.0",
78
82
  "typescript": "*",
79
- "vue": "^3.4.35",
80
- "@tmagic/core": "1.5.0-beta.1",
81
- "@tmagic/design": "1.5.0-beta.1",
82
- "@tmagic/form": "1.5.0-beta.1",
83
- "@tmagic/schema": "1.5.0-beta.1",
84
- "@tmagic/stage": "1.5.0-beta.1",
85
- "@tmagic/utils": "1.5.0-beta.1"
83
+ "vue": "^3.5.0",
84
+ "@tmagic/core": "1.5.0-beta.11"
86
85
  },
87
86
  "peerDependenciesMeta": {
88
87
  "typescript": {
package/src/Editor.vue CHANGED
@@ -16,7 +16,13 @@
16
16
 
17
17
  <template #sidebar>
18
18
  <slot name="sidebar" :editorService="editorService">
19
- <Sidebar :data="sidebar" :layer-content-menu="layerContentMenu" :custom-content-menu="customContentMenu">
19
+ <Sidebar
20
+ :data="sidebar"
21
+ :layer-content-menu="layerContentMenu"
22
+ :custom-content-menu="customContentMenu"
23
+ :indent="treeIndent"
24
+ :next-level-indent-increment="treeNextLevelIndentIncrement"
25
+ >
20
26
  <template #layer-panel-header>
21
27
  <slot name="layer-panel-header"></slot>
22
28
  </template>
@@ -119,7 +125,7 @@ import { EventEmitter } from 'events';
119
125
 
120
126
  import { provide } from 'vue';
121
127
 
122
- import type { MApp } from '@tmagic/schema';
128
+ import type { MApp } from '@tmagic/core';
123
129
 
124
130
  import Framework from './layouts/Framework.vue';
125
131
  import TMagicNavMenu from './layouts/NavMenu.vue';
@@ -141,7 +147,15 @@ import uiService from './services/ui';
141
147
  import keybindingConfig from './utils/keybinding-config';
142
148
  import { defaultEditorProps, EditorProps } from './editorProps';
143
149
  import { initServiceEvents, initServiceState } from './initService';
144
- import type { EventBus, FrameworkSlots, PropsPanelSlots, Services, SidebarSlots, WorkspaceSlots } from './type';
150
+ import type {
151
+ EventBus,
152
+ FrameworkSlots,
153
+ PropsPanelSlots,
154
+ Services,
155
+ SidebarSlots,
156
+ StageOptions,
157
+ WorkspaceSlots,
158
+ } from './type';
145
159
 
146
160
  defineSlots<
147
161
  FrameworkSlots &
@@ -186,7 +200,7 @@ initServiceState(props, services);
186
200
  keybindingService.register(keybindingConfig);
187
201
  keybindingService.registerEl('global');
188
202
 
189
- const stageOptions = {
203
+ const stageOptions: StageOptions = {
190
204
  runtimeUrl: props.runtimeUrl,
191
205
  autoScrollIntoView: props.autoScrollIntoView,
192
206
  render: props.render,
@@ -61,9 +61,9 @@
61
61
  <script lang="ts" setup>
62
62
  import { computed, inject, Ref, ref } from 'vue';
63
63
 
64
+ import type { CodeBlockContent } from '@tmagic/core';
64
65
  import { TMagicButton, TMagicDialog, tMagicMessage, tMagicMessageBox, TMagicTag } from '@tmagic/design';
65
- import { ColumnConfig, FormConfig, FormState, MFormBox } from '@tmagic/form';
66
- import type { CodeBlockContent } from '@tmagic/schema';
66
+ import { type FormConfig, type FormState, MFormBox, type TableColumnConfig } from '@tmagic/form';
67
67
 
68
68
  import FloatingBox from '@editor/components/FloatingBox.vue';
69
69
  import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
@@ -71,7 +71,7 @@ import { useNextFloatBoxPosition } from '@editor/hooks/use-next-float-box-positi
71
71
  import { useWindowRect } from '@editor/hooks/use-window-rect';
72
72
  import CodeEditor from '@editor/layouts/CodeEditor.vue';
73
73
  import type { Services } from '@editor/type';
74
- import { getConfig } from '@editor/utils/config';
74
+ import { getEditorConfig } from '@editor/utils/config';
75
75
 
76
76
  defineOptions({
77
77
  name: 'MEditorCodeBlockEditor',
@@ -110,7 +110,7 @@ const diffChange = () => {
110
110
  difVisible.value = false;
111
111
  };
112
112
 
113
- const defaultParamColConfig: ColumnConfig = {
113
+ const defaultParamColConfig: TableColumnConfig = {
114
114
  type: 'row',
115
115
  label: '参数类型',
116
116
  items: [
@@ -197,7 +197,7 @@ const functionConfig = computed<FormConfig>(() => [
197
197
  onChange: (formState: FormState | undefined, code: string) => {
198
198
  try {
199
199
  // 检测js代码是否存在语法错误
200
- getConfig('parseDSL')(code);
200
+ getEditorConfig('parseDSL')(code);
201
201
 
202
202
  return code;
203
203
  } catch (error: any) {
@@ -32,6 +32,7 @@ const filterTextChangeHandler = () => {
32
32
  timer && clearTimeout(timer);
33
33
  timer = setTimeout(() => {
34
34
  emit('search', filterText.value);
35
+ timer = null;
35
36
  }, 300);
36
37
  };
37
38
  </script>
@@ -1,7 +1,14 @@
1
1
  <template>
2
2
  <div class="m-editor-tree" @dragover="handleDragOver">
3
3
  <template v-if="data?.length">
4
- <TreeNode v-for="item in data" :key="item.id" :data="item" :indent="indent" :node-status-map="nodeStatusMap">
4
+ <TreeNode
5
+ v-for="item in data"
6
+ :key="item.id"
7
+ :data="item"
8
+ :indent="indent"
9
+ :next-level-indent-increment="nextLevelIndentIncrement"
10
+ :node-status-map="nodeStatusMap"
11
+ >
5
12
  <template #tree-node-content="{ data: nodeData }">
6
13
  <slot name="tree-node-content" :data="nodeData"> </slot>
7
14
  </template>
@@ -24,7 +31,7 @@
24
31
  <script setup lang="ts">
25
32
  import { provide } from 'vue';
26
33
 
27
- import type { Id } from '@tmagic/schema';
34
+ import type { Id } from '@tmagic/core';
28
35
 
29
36
  import type { LayerNodeStatus, TreeNodeData } from '@editor/type';
30
37
 
@@ -57,6 +64,7 @@ withDefaults(
57
64
  data: TreeNodeData[];
58
65
  nodeStatusMap: Map<Id, LayerNodeStatus>;
59
66
  indent?: number;
67
+ nextLevelIndentIncrement?: number;
60
68
  emptyText?: string;
61
69
  }>(),
62
70
  {
@@ -45,7 +45,7 @@
45
45
  :parent="data"
46
46
  :parentsId="[...parentsId, data.id]"
47
47
  :node-status-map="nodeStatusMap"
48
- :indent="indent + 11"
48
+ :indent="indent + nextLevelIndentIncrement"
49
49
  >
50
50
  <template #tree-node-content="{ data: nodeData }">
51
51
  <slot name="tree-node-content" :data="nodeData"> </slot>
@@ -65,7 +65,7 @@
65
65
  import { computed, inject } from 'vue';
66
66
  import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
67
67
 
68
- import type { Id } from '@tmagic/schema';
68
+ import type { Id } from '@tmagic/core';
69
69
 
70
70
  import MIcon from '@editor/components/Icon.vue';
71
71
  import type { LayerNodeStatus, TreeNodeData } from '@editor/type';
@@ -99,9 +99,11 @@ const props = withDefaults(
99
99
  parentsId?: Id[];
100
100
  nodeStatusMap: Map<Id, LayerNodeStatus>;
101
101
  indent?: number;
102
+ nextLevelIndentIncrement?: number;
102
103
  }>(),
103
104
  {
104
105
  indent: 0,
106
+ nextLevelIndentIncrement: 11,
105
107
  parentsId: () => [],
106
108
  },
107
109
  );
@@ -1,6 +1,5 @@
1
- import type { EventOption } from '@tmagic/core';
1
+ import type { DataSourceSchema, EventOption, Id, MApp, MNode } from '@tmagic/core';
2
2
  import type { FormConfig, FormState } from '@tmagic/form';
3
- import type { DataSourceSchema, Id, MApp, MNode } from '@tmagic/schema';
4
3
  import StageCore, {
5
4
  CONTAINER_HIGHLIGHT_CLASS_NAME,
6
5
  ContainerHighlightType,
@@ -81,8 +80,12 @@ export interface EditorProps {
81
80
  disabledStageOverlay?: boolean;
82
81
  /** 禁用属性配置面板右下角显示源码的按钮 */
83
82
  disabledShowSrc?: boolean;
83
+ /** 已选组件、代码编辑、数据源缩进配置 */
84
+ treeIndent?: number;
85
+ /** 已选组件、代码编辑、数据源子节点缩进增量配置 */
86
+ treeNextLevelIndentIncrement?: number;
84
87
  /** 中间工作区域中画布渲染的内容 */
85
- render?: (stage: StageCore) => HTMLDivElement | Promise<HTMLDivElement>;
88
+ render?: (stage: StageCore) => HTMLDivElement | void | Promise<HTMLDivElement | void>;
86
89
  /** 选中时会在画布上复制出一个大小相同的dom,实际拖拽的是这个dom,此方法用于干预这个dom的生成方式 */
87
90
  updateDragEl?: UpdateDragEl;
88
91
  /** 用于设置画布上的dom是否可以被选中 */
@@ -8,7 +8,7 @@ import serialize from 'serialize-javascript';
8
8
 
9
9
  import type { FieldProps, FormItem } from '@tmagic/form';
10
10
 
11
- import { getConfig } from '@editor/utils/config';
11
+ import { getEditorConfig } from '@editor/utils/config';
12
12
 
13
13
  defineOptions({
14
14
  name: 'MFieldsCodeLink',
@@ -70,7 +70,7 @@ const changeHandler = (v: Record<string, any>) => {
70
70
  if (!props.name || !props.model) return;
71
71
 
72
72
  try {
73
- const parseDSL = getConfig('parseDSL');
73
+ const parseDSL = getEditorConfig('parseDSL');
74
74
  props.model[props.name] = parseDSL(`(${v[props.name]})`);
75
75
  emit('change', props.model[props.name]);
76
76
  } catch (e) {
@@ -19,10 +19,10 @@
19
19
  import { computed, inject, watch } from 'vue';
20
20
  import { isEmpty } from 'lodash-es';
21
21
 
22
+ import { HookCodeType, HookType } from '@tmagic/core';
22
23
  import { TMagicCard } from '@tmagic/design';
23
24
  import type { FieldProps, FormItem } from '@tmagic/form';
24
25
  import { FormState, MContainer } from '@tmagic/form';
25
- import { HookCodeType, HookType } from '@tmagic/schema';
26
26
 
27
27
  import type { Services } from '@editor/type';
28
28
 
@@ -39,9 +39,9 @@ import { computed, inject, ref, watch } from 'vue';
39
39
  import { Edit, View } from '@element-plus/icons-vue';
40
40
  import { isEmpty, map } from 'lodash-es';
41
41
 
42
+ import type { Id } from '@tmagic/core';
42
43
  import { TMagicButton } from '@tmagic/design';
43
44
  import { createValues, type FieldProps, filterFunction, type FormState, MContainer } from '@tmagic/form';
44
- import type { Id } from '@tmagic/schema';
45
45
 
46
46
  import CodeParams from '@editor/components/CodeParams.vue';
47
47
  import MIcon from '@editor/components/Icon.vue';
@@ -29,7 +29,7 @@
29
29
  <script setup lang="ts">
30
30
  import { computed, inject } from 'vue';
31
31
 
32
- import { getConfig as getDesignConfig, TMagicSelect } from '@tmagic/design';
32
+ import { getDesignConfig, TMagicSelect } from '@tmagic/design';
33
33
  import type { FieldProps } from '@tmagic/form';
34
34
 
35
35
  import type { CondOpSelectConfig, Services } from '@editor/type';
@@ -69,15 +69,9 @@
69
69
  import { computed, inject, ref, watch } from 'vue';
70
70
  import { Edit, View } from '@element-plus/icons-vue';
71
71
 
72
- import {
73
- getConfig as getDesignConfig,
74
- TMagicButton,
75
- TMagicCascader,
76
- TMagicSelect,
77
- TMagicTooltip,
78
- } from '@tmagic/design';
72
+ import { DataSourceFieldType } from '@tmagic/core';
73
+ import { getDesignConfig, TMagicButton, TMagicCascader, TMagicSelect, TMagicTooltip } from '@tmagic/design';
79
74
  import { type FilterFunction, filterFunction, type FormState, type SelectOption } from '@tmagic/form';
80
- import { DataSourceFieldType } from '@tmagic/schema';
81
75
  import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
82
76
 
83
77
  import MIcon from '@editor/components/Icon.vue';
@@ -22,7 +22,7 @@
22
22
  :last-values="lastValues"
23
23
  :init-values="initValues"
24
24
  :values="values"
25
- :prop="`${prop}${prop ? '.' : ''}${name}`"
25
+ :prop="prop"
26
26
  @change="onChangeHandler"
27
27
  ></component>
28
28
 
@@ -42,9 +42,9 @@
42
42
  import { computed, inject, ref, resolveComponent, watch } from 'vue';
43
43
  import { Coin } from '@element-plus/icons-vue';
44
44
 
45
+ import { DataSchema } from '@tmagic/core';
45
46
  import { TMagicButton, tMagicMessage, TMagicTooltip } from '@tmagic/design';
46
47
  import type { FieldProps, FormState } from '@tmagic/form';
47
- import { DataSchema } from '@tmagic/schema';
48
48
  import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
49
49
 
50
50
  import MIcon from '@editor/components/Icon.vue';
@@ -49,9 +49,9 @@
49
49
  <script setup lang="ts">
50
50
  import { inject, Ref, ref } from 'vue';
51
51
 
52
+ import type { DataSchema } from '@tmagic/core';
52
53
  import { TMagicButton, tMagicMessage, tMagicMessageBox } from '@tmagic/design';
53
54
  import { type FieldProps, type FormConfig, type FormState, MFormBox } from '@tmagic/form';
54
- import type { DataSchema } from '@tmagic/schema';
55
55
  import { type ColumnConfig, MagicTable } from '@tmagic/table';
56
56
  import { getDefaultValueFromFields } from '@tmagic/utils';
57
57
 
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <component
3
3
  v-if="disabled || isFocused"
4
- :is="getConfig('components')?.autocomplete.component || 'el-autocomplete'"
4
+ :is="getDesignConfig('components')?.autocomplete.component || 'el-autocomplete'"
5
5
  class="tmagic-design-auto-complete"
6
6
  ref="autocomplete"
7
7
  v-model="state"
8
8
  v-bind="
9
- getConfig('components')?.autocomplete.props({
9
+ getDesignConfig('components')?.autocomplete.props({
10
10
  disabled,
11
11
  size,
12
12
  fetchSuggestions: querySearch,
@@ -51,9 +51,9 @@
51
51
  import { computed, inject, nextTick, ref, watch } from 'vue';
52
52
  import { Coin } from '@element-plus/icons-vue';
53
53
 
54
- import { getConfig, TMagicAutocomplete, TMagicTag } from '@tmagic/design';
54
+ import type { DataSchema, DataSourceSchema } from '@tmagic/core';
55
+ import { getDesignConfig, TMagicAutocomplete, TMagicTag } from '@tmagic/design';
55
56
  import type { FieldProps, FormItem } from '@tmagic/form';
56
- import type { DataSchema, DataSourceSchema } from '@tmagic/schema';
57
57
  import { getKeysArray, isNumber } from '@tmagic/utils';
58
58
 
59
59
  import Icon from '@editor/components/Icon.vue';
@@ -35,9 +35,9 @@
35
35
  import { computed, inject, ref } from 'vue';
36
36
  import { Edit, View } from '@element-plus/icons-vue';
37
37
 
38
+ import type { Id } from '@tmagic/core';
38
39
  import { TMagicButton, TMagicTooltip } from '@tmagic/design';
39
40
  import { createValues, type FieldProps, filterFunction, type FormState, MContainer } from '@tmagic/form';
40
- import type { Id } from '@tmagic/schema';
41
41
 
42
42
  import CodeParams from '@editor/components/CodeParams.vue';
43
43
  import MIcon from '@editor/components/Icon.vue';
@@ -21,9 +21,9 @@
21
21
  </template>
22
22
 
23
23
  <script setup lang="ts">
24
+ import type { CodeBlockContent } from '@tmagic/core';
24
25
  import { TMagicButton } from '@tmagic/design';
25
26
  import type { FieldProps } from '@tmagic/form';
26
- import type { CodeBlockContent } from '@tmagic/schema';
27
27
  import { type ColumnConfig, MagicTable } from '@tmagic/table';
28
28
 
29
29
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
@@ -31,9 +31,9 @@
31
31
  <script setup lang="ts">
32
32
  import { inject, Ref, ref } from 'vue';
33
33
 
34
+ import type { MockSchema } from '@tmagic/core';
34
35
  import { TMagicButton, tMagicMessageBox, TMagicSwitch } from '@tmagic/design';
35
36
  import { type FieldProps, type FormConfig, type FormState, MFormBox } from '@tmagic/form';
36
- import type { MockSchema } from '@tmagic/schema';
37
37
  import { type ColumnConfig, MagicTable } from '@tmagic/table';
38
38
  import { getDefaultValueFromFields } from '@tmagic/utils';
39
39
 
@@ -15,6 +15,7 @@
15
15
  <script lang="ts" setup>
16
16
  import { computed, inject } from 'vue';
17
17
 
18
+ import type { DisplayCond } from '@tmagic/core';
18
19
  import {
19
20
  type FieldProps,
20
21
  type FilterFunction,
@@ -23,7 +24,6 @@ import {
23
24
  type GroupListConfig,
24
25
  MGroupList,
25
26
  } from '@tmagic/form';
26
- import type { DisplayCond } from '@tmagic/schema';
27
27
 
28
28
  import type { Services } from '@editor/type';
29
29
  import { getCascaderOptionsFromFields } from '@editor/utils';
@@ -53,15 +53,15 @@ import { computed, inject } from 'vue';
53
53
  import { Delete } from '@element-plus/icons-vue';
54
54
  import { has } from 'lodash-es';
55
55
 
56
- import type { EventOption } from '@tmagic/core';
56
+ import type { EventOption, MComponent, MContainer } from '@tmagic/core';
57
+ import { ActionType } from '@tmagic/core';
57
58
  import { TMagicButton } from '@tmagic/design';
58
59
  import type { CascaderOption, ChildConfig, FieldProps, FormState, PanelConfig } from '@tmagic/form';
59
60
  import { MContainer as MFormContainer, MPanel } from '@tmagic/form';
60
- import { ActionType, type MComponent, type MContainer } from '@tmagic/schema';
61
- import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX } from '@tmagic/utils';
61
+ import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, traverseNode } from '@tmagic/utils';
62
62
 
63
63
  import type { CodeSelectColConfig, DataSourceMethodSelectConfig, EventSelectConfig, Services } from '@editor/type';
64
- import { getCascaderOptionsFromFields, traverseNode } from '@editor/utils';
64
+ import { getCascaderOptionsFromFields } from '@editor/utils';
65
65
 
66
66
  defineOptions({
67
67
  name: 'MFieldsEventSelect',
@@ -19,8 +19,8 @@
19
19
  import { computed, inject } from 'vue';
20
20
  import { Edit } from '@element-plus/icons-vue';
21
21
 
22
+ import { Id, NodeType } from '@tmagic/core';
22
23
  import { FieldProps } from '@tmagic/form';
23
- import { Id, NodeType } from '@tmagic/schema';
24
24
 
25
25
  import Icon from '@editor/components/Icon.vue';
26
26
  import type { PageFragmentSelectConfig, Services } from '@editor/type';
@@ -45,9 +45,9 @@ import { computed, inject, ref } from 'vue';
45
45
  import { Close, Delete } from '@element-plus/icons-vue';
46
46
  import { throttle } from 'lodash-es';
47
47
 
48
+ import type { Id } from '@tmagic/core';
48
49
  import { TMagicButton, TMagicTooltip } from '@tmagic/design';
49
50
  import type { FieldProps, FormItem, FormState } from '@tmagic/form';
50
- import type { Id } from '@tmagic/schema';
51
51
  import { getIdFromEl } from '@tmagic/utils';
52
52
 
53
53
  import { type Services, UI_SELECT_MODE_EVENT_NAME } from '@editor/type';
@@ -1,8 +1,8 @@
1
1
  import { nextTick, ref } from 'vue';
2
2
  import { cloneDeep } from 'lodash-es';
3
3
 
4
+ import type { CodeBlockContent } from '@tmagic/core';
4
5
  import { tMagicMessage } from '@tmagic/design';
5
- import type { CodeBlockContent } from '@tmagic/schema';
6
6
 
7
7
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
8
8
  import type { CodeBlockService } from '@editor/services/codeBlock';
@@ -1,6 +1,6 @@
1
1
  import { computed, ref } from 'vue';
2
2
 
3
- import type { DataSourceSchema } from '@tmagic/schema';
3
+ import type { DataSourceSchema } from '@tmagic/core';
4
4
 
5
5
  import DataSourceConfigPanel from '@editor/layouts/sidebar/data-source/DataSourceConfigPanel.vue';
6
6
  import type { DataSourceService } from '@editor/services/dataSource';
@@ -1,11 +1,11 @@
1
1
  import { nextTick, ref } from 'vue';
2
2
  import { cloneDeep } from 'lodash-es';
3
3
 
4
+ import type { CodeBlockContent, DataSourceSchema } from '@tmagic/core';
4
5
  import { tMagicMessage } from '@tmagic/design';
5
- import type { CodeBlockContent, DataSourceSchema } from '@tmagic/schema';
6
6
 
7
7
  import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
8
- import { getConfig } from '@editor/utils/config';
8
+ import { getEditorConfig } from '@editor/utils/config';
9
9
 
10
10
  export const useDataSourceMethod = () => {
11
11
  const codeConfig = ref<CodeBlockContent>();
@@ -81,7 +81,7 @@ export const useDataSourceMethod = () => {
81
81
 
82
82
  if (values.content) {
83
83
  // 在保存的时候转换代码内容
84
- const parseDSL = getConfig('parseDSL');
84
+ const parseDSL = getEditorConfig('parseDSL');
85
85
  if (typeof values.content === 'string') {
86
86
  values.content = parseDSL<(...args: any[]) => any>(values.content);
87
87
  }
@@ -1,9 +1,9 @@
1
1
  import { type Ref, ref } from 'vue';
2
2
 
3
- import type { Id, MNode } from '@tmagic/schema';
3
+ import type { Id, MNode } from '@tmagic/core';
4
+ import { traverseNode } from '@tmagic/utils';
4
5
 
5
6
  import type { LayerNodeStatus, TreeNodeData } from '@editor/type';
6
- import { traverseNode } from '@editor/utils';
7
7
  import { updateStatus } from '@editor/utils/tree';
8
8
 
9
9
  export const useFilter = (
@@ -1,9 +1,9 @@
1
- import { ComputedRef, ref, watch } from 'vue';
1
+ import { type ComputedRef, ref, watch } from 'vue';
2
2
 
3
- import type { Id, MNode } from '@tmagic/schema';
3
+ import type { Id, MNode } from '@tmagic/core';
4
+ import { traverseNode } from '@tmagic/utils';
4
5
 
5
6
  import { LayerNodeStatus, TreeNodeData } from '@editor/type';
6
- import { traverseNode } from '@editor/utils';
7
7
 
8
8
  const createPageNodeStatus = (nodeData: TreeNodeData[], initialLayerNodeStatus?: Map<Id, LayerNodeStatus>) => {
9
9
  const map = new Map<Id, LayerNodeStatus>();
@@ -1,6 +1,6 @@
1
1
  import { computed, watch } from 'vue';
2
2
 
3
- import type { MNode } from '@tmagic/schema';
3
+ import type { MNode } from '@tmagic/core';
4
4
  import StageCore, { GuidesType, RemoveEventData, SortEventData, UpdateEventData } from '@tmagic/stage';
5
5
  import { getIdFromEl } from '@tmagic/utils';
6
6
 
@@ -62,7 +62,7 @@ export const useStage = (stageOptions: StageOptions) => {
62
62
  },
63
63
  );
64
64
 
65
- stage.mask.setGuides([
65
+ stage.mask?.setGuides([
66
66
  getGuideLineFromCache(getGuideLineKey(H_GUIDE_LINE_STORAGE_KEY)),
67
67
  getGuideLineFromCache(getGuideLineKey(V_GUIDE_LINE_STORAGE_KEY)),
68
68
  ]);
package/src/index.ts CHANGED
@@ -15,7 +15,13 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- import { App } from 'vue';
18
+ import type { App } from 'vue';
19
+
20
+ import type { DesignPluginOptions } from '@tmagic/design';
21
+ import designPlugin from '@tmagic/design';
22
+ import type { FormInstallOptions } from '@tmagic/form';
23
+ import formPlugin from '@tmagic/form';
24
+ import tablePlugin from '@tmagic/table';
19
25
 
20
26
  import Code from './fields/Code.vue';
21
27
  import CodeLink from './fields/CodeLink.vue';
@@ -35,16 +41,25 @@ import KeyValue from './fields/KeyValue.vue';
35
41
  import PageFragmentSelect from './fields/PageFragmentSelect.vue';
36
42
  import uiSelect from './fields/UISelect.vue';
37
43
  import CodeEditor from './layouts/CodeEditor.vue';
38
- import { setConfig } from './utils/config';
44
+ import { setEditorConfig } from './utils/config';
39
45
  import Editor from './Editor.vue';
40
- import type { InstallOptions } from './type';
46
+ import type { EditorInstallOptions } from './type';
41
47
 
42
48
  import './theme/index.scss';
43
49
 
50
+ export * from '@tmagic/form';
51
+ export { default as formPlugin } from '@tmagic/form';
52
+ export * from '@tmagic/table';
53
+ export { default as tablePlugin } from '@tmagic/table';
54
+ export * from '@tmagic/stage';
55
+ export { default as StageCore } from '@tmagic/stage';
56
+ export * from '@tmagic/design';
57
+ export { default as designPlugin } from '@tmagic/design';
58
+ export * from '@tmagic/utils';
59
+
44
60
  export type { OnDrag } from 'gesto';
45
61
 
46
- export { DepTargetType } from '@tmagic/dep';
47
- export type { MoveableOptions } from '@tmagic/stage';
62
+ export { DepTargetType } from '@tmagic/core';
48
63
  export * from './type';
49
64
  export * from './hooks';
50
65
  export * from './utils';
@@ -91,18 +106,23 @@ export { default as PageFragmentSelect } from './fields/PageFragmentSelect.vue';
91
106
  export { default as DisplayConds } from './fields/DisplayConds.vue';
92
107
  export { default as CondOpSelect } from './fields/CondOpSelect.vue';
93
108
 
94
- const defaultInstallOpt: InstallOptions = {
109
+ const defaultInstallOpt: EditorInstallOptions = {
95
110
  // eslint-disable-next-line no-eval
96
111
  parseDSL: (dsl: string) => eval(dsl),
97
112
  };
98
113
 
99
114
  export default {
100
- install: (app: App, opt?: Partial<InstallOptions>): void => {
115
+ install: (app: App, opt?: Partial<EditorInstallOptions | DesignPluginOptions | FormInstallOptions>): void => {
101
116
  const option = Object.assign(defaultInstallOpt, opt || {});
102
117
 
118
+ app.use(designPlugin, opt || {});
119
+ app.use(formPlugin, opt || {});
120
+ app.use(tablePlugin);
121
+
103
122
  // eslint-disable-next-line no-param-reassign
104
123
  app.config.globalProperties.$TMAGIC_EDITOR = option;
105
- setConfig(option);
124
+ setEditorConfig(option);
125
+
106
126
  app.component(`${Editor.name || 'MEditor'}`, Editor);
107
127
  app.component('magic-code-editor', CodeEditor);
108
128
  app.component('m-fields-ui-select', uiSelect);