@tmagic/editor 1.3.0-alpha.0 → 1.3.0-alpha.10

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 (124) hide show
  1. package/dist/style.css +46 -9
  2. package/dist/tmagic-editor.js +1764 -871
  3. package/dist/tmagic-editor.js.map +1 -1
  4. package/dist/tmagic-editor.umd.cjs +1781 -882
  5. package/dist/tmagic-editor.umd.cjs.map +1 -1
  6. package/package.json +19 -20
  7. package/src/Editor.vue +29 -3
  8. package/src/components/CodeDraftEditor.vue +5 -1
  9. package/src/components/ContentMenu.vue +30 -11
  10. package/src/components/FunctionEditor.vue +12 -5
  11. package/src/components/Icon.vue +5 -1
  12. package/src/components/Resizer.vue +45 -0
  13. package/src/components/ScrollBar.vue +5 -1
  14. package/src/components/ScrollViewer.vue +5 -1
  15. package/src/components/SearchInput.vue +4 -0
  16. package/src/components/{Layout.vue → SplitView.vue} +8 -4
  17. package/src/components/ToolButton.vue +5 -1
  18. package/src/editorProps.ts +5 -1
  19. package/src/fields/Code.vue +5 -1
  20. package/src/fields/CodeLink.vue +9 -3
  21. package/src/fields/CodeSelect.vue +8 -2
  22. package/src/fields/CodeSelectCol.vue +6 -2
  23. package/src/fields/DataSourceFields.vue +5 -1
  24. package/src/fields/DataSourceInput.vue +358 -0
  25. package/src/fields/DataSourceSelect.vue +75 -0
  26. package/src/fields/EventSelect.vue +9 -3
  27. package/src/fields/KeyValue.vue +4 -0
  28. package/src/fields/UISelect.vue +5 -1
  29. package/src/icons/AppManageIcon.vue +5 -1
  30. package/src/icons/CenterIcon.vue +13 -0
  31. package/src/icons/CodeIcon.vue +5 -1
  32. package/src/index.ts +13 -3
  33. package/src/initService.ts +73 -0
  34. package/src/layouts/AddPageBox.vue +5 -1
  35. package/src/layouts/CodeEditor.vue +34 -10
  36. package/src/layouts/Framework.vue +25 -25
  37. package/src/layouts/NavMenu.vue +5 -1
  38. package/src/layouts/PropsPanel.vue +14 -4
  39. package/src/layouts/sidebar/ComponentListPanel.vue +8 -5
  40. package/src/layouts/sidebar/LayerMenu.vue +13 -25
  41. package/src/layouts/sidebar/LayerNode.vue +40 -0
  42. package/src/layouts/sidebar/LayerPanel.vue +70 -27
  43. package/src/layouts/sidebar/Sidebar.vue +11 -7
  44. package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +8 -4
  45. package/src/layouts/sidebar/code-block/CodeBlockList.vue +5 -1
  46. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +4 -0
  47. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +22 -2
  48. package/src/layouts/workspace/Breadcrumb.vue +5 -1
  49. package/src/layouts/workspace/PageBar.vue +5 -1
  50. package/src/layouts/workspace/PageBarScrollContainer.vue +5 -1
  51. package/src/layouts/workspace/Stage.vue +29 -7
  52. package/src/layouts/workspace/ViewerMenu.vue +15 -36
  53. package/src/layouts/workspace/Workspace.vue +9 -134
  54. package/src/services/codeBlock.ts +3 -2
  55. package/src/services/dep.ts +4 -0
  56. package/src/services/keybinding.ts +185 -0
  57. package/src/services/storage.ts +3 -2
  58. package/src/theme/content-menu.scss +1 -1
  59. package/src/theme/data-source-input.scss +18 -0
  60. package/src/theme/framework.scss +0 -3
  61. package/src/theme/layer-panel.scss +6 -0
  62. package/src/theme/layout.scss +4 -0
  63. package/src/theme/resizer.scss +25 -10
  64. package/src/theme/stage.scss +4 -0
  65. package/src/theme/theme.scss +1 -0
  66. package/src/type.ts +59 -1
  67. package/src/utils/config.ts +1 -1
  68. package/src/utils/content-menu.ts +92 -0
  69. package/src/utils/dep.ts +7 -1
  70. package/src/utils/keybinding-config.ts +120 -0
  71. package/src/utils/props.ts +34 -0
  72. package/types/Editor.vue.d.ts +7 -1
  73. package/types/components/CodeDraftEditor.vue.d.ts +6 -3
  74. package/types/components/ContentMenu.vue.d.ts +10 -5
  75. package/types/components/FunctionEditor.vue.d.ts +74 -51
  76. package/types/components/Icon.vue.d.ts +2 -2
  77. package/types/{layouts → components}/Resizer.vue.d.ts +2 -2
  78. package/types/components/ScrollBar.vue.d.ts +1 -1
  79. package/types/components/ScrollViewer.vue.d.ts +8 -5
  80. package/types/components/SearchInput.vue.d.ts +1 -1
  81. package/types/components/{Layout.vue.d.ts → SplitView.vue.d.ts} +9 -6
  82. package/types/components/ToolButton.vue.d.ts +8 -5
  83. package/types/editorProps.d.ts +4 -1
  84. package/types/fields/Code.vue.d.ts +1 -1
  85. package/types/fields/CodeLink.vue.d.ts +9 -9
  86. package/types/fields/CodeSelect.vue.d.ts +10 -7
  87. package/types/fields/CodeSelectCol.vue.d.ts +8 -5
  88. package/types/fields/DataSourceFields.vue.d.ts +8 -5
  89. package/types/fields/DataSourceInput.vue.d.ts +54 -0
  90. package/types/fields/DataSourceSelect.vue.d.ts +56 -0
  91. package/types/fields/EventSelect.vue.d.ts +3 -3
  92. package/types/fields/KeyValue.vue.d.ts +8 -5
  93. package/types/fields/UISelect.vue.d.ts +1 -1
  94. package/types/icons/AppManageIcon.vue.d.ts +1 -1
  95. package/types/icons/CenterIcon.vue.d.ts +2 -0
  96. package/types/icons/CodeIcon.vue.d.ts +1 -1
  97. package/types/index.d.ts +7 -2
  98. package/types/initService.d.ts +1 -1
  99. package/types/layouts/AddPageBox.vue.d.ts +1 -1
  100. package/types/layouts/CodeEditor.vue.d.ts +16 -10
  101. package/types/layouts/Framework.vue.d.ts +11 -32
  102. package/types/layouts/NavMenu.vue.d.ts +7 -4
  103. package/types/layouts/PropsPanel.vue.d.ts +276 -4
  104. package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +4 -4
  105. package/types/layouts/sidebar/LayerMenu.vue.d.ts +2 -2
  106. package/types/layouts/sidebar/LayerNode.vue.d.ts +16 -0
  107. package/types/layouts/sidebar/LayerPanel.vue.d.ts +5 -5
  108. package/types/layouts/sidebar/Sidebar.vue.d.ts +18 -15
  109. package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +4 -4
  110. package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +7 -7
  111. package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +1 -1
  112. package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +3 -3
  113. package/types/layouts/workspace/Breadcrumb.vue.d.ts +1 -1
  114. package/types/layouts/workspace/PageBar.vue.d.ts +5 -5
  115. package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +2 -2
  116. package/types/layouts/workspace/Stage.vue.d.ts +2 -2
  117. package/types/layouts/workspace/ViewerMenu.vue.d.ts +7 -4
  118. package/types/layouts/workspace/Workspace.vue.d.ts +9 -9
  119. package/types/services/keybinding.d.ts +20 -0
  120. package/types/type.d.ts +56 -1
  121. package/types/utils/config.d.ts +1 -1
  122. package/types/utils/content-menu.d.ts +7 -0
  123. package/types/utils/keybinding-config.d.ts +3 -0
  124. package/src/layouts/Resizer.vue +0 -32
@@ -0,0 +1,358 @@
1
+ <template>
2
+ <component
3
+ v-if="disabled || isFocused"
4
+ :is="getConfig('components')?.autocomplete.component || 'el-autocomplete'"
5
+ class="tmagic-design-auto-complete"
6
+ ref="autocomplete"
7
+ v-model="state"
8
+ v-bind="
9
+ getConfig('components')?.autocomplete.props({
10
+ disabled,
11
+ size,
12
+ fetchSuggestions: querySearch,
13
+ triggerOnFocus: false,
14
+ clearable: true,
15
+ }) || {}
16
+ "
17
+ style="width: 100%"
18
+ @blur="blurHandler"
19
+ @change="changeHandler"
20
+ @input="inputHandler"
21
+ @select="selectHandler"
22
+ >
23
+ <template #suffix>
24
+ <Icon :icon="Coin" />
25
+ </template>
26
+ <template #default="{ item }">
27
+ <div style="display: flex; flex-direction: column; line-height: 1.2em">
28
+ <div>{{ item.text }}</div>
29
+ <span style="font-size: 10px; color: rgba(0, 0, 0, 0.6)">{{ item.value }}</span>
30
+ </div>
31
+ </template>
32
+ </component>
33
+ <div :class="`tmagic-data-source-input-text el-input el-input--${size}`" @mouseup="mouseupHandler" v-else>
34
+ <div :class="`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused ? ' is-focus' : ''}`">
35
+ <div class="el-input__inner">
36
+ <template v-for="(item, index) in displayState">
37
+ <span :key="index" v-if="item.type === 'text'" style="margin-right: 2px">{{ item.value }}</span>
38
+ <TMagicTag :key="index" :size="size" v-if="item.type === 'var'">{{ item.value }}</TMagicTag>
39
+ </template>
40
+
41
+ <Icon class="tmagic-data-source-input-icon" :icon="Coin" />
42
+ </div>
43
+ </div>
44
+ </div>
45
+ </template>
46
+
47
+ <script setup lang="ts">
48
+ import { computed, inject, nextTick, ref, watch } from 'vue';
49
+ import { Coin } from '@element-plus/icons-vue';
50
+
51
+ import { FieldSize, getConfig, TMagicAutocomplete, TMagicTag } from '@tmagic/design';
52
+ import type { DataSchema, DataSourceSchema } from '@tmagic/schema';
53
+
54
+ import Icon from '@editor/components/Icon.vue';
55
+ import type { Services } from '@editor/type';
56
+
57
+ defineOptions({
58
+ name: 'MEditorDataSourceInput',
59
+ });
60
+
61
+ const props = withDefaults(
62
+ defineProps<{
63
+ config: {
64
+ type: 'data-source-input';
65
+ name: string;
66
+ text: string;
67
+ };
68
+ model: Record<string, any>;
69
+ name: string;
70
+ prop: string;
71
+ disabled: boolean;
72
+ lastValues?: Record<string, any>;
73
+ size?: FieldSize;
74
+ }>(),
75
+ {
76
+ disabled: false,
77
+ },
78
+ );
79
+
80
+ const emit = defineEmits<(e: 'change', value: string) => void>();
81
+
82
+ const { dataSourceService } = inject<Services>('services') || {};
83
+
84
+ const autocomplete = ref<InstanceType<typeof TMagicAutocomplete>>();
85
+ const isFocused = ref(false);
86
+ const state = ref('');
87
+ const displayState = ref<{ value: string; type: 'var' | 'text' }[]>([]);
88
+
89
+ const input = computed<HTMLInputElement>(() => autocomplete.value?.inputRef?.input);
90
+ const dataSources = computed(() => dataSourceService?.get('dataSources') || []);
91
+
92
+ const setDisplayState = () => {
93
+ displayState.value = [];
94
+
95
+ const matches = state.value.matchAll(/\$\{([\s\S]+?)\}/g);
96
+ let index = 0;
97
+ for (const match of matches) {
98
+ if (typeof match.index === 'undefined') break;
99
+
100
+ displayState.value.push({
101
+ type: 'text',
102
+ value: state.value.substring(index, match.index),
103
+ });
104
+
105
+ let dsText = '';
106
+ let ds: DataSourceSchema | undefined;
107
+ let fields: DataSchema[] | undefined;
108
+
109
+ match[1].split('.').forEach((item, index) => {
110
+ if (index === 0) {
111
+ ds = dataSources.value.find((ds) => ds.id === item);
112
+ dsText += ds?.title || item;
113
+ fields = ds?.fields;
114
+ return;
115
+ }
116
+
117
+ const field = fields?.find((field) => field.name === item);
118
+ fields = field?.fields;
119
+ dsText += `.${field?.title || item}`;
120
+ });
121
+
122
+ displayState.value.push({
123
+ type: 'var',
124
+ value: dsText,
125
+ });
126
+
127
+ index = match.index + match[0].length;
128
+ }
129
+
130
+ if (index < state.value.length) {
131
+ displayState.value.push({
132
+ type: 'text',
133
+ value: state.value.substring(index),
134
+ });
135
+ }
136
+ };
137
+
138
+ watch(
139
+ () => props.model[props.name],
140
+ (value = '') => {
141
+ state.value = value;
142
+
143
+ setDisplayState();
144
+ },
145
+ { immediate: true },
146
+ );
147
+
148
+ const mouseupHandler = async () => {
149
+ isFocused.value = true;
150
+ await nextTick();
151
+ autocomplete.value?.focus();
152
+ };
153
+
154
+ const blurHandler = () => {
155
+ isFocused.value = false;
156
+
157
+ setDisplayState();
158
+ };
159
+
160
+ const changeHandler = (v: string) => {
161
+ emit('change', v);
162
+ };
163
+
164
+ let inputText = '';
165
+
166
+ const inputHandler = (v: string) => {
167
+ if (!v) {
168
+ inputText = v;
169
+ }
170
+ };
171
+
172
+ /**
173
+ * 光标位置是不是}
174
+ * @param selectionStart 光标位置
175
+ */
176
+ const isRightCurlyBracket = (selectionStart = 0) => {
177
+ const lastChar = inputText.substring(selectionStart - 1, selectionStart);
178
+ return lastChar === '}';
179
+ };
180
+
181
+ /**
182
+ * 获取光标位置
183
+ */
184
+ const getSelectionStart = () => {
185
+ let selectionStart = input.value?.selectionStart || 0;
186
+
187
+ // 输入法可能会自动补全},如果当前光标前面一个字符是},则光标前移一位
188
+ if (isRightCurlyBracket(selectionStart)) {
189
+ selectionStart -= 1;
190
+ }
191
+
192
+ return selectionStart;
193
+ };
194
+
195
+ /**
196
+ * 当前输入的是{
197
+ * @param leftCurlyBracketIndex {字符索引
198
+ */
199
+ const curCharIsLeftCurlyBracket = (leftCurlyBracketIndex: number) =>
200
+ leftCurlyBracketIndex > 0 && leftCurlyBracketIndex === getSelectionStart() - 1;
201
+
202
+ /**
203
+ * 当前输入的是.
204
+ * @param leftCurlyBracketIndex .字符索引
205
+ */
206
+ const curCharIsDot = (dotIndex: number) => dotIndex > -1 && dotIndex === getSelectionStart() - 1;
207
+
208
+ /**
209
+ * @param leftCurlyBracketIndex 左大括号字符索引
210
+ * @param cb 建议的方法
211
+ */
212
+ const dsQuerySearch = (queryString: string, leftCurlyBracketIndex: number, cb: (data: { value: string }[]) => void) => {
213
+ let result: DataSourceSchema[] = [];
214
+
215
+ if (curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
216
+ // 当前输入的是{
217
+ result = dataSources.value;
218
+ } else if (leftCurlyBracketIndex > 0) {
219
+ // 当前输入的是{xx
220
+ const queryName = queryString.substring(leftCurlyBracketIndex + 1).toLowerCase();
221
+ result = dataSources.value.filter((ds) => ds.title?.toLowerCase().includes(queryName) || ds.id.includes(queryName));
222
+ }
223
+
224
+ cb(
225
+ result.map((ds) => ({
226
+ value: ds.id,
227
+ text: ds.title,
228
+ type: 'dataSource',
229
+ })),
230
+ );
231
+ };
232
+
233
+ /**
234
+ * 字段提示
235
+ * @param queryString 当前输入框内的字符串
236
+ * @param leftAngleIndex {字符索引
237
+ * @param dotIndex .字符索引
238
+ * @param cb 建议回调
239
+ */
240
+ const fieldQuerySearch = (
241
+ queryString: string,
242
+ leftAngleIndex: number,
243
+ dotIndex: number,
244
+ cb: (data: { value: string }[]) => void,
245
+ ) => {
246
+ let result: DataSchema[] = [];
247
+
248
+ const dsKey = queryString.substring(leftAngleIndex + 1, dotIndex);
249
+ // 可能是xx.xx.xx,存在链式调用
250
+ const keys = dsKey.split('.');
251
+ // 最前的是数据源id
252
+ const ds = dataSources.value.find((ds) => ds.id === keys.shift());
253
+ if (!ds) {
254
+ return;
255
+ }
256
+
257
+ let fields = ds.fields || [];
258
+
259
+ // 后面这些事字段
260
+ let key = keys.shift();
261
+ while (key) {
262
+ for (const field of fields) {
263
+ if (field.name === key) {
264
+ fields = field.fields || [];
265
+ key = keys.shift();
266
+ break;
267
+ }
268
+ }
269
+ }
270
+
271
+ if (curCharIsDot(dotIndex)) {
272
+ // 当前输入的是.
273
+ result = fields || [];
274
+ } else if (dotIndex > -1) {
275
+ const queryName = queryString.substring(dotIndex + 1).toLowerCase();
276
+ result =
277
+ fields.filter(
278
+ (field) => field.name?.toLowerCase().includes(queryName) || field.title?.toLowerCase().includes(queryName),
279
+ ) || [];
280
+ }
281
+
282
+ cb(
283
+ result.map((field) => ({
284
+ value: field.name,
285
+ text: field.title,
286
+ type: 'field',
287
+ })),
288
+ );
289
+ };
290
+
291
+ /**
292
+ * 数据源提示
293
+ * @param queryString 当前输入框内的字符串
294
+ * @param cb 建议回调
295
+ */
296
+ const querySearch = (queryString: string, cb: (data: { value: string }[]) => void) => {
297
+ inputText = queryString;
298
+
299
+ const selectionStart = getSelectionStart();
300
+
301
+ const curQueryString = queryString.substring(0, selectionStart);
302
+
303
+ const fieldKeyStringLastIndex = curQueryString.lastIndexOf('.');
304
+ const dsKeyStringLastIndex = curQueryString.lastIndexOf('${') + 1;
305
+
306
+ const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
307
+
308
+ if (isFieldTip) {
309
+ fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
310
+ } else {
311
+ dsQuerySearch(curQueryString, dsKeyStringLastIndex, cb);
312
+ }
313
+ };
314
+
315
+ /**
316
+ * 选择建议
317
+ * @param value 建议值
318
+ * @param type 建议类型,是数据源还是字段
319
+ */
320
+ const selectHandler = async ({ value, type }: { value: string; type: 'dataSource' | 'field' }) => {
321
+ const isDataSource = type === 'dataSource';
322
+ const selectionStart = input.value?.selectionStart || 0;
323
+ let startText = inputText.substring(0, selectionStart);
324
+
325
+ const dotIndex = startText.lastIndexOf('.');
326
+ const leftCurlyBracketIndex = startText.lastIndexOf('${') + 1;
327
+
328
+ const endText = inputText.substring(selectionStart);
329
+
330
+ let suggestText = value;
331
+
332
+ if (isDataSource) {
333
+ if (!curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
334
+ startText = startText.substring(0, leftCurlyBracketIndex + 1);
335
+ }
336
+
337
+ // 当前光标后一位是否为},不是的话需要补上
338
+ if (!isRightCurlyBracket(selectionStart + 1)) {
339
+ suggestText = `${suggestText}}`;
340
+ }
341
+ } else if (!curCharIsDot(dotIndex)) {
342
+ startText = startText.substring(0, dotIndex + 1);
343
+ }
344
+
345
+ state.value = `${startText}${suggestText}${endText}`;
346
+
347
+ await nextTick();
348
+
349
+ // 由于选择数据源时会在后面补全}, 所以光标要前移2位
350
+ let newSelectionStart = 0;
351
+ if (isDataSource) {
352
+ newSelectionStart = leftCurlyBracketIndex + suggestText.length;
353
+ } else {
354
+ newSelectionStart = dotIndex + suggestText.length + 1;
355
+ }
356
+ input.value?.setSelectionRange(newSelectionStart, newSelectionStart);
357
+ };
358
+ </script>
@@ -0,0 +1,75 @@
1
+ <template>
2
+ <MSelect
3
+ :model="model"
4
+ :name="name"
5
+ :size="size"
6
+ :prop="prop"
7
+ :disabled="disabled"
8
+ :config="selectConfig"
9
+ :last-values="lastValues"
10
+ @change="changeHandler"
11
+ ></MSelect>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { computed, inject } from 'vue';
16
+
17
+ import { FieldSize } from '@tmagic/design';
18
+ import { MSelect, SelectConfig } from '@tmagic/form';
19
+
20
+ import { Services } from '../type';
21
+
22
+ defineOptions({
23
+ name: 'MEditorDataSourceSelect',
24
+ });
25
+
26
+ const emit = defineEmits(['change']);
27
+
28
+ const props = withDefaults(
29
+ defineProps<{
30
+ config: {
31
+ type: 'data-source-select';
32
+ name: string;
33
+ text: string;
34
+ placeholder: string;
35
+ dataSourceType?: string;
36
+ };
37
+ model: Record<string, any>;
38
+ name: string;
39
+ prop: string;
40
+ disabled: boolean;
41
+ lastValues?: Record<string, any>;
42
+ size?: FieldSize;
43
+ }>(),
44
+ {
45
+ disabled: false,
46
+ },
47
+ );
48
+
49
+ const { dataSourceService } = inject<Services>('services') || {};
50
+
51
+ const dataSources = computed(() => dataSourceService?.get('dataSources') || []);
52
+
53
+ const selectConfig = computed<SelectConfig>(() => {
54
+ const { type, dataSourceType, ...config } = props.config;
55
+ return {
56
+ ...config,
57
+ type: 'select',
58
+ valueKey: 'dataSourceId',
59
+ options: dataSources.value
60
+ .filter((ds) => !dataSourceType || ds.type === dataSourceType)
61
+ .map((ds) => ({
62
+ value: {
63
+ isBindDataSource: true,
64
+ dataSourceType: ds.type,
65
+ dataSourceId: ds.id,
66
+ },
67
+ text: ds.title || ds.id,
68
+ })),
69
+ };
70
+ });
71
+
72
+ const changeHandler = (value: any) => {
73
+ emit('change', value);
74
+ };
75
+ </script>
@@ -33,8 +33,8 @@
33
33
  </div>
34
34
  </template>
35
35
 
36
- <script lang="ts" setup name="MEditorEventSelect">
37
- import { computed, defineProps, inject } from 'vue';
36
+ <script lang="ts" setup>
37
+ import { computed, inject } from 'vue';
38
38
  import { Delete } from '@element-plus/icons-vue';
39
39
  import { has } from 'lodash-es';
40
40
 
@@ -44,7 +44,9 @@ import { ActionType } from '@tmagic/schema';
44
44
 
45
45
  import type { EventSelectConfig, Services } from '@editor/type';
46
46
 
47
- const services = inject<Services>('services');
47
+ defineOptions({
48
+ name: 'MEditorEventSelect',
49
+ });
48
50
 
49
51
  const props = defineProps<{
50
52
  config: EventSelectConfig;
@@ -53,8 +55,11 @@ const props = defineProps<{
53
55
  name: string;
54
56
  size: 'small' | 'default' | 'large';
55
57
  }>();
58
+
56
59
  const emit = defineEmits(['change']);
57
60
 
61
+ const services = inject<Services>('services');
62
+
58
63
  // 事件名称下拉框表单配置
59
64
  const eventNameConfig = computed(() => {
60
65
  const defaultEventNameConfig = {
@@ -181,6 +186,7 @@ const actionsConfig = computed(() => ({
181
186
  {
182
187
  type: 'group-list',
183
188
  name: 'actions',
189
+ expandAll: true,
184
190
  enableToggleMode: false,
185
191
  items: [actionTypeConfig.value, targetCompConfig.value, compActionConfig.value, codeActionConfig.value],
186
192
  },
@@ -38,6 +38,10 @@ import { Delete, Plus } from '@element-plus/icons-vue';
38
38
 
39
39
  import { TMagicButton, TMagicInput } from '@tmagic/design';
40
40
 
41
+ defineOptions({
42
+ name: 'MEditorKeyValue',
43
+ });
44
+
41
45
  const props = withDefaults(
42
46
  defineProps<{
43
47
  config: {
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
  </template>
14
14
 
15
- <script lang="ts" setup name="MEditorUISelect">
15
+ <script lang="ts" setup>
16
16
  import { computed, inject, ref } from 'vue';
17
17
  import { Close, Delete } from '@element-plus/icons-vue';
18
18
 
@@ -21,6 +21,10 @@ import { FormState } from '@tmagic/form';
21
21
 
22
22
  import type { Services } from '@editor/type';
23
23
 
24
+ defineOptions({
25
+ name: 'MEditorUISelect',
26
+ });
27
+
24
28
  const props = defineProps<{
25
29
  config: any;
26
30
  model: any;
@@ -8,4 +8,8 @@
8
8
  </svg>
9
9
  </template>
10
10
 
11
- <script lang="ts" setup name="MEditorAppManageIcon"></script>
11
+ <script lang="ts" setup>
12
+ defineOptions({
13
+ name: 'MEditorAppManageIcon',
14
+ });
15
+ </script>
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M2 4H21V6H2V4Z" fill="black" fill-opacity="0.9" />
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M5 11H18V13H5V11Z" fill="black" fill-opacity="0.9" />
5
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M2 18H21V20H2V18Z" fill="black" fill-opacity="0.9" />
6
+ </svg>
7
+ </template>
8
+
9
+ <script lang="ts" setup>
10
+ defineOptions({
11
+ name: 'MEditorCenterIcon',
12
+ });
13
+ </script>
@@ -23,4 +23,8 @@
23
23
  </svg>
24
24
  </template>
25
25
 
26
- <script lang="ts" setup name="MEditorCodeIcon"></script>
26
+ <script lang="ts" setup>
27
+ defineOptions({
28
+ name: 'MEditorCodeIcon',
29
+ });
30
+ </script>
package/src/index.ts CHANGED
@@ -22,6 +22,8 @@ import CodeLink from './fields/CodeLink.vue';
22
22
  import CodeSelect from './fields/CodeSelect.vue';
23
23
  import CodeSelectCol from './fields/CodeSelectCol.vue';
24
24
  import DataSourceFields from './fields/DataSourceFields.vue';
25
+ import DataSourceInput from './fields/DataSourceInput.vue';
26
+ import DataSourceSelect from './fields/DataSourceSelect.vue';
25
27
  import EventSelect from './fields/EventSelect.vue';
26
28
  import KeyValue from './fields/KeyValue.vue';
27
29
  import uiSelect from './fields/UISelect.vue';
@@ -42,6 +44,7 @@ export { default as propsService } from './services/props';
42
44
  export { default as historyService } from './services/history';
43
45
  export { default as storageService } from './services/storage';
44
46
  export { default as eventsService } from './services/events';
47
+ export { default as dataSourceService } from './services/dataSource';
45
48
  export { default as uiService } from './services/ui';
46
49
  export { default as codeBlockService } from './services/codeBlock';
47
50
  export { default as depService } from './services/dep';
@@ -50,6 +53,8 @@ export { default as LayerPanel } from './layouts/sidebar/LayerPanel.vue';
50
53
  export { default as CodeSelect } from './fields/CodeSelect.vue';
51
54
  export { default as CodeSelectCol } from './fields/CodeSelectCol.vue';
52
55
  export { default as DataSourceFields } from './fields/DataSourceFields.vue';
56
+ export { default as DataSourceInput } from './fields/DataSourceInput.vue';
57
+ export { default as DataSourceSelect } from './fields/DataSourceSelect.vue';
53
58
  export { default as EventSelect } from './fields/EventSelect.vue';
54
59
  export { default as KeyValue } from './fields/KeyValue.vue';
55
60
  export { default as CodeBlockList } from './layouts/sidebar/code-block/CodeBlockList.vue';
@@ -57,14 +62,17 @@ export { default as PropsPanel } from './layouts/PropsPanel.vue';
57
62
  export { default as ToolButton } from './components/ToolButton.vue';
58
63
  export { default as ContentMenu } from './components/ContentMenu.vue';
59
64
  export { default as Icon } from './components/Icon.vue';
60
- export { default as LayoutContainer } from './components/Layout.vue';
65
+ export { default as LayoutContainer } from './components/SplitView.vue';
66
+ export { default as SplitView } from './components/SplitView.vue';
67
+ export { default as Resizer } from './components/Resizer.vue';
61
68
 
62
69
  const defaultInstallOpt: InstallOptions = {
63
- // @todo, 自定义图片上传方法等编辑器依赖的外部选项
70
+ // eslint-disable-next-line no-eval
71
+ parseDSL: (dsl: string) => eval(dsl),
64
72
  };
65
73
 
66
74
  export default {
67
- install: (app: App, opt?: InstallOptions): void => {
75
+ install: (app: App, opt?: Partial<InstallOptions>): void => {
68
76
  const option = Object.assign(defaultInstallOpt, opt || {});
69
77
 
70
78
  // eslint-disable-next-line no-param-reassign
@@ -80,5 +88,7 @@ export default {
80
88
  app.component('m-fields-event-select', EventSelect);
81
89
  app.component('m-fields-data-source-fields', DataSourceFields);
82
90
  app.component('m-fields-key-value', KeyValue);
91
+ app.component('m-fields-data-source-input', DataSourceInput);
92
+ app.component('m-fields-data-source-select', DataSourceSelect);
83
93
  },
84
94
  };