@tmagic/editor 1.5.0-beta.4 → 1.5.0-beta.6

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 (76) hide show
  1. package/dist/style.css +274 -2
  2. package/dist/tmagic-editor.js +103 -46
  3. package/dist/tmagic-editor.umd.cjs +325 -242
  4. package/package.json +7 -9
  5. package/src/Editor.vue +8 -2
  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 +5 -2
  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 +1 -1
  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 +2 -2
  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 +1 -1
  30. package/src/hooks/use-node-status.ts +1 -1
  31. package/src/hooks/use-stage.ts +2 -6
  32. package/src/index.ts +27 -7
  33. package/src/initService.ts +11 -3
  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 +1 -1
  41. package/src/layouts/page-bar/PageBarScrollContainer.vue +1 -1
  42. package/src/layouts/page-bar/PageList.vue +1 -1
  43. package/src/layouts/page-bar/SwitchTypeButton.vue +1 -1
  44. package/src/layouts/sidebar/Sidebar.vue +12 -0
  45. package/src/layouts/sidebar/code-block/CodeBlockList.vue +11 -3
  46. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +11 -2
  47. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +1 -1
  48. package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -3
  49. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +12 -1
  50. package/src/layouts/sidebar/layer/LayerNodeTool.vue +1 -1
  51. package/src/layouts/sidebar/layer/LayerPanel.vue +5 -1
  52. package/src/layouts/sidebar/layer/use-click.ts +1 -1
  53. package/src/layouts/sidebar/layer/use-drag.ts +1 -1
  54. package/src/layouts/sidebar/layer/use-node-status.ts +1 -1
  55. package/src/layouts/workspace/Breadcrumb.vue +1 -1
  56. package/src/layouts/workspace/viewer/NodeListMenu.vue +1 -1
  57. package/src/layouts/workspace/viewer/Stage.vue +7 -3
  58. package/src/layouts/workspace/viewer/StageOverlay.vue +6 -1
  59. package/src/layouts/workspace/viewer/ViewerMenu.vue +1 -1
  60. package/src/services/codeBlock.ts +7 -7
  61. package/src/services/dataSource.ts +3 -4
  62. package/src/services/dep.ts +2 -2
  63. package/src/services/editor.ts +7 -8
  64. package/src/services/history.ts +1 -1
  65. package/src/services/props.ts +3 -3
  66. package/src/services/storage.ts +2 -2
  67. package/src/theme/index.scss +3 -0
  68. package/src/type.ts +13 -10
  69. package/src/utils/config.ts +5 -5
  70. package/src/utils/content-menu.ts +1 -1
  71. package/src/utils/data-source/index.ts +1 -1
  72. package/src/utils/editor.ts +2 -8
  73. package/src/utils/operator.ts +2 -1
  74. package/src/utils/props.ts +1 -1
  75. package/src/utils/tree.ts +1 -1
  76. package/types/index.d.ts +53 -29
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.0-beta.4",
2
+ "version": "1.5.0-beta.6",
3
3
  "name": "@tmagic/editor",
4
4
  "type": "module",
5
5
  "sideEffects": [
@@ -55,8 +55,11 @@
55
55
  "moveable": "^0.53.0",
56
56
  "serialize-javascript": "^6.0.0",
57
57
  "sortablejs": "^1.15.2",
58
- "@tmagic/dep": "1.5.0-beta.4",
59
- "@tmagic/table": "1.5.0-beta.4"
58
+ "@tmagic/design": "1.5.0-beta.6",
59
+ "@tmagic/table": "1.5.0-beta.6",
60
+ "@tmagic/stage": "1.5.0-beta.6",
61
+ "@tmagic/utils": "1.5.0-beta.6",
62
+ "@tmagic/form": "1.5.0-beta.6"
60
63
  },
61
64
  "devDependencies": {
62
65
  "@types/events": "^3.0.0",
@@ -77,12 +80,7 @@
77
80
  "monaco-editor": "^0.48.0",
78
81
  "typescript": "*",
79
82
  "vue": "^3.4.35",
80
- "@tmagic/design": "1.5.0-beta.4",
81
- "@tmagic/core": "1.5.0-beta.4",
82
- "@tmagic/schema": "1.5.0-beta.4",
83
- "@tmagic/stage": "1.5.0-beta.4",
84
- "@tmagic/utils": "1.5.0-beta.4",
85
- "@tmagic/form": "1.5.0-beta.4"
83
+ "@tmagic/core": "1.5.0-beta.6"
86
84
  },
87
85
  "peerDependenciesMeta": {
88
86
  "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';
@@ -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,6 +80,10 @@ export interface EditorProps {
81
80
  disabledStageOverlay?: boolean;
82
81
  /** 禁用属性配置面板右下角显示源码的按钮 */
83
82
  disabledShowSrc?: boolean;
83
+ /** 已选组件、代码编辑、数据源缩进配置 */
84
+ treeIndent?: number;
85
+ /** 已选组件、代码编辑、数据源子节点缩进增量配置 */
86
+ treeNextLevelIndentIncrement?: number;
84
87
  /** 中间工作区域中画布渲染的内容 */
85
88
  render?: (stage: StageCore) => HTMLDivElement | void | Promise<HTMLDivElement | void>;
86
89
  /** 选中时会在画布上复制出一个大小相同的dom,实际拖拽的是这个dom,此方法用于干预这个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';
@@ -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,11 +53,11 @@ 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
61
  import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX } from '@tmagic/utils';
62
62
 
63
63
  import type { CodeSelectColConfig, DataSourceMethodSelectConfig, EventSelectConfig, Services } from '@editor/type';
@@ -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,6 +1,6 @@
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
4
 
5
5
  import type { LayerNodeStatus, TreeNodeData } from '@editor/type';
6
6
  import { traverseNode } from '@editor/utils';
@@ -1,6 +1,6 @@
1
1
  import { ComputedRef, ref, watch } from 'vue';
2
2
 
3
- import type { Id, MNode } from '@tmagic/schema';
3
+ import type { Id, MNode } from '@tmagic/core';
4
4
 
5
5
  import { LayerNodeStatus, TreeNodeData } from '@editor/type';
6
6
  import { traverseNode } from '@editor/utils';
@@ -1,6 +1,6 @@
1
- import { computed, onBeforeUnmount, watch } from 'vue';
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
 
@@ -131,9 +131,5 @@ export const useStage = (stageOptions: StageOptions) => {
131
131
  }
132
132
  });
133
133
 
134
- onBeforeUnmount(() => {
135
- stage.destroy();
136
- });
137
-
138
134
  return stage;
139
135
  };
package/src/index.ts CHANGED
@@ -17,6 +17,12 @@
17
17
  */
18
18
  import { App } from 'vue';
19
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';
25
+
20
26
  import Code from './fields/Code.vue';
21
27
  import CodeLink from './fields/CodeLink.vue';
22
28
  import CodeSelect from './fields/CodeSelect.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);
@@ -1,7 +1,16 @@
1
1
  import { onBeforeUnmount, reactive, toRaw, watch } from 'vue';
2
2
  import { cloneDeep } from 'lodash-es';
3
3
 
4
- import type { EventOption } from '@tmagic/core';
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,8 +18,7 @@ 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';
21
+ } from '@tmagic/core';
14
22
  import { isPage } from '@tmagic/utils';
15
23
 
16
24
  import PropsPanel from './layouts/PropsPanel.vue';
@@ -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
  }