@tmagic/editor 1.5.12 → 1.5.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.
- package/dist/tmagic-editor.js +219 -166
- package/dist/tmagic-editor.umd.cjs +225 -266
- package/package.json +7 -7
- package/src/Editor.vue +4 -20
- package/src/components/CodeBlockEditor.vue +14 -2
- package/src/components/ContentMenu.vue +2 -2
- package/src/components/FloatingBox.vue +1 -1
- package/src/components/ScrollBar.vue +9 -3
- package/src/components/SearchInput.vue +1 -1
- package/src/components/Tree.vue +3 -3
- package/src/components/TreeNode.vue +3 -3
- package/src/fields/CodeSelect.vue +5 -7
- package/src/fields/CodeSelectCol.vue +9 -5
- package/src/fields/DataSourceFields.vue +4 -2
- package/src/fields/DataSourceInput.vue +7 -3
- package/src/fields/DataSourceMethodSelect.vue +17 -6
- package/src/fields/DataSourceMethods.vue +3 -3
- package/src/fields/EventSelect.vue +3 -2
- package/src/fields/UISelect.vue +2 -2
- package/src/hooks/use-code-block-edit.ts +1 -1
- package/src/index.ts +0 -1
- package/src/initService.ts +75 -65
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/page-bar/PageBar.vue +1 -1
- package/src/layouts/props-panel/FormPanel.vue +2 -2
- package/src/layouts/props-panel/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +2 -1
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +20 -3
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +13 -1
- package/src/layouts/sidebar/data-source/DataSourceList.vue +1 -0
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +20 -3
- package/src/layouts/workspace/viewer/Stage.vue +1 -1
- package/src/services/BaseService.ts +1 -0
- package/src/services/editor.ts +4 -3
- package/src/type.ts +9 -0
- package/src/utils/props.ts +9 -7
- package/types/index.d.ts +945 -9788
package/src/initService.ts
CHANGED
|
@@ -269,13 +269,13 @@ export const initServiceEvents = (
|
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
|
|
272
|
-
const dsDepCollectedHandler =
|
|
272
|
+
const dsDepCollectedHandler = () => {
|
|
273
273
|
const root = editorService.get('root');
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
274
|
+
getTMagicApp()?.then((app?: TMagicCore) => {
|
|
275
|
+
if (root && app?.dsl) {
|
|
276
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
279
|
};
|
|
280
280
|
|
|
281
281
|
const collectIdle = (nodes: MComponent[], deep: boolean, type?: DepTargetType) =>
|
|
@@ -317,7 +317,7 @@ export const initServiceEvents = (
|
|
|
317
317
|
depService.addTarget(createDataSourceCondTarget(ds, reactive({})));
|
|
318
318
|
};
|
|
319
319
|
|
|
320
|
-
const rootChangeHandler =
|
|
320
|
+
const rootChangeHandler = (value: MApp | null, preValue?: MApp | null) => {
|
|
321
321
|
if (!value) return;
|
|
322
322
|
|
|
323
323
|
value.codeBlocks = value.codeBlocks || {};
|
|
@@ -347,39 +347,40 @@ export const initServiceEvents = (
|
|
|
347
347
|
delete value.dataSourceCondDeps;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
350
|
+
const handler = async () => {
|
|
351
|
+
const nodeId = editorService.get('node')?.id || props.defaultSelected;
|
|
352
|
+
let node;
|
|
353
|
+
if (nodeId) {
|
|
354
|
+
node = editorService.getNodeById(nodeId);
|
|
355
|
+
}
|
|
356
|
+
if (node && node !== value) {
|
|
357
|
+
await editorService.select(node.id);
|
|
358
|
+
} else if (value.items?.length) {
|
|
359
|
+
await editorService.select(value.items[0]);
|
|
360
|
+
} else if (value.id) {
|
|
361
|
+
editorService.set('nodes', [value]);
|
|
362
|
+
editorService.set('parent', null);
|
|
363
|
+
editorService.set('page', null);
|
|
364
|
+
}
|
|
355
365
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
} else if (value.id) {
|
|
361
|
-
editorService.set('nodes', [value]);
|
|
362
|
-
editorService.set('parent', null);
|
|
363
|
-
editorService.set('page', null);
|
|
364
|
-
}
|
|
366
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
367
|
+
emit('update:modelValue', value);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
365
370
|
|
|
366
|
-
|
|
367
|
-
emit('update:modelValue', value);
|
|
368
|
-
}
|
|
371
|
+
handler();
|
|
369
372
|
};
|
|
370
373
|
|
|
371
374
|
// 新增节点,收集依赖
|
|
372
|
-
const nodeAddHandler =
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
const nodeAddHandler = (nodes: MComponent[]) => {
|
|
376
|
+
collectIdle(nodes, true).then(() => {
|
|
377
|
+
updateStageNodes(nodes);
|
|
378
|
+
});
|
|
376
379
|
};
|
|
377
380
|
|
|
378
381
|
// 节点更新,收集依赖
|
|
379
382
|
// 仅当修改到数据源相关的才收集
|
|
380
|
-
const nodeUpdateHandler =
|
|
381
|
-
data: { newNode: MComponent; oldNode: MComponent; changeRecords?: ChangeRecord[] }[],
|
|
382
|
-
) => {
|
|
383
|
+
const nodeUpdateHandler = (data: { newNode: MComponent; oldNode: MComponent; changeRecords?: ChangeRecord[] }[]) => {
|
|
383
384
|
const needRecollectNodes: MComponent[] = [];
|
|
384
385
|
const normalNodes: MComponent[] = [];
|
|
385
386
|
for (const { newNode, oldNode, changeRecords } of data) {
|
|
@@ -424,9 +425,12 @@ export const initServiceEvents = (
|
|
|
424
425
|
|
|
425
426
|
if (needRecollectNodes.length) {
|
|
426
427
|
// 有数据源依赖,需要等依赖重新收集完才更新stage
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
const handler = async () => {
|
|
429
|
+
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE);
|
|
430
|
+
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE_COND);
|
|
431
|
+
updateStageNodes(needRecollectNodes);
|
|
432
|
+
};
|
|
433
|
+
handler();
|
|
430
434
|
} else {
|
|
431
435
|
updateStageNodes(normalNodes);
|
|
432
436
|
// 在上面判断是否需要收集数据源依赖中已经更新stage
|
|
@@ -443,9 +447,10 @@ export const initServiceEvents = (
|
|
|
443
447
|
};
|
|
444
448
|
|
|
445
449
|
// 由于历史记录变化是更新整个page,所以历史记录变化时,需要重新收集依赖
|
|
446
|
-
const historyChangeHandler =
|
|
447
|
-
|
|
448
|
-
|
|
450
|
+
const historyChangeHandler = (page: MPage | MPageFragment) => {
|
|
451
|
+
collectIdle([page], true).then(() => {
|
|
452
|
+
updateStageNode(page);
|
|
453
|
+
});
|
|
449
454
|
};
|
|
450
455
|
|
|
451
456
|
editorService.on('history-change', historyChangeHandler);
|
|
@@ -454,27 +459,28 @@ export const initServiceEvents = (
|
|
|
454
459
|
editorService.on('remove', nodeRemoveHandler);
|
|
455
460
|
editorService.on('update', nodeUpdateHandler);
|
|
456
461
|
|
|
457
|
-
const dataSourceAddHandler =
|
|
458
|
-
|
|
459
|
-
|
|
462
|
+
const dataSourceAddHandler = (config: DataSourceSchema) => {
|
|
463
|
+
const handler = async () => {
|
|
464
|
+
initDataSourceDepTarget(config);
|
|
465
|
+
const app = await getTMagicApp();
|
|
460
466
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
467
|
+
if (!app?.dataSourceManager) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
464
470
|
|
|
465
|
-
|
|
471
|
+
app.dataSourceManager.addDataSource(config);
|
|
466
472
|
|
|
467
|
-
|
|
473
|
+
const newDs = app.dataSourceManager.get(config.id);
|
|
468
474
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
475
|
+
if (newDs) {
|
|
476
|
+
app.dataSourceManager.init(newDs);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
handler();
|
|
472
481
|
};
|
|
473
482
|
|
|
474
|
-
const dataSourceUpdateHandler =
|
|
475
|
-
config: DataSourceSchema,
|
|
476
|
-
{ changeRecords }: { changeRecords: ChangeRecord[] },
|
|
477
|
-
) => {
|
|
483
|
+
const dataSourceUpdateHandler = (config: DataSourceSchema, { changeRecords }: { changeRecords: ChangeRecord[] }) => {
|
|
478
484
|
const updateDsData = async () => {
|
|
479
485
|
const app = await getTMagicApp();
|
|
480
486
|
|
|
@@ -565,29 +571,33 @@ export const initServiceEvents = (
|
|
|
565
571
|
depService.removeTarget(id, DepTargetType.DATA_SOURCE_METHOD);
|
|
566
572
|
};
|
|
567
573
|
|
|
568
|
-
const dataSourceRemoveHandler =
|
|
574
|
+
const dataSourceRemoveHandler = (id: string) => {
|
|
569
575
|
const root = editorService.get('root');
|
|
570
576
|
|
|
571
577
|
if (!root) {
|
|
572
578
|
return;
|
|
573
579
|
}
|
|
574
580
|
|
|
575
|
-
const
|
|
576
|
-
|
|
581
|
+
const handler = async () => {
|
|
582
|
+
const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
|
|
583
|
+
const nodes = getNodes(nodeIds, root.items);
|
|
577
584
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
585
|
+
await Promise.all([
|
|
586
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE),
|
|
587
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_COND),
|
|
588
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_METHOD),
|
|
589
|
+
]);
|
|
583
590
|
|
|
584
|
-
|
|
591
|
+
updateDataSourceSchema();
|
|
585
592
|
|
|
586
|
-
|
|
587
|
-
|
|
593
|
+
const app = await getTMagicApp();
|
|
594
|
+
app?.dataSourceManager?.removeDataSource(id);
|
|
595
|
+
|
|
596
|
+
updateStageNodes(nodes);
|
|
597
|
+
removeDataSourceTarget(id);
|
|
598
|
+
};
|
|
588
599
|
|
|
589
|
-
|
|
590
|
-
removeDataSourceTarget(id);
|
|
600
|
+
handler();
|
|
591
601
|
};
|
|
592
602
|
|
|
593
603
|
dataSourceService.on('add', dataSourceAddHandler);
|
|
@@ -91,7 +91,7 @@ defineOptions({
|
|
|
91
91
|
defineProps<{
|
|
92
92
|
disabledPageFragment: boolean;
|
|
93
93
|
pageBarSortOptions?: PageBarSortOptions;
|
|
94
|
-
pageFilterFunction?: (
|
|
94
|
+
pageFilterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
|
|
95
95
|
}>();
|
|
96
96
|
|
|
97
97
|
const codeOptions = inject('codeOptions', {});
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -69,7 +69,7 @@ const getConfig = (item: MenuItem): (MenuButton | MenuComponent)[] => {
|
|
|
69
69
|
type: 'button',
|
|
70
70
|
className: 'delete',
|
|
71
71
|
icon: markRaw(Delete),
|
|
72
|
-
tooltip:
|
|
72
|
+
tooltip: '刪除(Delete)',
|
|
73
73
|
disabled: () => editorService.get('node')?.type === NodeType.PAGE,
|
|
74
74
|
handler: () => {
|
|
75
75
|
const node = editorService.get('node');
|
|
@@ -91,7 +91,7 @@ const props = withDefaults(
|
|
|
91
91
|
defineProps<{
|
|
92
92
|
disabledPageFragment: boolean;
|
|
93
93
|
pageBarSortOptions?: PageBarSortOptions;
|
|
94
|
-
filterFunction?: (
|
|
94
|
+
filterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
|
|
95
95
|
}>(),
|
|
96
96
|
{
|
|
97
97
|
filterFunction: (page, keyword) => page.name?.includes(keyword) || `${page.id}`.includes(keyword),
|
|
@@ -56,7 +56,7 @@ import { useServices } from '@editor/hooks/use-services';
|
|
|
56
56
|
import CodeEditor from '../CodeEditor.vue';
|
|
57
57
|
|
|
58
58
|
defineSlots<{
|
|
59
|
-
'props-form-panel-header'(
|
|
59
|
+
'props-form-panel-header'(_props: {}): any;
|
|
60
60
|
}>();
|
|
61
61
|
|
|
62
62
|
defineOptions({
|
|
@@ -70,7 +70,7 @@ const props = defineProps<{
|
|
|
70
70
|
labelWidth?: string;
|
|
71
71
|
codeValueKey?: string;
|
|
72
72
|
labelPosition?: string;
|
|
73
|
-
extendState?: (
|
|
73
|
+
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
74
74
|
}>();
|
|
75
75
|
|
|
76
76
|
const emit = defineEmits<{
|
|
@@ -82,7 +82,7 @@ defineOptions({
|
|
|
82
82
|
|
|
83
83
|
defineProps<{
|
|
84
84
|
disabledShowSrc?: boolean;
|
|
85
|
-
extendState?: (
|
|
85
|
+
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
86
86
|
}>();
|
|
87
87
|
|
|
88
88
|
const emit = defineEmits<{
|
|
@@ -55,7 +55,7 @@ defineOptions({
|
|
|
55
55
|
const props = defineProps<{
|
|
56
56
|
indent?: number;
|
|
57
57
|
nextLevelIndentIncrement?: number;
|
|
58
|
-
customError?: (
|
|
58
|
+
customError?: (_id: Id, _errorType: CodeDeleteErrorType) => any;
|
|
59
59
|
}>();
|
|
60
60
|
|
|
61
61
|
const emit = defineEmits<{
|
|
@@ -173,6 +173,7 @@ const nodeContentMenuHandler = (event: MouseEvent, data: TreeNodeData) => {
|
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
defineExpose({
|
|
176
|
+
nodeStatusMap,
|
|
176
177
|
filter: filterTextChangeHandler,
|
|
177
178
|
deleteCode,
|
|
178
179
|
});
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
:disabled="!editable"
|
|
33
33
|
:content="codeConfig"
|
|
34
34
|
@submit="submitCodeBlockHandler"
|
|
35
|
+
@close="editDialogCloseHandler"
|
|
35
36
|
></CodeBlockEditor>
|
|
36
37
|
|
|
37
38
|
<Teleport to="body">
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
</template>
|
|
47
48
|
|
|
48
49
|
<script setup lang="ts">
|
|
49
|
-
import { computed, inject, useTemplateRef } from 'vue';
|
|
50
|
+
import { computed, inject, useTemplateRef, watch } from 'vue';
|
|
50
51
|
|
|
51
52
|
import type { Id } from '@tmagic/core';
|
|
52
53
|
import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
|
|
@@ -77,7 +78,7 @@ defineOptions({
|
|
|
77
78
|
const props = defineProps<{
|
|
78
79
|
indent?: number;
|
|
79
80
|
nextLevelIndentIncrement?: number;
|
|
80
|
-
customError?: (
|
|
81
|
+
customError?: (_id: Id, _errorType: CodeDeleteErrorType) => any;
|
|
81
82
|
customContentMenu: CustomContentMenuFunction;
|
|
82
83
|
}>();
|
|
83
84
|
|
|
@@ -87,7 +88,7 @@ const { codeBlockService } = useServices();
|
|
|
87
88
|
|
|
88
89
|
const editable = computed(() => codeBlockService.getEditStatus());
|
|
89
90
|
|
|
90
|
-
const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } =
|
|
91
|
+
const { codeId, codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } =
|
|
91
92
|
useCodeBlockEdit(codeBlockService);
|
|
92
93
|
|
|
93
94
|
const codeBlockListRef = useTemplateRef<InstanceType<typeof CodeBlockList>>('codeBlockList');
|
|
@@ -100,6 +101,22 @@ eventBus?.on('edit-code', (id: string) => {
|
|
|
100
101
|
editCode(id);
|
|
101
102
|
});
|
|
102
103
|
|
|
104
|
+
watch(codeId, () => {
|
|
105
|
+
if (codeBlockListRef.value) {
|
|
106
|
+
for (const [statusId, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
|
|
107
|
+
status.selected = statusId === codeId.value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const editDialogCloseHandler = () => {
|
|
113
|
+
if (codeBlockListRef.value) {
|
|
114
|
+
for (const [, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
|
|
115
|
+
status.selected = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
103
120
|
const {
|
|
104
121
|
nodeContentMenuHandler,
|
|
105
122
|
menuData: contentMenuData,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
24
|
<script setup lang="ts">
|
|
25
|
-
import { inject, Ref, ref, watchEffect } from 'vue';
|
|
25
|
+
import { inject, nextTick, Ref, ref, watch, watchEffect } from 'vue';
|
|
26
26
|
|
|
27
27
|
import type { DataSourceSchema } from '@tmagic/core';
|
|
28
28
|
import { tMagicMessage } from '@tmagic/design';
|
|
@@ -48,6 +48,8 @@ const width = defineModel<number>('width', { default: 670 });
|
|
|
48
48
|
|
|
49
49
|
const emit = defineEmits<{
|
|
50
50
|
submit: [v: any, eventData: ContainerChangeEventData];
|
|
51
|
+
close: [];
|
|
52
|
+
open: [id: string];
|
|
51
53
|
}>();
|
|
52
54
|
|
|
53
55
|
const { uiService, dataSourceService } = useServices();
|
|
@@ -73,6 +75,16 @@ const errorHandler = (error: any) => {
|
|
|
73
75
|
tMagicMessage.error(error.message);
|
|
74
76
|
};
|
|
75
77
|
|
|
78
|
+
watch(boxVisible, (visible) => {
|
|
79
|
+
nextTick(() => {
|
|
80
|
+
if (!visible) {
|
|
81
|
+
emit('close');
|
|
82
|
+
} else if (initValues.value?.id) {
|
|
83
|
+
emit('open', initValues.value.id);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
76
88
|
defineExpose({
|
|
77
89
|
show() {
|
|
78
90
|
calcBoxPosition();
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
:values="dataSourceValues"
|
|
46
46
|
:title="dialogTitle"
|
|
47
47
|
@submit="submitDataSourceHandler"
|
|
48
|
+
@close="editDialogCloseHandler"
|
|
48
49
|
></DataSourceConfigPanel>
|
|
49
50
|
|
|
50
51
|
<Teleport to="body">
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
</template>
|
|
60
61
|
|
|
61
62
|
<script setup lang="ts">
|
|
62
|
-
import { computed, inject,
|
|
63
|
+
import { computed, inject, useTemplateRef, watch } from 'vue';
|
|
63
64
|
import { mergeWith } from 'lodash-es';
|
|
64
65
|
|
|
65
66
|
import { TMagicButton, tMagicMessageBox, TMagicPopover, TMagicScrollbar } from '@tmagic/design';
|
|
@@ -93,6 +94,22 @@ const { dataSourceService } = useServices();
|
|
|
93
94
|
const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } =
|
|
94
95
|
useDataSourceEdit(dataSourceService);
|
|
95
96
|
|
|
97
|
+
const editDialogCloseHandler = () => {
|
|
98
|
+
if (dataSourceListRef.value) {
|
|
99
|
+
for (const [, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
100
|
+
status.selected = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
watch(dataSourceValues, (dataSourceValues) => {
|
|
106
|
+
if (dataSourceListRef.value && dataSourceValues.id) {
|
|
107
|
+
for (const [statusId, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
108
|
+
status.selected = statusId === dataSourceValues.id;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
96
113
|
const datasourceTypeList = computed(() =>
|
|
97
114
|
[
|
|
98
115
|
{ text: '基础', type: 'base' },
|
|
@@ -130,10 +147,10 @@ const removeHandler = async (id: string) => {
|
|
|
130
147
|
dataSourceService.remove(id);
|
|
131
148
|
};
|
|
132
149
|
|
|
133
|
-
const
|
|
150
|
+
const dataSourceListRef = useTemplateRef<InstanceType<typeof DataSourceList>>('dataSourceList');
|
|
134
151
|
|
|
135
152
|
const filterTextChangeHandler = (val: string) => {
|
|
136
|
-
|
|
153
|
+
dataSourceListRef.value?.filter(val);
|
|
137
154
|
};
|
|
138
155
|
|
|
139
156
|
eventBus?.on('edit-data-source', (id: string) => {
|
|
@@ -149,7 +149,7 @@ watch(zoom, (zoom) => {
|
|
|
149
149
|
stage.setZoom(zoom);
|
|
150
150
|
});
|
|
151
151
|
|
|
152
|
-
let timeoutId:
|
|
152
|
+
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
153
153
|
watch(page, (page) => {
|
|
154
154
|
if (runtime && page) {
|
|
155
155
|
editorService.set('stageLoading', true);
|
package/src/services/editor.ts
CHANGED
|
@@ -1088,10 +1088,11 @@ class Editor extends BaseService {
|
|
|
1088
1088
|
this.isHistoryStateChange = true;
|
|
1089
1089
|
await this.update(value.data);
|
|
1090
1090
|
this.set('modifiedNodeIds', value.modifiedNodeIds);
|
|
1091
|
-
setTimeout(
|
|
1091
|
+
setTimeout(() => {
|
|
1092
1092
|
if (!value.nodeId) return;
|
|
1093
|
-
|
|
1094
|
-
|
|
1093
|
+
this.select(value.nodeId).then(() => {
|
|
1094
|
+
this.get('stage')?.select(value.nodeId);
|
|
1095
|
+
});
|
|
1095
1096
|
}, 0);
|
|
1096
1097
|
this.emit('history-change', value.data);
|
|
1097
1098
|
}
|
package/src/type.ts
CHANGED
|
@@ -65,6 +65,15 @@ import type { StageOverlayService } from './services/stageOverlay';
|
|
|
65
65
|
import type { StorageService } from './services/storage';
|
|
66
66
|
import type { UiService } from './services/ui';
|
|
67
67
|
import type { UndoRedo } from './utils/undo-redo';
|
|
68
|
+
|
|
69
|
+
export type EditorSlots = FrameworkSlots &
|
|
70
|
+
WorkspaceSlots &
|
|
71
|
+
SidebarSlots &
|
|
72
|
+
PropsPanelSlots & {
|
|
73
|
+
workspace(props: { editorService: EditorService }): any;
|
|
74
|
+
'workspace-content'(props: { editorService: EditorService }): any;
|
|
75
|
+
};
|
|
76
|
+
|
|
68
77
|
export interface FrameworkSlots {
|
|
69
78
|
header(props: {}): any;
|
|
70
79
|
nav(props: {}): any;
|
package/src/utils/props.ts
CHANGED
|
@@ -179,13 +179,15 @@ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormCo
|
|
|
179
179
|
append: {
|
|
180
180
|
type: 'button',
|
|
181
181
|
text: '复制',
|
|
182
|
-
handler:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
handler: (vm, { model }) => {
|
|
183
|
+
navigator.clipboard
|
|
184
|
+
.writeText(`${model.id}`)
|
|
185
|
+
.then(() => {
|
|
186
|
+
tMagicMessage.success('已复制');
|
|
187
|
+
})
|
|
188
|
+
.catch(() => {
|
|
189
|
+
tMagicMessage.error('复制失败');
|
|
190
|
+
});
|
|
189
191
|
},
|
|
190
192
|
},
|
|
191
193
|
},
|