@tmagic/editor 1.3.0-alpha.13 → 1.3.0-alpha.14

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 (63) hide show
  1. package/dist/style.css +41 -113
  2. package/dist/tmagic-editor.js +1307 -1197
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +1318 -1204
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +11 -11
  7. package/src/Editor.vue +0 -4
  8. package/src/components/CodeBlockEditor.vue +155 -0
  9. package/src/components/CodeParams.vue +59 -0
  10. package/src/fields/Code.vue +27 -19
  11. package/src/fields/CodeSelect.vue +7 -1
  12. package/src/fields/CodeSelectCol.vue +65 -74
  13. package/src/fields/DataSourceFields.vue +7 -9
  14. package/src/fields/DataSourceMethodSelect.vue +147 -0
  15. package/src/fields/DataSourceMethods.vue +103 -0
  16. package/src/fields/EventSelect.vue +33 -7
  17. package/src/icons/CodeIcon.vue +0 -2
  18. package/src/index.ts +8 -0
  19. package/src/layouts/CodeEditor.vue +32 -1
  20. package/src/layouts/Framework.vue +7 -3
  21. package/src/layouts/sidebar/Sidebar.vue +2 -10
  22. package/src/layouts/sidebar/code-block/CodeBlockList.vue +73 -124
  23. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +64 -0
  24. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +23 -33
  25. package/src/layouts/sidebar/data-source/DataSourceList.vue +111 -0
  26. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +13 -81
  27. package/src/services/codeBlock.ts +17 -70
  28. package/src/services/dataSource.ts +2 -0
  29. package/src/theme/code-block.scss +0 -122
  30. package/src/theme/code-editor.scss +27 -2
  31. package/src/theme/data-source-methods.scss +13 -0
  32. package/src/theme/event.scss +15 -12
  33. package/src/theme/theme.scss +1 -0
  34. package/src/type.ts +21 -6
  35. package/src/utils/data-source/index.ts +11 -0
  36. package/src/utils/use-code-block-edit.ts +84 -0
  37. package/src/utils/use-data-source-method.ts +101 -0
  38. package/types/components/CodeBlockEditor.vue.d.ts +21 -0
  39. package/types/components/CodeParams.vue.d.ts +26 -0
  40. package/types/components/ContentMenu.vue.d.ts +2 -2
  41. package/types/fields/Code.vue.d.ts +26 -6
  42. package/types/fields/CodeSelectCol.vue.d.ts +16 -5
  43. package/types/fields/DataSourceFields.vue.d.ts +2 -0
  44. package/types/fields/DataSourceMethodSelect.vue.d.ts +44 -0
  45. package/types/fields/DataSourceMethods.vue.d.ts +45 -0
  46. package/types/index.d.ts +4 -0
  47. package/types/layouts/CodeEditor.vue.d.ts +2 -0
  48. package/types/layouts/PropsPanel.vue.d.ts +8 -8
  49. package/types/layouts/sidebar/Sidebar.vue.d.ts +0 -3
  50. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +4 -9
  51. package/types/layouts/sidebar/code-block/{CodeBlockEditor.vue.d.ts → CodeBlockListPanel.vue.d.ts} +5 -6
  52. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -1
  53. package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +14 -0
  54. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +1 -11
  55. package/types/services/codeBlock.d.ts +5 -36
  56. package/types/services/dataSource.d.ts +1 -0
  57. package/types/type.d.ts +19 -6
  58. package/types/{components/FunctionEditor.vue.d.ts → utils/use-code-block-edit.d.ts} +26 -123
  59. package/types/utils/use-data-source-method.d.ts +116 -0
  60. package/src/components/CodeDraftEditor.vue +0 -148
  61. package/src/components/FunctionEditor.vue +0 -197
  62. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +0 -100
  63. package/types/components/CodeDraftEditor.vue.d.ts +0 -61
@@ -1,97 +1,69 @@
1
1
  <template>
2
- <TMagicScrollbar class="m-editor-code-block-list m-editor-dep-list-panel">
3
- <slot name="code-block-panel-header">
4
- <div class="search-wrapper">
5
- <SearchInput @search="filterTextChangeHandler"></SearchInput>
6
- <TMagicButton class="create-code-button" type="primary" size="small" @click="createCodeBlock" v-if="editable"
7
- >新增</TMagicButton
8
- >
9
- </div>
10
- </slot>
11
-
12
- <!-- 代码块列表 -->
13
- <TMagicTree
14
- ref="tree"
15
- class="magic-editor-layer-tree"
16
- node-key="id"
17
- empty-text="暂无代码块"
18
- :default-expanded-keys="expandedKeys"
19
- :expand-on-click-node="false"
20
- :data="codeList"
21
- :props="treeProps"
22
- :highlight-current="true"
23
- :filter-node-method="filterNode"
24
- @node-click="clickHandler"
25
- >
26
- <template #default="{ data }">
27
- <div :id="data.id" class="list-container">
28
- <div class="list-item">
29
- <CodeIcon v-if="data.type === 'code'" class="codeIcon"></CodeIcon>
30
- <AppManageIcon v-if="data.type === 'node'" class="compIcon"></AppManageIcon>
31
- <span class="name" :class="{ code: data.type === 'code', hook: data.type === 'key' }"
32
- >{{ data.name }} ({{ data.id }})</span
33
- >
34
- <!-- 右侧工具栏 -->
35
- <div class="right-tool" v-if="data.type === 'code'">
36
- <TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
37
- <Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(`${data.id}`)"></Icon>
38
- </TMagicTooltip>
39
- <TMagicTooltip effect="dark" content="删除" placement="bottom" v-if="editable">
40
- <Icon :icon="Close" class="edit-icon" @click.stop="deleteCode(`${data.id}`)"></Icon>
41
- </TMagicTooltip>
42
- <slot name="code-block-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
43
- </div>
2
+ <TMagicTree
3
+ ref="tree"
4
+ class="magic-editor-layer-tree"
5
+ node-key="id"
6
+ empty-text="暂无代码块"
7
+ :default-expanded-keys="expandedKeys"
8
+ :expand-on-click-node="false"
9
+ :data="codeList"
10
+ :props="{
11
+ children: 'children',
12
+ label: 'name',
13
+ value: 'id',
14
+ }"
15
+ :highlight-current="true"
16
+ :filter-node-method="filterNode"
17
+ @node-click="clickHandler"
18
+ >
19
+ <template #default="{ data }">
20
+ <div :id="data.id" class="list-container">
21
+ <div class="list-item">
22
+ <CodeIcon v-if="data.type === 'code'" class="codeIcon"></CodeIcon>
23
+ <AppManageIcon v-if="data.type === 'node'" class="compIcon"></AppManageIcon>
24
+ <span class="name" :class="{ code: data.type === 'code', hook: data.type === 'key' }"
25
+ >{{ data.name }} ({{ data.id }})</span
26
+ >
27
+ <!-- 右侧工具栏 -->
28
+ <div class="right-tool" v-if="data.type === 'code'">
29
+ <TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
30
+ <Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(data.id)"></Icon>
31
+ </TMagicTooltip>
32
+ <TMagicTooltip v-if="editable" effect="dark" content="删除" placement="bottom">
33
+ <Icon :icon="Close" class="edit-icon" @click.stop="deleteCode(`${data.id}`)"></Icon>
34
+ </TMagicTooltip>
35
+ <slot name="code-block-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
44
36
  </div>
45
37
  </div>
46
- </template>
47
- </TMagicTree>
48
-
49
- <!-- 代码块编辑区 -->
50
- <CodeBlockEditor v-if="isShowCodeBlockEditor" :paramsColConfig="paramsColConfig">
51
- <template #code-block-edit-panel-header="{ id }">
52
- <slot name="code-block-edit-panel-header" :id="id"></slot>
53
- </template>
54
- </CodeBlockEditor>
55
- </TMagicScrollbar>
38
+ </div>
39
+ </template>
40
+ </TMagicTree>
56
41
  </template>
57
42
 
58
- <script setup lang="ts">
43
+ <script lang="ts" setup>
59
44
  import { computed, inject, ref } from 'vue';
60
45
  import { Close, Edit, View } from '@element-plus/icons-vue';
61
46
 
62
- import {
63
- TMagicButton,
64
- tMagicMessage,
65
- tMagicMessageBox,
66
- TMagicScrollbar,
67
- TMagicTooltip,
68
- TMagicTree,
69
- } from '@tmagic/design';
70
- import { ColumnConfig } from '@tmagic/form';
71
- import { CodeBlockContent, Id } from '@tmagic/schema';
47
+ import { tMagicMessage, tMagicMessageBox, TMagicTooltip, TMagicTree } from '@tmagic/design';
48
+ import type { Id } from '@tmagic/schema';
72
49
 
73
50
  import Icon from '@editor/components/Icon.vue';
74
- import SearchInput from '@editor/components/SearchInput.vue';
75
51
  import AppManageIcon from '@editor/icons/AppManageIcon.vue';
76
52
  import CodeIcon from '@editor/icons/CodeIcon.vue';
77
53
  import { CodeDeleteErrorType, CodeDslItem, Services } from '@editor/type';
78
54
 
79
- import CodeBlockEditor from './CodeBlockEditor.vue';
80
-
81
55
  defineOptions({
82
56
  name: 'MEditorCodeBlockList',
83
57
  });
84
58
 
85
59
  const props = defineProps<{
86
60
  customError?: (id: Id, errorType: CodeDeleteErrorType) => any;
87
- paramsColConfig?: ColumnConfig;
88
61
  }>();
89
62
 
90
- const treeProps = {
91
- children: 'children',
92
- label: 'name',
93
- value: 'id',
94
- };
63
+ const emit = defineEmits<{
64
+ edit: [id: string];
65
+ remove: [id: string];
66
+ }>();
95
67
 
96
68
  const { codeBlockService, depService, editorService } = inject<Services>('services') || {};
97
69
 
@@ -114,45 +86,42 @@ const codeList = computed(() =>
114
86
  };
115
87
  }),
116
88
  );
117
-
118
89
  // 默认展开组件层级的节点
119
90
  const expandedKeys = computed(() => codeList.value.map((item) => item.id));
120
-
121
91
  const editable = computed(() => codeBlockService?.getEditStatus());
122
92
 
123
- // 是否展示代码编辑区
124
- const isShowCodeBlockEditor = computed(() => codeBlockService?.getCodeEditorShowStatus() || false);
125
-
126
- // 新增代码块
127
- const createCodeBlock = async () => {
128
- if (!codeBlockService) {
129
- tMagicMessage.error('新增代码块失败');
130
- return;
93
+ const filterNode = (value: string, data: CodeDslItem): boolean => {
94
+ if (!value) {
95
+ return true;
131
96
  }
97
+ return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
98
+ };
132
99
 
133
- const codeConfig: CodeBlockContent = {
134
- name: '代码块',
135
- content: `({app, params}) => {\n // place your code here\n}`,
136
- params: [],
137
- };
138
-
139
- const id = await codeBlockService.getUniqueId();
100
+ // 选中组件
101
+ const selectComp = (compId: Id) => {
102
+ const stage = editorService?.get('stage');
103
+ editorService?.select(compId);
104
+ stage?.select(compId);
105
+ };
140
106
 
141
- await codeBlockService.setCodeDslById(id, codeConfig);
142
- codeBlockService.setCodeEditorContent(true, id);
107
+ const clickHandler = (data: any, node: any) => {
108
+ if (data.type === 'node') {
109
+ selectComp(data.id);
110
+ } else if (data.type === 'key') {
111
+ selectComp(node.parent.data.id);
112
+ }
143
113
  };
144
114
 
145
115
  // 编辑代码块
146
- const editCode = async (key: Id) => {
147
- codeBlockService?.setCodeEditorContent(true, key);
116
+ const editCode = (id: string) => {
117
+ emit('edit', id);
148
118
  };
149
119
 
150
- // 删除代码块
151
- const deleteCode = async (key: Id) => {
152
- const currentCode = codeList.value.find((codeItem) => codeItem.id === key);
120
+ const deleteCode = async (id: string) => {
121
+ const currentCode = codeList.value.find((codeItem) => codeItem.id === id);
153
122
  const existBinds = Boolean(currentCode?.children.length);
154
123
  const undeleteableList = codeBlockService?.getUndeletableList() || [];
155
- if (!existBinds && !undeleteableList.includes(key)) {
124
+ if (!existBinds && !undeleteableList.includes(id)) {
156
125
  await tMagicMessageBox.confirm('确定删除该代码块吗?', '提示', {
157
126
  confirmButtonText: '确定',
158
127
  cancelButtonText: '取消',
@@ -160,10 +129,10 @@ const deleteCode = async (key: Id) => {
160
129
  });
161
130
 
162
131
  // 无绑定关系,且不在不可删除列表中
163
- codeBlockService?.deleteCodeDslByIds([key]);
132
+ emit('remove', id);
164
133
  } else {
165
134
  if (typeof props.customError === 'function') {
166
- props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
135
+ props.customError(id, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
167
136
  } else {
168
137
  tMagicMessage.error('代码块删除失败');
169
138
  }
@@ -172,29 +141,9 @@ const deleteCode = async (key: Id) => {
172
141
 
173
142
  const tree = ref<InstanceType<typeof TMagicTree>>();
174
143
 
175
- const filterNode = (value: string, data: CodeDslItem): boolean => {
176
- if (!value) {
177
- return true;
178
- }
179
- return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
180
- };
181
-
182
- const filterTextChangeHandler = (val: string) => {
183
- tree.value?.filter(val);
184
- };
185
-
186
- // 选中组件
187
- const selectComp = (compId: Id) => {
188
- const stage = editorService?.get('stage');
189
- editorService?.select(compId);
190
- stage?.select(compId);
191
- };
192
-
193
- const clickHandler = (data: any, node: any) => {
194
- if (data.type === 'node') {
195
- selectComp(data.id);
196
- } else if (data.type === 'key') {
197
- selectComp(node.parent.data.id);
198
- }
199
- };
144
+ defineExpose({
145
+ filter(val: string) {
146
+ tree.value?.filter(val);
147
+ },
148
+ });
200
149
  </script>
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <TMagicScrollbar class="m-editor-code-block-list m-editor-dep-list-panel">
3
+ <slot name="code-block-panel-header">
4
+ <div class="search-wrapper">
5
+ <SearchInput @search="filterTextChangeHandler"></SearchInput>
6
+ <TMagicButton v-if="editable" class="create-code-button" type="primary" size="small" @click="createCodeBlock"
7
+ >新增</TMagicButton
8
+ >
9
+ </div>
10
+ </slot>
11
+
12
+ <!-- 代码块列表 -->
13
+ <CodeBlockList
14
+ ref="codeBlockList"
15
+ :custom-error="customError"
16
+ @edit="editCode"
17
+ @remove="deleteCode"
18
+ ></CodeBlockList>
19
+
20
+ <!-- 代码块编辑区 -->
21
+ <CodeBlockEditor
22
+ v-if="codeConfig"
23
+ ref="codeBlockEditor"
24
+ :disabled="!editable"
25
+ :content="codeConfig"
26
+ @submit="submitCodeBlockHandler"
27
+ ></CodeBlockEditor>
28
+ </TMagicScrollbar>
29
+ </template>
30
+
31
+ <script setup lang="ts">
32
+ import { computed, inject, ref } from 'vue';
33
+
34
+ import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
35
+ import type { Id } from '@tmagic/schema';
36
+
37
+ import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
38
+ import SearchInput from '@editor/components/SearchInput.vue';
39
+ import type { CodeDeleteErrorType, Services } from '@editor/type';
40
+ import { useCodeBlockEdit } from '@editor/utils/use-code-block-edit';
41
+
42
+ import CodeBlockList from './CodeBlockList.vue';
43
+
44
+ defineOptions({
45
+ name: 'MEditorCodeBlockListPanel',
46
+ });
47
+
48
+ defineProps<{
49
+ customError?: (id: Id, errorType: CodeDeleteErrorType) => any;
50
+ }>();
51
+
52
+ const { codeBlockService } = inject<Services>('services') || {};
53
+
54
+ const editable = computed(() => codeBlockService?.getEditStatus());
55
+
56
+ const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } =
57
+ useCodeBlockEdit(codeBlockService);
58
+
59
+ const codeBlockList = ref<InstanceType<typeof CodeBlockList>>();
60
+
61
+ const filterTextChangeHandler = (val: string) => {
62
+ codeBlockList.value?.filter(val);
63
+ };
64
+ </script>
@@ -1,29 +1,23 @@
1
1
  <template>
2
- <TMagicDrawer
3
- v-model="visible"
2
+ <MFormDrawer
3
+ ref="fomDrawer"
4
+ label-width="80px"
4
5
  :title="title"
5
- :close-on-press-escape="true"
6
- :append-to-body="true"
7
- :show-close="true"
8
- :close-on-click-modal="true"
9
- :size="size"
10
- >
11
- <MForm ref="form" :config="dataSourceConfig" :init-values="initValues" @change="changeHandler"></MForm>
12
-
13
- <template #footer>
14
- <div>
15
- <TMagicButton type="primary" @click="submitHandler">确定</TMagicButton>
16
- <TMagicButton @click="hide">关闭</TMagicButton>
17
- </div>
18
- </template>
19
- </TMagicDrawer>
6
+ :width="size"
7
+ :config="dataSourceConfig"
8
+ :values="initValues"
9
+ :disabled="disabled"
10
+ @change="changeHandler"
11
+ @submit="submitHandler"
12
+ @error="errorHandler"
13
+ ></MFormDrawer>
20
14
  </template>
21
15
 
22
16
  <script setup lang="ts">
23
17
  import { computed, inject, ref, watchEffect } from 'vue';
24
18
 
25
- import { TMagicButton, TMagicDrawer, tMagicMessage } from '@tmagic/design';
26
- import { MForm } from '@tmagic/form';
19
+ import { tMagicMessage } from '@tmagic/design';
20
+ import { MFormDrawer } from '@tmagic/form';
27
21
 
28
22
  import type { Services } from '@editor/type';
29
23
 
@@ -34,6 +28,7 @@ defineOptions({
34
28
  const props = defineProps<{
35
29
  title?: string;
36
30
  values: any;
31
+ disabled: boolean;
37
32
  }>();
38
33
 
39
34
  const type = ref('base');
@@ -46,7 +41,7 @@ const size = computed(() => globalThis.document.body.clientWidth - (services?.ui
46
41
 
47
42
  const dataSourceConfig = computed(() => services?.dataSourceService.getFormConfig(type.value) || []);
48
43
 
49
- const form = ref<InstanceType<typeof MForm>>();
44
+ const fomDrawer = ref<InstanceType<typeof MFormDrawer>>();
50
45
 
51
46
  const initValues = ref({});
52
47
 
@@ -63,26 +58,21 @@ const changeHandler = (value: Record<string, any>) => {
63
58
  initValues.value = value;
64
59
  };
65
60
 
66
- const submitHandler = async () => {
67
- try {
68
- const values = await form.value?.submitForm();
69
- emit('submit', values);
70
- } catch (error: any) {
71
- tMagicMessage.error(error.message);
72
- }
61
+ const submitHandler = (values: any) => {
62
+ emit('submit', values);
73
63
  };
74
64
 
75
- const visible = ref(false);
76
-
77
- const hide = () => {
78
- visible.value = false;
65
+ const errorHandler = (error: any) => {
66
+ tMagicMessage.error(error.message);
79
67
  };
80
68
 
81
69
  defineExpose({
82
70
  show() {
83
- visible.value = true;
71
+ fomDrawer.value?.show();
84
72
  },
85
73
 
86
- hide,
74
+ hide() {
75
+ fomDrawer.value?.hide();
76
+ },
87
77
  });
88
78
  </script>
@@ -0,0 +1,111 @@
1
+ <template>
2
+ <TMagicTree
3
+ ref="tree"
4
+ class="magic-editor-layer-tree"
5
+ node-key="id"
6
+ empty-text="暂无代码块"
7
+ default-expand-all
8
+ :expand-on-click-node="false"
9
+ :data="list"
10
+ :highlight-current="true"
11
+ @node-click="clickHandler"
12
+ >
13
+ <template #default="{ data }">
14
+ <div :id="data.id" class="list-container">
15
+ <div class="list-item">
16
+ <Icon v-if="data.type === 'code'" class="codeIcon" :icon="Coin"></Icon>
17
+ <Icon v-if="data.type === 'node'" class="compIcon" :icon="Aim"></Icon>
18
+ <span class="name" :class="{ code: data.type === 'code', hook: data.type === 'key' }"
19
+ >{{ data.name }}({{ data.id }})</span
20
+ >
21
+ <!-- 右侧工具栏 -->
22
+ <div class="right-tool" v-if="data.type === 'code'">
23
+ <TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
24
+ <Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editHandler(`${data.id}`)"></Icon>
25
+ </TMagicTooltip>
26
+ <TMagicTooltip v-if="editable" effect="dark" content="删除" placement="bottom">
27
+ <Icon :icon="Close" class="edit-icon" @click.stop="removeHandler(`${data.id}`)"></Icon>
28
+ </TMagicTooltip>
29
+ <slot name="data-source-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </template>
34
+ </TMagicTree>
35
+ </template>
36
+
37
+ <script lang="ts" setup>
38
+ import { computed, inject, ref } from 'vue';
39
+ import { Aim, Close, Coin, Edit, View } from '@element-plus/icons-vue';
40
+
41
+ import { tMagicMessageBox, TMagicTooltip, TMagicTree } from '@tmagic/design';
42
+ import { Id } from '@tmagic/schema';
43
+
44
+ import Icon from '@editor/components/Icon.vue';
45
+ import type { Services } from '@editor/type';
46
+
47
+ defineOptions({
48
+ name: 'MEditorDataSourceList',
49
+ });
50
+
51
+ const emit = defineEmits<{
52
+ edit: [id: string];
53
+ remove: [id: string];
54
+ }>();
55
+
56
+ const { depService, editorService, dataSourceService } = inject<Services>('services') || {};
57
+
58
+ const editable = computed(() => dataSourceService?.get('editable') ?? true);
59
+
60
+ const list = computed(() =>
61
+ Object.values(depService?.targets['data-source'] || {}).map((target) => ({
62
+ id: target.id,
63
+ name: target.name,
64
+ type: 'code',
65
+ children: Object.entries(target.deps).map(([id, dep]) => ({
66
+ name: dep.name,
67
+ type: 'node',
68
+ id,
69
+ children: dep.keys.map((key) => ({ name: key, id: key, type: 'key' })),
70
+ })),
71
+ })),
72
+ );
73
+
74
+ const editHandler = (id: string) => {
75
+ emit('edit', id);
76
+ };
77
+
78
+ const removeHandler = async (id: string) => {
79
+ await tMagicMessageBox.confirm('确定删除?', '提示', {
80
+ confirmButtonText: '确定',
81
+ cancelButtonText: '取消',
82
+ type: 'warning',
83
+ });
84
+
85
+ emit('remove', id);
86
+ };
87
+
88
+ // 选中组件
89
+ const selectComp = (compId: Id) => {
90
+ const stage = editorService?.get('stage');
91
+ editorService?.select(compId);
92
+ stage?.select(compId);
93
+ };
94
+
95
+ const clickHandler = (data: any, node: any) => {
96
+ if (data.type === 'node') {
97
+ selectComp(data.id);
98
+ } else if (data.type === 'key') {
99
+ selectComp(node.parent.data.id);
100
+ }
101
+ };
102
+
103
+ const tree = ref<InstanceType<typeof TMagicTree>>();
104
+
105
+ defineExpose({
106
+ filter(val: string) {
107
+ debugger;
108
+ tree.value?.filter(val);
109
+ },
110
+ });
111
+ </script>