@tmagic/editor 1.8.2 → 1.8.4-beta.1
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/es/Editor.vue_vue_type_script_setup_true_lang.js +23 -25
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +1 -1
- package/dist/es/fields/StyleSetter/configs.js +1 -1
- package/dist/es/fields/configs/codeSelect.js +5 -7
- package/dist/es/fields/configs/displayConds.js +8 -9
- package/dist/es/fields/configs/eventSelect.js +30 -27
- package/dist/es/headless.js +1 -2
- package/dist/es/hooks/use-stage.js +19 -18
- package/dist/es/index.js +9 -16
- package/dist/es/initService.js +33 -106
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/NavMenuColumn.vue_vue_type_script_setup_true_lang.js +12 -2
- package/dist/es/layouts/page-bar/AddButton.vue_vue_type_script_setup_true_lang.js +4 -6
- package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/layouts/props-panel/use-style-panel.js +1 -1
- package/dist/es/layouts/sidebar/ComponentListPanel.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/layouts/workspace/viewer/Stage.vue_vue_type_script_setup_true_lang.js +3 -0
- package/dist/es/sdk/index.js +151 -0
- package/dist/es/{services → sdk/services}/BaseService.js +1 -1
- package/dist/es/{services/codeBlock.js → sdk/services/CodeBlock.js} +37 -40
- package/dist/es/{services/componentList.js → sdk/services/ComponentList.js} +5 -6
- package/dist/es/{services/dataSource.js → sdk/services/DataSource.js} +38 -37
- package/dist/es/{services/dep.js → sdk/services/Dep.js} +27 -17
- package/dist/es/{services/editor.js → sdk/services/Editor.js} +124 -87
- package/dist/es/{services/events.js → sdk/services/Events.js} +13 -13
- package/dist/es/{services/history.js → sdk/services/History.js} +86 -33
- package/dist/es/{services/props.js → sdk/services/Props.js} +25 -26
- package/dist/es/{services/storage.js → sdk/services/WebStorage.js} +31 -8
- package/dist/es/sdk/utils/dep.js +100 -0
- package/dist/es/sdk/utils/operator.js +70 -0
- package/dist/es/sdk/utils/position.js +8 -0
- package/dist/es/sdk/utils/props.js +281 -0
- package/dist/es/sdk/validate/index.js +286 -0
- package/dist/es/sdk/wiring.js +163 -0
- package/dist/es/sdk.js +15 -0
- package/dist/es/services/keybinding.js +21 -21
- package/dist/es/services/sdk-instance.js +37 -0
- package/dist/es/services/stageOverlay.js +14 -14
- package/dist/es/services/ui.js +6 -6
- package/dist/es/style.css +31 -6
- package/dist/es/utils/data-source/formConfigs/base.js +1 -1
- package/dist/es/utils/data-source/formConfigs/http.js +1 -1
- package/dist/es/utils/dep/worker.js +1 -1
- package/dist/es/utils/editor.js +2 -2
- package/dist/es/utils/event.js +25 -21
- package/dist/es/utils/operator.js +11 -57
- package/dist/es/utils/props.js +12 -282
- package/dist/es/utils/type-match-rules.js +10 -12
- package/dist/style.css +31 -6
- package/dist/themes/magic-admin.css +31 -6
- package/dist/tmagic-editor-headless.umd.cjs +4690 -2891
- package/dist/tmagic-editor-sdk.umd.cjs +9911 -0
- package/dist/tmagic-editor.umd.cjs +14155 -13319
- package/package.json +13 -8
- package/src/Editor.vue +14 -9
- package/src/editorProps.ts +23 -0
- package/src/fields/configs/codeSelect.ts +6 -9
- package/src/fields/configs/displayConds.ts +10 -9
- package/src/fields/configs/eventSelect.ts +40 -25
- package/src/hooks/use-stage.ts +2 -1
- package/src/index.ts +11 -9
- package/src/initService.ts +59 -188
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenuColumn.vue +16 -4
- package/src/layouts/page-bar/AddButton.vue +5 -6
- package/src/layouts/props-panel/PropsPanel.vue +1 -1
- package/src/layouts/props-panel/use-style-panel.ts +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +7 -1
- package/src/layouts/workspace/viewer/Stage.vue +5 -0
- package/src/sdk/index.ts +264 -0
- package/src/{services/codeBlock.ts → sdk/services/CodeBlock.ts} +43 -38
- package/src/{services/componentList.ts → sdk/services/ComponentList.ts} +8 -7
- package/src/{services/dataSource.ts → sdk/services/DataSource.ts} +38 -32
- package/src/{services/dep.ts → sdk/services/Dep.ts} +29 -12
- package/src/{services/editor.ts → sdk/services/Editor.ts} +175 -86
- package/src/{services/events.ts → sdk/services/Events.ts} +15 -12
- package/src/{services/history.ts → sdk/services/History.ts} +100 -28
- package/src/{services/props.ts → sdk/services/Props.ts} +25 -25
- package/src/{services/storage.ts → sdk/services/WebStorage.ts} +41 -7
- package/src/sdk/type.ts +191 -0
- package/src/sdk/utils/dep.ts +196 -0
- package/src/sdk/utils/operator.ts +114 -0
- package/src/sdk/utils/position.ts +23 -0
- package/src/sdk/utils/props.ts +368 -0
- package/src/sdk/validate/index.ts +501 -0
- package/src/sdk/wiring.ts +211 -0
- package/src/sdk.ts +19 -0
- package/src/services/keybinding.ts +2 -2
- package/src/services/sdk-instance.ts +66 -0
- package/src/services/stageOverlay.ts +2 -2
- package/src/services/ui.ts +3 -3
- package/src/theme/nav-menu.scss +29 -2
- package/src/type.ts +33 -9
- package/src/utils/data-source/formConfigs/base.ts +1 -1
- package/src/utils/data-source/formConfigs/http.ts +1 -1
- package/src/utils/dep/collect-worker-client.ts +9 -6
- package/src/utils/dep/worker.ts +5 -0
- package/src/utils/editor.ts +2 -1
- package/src/utils/event.ts +36 -18
- package/src/utils/operator.ts +21 -87
- package/src/utils/props.ts +17 -332
- package/src/utils/type-match-rules.ts +1 -3
- package/types/index.d.ts +797 -540
- package/types/sdk.d.ts +2594 -0
- /package/src/{services → sdk/services}/BaseService.ts +0 -0
package/src/initService.ts
CHANGED
|
@@ -12,23 +12,22 @@ import type {
|
|
|
12
12
|
MPage,
|
|
13
13
|
MPageFragment,
|
|
14
14
|
} from '@tmagic/core';
|
|
15
|
-
import {
|
|
16
|
-
createCodeBlockTarget,
|
|
17
|
-
createDataSourceCondTarget,
|
|
18
|
-
createDataSourceMethodTarget,
|
|
19
|
-
createDataSourceTarget,
|
|
20
|
-
DepTargetType,
|
|
21
|
-
NODE_CONDS_KEY,
|
|
22
|
-
NodeType,
|
|
23
|
-
Target,
|
|
24
|
-
updateNode,
|
|
25
|
-
} from '@tmagic/core';
|
|
15
|
+
import { createCodeBlockTarget, DepTargetType, NodeType, Target, updateNode } from '@tmagic/core';
|
|
26
16
|
import { ChangeRecord } from '@tmagic/form';
|
|
27
17
|
import StageCore from '@tmagic/stage';
|
|
28
|
-
import { getDepNodeIds, getNodes, isPage
|
|
18
|
+
import { getDepNodeIds, getNodes, isPage } from '@tmagic/utils';
|
|
29
19
|
|
|
30
20
|
import PropsPanel from './layouts/PropsPanel.vue';
|
|
31
|
-
import {
|
|
21
|
+
import type { Reactivity } from './sdk/type';
|
|
22
|
+
import {
|
|
23
|
+
addDataSourceTargets,
|
|
24
|
+
classifyUpdatedNodes,
|
|
25
|
+
getDataSourceRecollectTypes,
|
|
26
|
+
removeDataSourceTargets,
|
|
27
|
+
removeTargetDeps,
|
|
28
|
+
resetDepTargets,
|
|
29
|
+
writeTargetDeps,
|
|
30
|
+
} from './sdk/utils/dep';
|
|
32
31
|
import { error as logError } from './utils/logger';
|
|
33
32
|
import { EditorProps } from './editorProps';
|
|
34
33
|
import { Services } from './type';
|
|
@@ -247,6 +246,16 @@ export const initServiceState = (
|
|
|
247
246
|
},
|
|
248
247
|
);
|
|
249
248
|
|
|
249
|
+
// 同步给 SDK 的结构合法性校验(浏览器端默认 validateMode 为 off,主动调用 `validate` 时才会用到)
|
|
250
|
+
watch(
|
|
251
|
+
() => [props.disabledPageFragment, props.canDropIn] as const,
|
|
252
|
+
([disabledPageFragment, canDropIn]) =>
|
|
253
|
+
editorService.setConfig({ disabledPageFragment: disabledPageFragment ?? false, canDropIn }),
|
|
254
|
+
{
|
|
255
|
+
immediate: true,
|
|
256
|
+
},
|
|
257
|
+
);
|
|
258
|
+
|
|
250
259
|
onBeforeUnmount(() => {
|
|
251
260
|
editorService.resetState();
|
|
252
261
|
historyService.resetState();
|
|
@@ -476,12 +485,6 @@ export const initServiceEvents = (
|
|
|
476
485
|
}
|
|
477
486
|
};
|
|
478
487
|
|
|
479
|
-
const initDataSourceDepTarget = (ds: DataSourceSchema) => {
|
|
480
|
-
depService.addTarget(createDataSourceTarget(ds, reactive({})));
|
|
481
|
-
depService.addTarget(createDataSourceMethodTarget(ds, reactive({})));
|
|
482
|
-
depService.addTarget(createDataSourceCondTarget(ds, reactive({})));
|
|
483
|
-
};
|
|
484
|
-
|
|
485
488
|
const rootChangeHandler = (value: MApp | null) => {
|
|
486
489
|
if (!value) return;
|
|
487
490
|
|
|
@@ -491,15 +494,12 @@ export const initServiceEvents = (
|
|
|
491
494
|
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
492
495
|
dataSourceService.set('dataSources', value.dataSources);
|
|
493
496
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
for (const ds of dataSourceService.get('dataSources')) {
|
|
501
|
-
initDataSourceDepTarget(ds);
|
|
502
|
-
}
|
|
497
|
+
resetDepTargets(
|
|
498
|
+
depService,
|
|
499
|
+
value.codeBlocks,
|
|
500
|
+
dataSourceService.get('dataSources'),
|
|
501
|
+
reactive as Reactivity['reactive'],
|
|
502
|
+
);
|
|
503
503
|
|
|
504
504
|
if (Array.isArray(value.items)) {
|
|
505
505
|
updateStageDsl(value);
|
|
@@ -549,49 +549,7 @@ export const initServiceEvents = (
|
|
|
549
549
|
// 节点更新,收集依赖
|
|
550
550
|
// 仅当修改到数据源相关的才收集
|
|
551
551
|
const nodeUpdateHandler = (data: { newNode: MComponent; oldNode: MComponent; changeRecords?: ChangeRecord[] }[]) => {
|
|
552
|
-
const needRecollectNodes
|
|
553
|
-
const normalNodes: MComponent[] = [];
|
|
554
|
-
for (const { newNode, oldNode, changeRecords } of data) {
|
|
555
|
-
if (newNode.type === NodeType.ROOT) {
|
|
556
|
-
normalNodes.push(newNode);
|
|
557
|
-
} else if (changeRecords?.length) {
|
|
558
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
559
|
-
forChangeRecords: for (const record of changeRecords) {
|
|
560
|
-
if (!record.propPath) {
|
|
561
|
-
needRecollectNodes.push(newNode);
|
|
562
|
-
break forChangeRecords;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// NODE_CONDS_KEY为显示条件key
|
|
566
|
-
if (
|
|
567
|
-
new RegExp(`${NODE_CONDS_KEY}.(\\d)+.cond`).test(record.propPath) ||
|
|
568
|
-
new RegExp(`${NODE_CONDS_KEY}.(\\d)+.cond.(\\d)+.value`).test(record.propPath) ||
|
|
569
|
-
record.propPath === NODE_CONDS_KEY ||
|
|
570
|
-
isValueIncludeDataSource(record.value)
|
|
571
|
-
) {
|
|
572
|
-
needRecollectNodes.push(newNode);
|
|
573
|
-
break forChangeRecords;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// 修改的key在收集的依赖中,则需要触发重新收集
|
|
577
|
-
for (const target of Object.values(depService.getTargets(DepTargetType.DATA_SOURCE))) {
|
|
578
|
-
if (!target.deps[newNode.id]) {
|
|
579
|
-
continue;
|
|
580
|
-
}
|
|
581
|
-
if (target.deps[newNode.id].keys.includes(record.propPath)) {
|
|
582
|
-
needRecollectNodes.push(newNode);
|
|
583
|
-
break forChangeRecords;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
normalNodes.push(newNode);
|
|
588
|
-
}
|
|
589
|
-
} else if (isIncludeDataSource(newNode, oldNode)) {
|
|
590
|
-
needRecollectNodes.push(newNode);
|
|
591
|
-
} else {
|
|
592
|
-
normalNodes.push(newNode);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
552
|
+
const { needRecollectNodes, normalNodes } = classifyUpdatedNodes({ dep: depService }, data);
|
|
595
553
|
|
|
596
554
|
if (needRecollectNodes.length) {
|
|
597
555
|
// 有数据源依赖,需要等依赖重新收集完才更新stage
|
|
@@ -603,13 +561,14 @@ export const initServiceEvents = (
|
|
|
603
561
|
handler();
|
|
604
562
|
} else {
|
|
605
563
|
updateStageNodes(normalNodes);
|
|
606
|
-
|
|
607
|
-
// 在上面判断是否需要收集数据源依赖中已经更新stage
|
|
608
|
-
Promise.all([
|
|
609
|
-
collectIdle(normalNodes, true, DepTargetType.CODE_BLOCK),
|
|
610
|
-
collectIdle(normalNodes, true, DepTargetType.DATA_SOURCE_METHOD),
|
|
611
|
-
]);
|
|
612
564
|
}
|
|
565
|
+
|
|
566
|
+
// 代码块、数据源方法依赖对所有被更新的节点都要收集:同一批里既改了数据源引用又改了方法时不能漏掉
|
|
567
|
+
const updatedNodes = [...needRecollectNodes, ...normalNodes];
|
|
568
|
+
Promise.all([
|
|
569
|
+
collectIdle(updatedNodes, true, DepTargetType.CODE_BLOCK),
|
|
570
|
+
collectIdle(updatedNodes, true, DepTargetType.DATA_SOURCE_METHOD),
|
|
571
|
+
]);
|
|
613
572
|
};
|
|
614
573
|
|
|
615
574
|
// 节点删除,清除对齐的依赖收集
|
|
@@ -634,7 +593,7 @@ export const initServiceEvents = (
|
|
|
634
593
|
|
|
635
594
|
const dataSourceAddHandler = (config: DataSourceSchema) => {
|
|
636
595
|
const handler = async () => {
|
|
637
|
-
|
|
596
|
+
addDataSourceTargets(depService, config, reactive as Reactivity['reactive']);
|
|
638
597
|
const app = await getTMagicApp();
|
|
639
598
|
|
|
640
599
|
if (!app?.dataSourceManager) {
|
|
@@ -669,84 +628,31 @@ export const initServiceEvents = (
|
|
|
669
628
|
ds.setData(config.mocks?.find((mock) => mock.useInEditor)?.data || ds.getDefaultData());
|
|
670
629
|
};
|
|
671
630
|
|
|
672
|
-
|
|
673
|
-
let isModifyField = false;
|
|
674
|
-
let isModifyMock = false;
|
|
675
|
-
let isModifyMethod = false;
|
|
676
|
-
for (const changeRecord of changeRecords) {
|
|
677
|
-
if (!changeRecord.propPath) {
|
|
678
|
-
continue;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
isModifyField =
|
|
682
|
-
changeRecord.propPath === 'fields' ||
|
|
683
|
-
/fields.(\d)+.name/.test(changeRecord.propPath) ||
|
|
684
|
-
/fields.(\d)+.defaultValue/.test(changeRecord.propPath) ||
|
|
685
|
-
/fields.(\d)+$/.test(changeRecord.propPath);
|
|
686
|
-
|
|
687
|
-
isModifyMock = changeRecord.propPath === 'mocks';
|
|
688
|
-
|
|
689
|
-
isModifyMethod =
|
|
690
|
-
changeRecord.propPath === 'methods' ||
|
|
691
|
-
/methods.(\d)+.name/.test(changeRecord.propPath) ||
|
|
692
|
-
/methods.(\d)+$/.test(changeRecord.propPath);
|
|
693
|
-
|
|
694
|
-
needRecollectDep = isModifyField || isModifyMock || isModifyMethod;
|
|
695
|
-
|
|
696
|
-
if (needRecollectDep) {
|
|
697
|
-
break;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
631
|
+
const types = getDataSourceRecollectTypes(changeRecords);
|
|
701
632
|
const root = editorService.get('root');
|
|
702
|
-
if (needRecollectDep) {
|
|
703
|
-
if (Array.isArray(root?.items)) {
|
|
704
|
-
depService.clearIdleTasks();
|
|
705
|
-
|
|
706
|
-
let collectIdlePromises: Promise<boolean>[] = [];
|
|
707
|
-
if (isModifyField) {
|
|
708
|
-
depService.removeTarget(config.id, DepTargetType.DATA_SOURCE);
|
|
709
|
-
depService.removeTarget(config.id, DepTargetType.DATA_SOURCE_COND);
|
|
710
633
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
collectIdle(root.items, true, DepTargetType.DATA_SOURCE),
|
|
716
|
-
collectIdle(root.items, true, DepTargetType.DATA_SOURCE_COND),
|
|
717
|
-
];
|
|
718
|
-
} else if (isModifyMock) {
|
|
719
|
-
depService.removeTarget(config.id, DepTargetType.DATA_SOURCE);
|
|
634
|
+
if (!types) {
|
|
635
|
+
if (root?.dataSources) updateDsData();
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
720
638
|
|
|
721
|
-
|
|
639
|
+
if (!Array.isArray(root?.items)) return;
|
|
722
640
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
641
|
+
depService.clearIdleTasks();
|
|
642
|
+
removeDataSourceTargets(depService, config.id, types);
|
|
643
|
+
addDataSourceTargets(depService, config, reactive as Reactivity['reactive'], types);
|
|
726
644
|
|
|
727
|
-
|
|
645
|
+
const collectIdlePromises = types.map((type) => collectIdle(root.items, true, type));
|
|
728
646
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const results = await Promise.all(collectIdlePromises);
|
|
733
|
-
if (!results.every(Boolean)) return;
|
|
734
|
-
|
|
735
|
-
updateDataSourceSchema();
|
|
736
|
-
await updateDsData();
|
|
737
|
-
updateStageNodes(root.items);
|
|
738
|
-
};
|
|
739
|
-
handler();
|
|
740
|
-
}
|
|
741
|
-
} else if (root?.dataSources) {
|
|
742
|
-
updateDsData();
|
|
743
|
-
}
|
|
744
|
-
};
|
|
647
|
+
const handler = async () => {
|
|
648
|
+
const results = await Promise.all(collectIdlePromises);
|
|
649
|
+
if (!results.every(Boolean)) return;
|
|
745
650
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
651
|
+
updateDataSourceSchema();
|
|
652
|
+
await updateDsData();
|
|
653
|
+
updateStageNodes(root.items);
|
|
654
|
+
};
|
|
655
|
+
handler();
|
|
750
656
|
};
|
|
751
657
|
|
|
752
658
|
const dataSourceRemoveHandler = (id: string) => {
|
|
@@ -773,7 +679,7 @@ export const initServiceEvents = (
|
|
|
773
679
|
app?.dataSourceManager?.removeDataSource(id);
|
|
774
680
|
|
|
775
681
|
updateStageNodes(nodes);
|
|
776
|
-
|
|
682
|
+
removeDataSourceTargets(depService, id);
|
|
777
683
|
};
|
|
778
684
|
|
|
779
685
|
handler();
|
|
@@ -799,45 +705,10 @@ export const initServiceEvents = (
|
|
|
799
705
|
codeBlockService.on('addOrUpdate', codeBlockAddOrUpdateHandler);
|
|
800
706
|
codeBlockService.on('remove', codeBlockRemoveHandler);
|
|
801
707
|
|
|
802
|
-
const targetAddHandler = (target: Target) =>
|
|
803
|
-
const root = editorService.get('root');
|
|
804
|
-
if (!root) return;
|
|
708
|
+
const targetAddHandler = (target: Target) => writeTargetDeps(editorService.get('root'), target);
|
|
805
709
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
root.dataSourceDeps = {};
|
|
809
|
-
}
|
|
810
|
-
root.dataSourceDeps[target.id] = target.deps;
|
|
811
|
-
} else if (target.type === DepTargetType.DATA_SOURCE_COND) {
|
|
812
|
-
if (!root.dataSourceCondDeps) {
|
|
813
|
-
root.dataSourceCondDeps = {};
|
|
814
|
-
}
|
|
815
|
-
root.dataSourceCondDeps[target.id] = target.deps;
|
|
816
|
-
} else if (target.type === DepTargetType.DATA_SOURCE_METHOD) {
|
|
817
|
-
if (!root.dataSourceMethodDeps) {
|
|
818
|
-
root.dataSourceMethodDeps = {};
|
|
819
|
-
}
|
|
820
|
-
root.dataSourceMethodDeps[target.id] = target.deps;
|
|
821
|
-
}
|
|
822
|
-
};
|
|
823
|
-
|
|
824
|
-
const targetRemoveHandler = (id: string | number, type: DepTargetType) => {
|
|
825
|
-
const root = editorService.get('root');
|
|
826
|
-
|
|
827
|
-
if (!root) return;
|
|
828
|
-
|
|
829
|
-
if (root.dataSourceDeps && type === DepTargetType.DATA_SOURCE) {
|
|
830
|
-
delete root.dataSourceDeps[id];
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
if (root.dataSourceCondDeps && type === DepTargetType.DATA_SOURCE_COND) {
|
|
834
|
-
delete root.dataSourceCondDeps[id];
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
if (root.dataSourceMethodDeps && type === DepTargetType.DATA_SOURCE_METHOD) {
|
|
838
|
-
delete root.dataSourceMethodDeps[id];
|
|
839
|
-
}
|
|
840
|
-
};
|
|
710
|
+
const targetRemoveHandler = (id: string | number, type: DepTargetType) =>
|
|
711
|
+
removeTargetDeps(editorService.get('root'), id, type);
|
|
841
712
|
|
|
842
713
|
depService.on('add-target', targetAddHandler);
|
|
843
714
|
depService.on('remove-target', targetRemoveHandler);
|
|
@@ -76,7 +76,7 @@ import type { MPage, MPageFragment } from '@tmagic/core';
|
|
|
76
76
|
|
|
77
77
|
import SplitView from '@editor/components/SplitView.vue';
|
|
78
78
|
import { useServices } from '@editor/hooks/use-services';
|
|
79
|
-
import { Protocol } from '@editor/services/
|
|
79
|
+
import { Protocol } from '@editor/services/sdk-instance';
|
|
80
80
|
import type { FrameworkSlots, GetColumnWidth, PageBarSortOptions } from '@editor/type';
|
|
81
81
|
import { getEditorConfig } from '@editor/utils/config';
|
|
82
82
|
import {
|
|
@@ -62,13 +62,14 @@ const props = withDefaults(
|
|
|
62
62
|
width?: number;
|
|
63
63
|
/** 子元素之间的间距,需与 SCSS gap 保持一致 */
|
|
64
64
|
gap?: number;
|
|
65
|
-
/**
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Popover 内容宽度。不传时按内容撑开,避免下拉框超出菜单。
|
|
67
|
+
*/
|
|
68
|
+
popoverWidth?: number | string;
|
|
67
69
|
}>(),
|
|
68
70
|
{
|
|
69
71
|
items: () => [],
|
|
70
72
|
gap: 3,
|
|
71
|
-
popoverWidth: 180,
|
|
72
73
|
},
|
|
73
74
|
);
|
|
74
75
|
|
|
@@ -110,7 +111,18 @@ const containerWidth = ref(0);
|
|
|
110
111
|
const hiddenIndexSet = ref<Set<number>>(new Set());
|
|
111
112
|
|
|
112
113
|
const hasOverflow = computed(() => hiddenIndexSet.value.size > 0);
|
|
113
|
-
|
|
114
|
+
// 更多菜单是纵向列表:分割线改成横线;收进去的首尾分割线没有分组意义,直接去掉。
|
|
115
|
+
const overflowItems = computed(() => {
|
|
116
|
+
const items = props.items
|
|
117
|
+
.filter((_, index) => hiddenIndexSet.value.has(index))
|
|
118
|
+
.map((item) => (item.type === 'divider' ? { ...item, direction: 'horizontal' as const } : item));
|
|
119
|
+
|
|
120
|
+
let start = 0;
|
|
121
|
+
let end = items.length;
|
|
122
|
+
while (start < end && items[start].type === 'divider') start += 1;
|
|
123
|
+
while (end > start && items[end - 1].type === 'divider') end -= 1;
|
|
124
|
+
return items.slice(start, end);
|
|
125
|
+
});
|
|
114
126
|
|
|
115
127
|
const measureAndCompute = () => {
|
|
116
128
|
if (!columnEl.value) return;
|
|
@@ -13,18 +13,14 @@
|
|
|
13
13
|
:data="{
|
|
14
14
|
type: 'button',
|
|
15
15
|
text: '页面',
|
|
16
|
-
handler:
|
|
17
|
-
addPage(NodeType.PAGE);
|
|
18
|
-
},
|
|
16
|
+
handler: addNormalPage,
|
|
19
17
|
}"
|
|
20
18
|
></ToolButton>
|
|
21
19
|
<ToolButton
|
|
22
20
|
:data="{
|
|
23
21
|
type: 'button',
|
|
24
22
|
text: '页面片',
|
|
25
|
-
handler:
|
|
26
|
-
addPage(NodeType.PAGE_FRAGMENT);
|
|
27
|
-
},
|
|
23
|
+
handler: addPageFragment,
|
|
28
24
|
}"
|
|
29
25
|
></ToolButton>
|
|
30
26
|
</TMagicPopover>
|
|
@@ -62,4 +58,7 @@ const addPage = (type: NodeType.PAGE | NodeType.PAGE_FRAGMENT) => {
|
|
|
62
58
|
};
|
|
63
59
|
editorService.add(pageConfig);
|
|
64
60
|
};
|
|
61
|
+
|
|
62
|
+
const addNormalPage = () => addPage(NodeType.PAGE);
|
|
63
|
+
const addPageFragment = () => addPage(NodeType.PAGE_FRAGMENT);
|
|
65
64
|
</script>
|
|
@@ -66,7 +66,7 @@ import MIcon from '@editor/components/Icon.vue';
|
|
|
66
66
|
import Resizer from '@editor/components/Resizer.vue';
|
|
67
67
|
import { ENABLE_PROPS_FORM_VALIDATE } from '@editor/editorProps';
|
|
68
68
|
import { useServices } from '@editor/hooks/use-services';
|
|
69
|
-
import { Protocol } from '@editor/services/
|
|
69
|
+
import { Protocol } from '@editor/services/sdk-instance';
|
|
70
70
|
import type { NodeInvalidSource, PropsPanelSlots } from '@editor/type';
|
|
71
71
|
import { styleTabConfig } from '@editor/utils';
|
|
72
72
|
import { PROPS_PANEL_WIDTH_STORAGE_KEY } from '@editor/utils/const';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, type Ref, watch } from 'vue';
|
|
2
2
|
|
|
3
|
-
import { Protocol } from '@editor/services/
|
|
3
|
+
import { Protocol } from '@editor/services/sdk-instance';
|
|
4
4
|
import { Services } from '@editor/type';
|
|
5
5
|
import { RIGHT_COLUMN_WIDTH_STORAGE_KEY } from '@editor/utils/const';
|
|
6
6
|
|
|
@@ -97,7 +97,13 @@ let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
|
97
97
|
let clientX: number;
|
|
98
98
|
let clientY: number;
|
|
99
99
|
|
|
100
|
-
const appendComponent = (
|
|
100
|
+
const appendComponent = async (item: ComponentItem): Promise<void> => {
|
|
101
|
+
if (stageOptions?.beforeAppendComponent) {
|
|
102
|
+
const result = await stageOptions.beforeAppendComponent(item);
|
|
103
|
+
if (result === false) return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const { text, type, data = {} } = item;
|
|
101
107
|
editorService.add(
|
|
102
108
|
{
|
|
103
109
|
name: text,
|
|
@@ -450,6 +450,11 @@ const dropHandler = async (e: DragEvent) => {
|
|
|
450
450
|
|
|
451
451
|
dragData.inputEvent = e;
|
|
452
452
|
|
|
453
|
+
if (props.stageOptions.beforeDropComponent) {
|
|
454
|
+
const result = await props.stageOptions.beforeDropComponent(dragData, parent);
|
|
455
|
+
if (result === false) return;
|
|
456
|
+
}
|
|
457
|
+
|
|
453
458
|
editorService.add(dragData, parent, { historySource: 'component-panel' });
|
|
454
459
|
}
|
|
455
460
|
};
|