@tmagic/editor 1.4.6 → 1.4.8
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/style.css +1 -1
- package/dist/tmagic-editor.js +636 -589
- package/dist/tmagic-editor.umd.cjs +634 -586
- package/package.json +15 -11
- package/types/editorProps.d.ts +0 -7
- package/types/layouts/PropsPanel.vue.d.ts +9 -9
- package/types/layouts/sidebar/layer/use-click.d.ts +1 -1
- package/types/services/codeBlock.d.ts +2 -1
- package/types/services/dataSource.d.ts +2 -1
- package/types/services/dep.d.ts +12 -2
- package/types/services/editor.d.ts +22 -4
- package/types/services/props.d.ts +7 -6
- package/types/type.d.ts +6 -0
- package/types/utils/editor.d.ts +1 -0
- package/types/utils/idle-task.d.ts +14 -0
- package/types/utils/operator.d.ts +2 -2
- package/src/Editor.vue +0 -211
- package/src/components/CodeBlockEditor.vue +0 -268
- package/src/components/CodeParams.vue +0 -60
- package/src/components/ContentMenu.vue +0 -193
- package/src/components/FloatingBox.vue +0 -178
- package/src/components/Icon.vue +0 -27
- package/src/components/Resizer.vue +0 -23
- package/src/components/ScrollBar.vue +0 -151
- package/src/components/ScrollViewer.vue +0 -128
- package/src/components/SearchInput.vue +0 -37
- package/src/components/SplitView.vue +0 -186
- package/src/components/ToolButton.vue +0 -138
- package/src/components/Tree.vue +0 -71
- package/src/components/TreeNode.vue +0 -148
- package/src/editorProps.ts +0 -124
- package/src/fields/Code.vue +0 -50
- package/src/fields/CodeLink.vue +0 -80
- package/src/fields/CodeSelect.vue +0 -132
- package/src/fields/CodeSelectCol.vue +0 -139
- package/src/fields/DataSourceFieldSelect.vue +0 -149
- package/src/fields/DataSourceFields.vue +0 -323
- package/src/fields/DataSourceInput.vue +0 -325
- package/src/fields/DataSourceMethodSelect.vue +0 -153
- package/src/fields/DataSourceMethods.vue +0 -104
- package/src/fields/DataSourceMocks.vue +0 -255
- package/src/fields/DataSourceSelect.vue +0 -98
- package/src/fields/EventSelect.vue +0 -301
- package/src/fields/KeyValue.vue +0 -137
- package/src/fields/PageFragmentSelect.vue +0 -63
- package/src/fields/UISelect.vue +0 -135
- package/src/hooks/index.ts +0 -24
- package/src/hooks/use-code-block-edit.ts +0 -83
- package/src/hooks/use-data-source-edit.ts +0 -46
- package/src/hooks/use-data-source-method.ts +0 -100
- package/src/hooks/use-editor-content-height.ts +0 -26
- package/src/hooks/use-filter.ts +0 -55
- package/src/hooks/use-float-box.ts +0 -76
- package/src/hooks/use-getso.ts +0 -35
- package/src/hooks/use-next-float-box-position.ts +0 -29
- package/src/hooks/use-node-status.ts +0 -48
- package/src/hooks/use-stage.ts +0 -129
- package/src/hooks/use-window-rect.ts +0 -20
- package/src/icons/AppManageIcon.vue +0 -15
- package/src/icons/CenterIcon.vue +0 -13
- package/src/icons/CodeIcon.vue +0 -28
- package/src/icons/FolderMinusIcon.vue +0 -22
- package/src/icons/PinIcon.vue +0 -25
- package/src/icons/PinnedIcon.vue +0 -25
- package/src/index.ts +0 -118
- package/src/initService.ts +0 -447
- package/src/layouts/AddPageBox.vue +0 -55
- package/src/layouts/CodeEditor.vue +0 -226
- package/src/layouts/Framework.vue +0 -163
- package/src/layouts/NavMenu.vue +0 -200
- package/src/layouts/PropsPanel.vue +0 -130
- package/src/layouts/page-bar/AddButton.vue +0 -48
- package/src/layouts/page-bar/PageBar.vue +0 -159
- package/src/layouts/page-bar/PageBarScrollContainer.vue +0 -156
- package/src/layouts/page-bar/SwitchTypeButton.vue +0 -45
- package/src/layouts/sidebar/ComponentListPanel.vue +0 -134
- package/src/layouts/sidebar/Sidebar.vue +0 -278
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +0 -142
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +0 -70
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +0 -84
- package/src/layouts/sidebar/data-source/DataSourceList.vue +0 -160
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +0 -106
- package/src/layouts/sidebar/layer/LayerMenu.vue +0 -128
- package/src/layouts/sidebar/layer/LayerNodeTool.vue +0 -32
- package/src/layouts/sidebar/layer/LayerPanel.vue +0 -119
- package/src/layouts/sidebar/layer/use-click.ts +0 -110
- package/src/layouts/sidebar/layer/use-drag.ts +0 -161
- package/src/layouts/sidebar/layer/use-keybinding.ts +0 -54
- package/src/layouts/sidebar/layer/use-node-status.ts +0 -114
- package/src/layouts/workspace/Breadcrumb.vue +0 -35
- package/src/layouts/workspace/Workspace.vue +0 -46
- package/src/layouts/workspace/viewer/NodeListMenu.vue +0 -115
- package/src/layouts/workspace/viewer/Stage.vue +0 -246
- package/src/layouts/workspace/viewer/StageOverlay.vue +0 -68
- package/src/layouts/workspace/viewer/ViewerMenu.vue +0 -145
- package/src/services/BaseService.ts +0 -230
- package/src/services/codeBlock.ts +0 -324
- package/src/services/componentList.ts +0 -58
- package/src/services/dataSource.ts +0 -209
- package/src/services/dep.ts +0 -80
- package/src/services/editor.ts +0 -1087
- package/src/services/events.ts +0 -93
- package/src/services/history.ts +0 -126
- package/src/services/keybinding.ts +0 -220
- package/src/services/props.ts +0 -265
- package/src/services/stageOverlay.ts +0 -212
- package/src/services/storage.ts +0 -155
- package/src/services/ui.ts +0 -156
- package/src/shims-vue.d.ts +0 -6
- package/src/theme/breadcrumb.scss +0 -6
- package/src/theme/code-block.scss +0 -6
- package/src/theme/code-editor.scss +0 -38
- package/src/theme/common/var.scss +0 -14
- package/src/theme/component-list-panel.scss +0 -95
- package/src/theme/content-menu.scss +0 -76
- package/src/theme/data-source-field.scss +0 -12
- package/src/theme/data-source-fields.scss +0 -13
- package/src/theme/data-source-input.scss +0 -18
- package/src/theme/data-source-methods.scss +0 -13
- package/src/theme/data-source.scss +0 -28
- package/src/theme/event.scss +0 -37
- package/src/theme/floating-box.scss +0 -32
- package/src/theme/framework.scss +0 -69
- package/src/theme/icon.scss +0 -12
- package/src/theme/index.scss +0 -10
- package/src/theme/key-value.scss +0 -20
- package/src/theme/layer-panel.scss +0 -26
- package/src/theme/layout.scss +0 -9
- package/src/theme/nav-menu.scss +0 -78
- package/src/theme/page-bar.scss +0 -89
- package/src/theme/page-fragment-select.scss +0 -14
- package/src/theme/props-panel.scss +0 -55
- package/src/theme/resizer.scss +0 -66
- package/src/theme/ruler.scss +0 -38
- package/src/theme/search-input.scss +0 -14
- package/src/theme/sidebar.scss +0 -79
- package/src/theme/stage.scss +0 -76
- package/src/theme/theme.scss +0 -27
- package/src/theme/tree.scss +0 -89
- package/src/theme/workspace.scss +0 -9
- package/src/type.ts +0 -746
- package/src/utils/compose.ts +0 -52
- package/src/utils/config.ts +0 -29
- package/src/utils/content-menu.ts +0 -95
- package/src/utils/data-source/formConfigs/base.ts +0 -30
- package/src/utils/data-source/formConfigs/http.ts +0 -60
- package/src/utils/data-source/index.ts +0 -236
- package/src/utils/editor.ts +0 -294
- package/src/utils/index.ts +0 -24
- package/src/utils/keybinding-config.ts +0 -125
- package/src/utils/logger.ts +0 -47
- package/src/utils/monaco-editor.ts +0 -8
- package/src/utils/operator.ts +0 -106
- package/src/utils/props.ts +0 -504
- package/src/utils/scroll-viewer.ts +0 -165
- package/src/utils/tree.ts +0 -15
- package/src/utils/undo-redo.ts +0 -76
- package/tsconfig.build.json +0 -16
|
@@ -153,8 +153,7 @@
|
|
|
153
153
|
};
|
|
154
154
|
const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
|
|
155
155
|
const init = async () => {
|
|
156
|
-
if (!codeEditor.value)
|
|
157
|
-
return;
|
|
156
|
+
if (!codeEditor.value) return;
|
|
158
157
|
const options = {
|
|
159
158
|
value: values.value,
|
|
160
159
|
language: props.language,
|
|
@@ -367,8 +366,7 @@
|
|
|
367
366
|
}
|
|
368
367
|
);
|
|
369
368
|
const changeHandler = (v) => {
|
|
370
|
-
if (!props.name || !props.model)
|
|
371
|
-
return;
|
|
369
|
+
if (!props.name || !props.model) return;
|
|
372
370
|
try {
|
|
373
371
|
const parseDSL = getConfig("parseDSL");
|
|
374
372
|
props.model[props.name] = parseDSL(`(${v[props.name]})`);
|
|
@@ -511,11 +509,9 @@
|
|
|
511
509
|
});
|
|
512
510
|
|
|
513
511
|
const compose = (middleware, isAsync) => {
|
|
514
|
-
if (!Array.isArray(middleware))
|
|
515
|
-
throw new TypeError("Middleware 必须是一个数组!");
|
|
512
|
+
if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
|
|
516
513
|
for (const fn of middleware) {
|
|
517
|
-
if (typeof fn !== "function")
|
|
518
|
-
throw new TypeError("Middleware 必须由函数组成!");
|
|
514
|
+
if (typeof fn !== "function") throw new TypeError("Middleware 必须由函数组成!");
|
|
519
515
|
}
|
|
520
516
|
return (args, next) => {
|
|
521
517
|
let index = -1;
|
|
@@ -530,8 +526,7 @@
|
|
|
530
526
|
}
|
|
531
527
|
index = i;
|
|
532
528
|
let fn = middleware[i];
|
|
533
|
-
if (i === middleware.length && next)
|
|
534
|
-
fn = next;
|
|
529
|
+
if (i === middleware.length && next) fn = next;
|
|
535
530
|
if (!fn) {
|
|
536
531
|
if (isAsync) {
|
|
537
532
|
return Promise.resolve();
|
|
@@ -561,8 +556,7 @@
|
|
|
561
556
|
let beforeArgs = args;
|
|
562
557
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
563
558
|
beforeArgs = beforeMethod(...beforeArgs) || [];
|
|
564
|
-
if (isError(beforeArgs))
|
|
565
|
-
throw beforeArgs;
|
|
559
|
+
if (isError(beforeArgs)) throw beforeArgs;
|
|
566
560
|
if (!Array.isArray(beforeArgs)) {
|
|
567
561
|
beforeArgs = [beforeArgs];
|
|
568
562
|
}
|
|
@@ -570,8 +564,7 @@
|
|
|
570
564
|
let returnValue = fn(beforeArgs, sourceMethod.bind(scope));
|
|
571
565
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
572
566
|
returnValue = afterMethod(returnValue, ...beforeArgs);
|
|
573
|
-
if (isError(returnValue))
|
|
574
|
-
throw returnValue;
|
|
567
|
+
if (isError(returnValue)) throw returnValue;
|
|
575
568
|
}
|
|
576
569
|
return returnValue;
|
|
577
570
|
} catch (error) {
|
|
@@ -583,8 +576,7 @@
|
|
|
583
576
|
let beforeArgs = args;
|
|
584
577
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
585
578
|
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
586
|
-
if (isError(beforeArgs))
|
|
587
|
-
throw beforeArgs;
|
|
579
|
+
if (isError(beforeArgs)) throw beforeArgs;
|
|
588
580
|
if (!Array.isArray(beforeArgs)) {
|
|
589
581
|
beforeArgs = [beforeArgs];
|
|
590
582
|
}
|
|
@@ -592,8 +584,7 @@
|
|
|
592
584
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
593
585
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
594
586
|
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
595
|
-
if (isError(returnValue))
|
|
596
|
-
throw returnValue;
|
|
587
|
+
if (isError(returnValue)) throw returnValue;
|
|
597
588
|
}
|
|
598
589
|
return returnValue;
|
|
599
590
|
} catch (error) {
|
|
@@ -644,14 +635,12 @@
|
|
|
644
635
|
*/
|
|
645
636
|
use(options) {
|
|
646
637
|
Object.entries(options).forEach(([methodName2, method]) => {
|
|
647
|
-
if (typeof method === "function")
|
|
648
|
-
this.middleware[methodName2].push(method);
|
|
638
|
+
if (typeof method === "function") this.middleware[methodName2].push(method);
|
|
649
639
|
});
|
|
650
640
|
}
|
|
651
641
|
usePlugin(options) {
|
|
652
642
|
Object.entries(options).forEach(([methodName2, method]) => {
|
|
653
|
-
if (typeof method === "function")
|
|
654
|
-
this.pluginOptionsList[methodName2].push(method);
|
|
643
|
+
if (typeof method === "function") this.pluginOptionsList[methodName2].push(method);
|
|
655
644
|
});
|
|
656
645
|
}
|
|
657
646
|
removeAllPlugins() {
|
|
@@ -673,48 +662,6 @@
|
|
|
673
662
|
}
|
|
674
663
|
}
|
|
675
664
|
|
|
676
|
-
class Dep extends BaseService {
|
|
677
|
-
watcher = new dep.Watcher({ initialTargets: vue.reactive({}) });
|
|
678
|
-
removeTargets(type = dep.DepTargetType.DEFAULT) {
|
|
679
|
-
this.watcher.removeTargets(type);
|
|
680
|
-
this.emit("remove-target");
|
|
681
|
-
}
|
|
682
|
-
getTargets(type = dep.DepTargetType.DEFAULT) {
|
|
683
|
-
return this.watcher.getTargets(type);
|
|
684
|
-
}
|
|
685
|
-
getTarget(id, type = dep.DepTargetType.DEFAULT) {
|
|
686
|
-
return this.watcher.getTarget(id, type);
|
|
687
|
-
}
|
|
688
|
-
addTarget(target) {
|
|
689
|
-
this.watcher.addTarget(target);
|
|
690
|
-
this.emit("add-target", target);
|
|
691
|
-
}
|
|
692
|
-
removeTarget(id, type = dep.DepTargetType.DEFAULT) {
|
|
693
|
-
this.watcher.removeTarget(id, type);
|
|
694
|
-
this.emit("remove-target");
|
|
695
|
-
}
|
|
696
|
-
clearTargets() {
|
|
697
|
-
this.watcher.clearTargets();
|
|
698
|
-
}
|
|
699
|
-
collect(nodes, deep = false, type) {
|
|
700
|
-
this.watcher.collect(nodes, deep, type);
|
|
701
|
-
this.emit("collected", nodes, deep);
|
|
702
|
-
}
|
|
703
|
-
clear(nodes) {
|
|
704
|
-
return this.watcher.clear(nodes);
|
|
705
|
-
}
|
|
706
|
-
clearByType(type, nodes) {
|
|
707
|
-
return this.watcher.clearByType(type, nodes);
|
|
708
|
-
}
|
|
709
|
-
hasTarget(id, type = dep.DepTargetType.DEFAULT) {
|
|
710
|
-
return this.watcher.hasTarget(id, type);
|
|
711
|
-
}
|
|
712
|
-
hasSpecifiedTypeTarget(type = dep.DepTargetType.DEFAULT) {
|
|
713
|
-
return this.watcher.hasSpecifiedTypeTarget(type);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
const depService = new Dep();
|
|
717
|
-
|
|
718
665
|
const canUsePluginMethods$6 = {
|
|
719
666
|
async: [
|
|
720
667
|
"setPropsConfig",
|
|
@@ -748,7 +695,11 @@
|
|
|
748
695
|
return fillConfig(config, typeof labelWidth !== "function" ? labelWidth : "80px");
|
|
749
696
|
}
|
|
750
697
|
async setPropsConfig(type, config) {
|
|
751
|
-
|
|
698
|
+
let c = config;
|
|
699
|
+
if (typeof config === "function") {
|
|
700
|
+
c = config({ editorService });
|
|
701
|
+
}
|
|
702
|
+
this.state.propsConfigMap[utils.toLine(type)] = await this.fillConfig(Array.isArray(c) ? c : [c]);
|
|
752
703
|
}
|
|
753
704
|
/**
|
|
754
705
|
* 获取指点类型的组件属性表单配置
|
|
@@ -772,7 +723,11 @@
|
|
|
772
723
|
* @param value 组件初始值
|
|
773
724
|
*/
|
|
774
725
|
async setPropsValue(type, value) {
|
|
775
|
-
|
|
726
|
+
let v = value;
|
|
727
|
+
if (typeof value === "function") {
|
|
728
|
+
v = value({ editorService });
|
|
729
|
+
}
|
|
730
|
+
this.state.propsValueMap[utils.toLine(type)] = v;
|
|
776
731
|
}
|
|
777
732
|
/**
|
|
778
733
|
* 获取指定类型的组件初始值
|
|
@@ -854,30 +809,28 @@
|
|
|
854
809
|
* @param originConfigs 原组件配置
|
|
855
810
|
* @param targetConfigs 待替换的组件配置
|
|
856
811
|
*/
|
|
857
|
-
replaceRelateId(originConfigs, targetConfigs) {
|
|
812
|
+
replaceRelateId(originConfigs, targetConfigs, collectorOptions) {
|
|
858
813
|
const relateIdMap = this.getRelateIdMap();
|
|
859
|
-
if (Object.keys(relateIdMap).length === 0)
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
814
|
+
if (Object.keys(relateIdMap).length === 0) return;
|
|
815
|
+
const target = new dep.Target({
|
|
816
|
+
...collectorOptions
|
|
817
|
+
});
|
|
818
|
+
const coperWatcher = new dep.Watcher();
|
|
819
|
+
coperWatcher.addTarget(target);
|
|
820
|
+
coperWatcher.collect(originConfigs, {}, true, collectorOptions.type);
|
|
866
821
|
originConfigs.forEach((config) => {
|
|
867
822
|
const newId = relateIdMap[config.id];
|
|
868
823
|
const path = utils.getNodePath(newId, targetConfigs);
|
|
869
824
|
const targetConfig = path[path.length - 1];
|
|
870
|
-
if (!targetConfig)
|
|
871
|
-
return;
|
|
825
|
+
if (!targetConfig) return;
|
|
872
826
|
target.deps[config.id]?.keys?.forEach((fullKey) => {
|
|
873
827
|
const relateOriginId = utils.getValueByKeyPath(fullKey, config);
|
|
874
828
|
const relateTargetId = relateIdMap[relateOriginId];
|
|
875
|
-
if (!relateTargetId)
|
|
876
|
-
return;
|
|
829
|
+
if (!relateTargetId) return;
|
|
877
830
|
utils.setValueByKeyPath(fullKey, relateTargetId, targetConfig);
|
|
878
831
|
});
|
|
879
832
|
if (config.items && Array.isArray(config.items)) {
|
|
880
|
-
this.replaceRelateId(config.items, targetConfigs);
|
|
833
|
+
this.replaceRelateId(config.items, targetConfigs, collectorOptions);
|
|
881
834
|
}
|
|
882
835
|
});
|
|
883
836
|
}
|
|
@@ -983,8 +936,7 @@
|
|
|
983
936
|
this.state.canUndo = false;
|
|
984
937
|
}
|
|
985
938
|
changePage(page) {
|
|
986
|
-
if (!page)
|
|
987
|
-
return;
|
|
939
|
+
if (!page) return;
|
|
988
940
|
this.state.pageId = page.id;
|
|
989
941
|
if (!this.state.pageSteps[this.state.pageId]) {
|
|
990
942
|
const undoRedo = new UndoRedo();
|
|
@@ -1006,24 +958,21 @@
|
|
|
1006
958
|
}
|
|
1007
959
|
push(state) {
|
|
1008
960
|
const undoRedo = this.getUndoRedo();
|
|
1009
|
-
if (!undoRedo)
|
|
1010
|
-
return null;
|
|
961
|
+
if (!undoRedo) return null;
|
|
1011
962
|
undoRedo.pushElement(state);
|
|
1012
963
|
this.emit("change", state);
|
|
1013
964
|
return state;
|
|
1014
965
|
}
|
|
1015
966
|
undo() {
|
|
1016
967
|
const undoRedo = this.getUndoRedo();
|
|
1017
|
-
if (!undoRedo)
|
|
1018
|
-
return null;
|
|
968
|
+
if (!undoRedo) return null;
|
|
1019
969
|
const state = undoRedo.undo();
|
|
1020
970
|
this.emit("change", state);
|
|
1021
971
|
return state;
|
|
1022
972
|
}
|
|
1023
973
|
redo() {
|
|
1024
974
|
const undoRedo = this.getUndoRedo();
|
|
1025
|
-
if (!undoRedo)
|
|
1026
|
-
return null;
|
|
975
|
+
if (!undoRedo) return null;
|
|
1027
976
|
const state = undoRedo.redo();
|
|
1028
977
|
this.emit("change", state);
|
|
1029
978
|
return state;
|
|
@@ -1034,8 +983,7 @@
|
|
|
1034
983
|
this.removeAllPlugins();
|
|
1035
984
|
}
|
|
1036
985
|
getUndoRedo() {
|
|
1037
|
-
if (!this.state.pageId)
|
|
1038
|
-
return null;
|
|
986
|
+
if (!this.state.pageId) return null;
|
|
1039
987
|
return this.state.pageSteps[this.state.pageId];
|
|
1040
988
|
}
|
|
1041
989
|
setCanUndoRedo() {
|
|
@@ -1096,8 +1044,7 @@
|
|
|
1096
1044
|
const { protocol = options.protocol, item } = this.getValueAndProtocol(
|
|
1097
1045
|
storage.getItem(`${options.namespace || namespace}:${key}`)
|
|
1098
1046
|
);
|
|
1099
|
-
if (item === null)
|
|
1100
|
-
return null;
|
|
1047
|
+
if (item === null) return null;
|
|
1101
1048
|
switch (protocol) {
|
|
1102
1049
|
case "object" /* OBJECT */:
|
|
1103
1050
|
return getConfig("parseDSL")(`(${item})`);
|
|
@@ -1238,24 +1185,19 @@
|
|
|
1238
1185
|
const COPY_CODE_STORAGE_KEY = "$MagicEditorCopyCode";
|
|
1239
1186
|
const COPY_DS_STORAGE_KEY = "$MagicEditorCopyDataSource";
|
|
1240
1187
|
const getPageList = (root) => {
|
|
1241
|
-
if (!root)
|
|
1242
|
-
|
|
1243
|
-
if (!Array.isArray(root.items))
|
|
1244
|
-
return [];
|
|
1188
|
+
if (!root) return [];
|
|
1189
|
+
if (!Array.isArray(root.items)) return [];
|
|
1245
1190
|
return root.items.filter((item) => utils.isPage(item));
|
|
1246
1191
|
};
|
|
1247
1192
|
const getPageFragmentList = (root) => {
|
|
1248
|
-
if (!root)
|
|
1249
|
-
|
|
1250
|
-
if (!Array.isArray(root.items))
|
|
1251
|
-
return [];
|
|
1193
|
+
if (!root) return [];
|
|
1194
|
+
if (!Array.isArray(root.items)) return [];
|
|
1252
1195
|
return root.items.filter((item) => utils.isPageFragment(item));
|
|
1253
1196
|
};
|
|
1254
1197
|
const getPageNameList = (pages) => pages.map((page) => page.name || "index");
|
|
1255
1198
|
const generatePageName = (pageNameList, type) => {
|
|
1256
1199
|
let pageLength = pageNameList.length;
|
|
1257
|
-
if (!pageLength)
|
|
1258
|
-
return `${type}_index`;
|
|
1200
|
+
if (!pageLength) return `${type}_index`;
|
|
1259
1201
|
let pageName = `${type}_${pageLength}`;
|
|
1260
1202
|
while (pageNameList.includes(pageName)) {
|
|
1261
1203
|
pageLength += 1;
|
|
@@ -1277,8 +1219,7 @@
|
|
|
1277
1219
|
});
|
|
1278
1220
|
const getMiddleTop = (node, parentNode, stage) => {
|
|
1279
1221
|
let height = node.style?.height || 0;
|
|
1280
|
-
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
1281
|
-
return node.style?.top;
|
|
1222
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style) return node.style?.top;
|
|
1282
1223
|
if (!utils.isNumber(height)) {
|
|
1283
1224
|
height = 0;
|
|
1284
1225
|
}
|
|
@@ -1314,11 +1255,9 @@
|
|
|
1314
1255
|
return node;
|
|
1315
1256
|
};
|
|
1316
1257
|
const setLayout = (node, layout) => {
|
|
1317
|
-
if (utils.isPop(node))
|
|
1318
|
-
return;
|
|
1258
|
+
if (utils.isPop(node)) return;
|
|
1319
1259
|
const style = node.style || {};
|
|
1320
|
-
if (style.position === "fixed")
|
|
1321
|
-
return;
|
|
1260
|
+
if (style.position === "fixed") return;
|
|
1322
1261
|
if (layout !== Layout.RELATIVE) {
|
|
1323
1262
|
style.position = "absolute";
|
|
1324
1263
|
} else {
|
|
@@ -1372,8 +1311,7 @@
|
|
|
1372
1311
|
return getRelativeStyle(style);
|
|
1373
1312
|
};
|
|
1374
1313
|
const getGuideLineFromCache = (key) => {
|
|
1375
|
-
if (!key)
|
|
1376
|
-
return [];
|
|
1314
|
+
if (!key) return [];
|
|
1377
1315
|
const guideLineCacheData = globalThis.localStorage.getItem(key);
|
|
1378
1316
|
if (guideLineCacheData) {
|
|
1379
1317
|
try {
|
|
@@ -1385,8 +1323,7 @@
|
|
|
1385
1323
|
return [];
|
|
1386
1324
|
};
|
|
1387
1325
|
const fixNodeLeft = (config, parent, doc) => {
|
|
1388
|
-
if (!doc || !config.style || !utils.isNumber(config.style.left))
|
|
1389
|
-
return config.style?.left;
|
|
1326
|
+
if (!doc || !config.style || !utils.isNumber(config.style.left)) return config.style?.left;
|
|
1390
1327
|
const el = doc.getElementById(`${config.id}`);
|
|
1391
1328
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1392
1329
|
const left = Number(config.style?.left) || 0;
|
|
@@ -1415,24 +1352,39 @@
|
|
|
1415
1352
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1416
1353
|
const traverseNode = (node, cb, parents = []) => {
|
|
1417
1354
|
cb(node, parents);
|
|
1418
|
-
if (node.items
|
|
1355
|
+
if (Array.isArray(node.items) && node.items.length) {
|
|
1419
1356
|
parents.push(node);
|
|
1420
1357
|
node.items.forEach((item) => {
|
|
1421
1358
|
traverseNode(item, cb, [...parents]);
|
|
1422
1359
|
});
|
|
1423
1360
|
}
|
|
1424
1361
|
};
|
|
1362
|
+
const moveItemsInContainer = (sourceIndices, parent, targetIndex) => {
|
|
1363
|
+
sourceIndices.sort((a, b) => a - b);
|
|
1364
|
+
for (let i = sourceIndices.length - 1; i >= 0; i--) {
|
|
1365
|
+
const sourceIndex = sourceIndices[i];
|
|
1366
|
+
if (sourceIndex === targetIndex) {
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
const [item] = parent.items.splice(sourceIndex, 1);
|
|
1370
|
+
parent.items.splice(sourceIndex < targetIndex ? targetIndex - 1 : targetIndex, 0, item);
|
|
1371
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
1372
|
+
if (sourceIndices[j] >= targetIndex) {
|
|
1373
|
+
sourceIndices[j] += 1;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1425
1378
|
|
|
1426
|
-
const beforePaste = (position, config) => {
|
|
1427
|
-
if (!config[0]?.style)
|
|
1428
|
-
return config;
|
|
1379
|
+
const beforePaste = (position, config, doc) => {
|
|
1380
|
+
if (!config[0]?.style) return config;
|
|
1429
1381
|
const curNode = editorService.get("node");
|
|
1430
1382
|
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
1431
1383
|
const pasteConfigs = config.map((configItem) => {
|
|
1432
1384
|
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
1433
1385
|
let pastePosition = positionClone;
|
|
1434
1386
|
if (!lodashEs.isEmpty(pastePosition) && curNode?.items) {
|
|
1435
|
-
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
1387
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id, doc);
|
|
1436
1388
|
}
|
|
1437
1389
|
if (pastePosition.left && configItem.style?.left) {
|
|
1438
1390
|
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
@@ -1462,12 +1414,12 @@
|
|
|
1462
1414
|
});
|
|
1463
1415
|
return pasteConfigs;
|
|
1464
1416
|
};
|
|
1465
|
-
const getPositionInContainer = (position = {}, id) => {
|
|
1417
|
+
const getPositionInContainer = (position = {}, id, doc) => {
|
|
1466
1418
|
let { left = 0, top = 0 } = position;
|
|
1467
1419
|
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1468
1420
|
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1469
|
-
left = left - (parentElRect?.left || 0);
|
|
1470
|
-
top = top - (parentElRect?.top || 0);
|
|
1421
|
+
left = left - utils.calcValueByFontsize(doc, parentElRect?.left || 0);
|
|
1422
|
+
top = top - utils.calcValueByFontsize(doc, parentElRect?.top || 0);
|
|
1471
1423
|
return {
|
|
1472
1424
|
left,
|
|
1473
1425
|
top
|
|
@@ -1595,15 +1547,13 @@
|
|
|
1595
1547
|
parent: null,
|
|
1596
1548
|
page: null
|
|
1597
1549
|
};
|
|
1598
|
-
if (!root)
|
|
1599
|
-
return info;
|
|
1550
|
+
if (!root) return info;
|
|
1600
1551
|
if (id === root.id) {
|
|
1601
1552
|
info.node = root;
|
|
1602
1553
|
return info;
|
|
1603
1554
|
}
|
|
1604
1555
|
const path = utils.getNodePath(id, root.items);
|
|
1605
|
-
if (!path.length)
|
|
1606
|
-
return info;
|
|
1556
|
+
if (!path.length) return info;
|
|
1607
1557
|
path.unshift(root);
|
|
1608
1558
|
info.node = path[path.length - 1];
|
|
1609
1559
|
info.parent = path[path.length - 2];
|
|
@@ -1639,8 +1589,7 @@
|
|
|
1639
1589
|
* 只有容器拥有布局
|
|
1640
1590
|
*/
|
|
1641
1591
|
async getLayout(parent, node) {
|
|
1642
|
-
if (node && typeof node !== "function" && isFixed(node))
|
|
1643
|
-
return Layout.FIXED;
|
|
1592
|
+
if (node && typeof node !== "function" && isFixed(node)) return Layout.FIXED;
|
|
1644
1593
|
if (parent.layout) {
|
|
1645
1594
|
return parent.layout;
|
|
1646
1595
|
}
|
|
@@ -1680,11 +1629,9 @@
|
|
|
1680
1629
|
}
|
|
1681
1630
|
async selectNextNode() {
|
|
1682
1631
|
const node = vue.toRaw(this.get("node"));
|
|
1683
|
-
if (!node || utils.isPage(node) || node.type === schema.NodeType.ROOT)
|
|
1684
|
-
return node;
|
|
1632
|
+
if (!node || utils.isPage(node) || node.type === schema.NodeType.ROOT) return node;
|
|
1685
1633
|
const parent = vue.toRaw(this.getParentById(node.id));
|
|
1686
|
-
if (!parent)
|
|
1687
|
-
return node;
|
|
1634
|
+
if (!parent) return node;
|
|
1688
1635
|
const index = getNodeIndex(node.id, parent);
|
|
1689
1636
|
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
1690
1637
|
await this.select(nextNode);
|
|
@@ -1694,10 +1641,8 @@
|
|
|
1694
1641
|
async selectNextPage() {
|
|
1695
1642
|
const root = vue.toRaw(this.get("root"));
|
|
1696
1643
|
const page = vue.toRaw(this.get("page"));
|
|
1697
|
-
if (!page)
|
|
1698
|
-
|
|
1699
|
-
if (!root)
|
|
1700
|
-
throw new Error("root不能为空");
|
|
1644
|
+
if (!page) throw new Error("page不能为空");
|
|
1645
|
+
if (!root) throw new Error("root不能为空");
|
|
1701
1646
|
const index = getNodeIndex(page.id, root);
|
|
1702
1647
|
const nextPage = root.items[index + 1] || root.items[0];
|
|
1703
1648
|
await this.select(nextPage);
|
|
@@ -1712,8 +1657,7 @@
|
|
|
1712
1657
|
highlight(config) {
|
|
1713
1658
|
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1714
1659
|
const currentHighlightNode = this.get("highlightNode");
|
|
1715
|
-
if (currentHighlightNode === node)
|
|
1716
|
-
return;
|
|
1660
|
+
if (currentHighlightNode === node) return;
|
|
1717
1661
|
this.set("highlightNode", node);
|
|
1718
1662
|
}
|
|
1719
1663
|
/**
|
|
@@ -1726,16 +1670,14 @@
|
|
|
1726
1670
|
const idsUnique = lodashEs.uniq(ids);
|
|
1727
1671
|
idsUnique.forEach((id) => {
|
|
1728
1672
|
const { node } = this.getNodeInfo(id);
|
|
1729
|
-
if (!node)
|
|
1730
|
-
return;
|
|
1673
|
+
if (!node) return;
|
|
1731
1674
|
nodes.push(node);
|
|
1732
1675
|
});
|
|
1733
1676
|
this.set("nodes", nodes);
|
|
1734
1677
|
}
|
|
1735
1678
|
selectRoot() {
|
|
1736
1679
|
const root = this.get("root");
|
|
1737
|
-
if (!root)
|
|
1738
|
-
return;
|
|
1680
|
+
if (!root) return;
|
|
1739
1681
|
this.set("nodes", [root]);
|
|
1740
1682
|
this.set("parent", null);
|
|
1741
1683
|
this.set("page", null);
|
|
@@ -1744,12 +1686,10 @@
|
|
|
1744
1686
|
}
|
|
1745
1687
|
async doAdd(node, parent) {
|
|
1746
1688
|
const root = this.get("root");
|
|
1747
|
-
if (!root)
|
|
1748
|
-
throw new Error("root为空");
|
|
1689
|
+
if (!root) throw new Error("root为空");
|
|
1749
1690
|
const curNode = this.get("node");
|
|
1750
1691
|
const stage = this.get("stage");
|
|
1751
|
-
if (!curNode)
|
|
1752
|
-
throw new Error("当前选中节点为空");
|
|
1692
|
+
if (!curNode) throw new Error("当前选中节点为空");
|
|
1753
1693
|
if ((parent.type === schema.NodeType.ROOT || curNode?.type === schema.NodeType.ROOT) && !(utils.isPage(node) || utils.isPageFragment(node))) {
|
|
1754
1694
|
throw new Error("app下不能添加组件");
|
|
1755
1695
|
}
|
|
@@ -1786,8 +1726,7 @@
|
|
|
1786
1726
|
const addNodes = [];
|
|
1787
1727
|
if (!Array.isArray(addNode)) {
|
|
1788
1728
|
const { type, inputEvent, ...config } = addNode;
|
|
1789
|
-
if (!type)
|
|
1790
|
-
throw new Error("组件类型不能为空");
|
|
1729
|
+
if (!type) throw new Error("组件类型不能为空");
|
|
1791
1730
|
addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
|
|
1792
1731
|
} else {
|
|
1793
1732
|
addNodes.push(...addNode);
|
|
@@ -1799,8 +1738,7 @@
|
|
|
1799
1738
|
return this.doAdd(node, root);
|
|
1800
1739
|
}
|
|
1801
1740
|
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1802
|
-
if (!parentNode)
|
|
1803
|
-
throw new Error("未找到父元素");
|
|
1741
|
+
if (!parentNode) throw new Error("未找到父元素");
|
|
1804
1742
|
return this.doAdd(node, parentNode);
|
|
1805
1743
|
})
|
|
1806
1744
|
);
|
|
@@ -1826,14 +1764,11 @@
|
|
|
1826
1764
|
}
|
|
1827
1765
|
async doRemove(node) {
|
|
1828
1766
|
const root = this.get("root");
|
|
1829
|
-
if (!root)
|
|
1830
|
-
throw new Error("root不能为空");
|
|
1767
|
+
if (!root) throw new Error("root不能为空");
|
|
1831
1768
|
const { parent, node: curNode } = this.getNodeInfo(node.id, false);
|
|
1832
|
-
if (!parent || !curNode)
|
|
1833
|
-
throw new Error("找不要删除的节点");
|
|
1769
|
+
if (!parent || !curNode) throw new Error("找不要删除的节点");
|
|
1834
1770
|
const index = getNodeIndex(curNode.id, parent);
|
|
1835
|
-
if (typeof index !== "number" || index === -1)
|
|
1836
|
-
throw new Error("找不要删除的节点");
|
|
1771
|
+
if (typeof index !== "number" || index === -1) throw new Error("找不要删除的节点");
|
|
1837
1772
|
parent.items?.splice(index, 1);
|
|
1838
1773
|
const stage = this.get("stage");
|
|
1839
1774
|
stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
@@ -1877,13 +1812,10 @@
|
|
|
1877
1812
|
}
|
|
1878
1813
|
async doUpdate(config) {
|
|
1879
1814
|
const root = this.get("root");
|
|
1880
|
-
if (!root)
|
|
1881
|
-
|
|
1882
|
-
if (!config?.id)
|
|
1883
|
-
throw new Error("没有配置或者配置缺少id值");
|
|
1815
|
+
if (!root) throw new Error("root为空");
|
|
1816
|
+
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
1884
1817
|
const info = this.getNodeInfo(config.id, false);
|
|
1885
|
-
if (!info.node)
|
|
1886
|
-
throw new Error(`获取不到id为${config.id}的节点`);
|
|
1818
|
+
if (!info.node) throw new Error(`获取不到id为${config.id}的节点`);
|
|
1887
1819
|
const node = lodashEs.cloneDeep(vue.toRaw(info.node));
|
|
1888
1820
|
let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, root);
|
|
1889
1821
|
newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue, key) => {
|
|
@@ -1897,19 +1829,16 @@
|
|
|
1897
1829
|
return srcValue;
|
|
1898
1830
|
}
|
|
1899
1831
|
});
|
|
1900
|
-
if (!newConfig.type)
|
|
1901
|
-
throw new Error("配置缺少type值");
|
|
1832
|
+
if (!newConfig.type) throw new Error("配置缺少type值");
|
|
1902
1833
|
if (newConfig.type === schema.NodeType.ROOT) {
|
|
1903
1834
|
this.set("root", newConfig);
|
|
1904
1835
|
return newConfig;
|
|
1905
1836
|
}
|
|
1906
1837
|
const { parent } = info;
|
|
1907
|
-
if (!parent)
|
|
1908
|
-
throw new Error("获取不到父级节点");
|
|
1838
|
+
if (!parent) throw new Error("获取不到父级节点");
|
|
1909
1839
|
const parentNodeItems = parent.items;
|
|
1910
1840
|
const index = getNodeIndex(newConfig.id, parent);
|
|
1911
|
-
if (!parentNodeItems || typeof index === "undefined" || index === -1)
|
|
1912
|
-
throw new Error("更新的节点未找到");
|
|
1841
|
+
if (!parentNodeItems || typeof index === "undefined" || index === -1) throw new Error("更新的节点未找到");
|
|
1913
1842
|
const newLayout = await this.getLayout(newConfig);
|
|
1914
1843
|
const layout = await this.getLayout(node);
|
|
1915
1844
|
if (Array.isArray(newConfig.items) && newLayout !== layout) {
|
|
@@ -1953,17 +1882,13 @@
|
|
|
1953
1882
|
*/
|
|
1954
1883
|
async sort(id1, id2) {
|
|
1955
1884
|
const root = this.get("root");
|
|
1956
|
-
if (!root)
|
|
1957
|
-
throw new Error("root为空");
|
|
1885
|
+
if (!root) throw new Error("root为空");
|
|
1958
1886
|
const node = this.get("node");
|
|
1959
|
-
if (!node)
|
|
1960
|
-
throw new Error("当前节点为空");
|
|
1887
|
+
if (!node) throw new Error("当前节点为空");
|
|
1961
1888
|
const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
|
|
1962
|
-
if (!parent)
|
|
1963
|
-
throw new Error("父节点为空");
|
|
1889
|
+
if (!parent) throw new Error("父节点为空");
|
|
1964
1890
|
const index2 = parent.items.findIndex((node2) => `${node2.id}` === `${id2}`);
|
|
1965
|
-
if (index2 < 0)
|
|
1966
|
-
return;
|
|
1891
|
+
if (index2 < 0) return;
|
|
1967
1892
|
const index1 = parent.items.findIndex((node2) => `${node2.id}` === `${id1}`);
|
|
1968
1893
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1969
1894
|
await this.update(parent);
|
|
@@ -1991,19 +1916,18 @@
|
|
|
1991
1916
|
* @param config 组件节点配置
|
|
1992
1917
|
* @returns
|
|
1993
1918
|
*/
|
|
1994
|
-
copyWithRelated(config) {
|
|
1919
|
+
copyWithRelated(config, collectorOptions) {
|
|
1995
1920
|
const copyNodes = Array.isArray(config) ? config : [config];
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
dep.
|
|
2001
|
-
|
|
2002
|
-
|
|
1921
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
1922
|
+
const customTarget = new dep.Target({
|
|
1923
|
+
...collectorOptions
|
|
1924
|
+
});
|
|
1925
|
+
const coperWatcher = new dep.Watcher();
|
|
1926
|
+
coperWatcher.addTarget(customTarget);
|
|
1927
|
+
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
2003
1928
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
2004
1929
|
const node = this.getNodeById(nodeId);
|
|
2005
|
-
if (!node)
|
|
2006
|
-
return;
|
|
1930
|
+
if (!node) return;
|
|
2007
1931
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
2008
1932
|
const relateNodeId = lodashEs.get(node, key);
|
|
2009
1933
|
const isExist = copyNodes.find((node2) => node2.id === relateNodeId);
|
|
@@ -2025,10 +1949,9 @@
|
|
|
2025
1949
|
* @param position 粘贴的坐标
|
|
2026
1950
|
* @returns 添加后的组件节点配置
|
|
2027
1951
|
*/
|
|
2028
|
-
async paste(position = {}) {
|
|
1952
|
+
async paste(position = {}, collectorOptions) {
|
|
2029
1953
|
const config = storageService.getItem(COPY_STORAGE_KEY);
|
|
2030
|
-
if (!Array.isArray(config))
|
|
2031
|
-
return;
|
|
1954
|
+
if (!Array.isArray(config)) return;
|
|
2032
1955
|
const node = this.get("node");
|
|
2033
1956
|
let parent = null;
|
|
2034
1957
|
if (config.length === 1 && config[0].id === node?.id) {
|
|
@@ -2038,25 +1961,26 @@
|
|
|
2038
1961
|
}
|
|
2039
1962
|
}
|
|
2040
1963
|
const pasteConfigs = await this.doPaste(config, position);
|
|
2041
|
-
|
|
1964
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
1965
|
+
propsService.replaceRelateId(config, pasteConfigs, collectorOptions);
|
|
1966
|
+
}
|
|
2042
1967
|
return this.add(pasteConfigs, parent);
|
|
2043
1968
|
}
|
|
2044
1969
|
async doPaste(config, position = {}) {
|
|
2045
1970
|
propsService.clearRelateId();
|
|
2046
|
-
const
|
|
1971
|
+
const doc = this.get("stage")?.renderer.contentWindow?.document;
|
|
1972
|
+
const pasteConfigs = beforePaste(position, lodashEs.cloneDeep(config), doc);
|
|
2047
1973
|
return pasteConfigs;
|
|
2048
1974
|
}
|
|
2049
1975
|
async doAlignCenter(config) {
|
|
2050
1976
|
const parent = this.getParentById(config.id);
|
|
2051
|
-
if (!parent)
|
|
2052
|
-
throw new Error("找不到父节点");
|
|
1977
|
+
if (!parent) throw new Error("找不到父节点");
|
|
2053
1978
|
const node = lodashEs.cloneDeep(vue.toRaw(config));
|
|
2054
1979
|
const layout = await this.getLayout(parent, node);
|
|
2055
1980
|
if (layout === Layout.RELATIVE) {
|
|
2056
1981
|
return config;
|
|
2057
1982
|
}
|
|
2058
|
-
if (!node.style)
|
|
2059
|
-
return config;
|
|
1983
|
+
if (!node.style) return config;
|
|
2060
1984
|
const stage = this.get("stage");
|
|
2061
1985
|
const doc = stage?.renderer.contentWindow?.document;
|
|
2062
1986
|
if (doc) {
|
|
@@ -2095,14 +2019,11 @@
|
|
|
2095
2019
|
*/
|
|
2096
2020
|
async moveLayer(offset) {
|
|
2097
2021
|
const root = this.get("root");
|
|
2098
|
-
if (!root)
|
|
2099
|
-
throw new Error("root为空");
|
|
2022
|
+
if (!root) throw new Error("root为空");
|
|
2100
2023
|
const parent = this.get("parent");
|
|
2101
|
-
if (!parent)
|
|
2102
|
-
throw new Error("父节点为空");
|
|
2024
|
+
if (!parent) throw new Error("父节点为空");
|
|
2103
2025
|
const node = this.get("node");
|
|
2104
|
-
if (!node)
|
|
2105
|
-
throw new Error("当前节点为空");
|
|
2026
|
+
if (!node) throw new Error("当前节点为空");
|
|
2106
2027
|
const brothers = parent.items || [];
|
|
2107
2028
|
const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
|
|
2108
2029
|
const layout = await this.getLayout(parent, node);
|
|
@@ -2164,28 +2085,35 @@
|
|
|
2164
2085
|
}
|
|
2165
2086
|
}
|
|
2166
2087
|
async dragTo(config, targetParent, targetIndex) {
|
|
2167
|
-
if (!targetParent || !Array.isArray(targetParent.items))
|
|
2168
|
-
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2171
|
-
throw new Error("找不要删除的节点");
|
|
2172
|
-
const index = getNodeIndex(curNode.id, parent);
|
|
2173
|
-
if (typeof index !== "number" || index === -1)
|
|
2174
|
-
throw new Error("找不要删除的节点");
|
|
2175
|
-
if (parent.id === targetParent.id) {
|
|
2176
|
-
if (index === targetIndex)
|
|
2177
|
-
return;
|
|
2178
|
-
if (index < targetIndex) {
|
|
2179
|
-
targetIndex -= 1;
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
const layout = await this.getLayout(parent);
|
|
2088
|
+
if (!targetParent || !Array.isArray(targetParent.items)) return;
|
|
2089
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
2090
|
+
const sourceIndicesInTargetParent = [];
|
|
2091
|
+
const sourceOutTargetParent = [];
|
|
2183
2092
|
const newLayout = await this.getLayout(targetParent);
|
|
2184
|
-
|
|
2185
|
-
|
|
2093
|
+
for (const config2 of configs) {
|
|
2094
|
+
const { parent, node: curNode } = this.getNodeInfo(config2.id, false);
|
|
2095
|
+
if (!parent || !curNode) throw new Error("找不要删除的节点");
|
|
2096
|
+
const index = getNodeIndex(curNode.id, parent);
|
|
2097
|
+
if (parent.id === targetParent.id) {
|
|
2098
|
+
if (typeof index !== "number" || index === -1) {
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
sourceIndicesInTargetParent.push(index);
|
|
2102
|
+
} else {
|
|
2103
|
+
const layout = await this.getLayout(parent);
|
|
2104
|
+
if (newLayout !== layout) {
|
|
2105
|
+
setLayout(config2, newLayout);
|
|
2106
|
+
}
|
|
2107
|
+
parent.items?.splice(index, 1);
|
|
2108
|
+
sourceOutTargetParent.push(config2);
|
|
2109
|
+
this.addModifiedNodeId(parent.id);
|
|
2110
|
+
}
|
|
2186
2111
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2112
|
+
moveItemsInContainer(sourceIndicesInTargetParent, targetParent, targetIndex);
|
|
2113
|
+
sourceOutTargetParent.forEach((config2, index) => {
|
|
2114
|
+
targetParent.items?.splice(targetIndex + index, 0, config2);
|
|
2115
|
+
this.addModifiedNodeId(config2.id);
|
|
2116
|
+
});
|
|
2189
2117
|
const page = this.get("page");
|
|
2190
2118
|
const root = this.get("root");
|
|
2191
2119
|
const stage = this.get("stage");
|
|
@@ -2196,10 +2124,8 @@
|
|
|
2196
2124
|
root: lodashEs.cloneDeep(root)
|
|
2197
2125
|
});
|
|
2198
2126
|
}
|
|
2199
|
-
this.addModifiedNodeId(config.id);
|
|
2200
|
-
this.addModifiedNodeId(parent.id);
|
|
2201
2127
|
this.pushHistoryState();
|
|
2202
|
-
this.emit("drag-to", {
|
|
2128
|
+
this.emit("drag-to", { targetIndex, configs, targetParent });
|
|
2203
2129
|
}
|
|
2204
2130
|
/**
|
|
2205
2131
|
* 撤销当前操作
|
|
@@ -2221,11 +2147,9 @@
|
|
|
2221
2147
|
}
|
|
2222
2148
|
async move(left, top) {
|
|
2223
2149
|
const node = vue.toRaw(this.get("node"));
|
|
2224
|
-
if (!node || utils.isPage(node))
|
|
2225
|
-
return;
|
|
2150
|
+
if (!node || utils.isPage(node)) return;
|
|
2226
2151
|
const { style, id, type } = node;
|
|
2227
|
-
if (!style || !["absolute", "fixed"].includes(style.position))
|
|
2228
|
-
return;
|
|
2152
|
+
if (!style || !["absolute", "fixed"].includes(style.position)) return;
|
|
2229
2153
|
const update = (style2) => this.update({
|
|
2230
2154
|
id,
|
|
2231
2155
|
type,
|
|
@@ -2284,6 +2208,15 @@
|
|
|
2284
2208
|
usePlugin(options) {
|
|
2285
2209
|
super.usePlugin(options);
|
|
2286
2210
|
}
|
|
2211
|
+
on(eventName, listener) {
|
|
2212
|
+
return super.on(eventName, listener);
|
|
2213
|
+
}
|
|
2214
|
+
once(eventName, listener) {
|
|
2215
|
+
return super.once(eventName, listener);
|
|
2216
|
+
}
|
|
2217
|
+
emit(eventName, ...args) {
|
|
2218
|
+
return super.emit(eventName, ...args);
|
|
2219
|
+
}
|
|
2287
2220
|
addModifiedNodeId(id) {
|
|
2288
2221
|
if (!this.isHistoryStateChange) {
|
|
2289
2222
|
this.get("modifiedNodeIds").set(id, id);
|
|
@@ -2302,14 +2235,12 @@
|
|
|
2302
2235
|
this.isHistoryStateChange = false;
|
|
2303
2236
|
}
|
|
2304
2237
|
async changeHistoryState(value) {
|
|
2305
|
-
if (!value)
|
|
2306
|
-
return;
|
|
2238
|
+
if (!value) return;
|
|
2307
2239
|
this.isHistoryStateChange = true;
|
|
2308
2240
|
await this.update(value.data);
|
|
2309
2241
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2310
2242
|
setTimeout(async () => {
|
|
2311
|
-
if (!value.nodeId)
|
|
2312
|
-
return;
|
|
2243
|
+
if (!value.nodeId) return;
|
|
2313
2244
|
await this.select(value.nodeId);
|
|
2314
2245
|
this.get("stage")?.select(value.nodeId);
|
|
2315
2246
|
}, 0);
|
|
@@ -2337,8 +2268,7 @@
|
|
|
2337
2268
|
throw new Error("没有ID,无法选中");
|
|
2338
2269
|
}
|
|
2339
2270
|
const { node, parent, page } = this.getNodeInfo(id);
|
|
2340
|
-
if (!node)
|
|
2341
|
-
throw new Error("获取不到组件信息");
|
|
2271
|
+
if (!node) throw new Error("获取不到组件信息");
|
|
2342
2272
|
if (node.id === this.state.root?.id) {
|
|
2343
2273
|
throw new Error("不能选根节点");
|
|
2344
2274
|
}
|
|
@@ -2583,8 +2513,7 @@
|
|
|
2583
2513
|
const matches = key.matchAll(/\$\{([\s\S]+?)\}/g);
|
|
2584
2514
|
let index = 0;
|
|
2585
2515
|
for (const match of matches) {
|
|
2586
|
-
if (typeof match.index === "undefined")
|
|
2587
|
-
break;
|
|
2516
|
+
if (typeof match.index === "undefined") break;
|
|
2588
2517
|
displayState.push({
|
|
2589
2518
|
type: "text",
|
|
2590
2519
|
value: key.substring(index, match.index)
|
|
@@ -2592,16 +2521,20 @@
|
|
|
2592
2521
|
let dsText = "";
|
|
2593
2522
|
let ds;
|
|
2594
2523
|
let fields;
|
|
2595
|
-
match[1].split(".").forEach((item, index2) => {
|
|
2524
|
+
match[1].replaceAll(/\[(\d+)\]/g, ".$1").split(".").forEach((item, index2) => {
|
|
2596
2525
|
if (index2 === 0) {
|
|
2597
2526
|
ds = dataSources.find((ds2) => ds2.id === item);
|
|
2598
2527
|
dsText += ds?.title || item;
|
|
2599
2528
|
fields = ds?.fields;
|
|
2600
2529
|
return;
|
|
2601
2530
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2531
|
+
if (utils.isNumber(item)) {
|
|
2532
|
+
dsText += `[${item}]`;
|
|
2533
|
+
} else {
|
|
2534
|
+
const field = fields?.find((field2) => field2.name === item);
|
|
2535
|
+
fields = field?.fields;
|
|
2536
|
+
dsText += `.${field?.title || item}`;
|
|
2537
|
+
}
|
|
2605
2538
|
});
|
|
2606
2539
|
displayState.push({
|
|
2607
2540
|
type: "var",
|
|
@@ -2749,17 +2682,19 @@
|
|
|
2749
2682
|
* @param config 组件节点配置
|
|
2750
2683
|
* @returns
|
|
2751
2684
|
*/
|
|
2752
|
-
copyWithRelated(config) {
|
|
2685
|
+
copyWithRelated(config, collectorOptions) {
|
|
2753
2686
|
const copyNodes = Array.isArray(config) ? config : [config];
|
|
2754
|
-
depService.clearByType(dep.DepTargetType.RELATED_DS_WHEN_COPY);
|
|
2755
|
-
depService.collect(copyNodes, true, dep.DepTargetType.RELATED_DS_WHEN_COPY);
|
|
2756
|
-
const customTarget = depService.getTarget(dep.DepTargetType.RELATED_DS_WHEN_COPY, dep.DepTargetType.RELATED_DS_WHEN_COPY);
|
|
2757
2687
|
const copyData = [];
|
|
2758
|
-
if (
|
|
2688
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
2689
|
+
const customTarget = new dep.Target({
|
|
2690
|
+
...collectorOptions
|
|
2691
|
+
});
|
|
2692
|
+
const coperWatcher = new dep.Watcher();
|
|
2693
|
+
coperWatcher.addTarget(customTarget);
|
|
2694
|
+
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
2759
2695
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
2760
2696
|
const node = editorService.getNodeById(nodeId);
|
|
2761
|
-
if (!node)
|
|
2762
|
-
return;
|
|
2697
|
+
if (!node) return;
|
|
2763
2698
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
2764
2699
|
const [relateDsId] = lodashEs.get(node, key);
|
|
2765
2700
|
const isExist = copyData.find((dsItem) => dsItem.id === relateDsId);
|
|
@@ -3354,11 +3289,9 @@
|
|
|
3354
3289
|
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
|
|
3355
3290
|
);
|
|
3356
3291
|
const getParamItemsConfig = (codeId) => {
|
|
3357
|
-
if (!codeDsl.value || !codeId)
|
|
3358
|
-
return [];
|
|
3292
|
+
if (!codeDsl.value || !codeId) return [];
|
|
3359
3293
|
const paramStatements = codeDsl.value[codeId]?.params;
|
|
3360
|
-
if (lodashEs.isEmpty(paramStatements))
|
|
3361
|
-
return [];
|
|
3294
|
+
if (lodashEs.isEmpty(paramStatements)) return [];
|
|
3362
3295
|
return paramStatements.map((paramState) => ({
|
|
3363
3296
|
labelWidth: "100px",
|
|
3364
3297
|
text: paramState.name,
|
|
@@ -3658,8 +3591,7 @@
|
|
|
3658
3591
|
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3659
3592
|
};
|
|
3660
3593
|
const submitCodeBlockHandler = async (values) => {
|
|
3661
|
-
if (!codeId.value)
|
|
3662
|
-
return;
|
|
3594
|
+
if (!codeId.value) return;
|
|
3663
3595
|
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
3664
3596
|
codeBlockEditor.value?.hide();
|
|
3665
3597
|
};
|
|
@@ -3715,8 +3647,7 @@
|
|
|
3715
3647
|
codeBlockEditor.value?.show();
|
|
3716
3648
|
},
|
|
3717
3649
|
deleteCode: async (model, methodName) => {
|
|
3718
|
-
if (!model.methods)
|
|
3719
|
-
return;
|
|
3650
|
+
if (!model.methods) return;
|
|
3720
3651
|
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
3721
3652
|
if (index === -1) {
|
|
3722
3653
|
return;
|
|
@@ -3724,8 +3655,7 @@
|
|
|
3724
3655
|
model.methods.splice(index, 1);
|
|
3725
3656
|
},
|
|
3726
3657
|
submitCode: (values) => {
|
|
3727
|
-
if (!dataSource.value)
|
|
3728
|
-
return;
|
|
3658
|
+
if (!dataSource.value) return;
|
|
3729
3659
|
if (!dataSource.value.methods) {
|
|
3730
3660
|
dataSource.value.methods = [];
|
|
3731
3661
|
}
|
|
@@ -3809,14 +3739,12 @@
|
|
|
3809
3739
|
}
|
|
3810
3740
|
async zoom(zoom) {
|
|
3811
3741
|
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
3812
|
-
if (this.get("zoom") < 0.1)
|
|
3813
|
-
this.set("zoom", 0.1);
|
|
3742
|
+
if (this.get("zoom") < 0.1) this.set("zoom", 0.1);
|
|
3814
3743
|
}
|
|
3815
3744
|
async calcZoom() {
|
|
3816
3745
|
const { stageRect, stageContainerRect } = state;
|
|
3817
3746
|
const { height, width } = stageContainerRect;
|
|
3818
|
-
if (!width || !height)
|
|
3819
|
-
return 1;
|
|
3747
|
+
if (!width || !height) return 1;
|
|
3820
3748
|
let stageWidth = utils.convertToNumber(stageRect.width, width);
|
|
3821
3749
|
let stageHeight = utils.convertToNumber(stageRect.height, height);
|
|
3822
3750
|
stageWidth = stageWidth + 30;
|
|
@@ -3871,8 +3799,7 @@
|
|
|
3871
3799
|
disabledDragStart: stageOptions.disabledDragStart,
|
|
3872
3800
|
renderType: stageOptions.renderType,
|
|
3873
3801
|
canSelect: (el, event, stop) => {
|
|
3874
|
-
if (!stageOptions.canSelect)
|
|
3875
|
-
return true;
|
|
3802
|
+
if (!stageOptions.canSelect) return true;
|
|
3876
3803
|
const elCanSelect = stageOptions.canSelect?.(el);
|
|
3877
3804
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
3878
3805
|
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
@@ -3903,8 +3830,7 @@
|
|
|
3903
3830
|
editorService.set("stageLoading", false);
|
|
3904
3831
|
});
|
|
3905
3832
|
stage.on("select", (el) => {
|
|
3906
|
-
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
3907
|
-
return;
|
|
3833
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1) return;
|
|
3908
3834
|
editorService.select(el.id);
|
|
3909
3835
|
});
|
|
3910
3836
|
stage.on("highlight", (el) => {
|
|
@@ -3931,15 +3857,13 @@
|
|
|
3931
3857
|
});
|
|
3932
3858
|
stage.on("select-parent", () => {
|
|
3933
3859
|
const parent = editorService.get("parent");
|
|
3934
|
-
if (!parent)
|
|
3935
|
-
throw new Error("父节点为空");
|
|
3860
|
+
if (!parent) throw new Error("父节点为空");
|
|
3936
3861
|
editorService.select(parent);
|
|
3937
3862
|
editorService.get("stage")?.select(parent.id);
|
|
3938
3863
|
});
|
|
3939
3864
|
stage.on("change-guides", (e) => {
|
|
3940
3865
|
uiService.set("showGuides", true);
|
|
3941
|
-
if (!root.value || !page.value)
|
|
3942
|
-
return;
|
|
3866
|
+
if (!root.value || !page.value) return;
|
|
3943
3867
|
const storageKey = getGuideLineKey(
|
|
3944
3868
|
e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
3945
3869
|
);
|
|
@@ -3982,8 +3906,7 @@
|
|
|
3982
3906
|
isDragging.value = false;
|
|
3983
3907
|
};
|
|
3984
3908
|
document.body.addEventListener("dragover", (e) => {
|
|
3985
|
-
if (!isDragging.value)
|
|
3986
|
-
return;
|
|
3909
|
+
if (!isDragging.value) return;
|
|
3987
3910
|
e.preventDefault();
|
|
3988
3911
|
});
|
|
3989
3912
|
vue.watch(
|
|
@@ -4036,8 +3959,7 @@
|
|
|
4036
3959
|
vue.watch(
|
|
4037
3960
|
editorContentHeight,
|
|
4038
3961
|
() => {
|
|
4039
|
-
if (height.value > 0 && height.value === editorContentHeight.value)
|
|
4040
|
-
return;
|
|
3962
|
+
if (height.value > 0 && height.value === editorContentHeight.value) return;
|
|
4041
3963
|
height.value = editorContentHeight.value;
|
|
4042
3964
|
},
|
|
4043
3965
|
{
|
|
@@ -4230,12 +4152,9 @@
|
|
|
4230
4152
|
height: "200px",
|
|
4231
4153
|
parse: true,
|
|
4232
4154
|
type: (mForm, { model }) => {
|
|
4233
|
-
if (model.type === "number")
|
|
4234
|
-
|
|
4235
|
-
if (model.type === "
|
|
4236
|
-
return "select";
|
|
4237
|
-
if (model.type === "string")
|
|
4238
|
-
return "text";
|
|
4155
|
+
if (model.type === "number") return "number";
|
|
4156
|
+
if (model.type === "boolean") return "select";
|
|
4157
|
+
if (model.type === "string") return "text";
|
|
4239
4158
|
return "vs-code";
|
|
4240
4159
|
},
|
|
4241
4160
|
options: [
|
|
@@ -4275,23 +4194,16 @@
|
|
|
4275
4194
|
addFromJsonDialogVisible.value = true;
|
|
4276
4195
|
};
|
|
4277
4196
|
const getValueType = (value) => {
|
|
4278
|
-
if (Array.isArray(value))
|
|
4279
|
-
|
|
4280
|
-
if (value ===
|
|
4281
|
-
|
|
4282
|
-
if (typeof value === "
|
|
4283
|
-
|
|
4284
|
-
if (typeof value === "number")
|
|
4285
|
-
return "number";
|
|
4286
|
-
if (typeof value === "boolean")
|
|
4287
|
-
return "boolean";
|
|
4288
|
-
if (typeof value === "string")
|
|
4289
|
-
return "string";
|
|
4197
|
+
if (Array.isArray(value)) return "array";
|
|
4198
|
+
if (value === null) return "null";
|
|
4199
|
+
if (typeof value === "object") return "object";
|
|
4200
|
+
if (typeof value === "number") return "number";
|
|
4201
|
+
if (typeof value === "boolean") return "boolean";
|
|
4202
|
+
if (typeof value === "string") return "string";
|
|
4290
4203
|
return "any";
|
|
4291
4204
|
};
|
|
4292
4205
|
const getFieldsConfig = (value, fields = []) => {
|
|
4293
|
-
if (!value || typeof value !== "object")
|
|
4294
|
-
throw new Error("数据格式错误");
|
|
4206
|
+
if (!value || typeof value !== "object") throw new Error("数据格式错误");
|
|
4295
4207
|
const newFields = [];
|
|
4296
4208
|
Object.entries(value).forEach(([key, value2]) => {
|
|
4297
4209
|
const type = getValueType(value2);
|
|
@@ -4481,10 +4393,8 @@
|
|
|
4481
4393
|
model: props.model
|
|
4482
4394
|
});
|
|
4483
4395
|
}
|
|
4484
|
-
if (type2 === "form")
|
|
4485
|
-
|
|
4486
|
-
if (type2 === "container")
|
|
4487
|
-
return "";
|
|
4396
|
+
if (type2 === "form") return "";
|
|
4397
|
+
if (type2 === "container") return "";
|
|
4488
4398
|
return type2?.replace(/([A-Z])/g, "-$1").toLowerCase() || (props.config.items ? "" : "text");
|
|
4489
4399
|
});
|
|
4490
4400
|
const tagName = vue.computed(() => {
|
|
@@ -4492,8 +4402,7 @@
|
|
|
4492
4402
|
return form.MCascader;
|
|
4493
4403
|
}
|
|
4494
4404
|
const component = vue.resolveComponent(`m-${props.config.items ? "form" : "fields"}-${type.value}`);
|
|
4495
|
-
if (typeof component !== "string")
|
|
4496
|
-
return component;
|
|
4405
|
+
if (typeof component !== "string") return component;
|
|
4497
4406
|
return "m-fields-text";
|
|
4498
4407
|
});
|
|
4499
4408
|
const onChangeHandler = (value) => {
|
|
@@ -4588,9 +4497,15 @@
|
|
|
4588
4497
|
{ immediate: true }
|
|
4589
4498
|
);
|
|
4590
4499
|
const mouseupHandler = async () => {
|
|
4500
|
+
const selection = globalThis.document.getSelection();
|
|
4501
|
+
const anchorOffset = selection?.anchorOffset || 0;
|
|
4502
|
+
const focusOffset = selection?.focusOffset || 0;
|
|
4591
4503
|
isFocused.value = true;
|
|
4592
4504
|
await vue.nextTick();
|
|
4593
4505
|
autocomplete.value?.focus();
|
|
4506
|
+
if (focusOffset && input.value) {
|
|
4507
|
+
input.value.setSelectionRange(anchorOffset, focusOffset);
|
|
4508
|
+
}
|
|
4594
4509
|
};
|
|
4595
4510
|
const blurHandler = () => {
|
|
4596
4511
|
isFocused.value = false;
|
|
@@ -4638,7 +4553,7 @@
|
|
|
4638
4553
|
const fieldQuerySearch = (queryString, leftAngleIndex, dotIndex, cb) => {
|
|
4639
4554
|
let result = [];
|
|
4640
4555
|
const dsKey = queryString.substring(leftAngleIndex + 1, dotIndex);
|
|
4641
|
-
const keys = dsKey.split(".");
|
|
4556
|
+
const keys = dsKey.replaceAll(/\[(\d+)\]/g, ".$1").split(".");
|
|
4642
4557
|
const dsId = keys.shift();
|
|
4643
4558
|
const ds = dataSources.value.find((ds2) => ds2.id === dsId);
|
|
4644
4559
|
if (!ds) {
|
|
@@ -4648,6 +4563,10 @@
|
|
|
4648
4563
|
let fields = ds.fields || [];
|
|
4649
4564
|
let key = keys.shift();
|
|
4650
4565
|
while (key) {
|
|
4566
|
+
if (utils.isNumber(key)) {
|
|
4567
|
+
key = keys.shift();
|
|
4568
|
+
continue;
|
|
4569
|
+
}
|
|
4651
4570
|
for (const field of fields) {
|
|
4652
4571
|
if (field.name === key) {
|
|
4653
4572
|
fields = field.fields || [];
|
|
@@ -5225,11 +5144,9 @@
|
|
|
5225
5144
|
return Boolean(dataSource?.methods.find((method) => method.name === name));
|
|
5226
5145
|
});
|
|
5227
5146
|
const getParamItemsConfig = ([dataSourceId, methodName] = ["", ""]) => {
|
|
5228
|
-
if (!dataSourceId)
|
|
5229
|
-
return [];
|
|
5147
|
+
if (!dataSourceId) return [];
|
|
5230
5148
|
const paramStatements = dataSources.value?.find((item) => item.id === dataSourceId)?.methods?.find((item) => item.name === methodName)?.params;
|
|
5231
|
-
if (!paramStatements)
|
|
5232
|
-
return [];
|
|
5149
|
+
if (!paramStatements) return [];
|
|
5233
5150
|
return paramStatements.map((paramState) => ({
|
|
5234
5151
|
text: paramState.name,
|
|
5235
5152
|
...paramState
|
|
@@ -5274,8 +5191,7 @@
|
|
|
5274
5191
|
const editCodeHandler = () => {
|
|
5275
5192
|
const [id] = props.model[props.name];
|
|
5276
5193
|
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5277
|
-
if (!dataSource)
|
|
5278
|
-
return;
|
|
5194
|
+
if (!dataSource) return;
|
|
5279
5195
|
eventBus?.emit("edit-data-source", id);
|
|
5280
5196
|
};
|
|
5281
5197
|
return (_ctx, _cache) => {
|
|
@@ -5386,15 +5302,13 @@
|
|
|
5386
5302
|
defaultValue: "{}",
|
|
5387
5303
|
height: "400px",
|
|
5388
5304
|
onChange: (formState, v) => {
|
|
5389
|
-
if (typeof v !== "string")
|
|
5390
|
-
return v;
|
|
5305
|
+
if (typeof v !== "string") return v;
|
|
5391
5306
|
return JSON.parse(v);
|
|
5392
5307
|
},
|
|
5393
5308
|
rules: [
|
|
5394
5309
|
{
|
|
5395
5310
|
validator: ({ value, callback }) => {
|
|
5396
|
-
if (typeof value !== "string")
|
|
5397
|
-
return callback();
|
|
5311
|
+
if (typeof value !== "string") return callback();
|
|
5398
5312
|
try {
|
|
5399
5313
|
JSON.parse(value);
|
|
5400
5314
|
callback();
|
|
@@ -5622,12 +5536,10 @@
|
|
|
5622
5536
|
};
|
|
5623
5537
|
const editHandler = () => {
|
|
5624
5538
|
const value = props.model[props.name];
|
|
5625
|
-
if (!value)
|
|
5626
|
-
return;
|
|
5539
|
+
if (!value) return;
|
|
5627
5540
|
const id = typeof value === "string" ? value : value.dataSourceId;
|
|
5628
5541
|
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5629
|
-
if (!dataSource)
|
|
5630
|
-
return;
|
|
5542
|
+
if (!dataSource) return;
|
|
5631
5543
|
eventBus?.emit("edit-data-source", id);
|
|
5632
5544
|
};
|
|
5633
5545
|
return (_ctx, _cache) => {
|
|
@@ -5691,20 +5603,46 @@
|
|
|
5691
5603
|
const eventsService = services?.eventsService;
|
|
5692
5604
|
const codeBlockService = services?.codeBlockService;
|
|
5693
5605
|
const eventNameConfig = vue.computed(() => {
|
|
5694
|
-
const fieldType = props.config.src === "component" ? "select" : "cascader";
|
|
5695
5606
|
const defaultEventNameConfig = {
|
|
5696
5607
|
name: "name",
|
|
5697
5608
|
text: "事件",
|
|
5698
|
-
type:
|
|
5609
|
+
type: (mForm, { formValue }) => {
|
|
5610
|
+
if (props.config.src !== "component" || formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
|
|
5611
|
+
return "cascader";
|
|
5612
|
+
}
|
|
5613
|
+
return "select";
|
|
5614
|
+
},
|
|
5699
5615
|
labelWidth: "40px",
|
|
5700
|
-
checkStrictly:
|
|
5616
|
+
checkStrictly: () => props.config.src !== "component",
|
|
5701
5617
|
valueSeparator: ".",
|
|
5702
5618
|
options: (mForm, { formValue }) => {
|
|
5703
5619
|
let events = [];
|
|
5704
|
-
if (!eventsService || !dataSourceService)
|
|
5705
|
-
return events;
|
|
5620
|
+
if (!eventsService || !dataSourceService) return events;
|
|
5706
5621
|
if (props.config.src === "component") {
|
|
5707
5622
|
events = eventsService.getEvent(formValue.type);
|
|
5623
|
+
if (formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
|
|
5624
|
+
const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
|
|
5625
|
+
if (pageFragment) {
|
|
5626
|
+
events = [
|
|
5627
|
+
{
|
|
5628
|
+
label: pageFragment.name || "迭代器容器",
|
|
5629
|
+
value: pageFragment.id,
|
|
5630
|
+
children: events
|
|
5631
|
+
}
|
|
5632
|
+
];
|
|
5633
|
+
pageFragment.items.forEach((node) => {
|
|
5634
|
+
traverseNode(node, (node2) => {
|
|
5635
|
+
const nodeEvents = node2.type && eventsService.getEvent(node2.type) || [];
|
|
5636
|
+
events.push({
|
|
5637
|
+
label: `${node2.name}_${node2.id}`,
|
|
5638
|
+
value: `${node2.id}`,
|
|
5639
|
+
children: nodeEvents
|
|
5640
|
+
});
|
|
5641
|
+
});
|
|
5642
|
+
});
|
|
5643
|
+
return events;
|
|
5644
|
+
}
|
|
5645
|
+
}
|
|
5708
5646
|
return events.map((option) => ({
|
|
5709
5647
|
text: option.label,
|
|
5710
5648
|
value: option.value
|
|
@@ -5763,7 +5701,11 @@
|
|
|
5763
5701
|
name: "to",
|
|
5764
5702
|
text: "联动组件",
|
|
5765
5703
|
type: "ui-select",
|
|
5766
|
-
display: (mForm, { model }) => model.actionType === schema.ActionType.COMP
|
|
5704
|
+
display: (mForm, { model }) => model.actionType === schema.ActionType.COMP,
|
|
5705
|
+
onChange: (MForm, v, { model }) => {
|
|
5706
|
+
model.method = "";
|
|
5707
|
+
return v;
|
|
5708
|
+
}
|
|
5767
5709
|
};
|
|
5768
5710
|
return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
|
|
5769
5711
|
});
|
|
@@ -5771,15 +5713,42 @@
|
|
|
5771
5713
|
const defaultCompActionConfig = {
|
|
5772
5714
|
name: "method",
|
|
5773
5715
|
text: "动作",
|
|
5774
|
-
type:
|
|
5716
|
+
type: (mForm, { model }) => {
|
|
5717
|
+
const to = editorService?.getNodeById(model.to);
|
|
5718
|
+
if (to && to.type === "page-fragment-container" && to.pageFragmentId) {
|
|
5719
|
+
return "cascader";
|
|
5720
|
+
}
|
|
5721
|
+
return "select";
|
|
5722
|
+
},
|
|
5723
|
+
checkStrictly: () => props.config.src !== "component",
|
|
5775
5724
|
display: (mForm, { model }) => model.actionType === schema.ActionType.COMP,
|
|
5776
5725
|
options: (mForm, { model }) => {
|
|
5777
5726
|
const node = editorService?.getNodeById(model.to);
|
|
5778
|
-
if (!node?.type)
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5727
|
+
if (!node?.type) return [];
|
|
5728
|
+
let methods = [];
|
|
5729
|
+
methods = eventsService?.getMethod(node.type) || [];
|
|
5730
|
+
if (node.type === "page-fragment-container" && node.pageFragmentId) {
|
|
5731
|
+
const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
|
|
5732
|
+
if (pageFragment) {
|
|
5733
|
+
methods = [];
|
|
5734
|
+
pageFragment.items.forEach((node2) => {
|
|
5735
|
+
traverseNode(node2, (node3) => {
|
|
5736
|
+
const nodeMethods = node3.type && eventsService?.getMethod(node3.type) || [];
|
|
5737
|
+
if (nodeMethods.length) {
|
|
5738
|
+
methods.push({
|
|
5739
|
+
label: `${node3.name}_${node3.id}`,
|
|
5740
|
+
value: `${node3.id}`,
|
|
5741
|
+
children: nodeMethods
|
|
5742
|
+
});
|
|
5743
|
+
}
|
|
5744
|
+
});
|
|
5745
|
+
});
|
|
5746
|
+
return methods;
|
|
5747
|
+
}
|
|
5748
|
+
}
|
|
5749
|
+
return methods.map((method) => ({
|
|
5750
|
+
text: method.label,
|
|
5751
|
+
value: method.value
|
|
5783
5752
|
}));
|
|
5784
5753
|
}
|
|
5785
5754
|
};
|
|
@@ -5829,8 +5798,7 @@
|
|
|
5829
5798
|
type: compActionConfig.value.type,
|
|
5830
5799
|
options: (mForm, { model }) => {
|
|
5831
5800
|
const node = editorService?.getNodeById(model.to);
|
|
5832
|
-
if (!node?.type)
|
|
5833
|
-
return [];
|
|
5801
|
+
if (!node?.type) return [];
|
|
5834
5802
|
return eventsService?.getMethod(node.type).map((option) => ({
|
|
5835
5803
|
text: option.label,
|
|
5836
5804
|
value: option.value
|
|
@@ -5859,8 +5827,7 @@
|
|
|
5859
5827
|
]
|
|
5860
5828
|
}));
|
|
5861
5829
|
const isOldVersion = vue.computed(() => {
|
|
5862
|
-
if (props.model[props.name].length === 0)
|
|
5863
|
-
return false;
|
|
5830
|
+
if (props.model[props.name].length === 0) return false;
|
|
5864
5831
|
return !lodashEs.has(props.model[props.name][0], "actions");
|
|
5865
5832
|
});
|
|
5866
5833
|
const addEvent = () => {
|
|
@@ -5875,8 +5842,7 @@
|
|
|
5875
5842
|
onChangeHandler();
|
|
5876
5843
|
};
|
|
5877
5844
|
const removeEvent = (index) => {
|
|
5878
|
-
if (!props.name)
|
|
5879
|
-
return;
|
|
5845
|
+
if (!props.name) return;
|
|
5880
5846
|
props.model[props.name].splice(index, 1);
|
|
5881
5847
|
onChangeHandler();
|
|
5882
5848
|
};
|
|
@@ -6201,8 +6167,7 @@
|
|
|
6201
6167
|
const val = vue.computed(() => props.model[props.name]);
|
|
6202
6168
|
const uiSelectMode = vue.ref(false);
|
|
6203
6169
|
const cancelHandler = () => {
|
|
6204
|
-
if (!services?.uiService)
|
|
6205
|
-
return;
|
|
6170
|
+
if (!services?.uiService) return;
|
|
6206
6171
|
services.uiService.set("uiSelectMode", false);
|
|
6207
6172
|
uiSelectMode.value = false;
|
|
6208
6173
|
globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
|
|
@@ -6222,8 +6187,7 @@
|
|
|
6222
6187
|
return config?.name || "";
|
|
6223
6188
|
});
|
|
6224
6189
|
const startSelect = () => {
|
|
6225
|
-
if (!services?.uiService)
|
|
6226
|
-
return;
|
|
6190
|
+
if (!services?.uiService) return;
|
|
6227
6191
|
services.uiService.set("uiSelectMode", true);
|
|
6228
6192
|
uiSelectMode.value = true;
|
|
6229
6193
|
globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
|
|
@@ -6340,14 +6304,12 @@
|
|
|
6340
6304
|
let getso;
|
|
6341
6305
|
const isDraging = vue.ref(false);
|
|
6342
6306
|
vue.onMounted(() => {
|
|
6343
|
-
if (!target.value)
|
|
6344
|
-
return;
|
|
6307
|
+
if (!target.value) return;
|
|
6345
6308
|
getso = new Gesto(target.value, {
|
|
6346
6309
|
container: window,
|
|
6347
6310
|
pinchOutside: true
|
|
6348
6311
|
}).on("drag", (e) => {
|
|
6349
|
-
if (!target.value)
|
|
6350
|
-
return;
|
|
6312
|
+
if (!target.value) return;
|
|
6351
6313
|
emit("change", e);
|
|
6352
6314
|
}).on("dragStart", () => {
|
|
6353
6315
|
isDraging.value = true;
|
|
@@ -6463,13 +6425,11 @@
|
|
|
6463
6425
|
});
|
|
6464
6426
|
} else {
|
|
6465
6427
|
vue.watchEffect(() => {
|
|
6466
|
-
if (typeof props.width === "number")
|
|
6467
|
-
widthChange(props.width);
|
|
6428
|
+
if (typeof props.width === "number") widthChange(props.width);
|
|
6468
6429
|
});
|
|
6469
6430
|
}
|
|
6470
6431
|
const changeLeft = ({ deltaX }) => {
|
|
6471
|
-
if (typeof props.left === "undefined")
|
|
6472
|
-
return;
|
|
6432
|
+
if (typeof props.left === "undefined") return;
|
|
6473
6433
|
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
6474
6434
|
emit("update:left", left);
|
|
6475
6435
|
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
@@ -6484,8 +6444,7 @@
|
|
|
6484
6444
|
});
|
|
6485
6445
|
};
|
|
6486
6446
|
const changeRight = ({ deltaX }) => {
|
|
6487
|
-
if (typeof props.right === "undefined")
|
|
6488
|
-
return;
|
|
6447
|
+
if (typeof props.right === "undefined") return;
|
|
6489
6448
|
let right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
6490
6449
|
emit("update:right", right);
|
|
6491
6450
|
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
@@ -6570,28 +6529,23 @@
|
|
|
6570
6529
|
const props = __props;
|
|
6571
6530
|
const services = vue.inject("services");
|
|
6572
6531
|
const disabled = vue.computed(() => {
|
|
6573
|
-
if (typeof props.data === "string")
|
|
6574
|
-
|
|
6575
|
-
if (props.data.type === "component")
|
|
6576
|
-
return false;
|
|
6532
|
+
if (typeof props.data === "string") return false;
|
|
6533
|
+
if (props.data.type === "component") return false;
|
|
6577
6534
|
if (typeof props.data.disabled === "function") {
|
|
6578
6535
|
return props.data.disabled(services);
|
|
6579
6536
|
}
|
|
6580
6537
|
return props.data.disabled;
|
|
6581
6538
|
});
|
|
6582
6539
|
const display = vue.computed(() => {
|
|
6583
|
-
if (!props.data)
|
|
6584
|
-
|
|
6585
|
-
if (typeof props.data === "string")
|
|
6586
|
-
return true;
|
|
6540
|
+
if (!props.data) return false;
|
|
6541
|
+
if (typeof props.data === "string") return true;
|
|
6587
6542
|
if (typeof props.data.display === "function") {
|
|
6588
6543
|
return props.data.display(services);
|
|
6589
6544
|
}
|
|
6590
6545
|
return props.data.display ?? true;
|
|
6591
6546
|
});
|
|
6592
6547
|
const buttonHandler = (item, event) => {
|
|
6593
|
-
if (disabled.value)
|
|
6594
|
-
return;
|
|
6548
|
+
if (disabled.value) return;
|
|
6595
6549
|
if (typeof item.handler === "function" && services) {
|
|
6596
6550
|
item.handler?.(services, event);
|
|
6597
6551
|
}
|
|
@@ -6602,22 +6556,19 @@
|
|
|
6602
6556
|
}
|
|
6603
6557
|
};
|
|
6604
6558
|
const clickHandler = (item, event) => {
|
|
6605
|
-
if (props.eventType !== "click")
|
|
6606
|
-
return;
|
|
6559
|
+
if (props.eventType !== "click") return;
|
|
6607
6560
|
if (item.type === "button") {
|
|
6608
6561
|
buttonHandler(item, event);
|
|
6609
6562
|
}
|
|
6610
6563
|
};
|
|
6611
6564
|
const mousedownHandler = (item, event) => {
|
|
6612
|
-
if (props.eventType !== "mousedown")
|
|
6613
|
-
return;
|
|
6565
|
+
if (props.eventType !== "mousedown") return;
|
|
6614
6566
|
if (item.type === "button") {
|
|
6615
6567
|
buttonHandler(item, event);
|
|
6616
6568
|
}
|
|
6617
6569
|
};
|
|
6618
6570
|
const mouseupHandler = (item, event) => {
|
|
6619
|
-
if (props.eventType !== "mouseup")
|
|
6620
|
-
return;
|
|
6571
|
+
if (props.eventType !== "mouseup") return;
|
|
6621
6572
|
if (item.type === "button") {
|
|
6622
6573
|
buttonHandler(item, event);
|
|
6623
6574
|
}
|
|
@@ -6734,11 +6685,9 @@
|
|
|
6734
6685
|
const editorService = services?.editorService;
|
|
6735
6686
|
const showAddPageButton = vue.computed(() => uiService?.get("showAddPageButton"));
|
|
6736
6687
|
const addPage = () => {
|
|
6737
|
-
if (!editorService)
|
|
6738
|
-
return;
|
|
6688
|
+
if (!editorService) return;
|
|
6739
6689
|
const root = vue.toRaw(editorService.get("root"));
|
|
6740
|
-
if (!root)
|
|
6741
|
-
throw new Error("root 不能为空");
|
|
6690
|
+
if (!root) throw new Error("root 不能为空");
|
|
6742
6691
|
const pageConfig = {
|
|
6743
6692
|
type: props.type,
|
|
6744
6693
|
name: generatePageNameByApp(root, props.type),
|
|
@@ -6796,8 +6745,7 @@
|
|
|
6796
6745
|
});
|
|
6797
6746
|
let translateLeft = 0;
|
|
6798
6747
|
const scroll = (type) => {
|
|
6799
|
-
if (!itemsContainer.value)
|
|
6800
|
-
return;
|
|
6748
|
+
if (!itemsContainer.value) return;
|
|
6801
6749
|
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
6802
6750
|
if (type === "left") {
|
|
6803
6751
|
translateLeft += 100;
|
|
@@ -7102,11 +7050,9 @@
|
|
|
7102
7050
|
const services = vue.inject("services");
|
|
7103
7051
|
const clickHandler = (type) => {
|
|
7104
7052
|
const { editorService } = services || {};
|
|
7105
|
-
if (!editorService)
|
|
7106
|
-
return;
|
|
7053
|
+
if (!editorService) return;
|
|
7107
7054
|
const root = vue.toRaw(editorService.get("root"));
|
|
7108
|
-
if (!root)
|
|
7109
|
-
throw new Error("root 不能为空");
|
|
7055
|
+
if (!root) throw new Error("root 不能为空");
|
|
7110
7056
|
editorService.add({
|
|
7111
7057
|
type,
|
|
7112
7058
|
name: generatePageNameByApp(root, type),
|
|
@@ -7578,6 +7524,7 @@
|
|
|
7578
7524
|
}, 8, ["type"])) : vue.createCommentVNode("", true),
|
|
7579
7525
|
showSrc.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
|
|
7580
7526
|
key: 1,
|
|
7527
|
+
class: "m-editor-props-panel-src-code",
|
|
7581
7528
|
height: `${vue.unref(editorContentHeight)}px`,
|
|
7582
7529
|
"init-values": values.value,
|
|
7583
7530
|
options: vue.unref(codeOptions),
|
|
@@ -7633,8 +7580,7 @@
|
|
|
7633
7580
|
|
|
7634
7581
|
const updateStatus = (nodeStatusMap, id, status) => {
|
|
7635
7582
|
const nodeStatus = nodeStatusMap.get(id);
|
|
7636
|
-
if (!nodeStatus)
|
|
7637
|
-
return;
|
|
7583
|
+
if (!nodeStatus) return;
|
|
7638
7584
|
utils.getKeys(status).forEach((key) => {
|
|
7639
7585
|
if (nodeStatus[key] !== void 0 && status[key] !== void 0) {
|
|
7640
7586
|
nodeStatus[key] = Boolean(status[key]);
|
|
@@ -7675,7 +7621,9 @@
|
|
|
7675
7621
|
const selected = vue.computed(() => nodeStatus.value.selected);
|
|
7676
7622
|
const visible = vue.computed(() => nodeStatus.value.visible);
|
|
7677
7623
|
const draggable = vue.computed(() => nodeStatus.value.draggable);
|
|
7678
|
-
const hasChildren = vue.computed(
|
|
7624
|
+
const hasChildren = vue.computed(
|
|
7625
|
+
() => Array.isArray(props.data.items) && props.data.items.some((item) => props.nodeStatusMap.get(item.id)?.visible)
|
|
7626
|
+
);
|
|
7679
7627
|
const handleDragStart = (event) => {
|
|
7680
7628
|
treeEmit?.("node-dragstart", event, props.data);
|
|
7681
7629
|
};
|
|
@@ -7828,12 +7776,10 @@
|
|
|
7828
7776
|
return string.some((v) => filterNodeMethod(v, data));
|
|
7829
7777
|
};
|
|
7830
7778
|
const filter = (text) => {
|
|
7831
|
-
if (!nodeData.value.length)
|
|
7832
|
-
return;
|
|
7779
|
+
if (!nodeData.value.length) return;
|
|
7833
7780
|
nodeData.value.forEach((node) => {
|
|
7834
7781
|
traverseNode(node, (node2, parents) => {
|
|
7835
|
-
if (!nodeStatusMap.value)
|
|
7836
|
-
return;
|
|
7782
|
+
if (!nodeStatusMap.value) return;
|
|
7837
7783
|
const visible = filterIsMatch(text, node2);
|
|
7838
7784
|
if (visible && parents.length) {
|
|
7839
7785
|
parents.forEach((parent) => {
|
|
@@ -7906,24 +7852,38 @@
|
|
|
7906
7852
|
const services = vue.inject("services");
|
|
7907
7853
|
const { codeBlockService, depService, editorService } = services || {};
|
|
7908
7854
|
const codeList = vue.computed(
|
|
7909
|
-
() => Object.
|
|
7910
|
-
const
|
|
7911
|
-
|
|
7855
|
+
() => Object.entries(codeBlockService?.getCodeDsl() || {}).map(([codeId, code]) => {
|
|
7856
|
+
const target = depService?.getTarget(codeId, dep.DepTargetType.CODE_BLOCK);
|
|
7857
|
+
const pageList = editorService?.get("root")?.items.map((page) => ({
|
|
7858
|
+
name: page.devconfig?.tabName || page.name,
|
|
7912
7859
|
type: "node",
|
|
7913
|
-
id: `${
|
|
7914
|
-
key: id,
|
|
7915
|
-
items:
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7860
|
+
id: `${codeId}_${page.id}`,
|
|
7861
|
+
key: page.id,
|
|
7862
|
+
items: []
|
|
7863
|
+
})) || [];
|
|
7864
|
+
if (target) {
|
|
7865
|
+
Object.entries(target.deps).forEach(([id, dep]) => {
|
|
7866
|
+
const page = pageList.find((page2) => page2.key === dep.data?.pageId);
|
|
7867
|
+
page?.items?.push({
|
|
7868
|
+
name: dep.name,
|
|
7869
|
+
type: "node",
|
|
7870
|
+
id: `${page.id}_${id}`,
|
|
7871
|
+
key: id,
|
|
7872
|
+
items: dep.keys.map((key) => {
|
|
7873
|
+
const data2 = { name: `${key}`, id: `${target.id}_${id}_${key}`, type: "key" };
|
|
7874
|
+
return data2;
|
|
7875
|
+
})
|
|
7876
|
+
});
|
|
7877
|
+
});
|
|
7878
|
+
}
|
|
7920
7879
|
const data = {
|
|
7921
|
-
id:
|
|
7922
|
-
key:
|
|
7923
|
-
name:
|
|
7880
|
+
id: codeId,
|
|
7881
|
+
key: codeId,
|
|
7882
|
+
name: code.name,
|
|
7924
7883
|
type: "code",
|
|
7925
|
-
codeBlockContent: codeBlockService?.getCodeContentById(
|
|
7926
|
-
|
|
7884
|
+
codeBlockContent: codeBlockService?.getCodeContentById(codeId),
|
|
7885
|
+
// 只有一个页面不显示页面分类
|
|
7886
|
+
items: pageList.length > 1 ? pageList.filter((page) => page.items?.length) : pageList[0]?.items || []
|
|
7927
7887
|
};
|
|
7928
7888
|
return data;
|
|
7929
7889
|
})
|
|
@@ -8109,8 +8069,7 @@
|
|
|
8109
8069
|
const dataSourceValues = vue.ref({});
|
|
8110
8070
|
const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
|
|
8111
8071
|
const editHandler = (id) => {
|
|
8112
|
-
if (!editDialog.value)
|
|
8113
|
-
return;
|
|
8072
|
+
if (!editDialog.value) return;
|
|
8114
8073
|
dataSourceValues.value = {
|
|
8115
8074
|
...dataSourceService?.getDataSourceById(id)
|
|
8116
8075
|
};
|
|
@@ -8238,13 +8197,14 @@
|
|
|
8238
8197
|
key: id,
|
|
8239
8198
|
items: getKeyTreeConfig(dep, type, `${parentKey}_${id}`)
|
|
8240
8199
|
});
|
|
8241
|
-
const mergeChildren = (dsId,
|
|
8200
|
+
const mergeChildren = (dsId, pageItems, deps, type) => {
|
|
8242
8201
|
Object.entries(deps).forEach(([id, dep]) => {
|
|
8243
|
-
const
|
|
8202
|
+
const page = pageItems.find((page2) => page2.key === dep.data?.pageId);
|
|
8203
|
+
const nodeItem = page?.items.find((item) => item.key === id);
|
|
8244
8204
|
if (nodeItem) {
|
|
8245
8205
|
nodeItem.items = nodeItem.items.concat(getKeyTreeConfig(dep, type, nodeItem.key));
|
|
8246
8206
|
} else {
|
|
8247
|
-
items.push(getNodeTreeConfig(id, dep, type,
|
|
8207
|
+
page?.items.push(getNodeTreeConfig(id, dep, type, page.id));
|
|
8248
8208
|
}
|
|
8249
8209
|
});
|
|
8250
8210
|
};
|
|
@@ -8253,7 +8213,13 @@
|
|
|
8253
8213
|
const dsDeps = dsDep.value[ds.id]?.deps || {};
|
|
8254
8214
|
const dsMethodDeps = dsMethodDep.value[ds.id]?.deps || {};
|
|
8255
8215
|
const dsCondDeps = dsCondDep.value[ds.id]?.deps || {};
|
|
8256
|
-
const items =
|
|
8216
|
+
const items = editorService?.get("root")?.items.map((page) => ({
|
|
8217
|
+
name: page.devconfig?.tabName || page.name,
|
|
8218
|
+
type: "node",
|
|
8219
|
+
id: `${ds.id}_${page.id}`,
|
|
8220
|
+
key: page.id,
|
|
8221
|
+
items: []
|
|
8222
|
+
})) || [];
|
|
8257
8223
|
mergeChildren(ds.id, items, dsDeps);
|
|
8258
8224
|
mergeChildren(ds.id, items, dsMethodDeps, "method");
|
|
8259
8225
|
mergeChildren(ds.id, items, dsCondDeps, "cond");
|
|
@@ -8262,7 +8228,8 @@
|
|
|
8262
8228
|
key: ds.id,
|
|
8263
8229
|
name: ds.title,
|
|
8264
8230
|
type: "ds",
|
|
8265
|
-
|
|
8231
|
+
// 只有一个页面不显示页面分类
|
|
8232
|
+
items: items.length > 1 ? items.filter((page) => page.items.length) : items[0]?.items || []
|
|
8266
8233
|
};
|
|
8267
8234
|
})
|
|
8268
8235
|
);
|
|
@@ -8370,8 +8337,7 @@
|
|
|
8370
8337
|
].concat(dataSourceService?.get("datasourceTypeList") ?? [])
|
|
8371
8338
|
);
|
|
8372
8339
|
const addHandler = (type) => {
|
|
8373
|
-
if (!editDialog.value)
|
|
8374
|
-
return;
|
|
8340
|
+
if (!editDialog.value) return;
|
|
8375
8341
|
const datasourceType = datasourceTypeList.value.find((item) => item.type === type);
|
|
8376
8342
|
dataSourceValues.value = lodashEs.mergeWith(
|
|
8377
8343
|
{ type, title: datasourceType?.text },
|
|
@@ -8488,20 +8454,17 @@
|
|
|
8488
8454
|
}));
|
|
8489
8455
|
const contains = (el) => menu.value?.contains(el) || subMenu.value?.contains(el);
|
|
8490
8456
|
const hide = () => {
|
|
8491
|
-
if (!visible.value)
|
|
8492
|
-
return;
|
|
8457
|
+
if (!visible.value) return;
|
|
8493
8458
|
visible.value = false;
|
|
8494
8459
|
subMenu.value?.hide();
|
|
8495
8460
|
emit("hide");
|
|
8496
8461
|
};
|
|
8497
8462
|
const clickHandler = () => {
|
|
8498
|
-
if (!props.autoHide)
|
|
8499
|
-
return;
|
|
8463
|
+
if (!props.autoHide) return;
|
|
8500
8464
|
hide();
|
|
8501
8465
|
};
|
|
8502
8466
|
const outsideClickHideHandler = (e) => {
|
|
8503
|
-
if (!props.autoHide)
|
|
8504
|
-
return;
|
|
8467
|
+
if (!props.autoHide) return;
|
|
8505
8468
|
const target = e.target;
|
|
8506
8469
|
if (!visible.value || !target) {
|
|
8507
8470
|
return;
|
|
@@ -8558,13 +8521,11 @@
|
|
|
8558
8521
|
emit("mouseenter");
|
|
8559
8522
|
};
|
|
8560
8523
|
vue.onMounted(() => {
|
|
8561
|
-
if (props.isSubMenu)
|
|
8562
|
-
return;
|
|
8524
|
+
if (props.isSubMenu) return;
|
|
8563
8525
|
globalThis.addEventListener("mousedown", outsideClickHideHandler, true);
|
|
8564
8526
|
});
|
|
8565
8527
|
vue.onBeforeUnmount(() => {
|
|
8566
|
-
if (props.isSubMenu)
|
|
8567
|
-
return;
|
|
8528
|
+
if (props.isSubMenu) return;
|
|
8568
8529
|
globalThis.removeEventListener("mousedown", outsideClickHideHandler, true);
|
|
8569
8530
|
});
|
|
8570
8531
|
__expose({
|
|
@@ -8685,8 +8646,7 @@
|
|
|
8685
8646
|
display: (services) => !!services?.storageService?.getItem(COPY_STORAGE_KEY),
|
|
8686
8647
|
handler: (services) => {
|
|
8687
8648
|
const nodes = services?.editorService?.get("nodes");
|
|
8688
|
-
if (!nodes || nodes.length === 0)
|
|
8689
|
-
return;
|
|
8649
|
+
if (!nodes || nodes.length === 0) return;
|
|
8690
8650
|
if (menu?.value?.$el) {
|
|
8691
8651
|
const stage = services?.editorService?.get("stage");
|
|
8692
8652
|
const rect = menu.value.$el.getBoundingClientRect();
|
|
@@ -8700,12 +8660,10 @@
|
|
|
8700
8660
|
}
|
|
8701
8661
|
});
|
|
8702
8662
|
const moveTo = (id, services) => {
|
|
8703
|
-
if (!services?.editorService)
|
|
8704
|
-
return;
|
|
8663
|
+
if (!services?.editorService) return;
|
|
8705
8664
|
const nodes = services.editorService.get("nodes") || [];
|
|
8706
8665
|
const parent = services.editorService.getNodeById(id);
|
|
8707
|
-
if (!parent)
|
|
8708
|
-
return;
|
|
8666
|
+
if (!parent) return;
|
|
8709
8667
|
services?.editorService.add(nodes, parent);
|
|
8710
8668
|
services?.editorService.remove(nodes);
|
|
8711
8669
|
};
|
|
@@ -8845,8 +8803,7 @@
|
|
|
8845
8803
|
const services = vue.inject("services");
|
|
8846
8804
|
const editorService = services?.editorService;
|
|
8847
8805
|
const setNodeVisible = (visible) => {
|
|
8848
|
-
if (!editorService)
|
|
8849
|
-
return;
|
|
8806
|
+
if (!editorService) return;
|
|
8850
8807
|
editorService.update({
|
|
8851
8808
|
id: props.data.id,
|
|
8852
8809
|
visible
|
|
@@ -8904,17 +8861,19 @@
|
|
|
8904
8861
|
services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
|
|
8905
8862
|
};
|
|
8906
8863
|
const throttleTime = 300;
|
|
8907
|
-
const highlightHandler = lodashEs.throttle(
|
|
8908
|
-
|
|
8909
|
-
|
|
8864
|
+
const highlightHandler = lodashEs.throttle(
|
|
8865
|
+
(event, data) => {
|
|
8866
|
+
highlight(data);
|
|
8867
|
+
},
|
|
8868
|
+
throttleTime
|
|
8869
|
+
);
|
|
8910
8870
|
const highlight = (data) => {
|
|
8911
8871
|
services?.editorService?.highlight(data);
|
|
8912
8872
|
services?.editorService?.get("stage")?.highlight(data.id);
|
|
8913
8873
|
services?.stageOverlayService?.get("stage")?.highlight(data.id);
|
|
8914
8874
|
};
|
|
8915
8875
|
const nodeClickHandler = (event, data) => {
|
|
8916
|
-
if (!nodeStatusMap?.value)
|
|
8917
|
-
return;
|
|
8876
|
+
if (!nodeStatusMap?.value) return;
|
|
8918
8877
|
if (services?.uiService.get("uiSelectMode")) {
|
|
8919
8878
|
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: data }));
|
|
8920
8879
|
return;
|
|
@@ -8958,8 +8917,7 @@
|
|
|
8958
8917
|
}
|
|
8959
8918
|
};
|
|
8960
8919
|
const removeStatusClass = (el) => {
|
|
8961
|
-
if (!el)
|
|
8962
|
-
return;
|
|
8920
|
+
if (!el) return;
|
|
8963
8921
|
["drag-before", "drag-after", "drag-inner"].forEach((className) => {
|
|
8964
8922
|
el.querySelectorAll(`.${className}`).forEach((el2) => {
|
|
8965
8923
|
utils.removeClassName(el2, className);
|
|
@@ -8968,11 +8926,9 @@
|
|
|
8968
8926
|
};
|
|
8969
8927
|
const useDrag = (services) => {
|
|
8970
8928
|
const handleDragStart = (event) => {
|
|
8971
|
-
if (!event.dataTransfer || !event.target || !event.currentTarget)
|
|
8972
|
-
return;
|
|
8929
|
+
if (!event.dataTransfer || !event.target || !event.currentTarget) return;
|
|
8973
8930
|
const targetEl = getNodeEl(event.target);
|
|
8974
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
8975
|
-
return;
|
|
8931
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
8976
8932
|
event.dataTransfer.effectAllowed = "move";
|
|
8977
8933
|
try {
|
|
8978
8934
|
event.dataTransfer.setData(
|
|
@@ -8985,14 +8941,11 @@
|
|
|
8985
8941
|
}
|
|
8986
8942
|
};
|
|
8987
8943
|
const handleDragOver = (event) => {
|
|
8988
|
-
if (!event.target)
|
|
8989
|
-
return;
|
|
8944
|
+
if (!event.target) return;
|
|
8990
8945
|
const targetEl = getNodeEl(event.target);
|
|
8991
|
-
if (!targetEl?.draggable)
|
|
8992
|
-
return;
|
|
8946
|
+
if (!targetEl?.draggable) return;
|
|
8993
8947
|
const labelEl = targetEl.children[0];
|
|
8994
|
-
if (!labelEl)
|
|
8995
|
-
return;
|
|
8948
|
+
if (!labelEl) return;
|
|
8996
8949
|
const { top: targetTop, height: targetHeight } = labelEl.getBoundingClientRect();
|
|
8997
8950
|
const distance = event.clientY - targetTop;
|
|
8998
8951
|
const isContainer = targetEl.dataset.isContainer === "true";
|
|
@@ -9017,20 +8970,16 @@
|
|
|
9017
8970
|
event.preventDefault();
|
|
9018
8971
|
};
|
|
9019
8972
|
const handleDragLeave = (event) => {
|
|
9020
|
-
if (!event.target || !event.currentTarget)
|
|
9021
|
-
return;
|
|
8973
|
+
if (!event.target || !event.currentTarget) return;
|
|
9022
8974
|
const targetEl = getNodeEl(event.target);
|
|
9023
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
9024
|
-
return;
|
|
8975
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
9025
8976
|
const labelEl = targetEl.children[0];
|
|
9026
8977
|
utils.removeClassName(labelEl, "drag-before", "drag-after", "drag-inner");
|
|
9027
8978
|
};
|
|
9028
8979
|
const handleDragEnd = (event, node) => {
|
|
9029
|
-
if (!event.target || !event.currentTarget)
|
|
9030
|
-
return;
|
|
8980
|
+
if (!event.target || !event.currentTarget) return;
|
|
9031
8981
|
const targetEl = getNodeEl(event.target);
|
|
9032
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
9033
|
-
return;
|
|
8982
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
9034
8983
|
removeStatusClass(dragState.container);
|
|
9035
8984
|
if (node && dragState.dragOverNodeId && dragState.dropType && services) {
|
|
9036
8985
|
if (dragState.dragOverNodeId === node.id) {
|
|
@@ -9039,8 +8988,7 @@
|
|
|
9039
8988
|
const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
|
|
9040
8989
|
const targetNode = targetInfo.node;
|
|
9041
8990
|
let targetParent = targetInfo.parent;
|
|
9042
|
-
if (!targetParent || !targetNode)
|
|
9043
|
-
return;
|
|
8991
|
+
if (!targetParent || !targetNode) return;
|
|
9044
8992
|
let targetIndex = -1;
|
|
9045
8993
|
if (Array.isArray(targetNode.items) && dragState.dropType === "inner") {
|
|
9046
8994
|
targetIndex = targetNode.items.length;
|
|
@@ -9051,7 +8999,12 @@
|
|
|
9051
8999
|
if (dragState.dropType === "after") {
|
|
9052
9000
|
targetIndex += 1;
|
|
9053
9001
|
}
|
|
9054
|
-
services
|
|
9002
|
+
const selectedNodes = services.editorService.get("nodes");
|
|
9003
|
+
if (selectedNodes.find((n) => `${n.id}` === `${node.id}`)) {
|
|
9004
|
+
services.editorService.dragTo(selectedNodes, targetParent, targetIndex);
|
|
9005
|
+
} else {
|
|
9006
|
+
services.editorService.dragTo([node], targetParent, targetIndex);
|
|
9007
|
+
}
|
|
9055
9008
|
}
|
|
9056
9009
|
dragState.dragOverNodeId = "";
|
|
9057
9010
|
dragState.dropType = "";
|
|
@@ -9272,8 +9225,7 @@
|
|
|
9272
9225
|
vue.watch(
|
|
9273
9226
|
nodes,
|
|
9274
9227
|
(nodes2) => {
|
|
9275
|
-
if (!nodeStatusMap.value)
|
|
9276
|
-
return;
|
|
9228
|
+
if (!nodeStatusMap.value) return;
|
|
9277
9229
|
for (const [id, status] of nodeStatusMap.value.entries()) {
|
|
9278
9230
|
status.selected = nodes2.some((node) => node.id === id);
|
|
9279
9231
|
if (status.selected) {
|
|
@@ -9291,8 +9243,7 @@
|
|
|
9291
9243
|
);
|
|
9292
9244
|
services?.editorService.on("add", (newNodes) => {
|
|
9293
9245
|
newNodes.forEach((node) => {
|
|
9294
|
-
if (utils.isPage(node) || utils.isPageFragment(node))
|
|
9295
|
-
return;
|
|
9246
|
+
if (utils.isPage(node) || utils.isPageFragment(node)) return;
|
|
9296
9247
|
traverseNode(node, (node2) => {
|
|
9297
9248
|
nodeStatusMap.value?.set(node2.id, {
|
|
9298
9249
|
visible: true,
|
|
@@ -9344,8 +9295,7 @@
|
|
|
9344
9295
|
};
|
|
9345
9296
|
const { filterTextChangeHandler } = useFilter(nodeData, nodeStatusMap, filterNodeMethod);
|
|
9346
9297
|
const collapseAllHandler = () => {
|
|
9347
|
-
if (!page.value || !nodeStatusMap.value)
|
|
9348
|
-
return;
|
|
9298
|
+
if (!page.value || !nodeStatusMap.value) return;
|
|
9349
9299
|
const items = nodeStatusMap.value.entries();
|
|
9350
9300
|
for (const [id, status] of items) {
|
|
9351
9301
|
if (id === page.value.id) {
|
|
@@ -9479,8 +9429,7 @@
|
|
|
9479
9429
|
}
|
|
9480
9430
|
return;
|
|
9481
9431
|
}
|
|
9482
|
-
if (timeout || !stage.value)
|
|
9483
|
-
return;
|
|
9432
|
+
if (timeout || !stage.value) return;
|
|
9484
9433
|
timeout = stage.value.delayedMarkContainer(e);
|
|
9485
9434
|
};
|
|
9486
9435
|
return (_ctx, _cache) => {
|
|
@@ -9644,8 +9593,7 @@
|
|
|
9644
9593
|
const isActiveTabShow = showingBoxKeys.value.some(
|
|
9645
9594
|
(key) => activeTabName.value === sideBarItems.value.find((v) => v.$key === key)?.text
|
|
9646
9595
|
);
|
|
9647
|
-
if (!isActiveTabShow && activeTabName.value)
|
|
9648
|
-
return;
|
|
9596
|
+
if (!isActiveTabShow && activeTabName.value) return;
|
|
9649
9597
|
const nextSlideBarItem = sideBarItems.value.find((sideBarItem) => !showingBoxKeys.value.includes(sideBarItem.$key));
|
|
9650
9598
|
if (!nextSlideBarItem) {
|
|
9651
9599
|
activeTabName.value = "";
|
|
@@ -9900,8 +9848,7 @@
|
|
|
9900
9848
|
}
|
|
9901
9849
|
wheelHandler = (event) => {
|
|
9902
9850
|
const { deltaX, deltaY, currentTarget } = event;
|
|
9903
|
-
if (currentTarget !== this.container)
|
|
9904
|
-
return;
|
|
9851
|
+
if (currentTarget !== this.container) return;
|
|
9905
9852
|
let top;
|
|
9906
9853
|
if (this.scrollHeight > this.height) {
|
|
9907
9854
|
top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
|
|
@@ -9994,8 +9941,7 @@
|
|
|
9994
9941
|
}));
|
|
9995
9942
|
let gesto;
|
|
9996
9943
|
vue.onMounted(() => {
|
|
9997
|
-
if (!thumb.value)
|
|
9998
|
-
return;
|
|
9944
|
+
if (!thumb.value) return;
|
|
9999
9945
|
const thumbEl = thumb.value;
|
|
10000
9946
|
gesto = new Gesto(thumbEl, {
|
|
10001
9947
|
container: window
|
|
@@ -10009,8 +9955,7 @@
|
|
|
10009
9955
|
bar.value?.addEventListener("wheel", wheelHandler, false);
|
|
10010
9956
|
});
|
|
10011
9957
|
vue.onBeforeUnmount(() => {
|
|
10012
|
-
if (gesto)
|
|
10013
|
-
gesto.off();
|
|
9958
|
+
if (gesto) gesto.off();
|
|
10014
9959
|
bar.value?.removeEventListener("wheel", wheelHandler, false);
|
|
10015
9960
|
});
|
|
10016
9961
|
const wheelHandler = (e) => {
|
|
@@ -10089,8 +10034,7 @@
|
|
|
10089
10034
|
const scrollHeight = vue.ref(0);
|
|
10090
10035
|
let scrollViewer;
|
|
10091
10036
|
vue.onMounted(() => {
|
|
10092
|
-
if (!container.value || !el.value)
|
|
10093
|
-
return;
|
|
10037
|
+
if (!container.value || !el.value) return;
|
|
10094
10038
|
scrollViewer = new ScrollViewer({
|
|
10095
10039
|
container: container.value,
|
|
10096
10040
|
target: el.value,
|
|
@@ -10183,8 +10127,7 @@
|
|
|
10183
10127
|
const unWatch = vue.watch(
|
|
10184
10128
|
stage,
|
|
10185
10129
|
(stage2) => {
|
|
10186
|
-
if (!stage2)
|
|
10187
|
-
return;
|
|
10130
|
+
if (!stage2) return;
|
|
10188
10131
|
vue.nextTick(() => unWatch());
|
|
10189
10132
|
stage2.on("select", (el, event) => {
|
|
10190
10133
|
const els = stage2.renderer.getElementsFromPoint(event) || [];
|
|
@@ -10200,8 +10143,7 @@
|
|
|
10200
10143
|
vue.watch(
|
|
10201
10144
|
nodes,
|
|
10202
10145
|
(nodes2) => {
|
|
10203
|
-
if (!nodeStatusMap.value)
|
|
10204
|
-
return;
|
|
10146
|
+
if (!nodeStatusMap.value) return;
|
|
10205
10147
|
for (const [id, status] of nodeStatusMap.value.entries()) {
|
|
10206
10148
|
status.selected = nodes2.some((node) => node.id === id);
|
|
10207
10149
|
}
|
|
@@ -10295,8 +10237,7 @@
|
|
|
10295
10237
|
}
|
|
10296
10238
|
});
|
|
10297
10239
|
vue.watch(stageOverlay, (stageOverlay2) => {
|
|
10298
|
-
if (!services)
|
|
10299
|
-
return;
|
|
10240
|
+
if (!services) return;
|
|
10300
10241
|
const subStage = services.stageOverlayService.createStage(stageOptions);
|
|
10301
10242
|
services?.stageOverlayService.set("stage", subStage);
|
|
10302
10243
|
if (stageOverlay2 && subStage) {
|
|
@@ -10411,8 +10352,7 @@
|
|
|
10411
10352
|
icon: vue.markRaw(_sfc_main$5),
|
|
10412
10353
|
display: () => canCenter.value,
|
|
10413
10354
|
handler: () => {
|
|
10414
|
-
if (!nodes.value)
|
|
10415
|
-
return;
|
|
10355
|
+
if (!nodes.value) return;
|
|
10416
10356
|
editorService?.alignCenter(nodes.value);
|
|
10417
10357
|
}
|
|
10418
10358
|
},
|
|
@@ -10422,8 +10362,7 @@
|
|
|
10422
10362
|
type: "divider",
|
|
10423
10363
|
direction: "horizontal",
|
|
10424
10364
|
display: () => {
|
|
10425
|
-
if (!node.value)
|
|
10426
|
-
return false;
|
|
10365
|
+
if (!node.value) return false;
|
|
10427
10366
|
return !utils.isPage(node.value) && !utils.isPageFragment(node.value);
|
|
10428
10367
|
}
|
|
10429
10368
|
},
|
|
@@ -10489,8 +10428,7 @@
|
|
|
10489
10428
|
vue.watch(
|
|
10490
10429
|
parent,
|
|
10491
10430
|
async () => {
|
|
10492
|
-
if (!parent.value || !editorService)
|
|
10493
|
-
return canCenter.value = false;
|
|
10431
|
+
if (!parent.value || !editorService) return canCenter.value = false;
|
|
10494
10432
|
const layout = await editorService.getLayout(parent.value);
|
|
10495
10433
|
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
10496
10434
|
const isTypeConform = nodes.value?.every(
|
|
@@ -10541,12 +10479,9 @@
|
|
|
10541
10479
|
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
10542
10480
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
10543
10481
|
vue.watchEffect(() => {
|
|
10544
|
-
if (stage || !page.value)
|
|
10545
|
-
|
|
10546
|
-
if (!
|
|
10547
|
-
return;
|
|
10548
|
-
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
10549
|
-
return;
|
|
10482
|
+
if (stage || !page.value) return;
|
|
10483
|
+
if (!stageContainer.value) return;
|
|
10484
|
+
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value) return;
|
|
10550
10485
|
stage = useStage(stageOptions);
|
|
10551
10486
|
stage.on("select", () => {
|
|
10552
10487
|
stageWrap.value?.container?.focus();
|
|
@@ -10566,8 +10501,7 @@
|
|
|
10566
10501
|
});
|
|
10567
10502
|
});
|
|
10568
10503
|
vue.watch(zoom, (zoom2) => {
|
|
10569
|
-
if (!stage || !zoom2)
|
|
10570
|
-
return;
|
|
10504
|
+
if (!stage || !zoom2) return;
|
|
10571
10505
|
stage.setZoom(zoom2);
|
|
10572
10506
|
});
|
|
10573
10507
|
vue.watch(page, (page2) => {
|
|
@@ -10612,20 +10546,16 @@
|
|
|
10612
10546
|
menu.value?.show(e);
|
|
10613
10547
|
};
|
|
10614
10548
|
const dragoverHandler = (e) => {
|
|
10615
|
-
if (!e.dataTransfer)
|
|
10616
|
-
return;
|
|
10549
|
+
if (!e.dataTransfer) return;
|
|
10617
10550
|
e.preventDefault();
|
|
10618
10551
|
e.dataTransfer.dropEffect = "move";
|
|
10619
10552
|
};
|
|
10620
10553
|
const dropHandler = async (e) => {
|
|
10621
|
-
if (!e.dataTransfer)
|
|
10622
|
-
return;
|
|
10554
|
+
if (!e.dataTransfer) return;
|
|
10623
10555
|
const data = e.dataTransfer.getData("text/json");
|
|
10624
|
-
if (!data)
|
|
10625
|
-
return;
|
|
10556
|
+
if (!data) return;
|
|
10626
10557
|
const config = parseDSL(`(${data})`);
|
|
10627
|
-
if (!config || config.dragType !== DragType.COMPONENT_LIST)
|
|
10628
|
-
return;
|
|
10558
|
+
if (!config || config.dragType !== DragType.COMPONENT_LIST) return;
|
|
10629
10559
|
e.preventDefault();
|
|
10630
10560
|
const doc = stage?.renderer.contentWindow?.document;
|
|
10631
10561
|
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
@@ -10830,11 +10760,9 @@
|
|
|
10830
10760
|
* @returns {CodeBlockContent | null}
|
|
10831
10761
|
*/
|
|
10832
10762
|
getCodeContentById(id) {
|
|
10833
|
-
if (!id)
|
|
10834
|
-
return null;
|
|
10763
|
+
if (!id) return null;
|
|
10835
10764
|
const totalCodeDsl = this.getCodeDsl();
|
|
10836
|
-
if (!totalCodeDsl)
|
|
10837
|
-
return null;
|
|
10765
|
+
if (!totalCodeDsl) return null;
|
|
10838
10766
|
return totalCodeDsl[id] ?? null;
|
|
10839
10767
|
}
|
|
10840
10768
|
/**
|
|
@@ -10859,8 +10787,7 @@
|
|
|
10859
10787
|
if (!codeDsl) {
|
|
10860
10788
|
throw new Error("dsl中没有codeBlocks");
|
|
10861
10789
|
}
|
|
10862
|
-
if (codeDsl[id] && !force)
|
|
10863
|
-
return;
|
|
10790
|
+
if (codeDsl[id] && !force) return;
|
|
10864
10791
|
const codeConfigProcessed = lodashEs.cloneDeep(codeConfig);
|
|
10865
10792
|
if (codeConfigProcessed.content) {
|
|
10866
10793
|
const parseDSL = getConfig("parseDSL");
|
|
@@ -10953,8 +10880,7 @@
|
|
|
10953
10880
|
*/
|
|
10954
10881
|
async deleteCodeDslByIds(codeIds) {
|
|
10955
10882
|
const currentDsl = await this.getCodeDsl();
|
|
10956
|
-
if (!currentDsl)
|
|
10957
|
-
return;
|
|
10883
|
+
if (!currentDsl) return;
|
|
10958
10884
|
codeIds.forEach((id) => {
|
|
10959
10885
|
delete currentDsl[id];
|
|
10960
10886
|
this.emit("remove", id);
|
|
@@ -10974,8 +10900,7 @@
|
|
|
10974
10900
|
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
10975
10901
|
const dsl = await this.getCodeDsl();
|
|
10976
10902
|
const existedIds = lodashEs.keys(dsl);
|
|
10977
|
-
if (!existedIds.includes(newId))
|
|
10978
|
-
return newId;
|
|
10903
|
+
if (!existedIds.includes(newId)) return newId;
|
|
10979
10904
|
return await this.getUniqueId();
|
|
10980
10905
|
}
|
|
10981
10906
|
/**
|
|
@@ -10983,20 +10908,19 @@
|
|
|
10983
10908
|
* @param config 组件节点配置
|
|
10984
10909
|
* @returns
|
|
10985
10910
|
*/
|
|
10986
|
-
copyWithRelated(config) {
|
|
10911
|
+
copyWithRelated(config, collectorOptions) {
|
|
10987
10912
|
const copyNodes = Array.isArray(config) ? config : [config];
|
|
10988
|
-
depService.clearByType(dep.DepTargetType.RELATED_CODE_WHEN_COPY);
|
|
10989
|
-
depService.collect(copyNodes, true, dep.DepTargetType.RELATED_CODE_WHEN_COPY);
|
|
10990
|
-
const customTarget = depService.getTarget(
|
|
10991
|
-
dep.DepTargetType.RELATED_CODE_WHEN_COPY,
|
|
10992
|
-
dep.DepTargetType.RELATED_CODE_WHEN_COPY
|
|
10993
|
-
);
|
|
10994
10913
|
const copyData = {};
|
|
10995
|
-
if (
|
|
10914
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
10915
|
+
const customTarget = new dep.Target({
|
|
10916
|
+
...collectorOptions
|
|
10917
|
+
});
|
|
10918
|
+
const coperWatcher = new dep.Watcher();
|
|
10919
|
+
coperWatcher.addTarget(customTarget);
|
|
10920
|
+
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
10996
10921
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
10997
10922
|
const node = editorService.getNodeById(nodeId);
|
|
10998
|
-
if (!node)
|
|
10999
|
-
return;
|
|
10923
|
+
if (!node) return;
|
|
11000
10924
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
11001
10925
|
const relateCodeId = lodashEs.get(node, key);
|
|
11002
10926
|
const isExist = Object.keys(copyData).find((codeId) => codeId === relateCodeId);
|
|
@@ -11067,6 +10991,139 @@
|
|
|
11067
10991
|
}
|
|
11068
10992
|
const componentListService = new ComponentList();
|
|
11069
10993
|
|
|
10994
|
+
globalThis.requestIdleCallback = globalThis.requestIdleCallback || function(cb) {
|
|
10995
|
+
const start = Date.now();
|
|
10996
|
+
return setTimeout(() => {
|
|
10997
|
+
cb({
|
|
10998
|
+
didTimeout: false,
|
|
10999
|
+
timeRemaining() {
|
|
11000
|
+
return Math.max(0, 50 - (Date.now() - start));
|
|
11001
|
+
}
|
|
11002
|
+
});
|
|
11003
|
+
}, 1);
|
|
11004
|
+
};
|
|
11005
|
+
class IdleTask extends events.EventEmitter {
|
|
11006
|
+
taskList = [];
|
|
11007
|
+
taskHandle = null;
|
|
11008
|
+
enqueueTask(taskHandler, taskData) {
|
|
11009
|
+
this.taskList.push({
|
|
11010
|
+
handler: taskHandler,
|
|
11011
|
+
data: taskData
|
|
11012
|
+
});
|
|
11013
|
+
if (!this.taskHandle) {
|
|
11014
|
+
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
|
|
11015
|
+
}
|
|
11016
|
+
}
|
|
11017
|
+
on(eventName, listener) {
|
|
11018
|
+
return super.on(eventName, listener);
|
|
11019
|
+
}
|
|
11020
|
+
once(eventName, listener) {
|
|
11021
|
+
return super.once(eventName, listener);
|
|
11022
|
+
}
|
|
11023
|
+
emit(eventName, ...args) {
|
|
11024
|
+
return super.emit(eventName, ...args);
|
|
11025
|
+
}
|
|
11026
|
+
runTaskQueue(deadline) {
|
|
11027
|
+
while ((deadline.timeRemaining() > 15 || deadline.didTimeout) && this.taskList.length) {
|
|
11028
|
+
const task = this.taskList.shift();
|
|
11029
|
+
task.handler(task.data);
|
|
11030
|
+
}
|
|
11031
|
+
if (this.taskList.length) {
|
|
11032
|
+
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
|
|
11033
|
+
} else {
|
|
11034
|
+
this.taskHandle = 0;
|
|
11035
|
+
this.emit("finish");
|
|
11036
|
+
}
|
|
11037
|
+
}
|
|
11038
|
+
}
|
|
11039
|
+
|
|
11040
|
+
const idleTask = new IdleTask();
|
|
11041
|
+
class Dep extends BaseService {
|
|
11042
|
+
watcher = new dep.Watcher({ initialTargets: vue.reactive({}) });
|
|
11043
|
+
removeTargets(type = dep.DepTargetType.DEFAULT) {
|
|
11044
|
+
this.watcher.removeTargets(type);
|
|
11045
|
+
const targets = this.watcher.getTargets(type);
|
|
11046
|
+
if (!targets) return;
|
|
11047
|
+
for (const target of Object.values(targets)) {
|
|
11048
|
+
this.emit("remove-target", target.id);
|
|
11049
|
+
}
|
|
11050
|
+
}
|
|
11051
|
+
getTargets(type = dep.DepTargetType.DEFAULT) {
|
|
11052
|
+
return this.watcher.getTargets(type);
|
|
11053
|
+
}
|
|
11054
|
+
getTarget(id, type = dep.DepTargetType.DEFAULT) {
|
|
11055
|
+
return this.watcher.getTarget(id, type);
|
|
11056
|
+
}
|
|
11057
|
+
addTarget(target) {
|
|
11058
|
+
this.watcher.addTarget(target);
|
|
11059
|
+
this.emit("add-target", target);
|
|
11060
|
+
}
|
|
11061
|
+
removeTarget(id, type = dep.DepTargetType.DEFAULT) {
|
|
11062
|
+
this.watcher.removeTarget(id, type);
|
|
11063
|
+
this.emit("remove-target", id);
|
|
11064
|
+
}
|
|
11065
|
+
clearTargets() {
|
|
11066
|
+
this.watcher.clearTargets();
|
|
11067
|
+
}
|
|
11068
|
+
collect(nodes, depExtendedData = {}, deep = false, type) {
|
|
11069
|
+
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
|
11070
|
+
this.collectNode(node, target, depExtendedData, deep);
|
|
11071
|
+
});
|
|
11072
|
+
this.emit("collected", nodes, deep);
|
|
11073
|
+
}
|
|
11074
|
+
collectIdle(nodes, depExtendedData = {}, deep = false, type) {
|
|
11075
|
+
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
|
11076
|
+
idleTask.enqueueTask(
|
|
11077
|
+
({ node: node2, deep: deep2, target: target2 }) => {
|
|
11078
|
+
this.collectNode(node2, target2, depExtendedData, deep2);
|
|
11079
|
+
},
|
|
11080
|
+
{
|
|
11081
|
+
node,
|
|
11082
|
+
deep,
|
|
11083
|
+
target
|
|
11084
|
+
}
|
|
11085
|
+
);
|
|
11086
|
+
});
|
|
11087
|
+
idleTask.once("finish", () => {
|
|
11088
|
+
this.emit("collected", nodes, deep);
|
|
11089
|
+
});
|
|
11090
|
+
}
|
|
11091
|
+
collectNode(node, target, depExtendedData = {}, deep = false) {
|
|
11092
|
+
if (utils.isPage(node)) {
|
|
11093
|
+
Object.entries(target.deps).forEach(([depKey, dep]) => {
|
|
11094
|
+
if (dep.data?.pageId && dep.data.pageId === depExtendedData.pageId) {
|
|
11095
|
+
delete target.deps[depKey];
|
|
11096
|
+
}
|
|
11097
|
+
});
|
|
11098
|
+
} else {
|
|
11099
|
+
this.watcher.removeTargetDep(target, node);
|
|
11100
|
+
}
|
|
11101
|
+
this.watcher.collectItem(node, target, depExtendedData, deep);
|
|
11102
|
+
}
|
|
11103
|
+
clear(nodes) {
|
|
11104
|
+
return this.watcher.clear(nodes);
|
|
11105
|
+
}
|
|
11106
|
+
clearByType(type, nodes) {
|
|
11107
|
+
return this.watcher.clearByType(type, nodes);
|
|
11108
|
+
}
|
|
11109
|
+
hasTarget(id, type = dep.DepTargetType.DEFAULT) {
|
|
11110
|
+
return this.watcher.hasTarget(id, type);
|
|
11111
|
+
}
|
|
11112
|
+
hasSpecifiedTypeTarget(type = dep.DepTargetType.DEFAULT) {
|
|
11113
|
+
return this.watcher.hasSpecifiedTypeTarget(type);
|
|
11114
|
+
}
|
|
11115
|
+
on(eventName, listener) {
|
|
11116
|
+
return super.on(eventName, listener);
|
|
11117
|
+
}
|
|
11118
|
+
once(eventName, listener) {
|
|
11119
|
+
return super.once(eventName, listener);
|
|
11120
|
+
}
|
|
11121
|
+
emit(eventName, ...args) {
|
|
11122
|
+
return super.emit(eventName, ...args);
|
|
11123
|
+
}
|
|
11124
|
+
}
|
|
11125
|
+
const depService = new Dep();
|
|
11126
|
+
|
|
11070
11127
|
let eventMap = vue.reactive({});
|
|
11071
11128
|
let methodMap = vue.reactive({});
|
|
11072
11129
|
class Events extends BaseService {
|
|
@@ -11127,8 +11184,7 @@
|
|
|
11127
11184
|
commands = {
|
|
11128
11185
|
[KeyBindingCommand.DELETE_NODE]: () => {
|
|
11129
11186
|
const nodes = editorService.get("nodes");
|
|
11130
|
-
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0]))
|
|
11131
|
-
return;
|
|
11187
|
+
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0])) return;
|
|
11132
11188
|
editorService.remove(nodes);
|
|
11133
11189
|
},
|
|
11134
11190
|
[KeyBindingCommand.COPY_NODE]: () => {
|
|
@@ -11137,8 +11193,7 @@
|
|
|
11137
11193
|
},
|
|
11138
11194
|
[KeyBindingCommand.CUT_NODE]: () => {
|
|
11139
11195
|
const nodes = editorService.get("nodes");
|
|
11140
|
-
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0]))
|
|
11141
|
-
return;
|
|
11196
|
+
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0])) return;
|
|
11142
11197
|
editorService.copy(nodes);
|
|
11143
11198
|
editorService.remove(nodes);
|
|
11144
11199
|
},
|
|
@@ -11327,8 +11382,7 @@
|
|
|
11327
11382
|
}
|
|
11328
11383
|
openOverlay(el) {
|
|
11329
11384
|
const stageOptions = this.get("stageOptions");
|
|
11330
|
-
if (!el || !stageOptions)
|
|
11331
|
-
return;
|
|
11385
|
+
if (!el || !stageOptions) return;
|
|
11332
11386
|
this.set("sourceEl", el);
|
|
11333
11387
|
this.createContentEl();
|
|
11334
11388
|
this.set("stageOverlayVisible", true);
|
|
@@ -11355,8 +11409,7 @@
|
|
|
11355
11409
|
}
|
|
11356
11410
|
updateOverlay() {
|
|
11357
11411
|
const sourceEl = this.get("sourceEl");
|
|
11358
|
-
if (!sourceEl)
|
|
11359
|
-
return;
|
|
11412
|
+
if (!sourceEl) return;
|
|
11360
11413
|
const { scrollWidth, scrollHeight } = sourceEl;
|
|
11361
11414
|
this.set("wrapWidth", scrollWidth);
|
|
11362
11415
|
this.set("wrapHeight", scrollHeight);
|
|
@@ -11389,8 +11442,7 @@
|
|
|
11389
11442
|
}
|
|
11390
11443
|
createContentEl() {
|
|
11391
11444
|
const sourceEl = this.get("sourceEl");
|
|
11392
|
-
if (!sourceEl)
|
|
11393
|
-
return;
|
|
11445
|
+
if (!sourceEl) return;
|
|
11394
11446
|
const contentEl = sourceEl.cloneNode(true);
|
|
11395
11447
|
this.set("contentEl", contentEl);
|
|
11396
11448
|
contentEl.style.position = "static";
|
|
@@ -11412,8 +11464,7 @@
|
|
|
11412
11464
|
const wrapDiv = this.get("wrapDiv");
|
|
11413
11465
|
const subStage = this.get("stage");
|
|
11414
11466
|
const stageOptions = this.get("stageOptions");
|
|
11415
|
-
if (!contentEl)
|
|
11416
|
-
return;
|
|
11467
|
+
if (!contentEl) return;
|
|
11417
11468
|
wrapDiv.style.cssText = `
|
|
11418
11469
|
width: ${sourceEl?.scrollWidth}px;
|
|
11419
11470
|
height: ${sourceEl?.scrollHeight}px;
|
|
@@ -11633,37 +11684,9 @@
|
|
|
11633
11684
|
getApp()?.dataSourceManager?.updateSchema(root.dataSources);
|
|
11634
11685
|
}
|
|
11635
11686
|
};
|
|
11636
|
-
const updateNodeWhenDataSourceChange = (nodes) => {
|
|
11637
|
-
const root = editorService.get("root");
|
|
11638
|
-
const stage = editorService.get("stage");
|
|
11639
|
-
if (!root || !stage)
|
|
11640
|
-
return;
|
|
11641
|
-
const app = getApp();
|
|
11642
|
-
if (!app)
|
|
11643
|
-
return;
|
|
11644
|
-
if (app.dsl) {
|
|
11645
|
-
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
11646
|
-
app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
|
|
11647
|
-
app.dsl.dataSources = root.dataSources;
|
|
11648
|
-
}
|
|
11649
|
-
updateDataSourceSchema();
|
|
11650
|
-
nodes.forEach((node) => {
|
|
11651
|
-
const deps = Object.values(root.dataSourceDeps || {});
|
|
11652
|
-
deps.forEach((dep) => {
|
|
11653
|
-
if (dep[node.id]) {
|
|
11654
|
-
stage.update({
|
|
11655
|
-
config: lodashEs.cloneDeep(node),
|
|
11656
|
-
parentId: editorService.getParentById(node.id)?.id,
|
|
11657
|
-
root: lodashEs.cloneDeep(root)
|
|
11658
|
-
});
|
|
11659
|
-
}
|
|
11660
|
-
});
|
|
11661
|
-
});
|
|
11662
|
-
};
|
|
11663
11687
|
const targetAddHandler = (target) => {
|
|
11664
11688
|
const root = editorService.get("root");
|
|
11665
|
-
if (!root)
|
|
11666
|
-
return;
|
|
11689
|
+
if (!root) return;
|
|
11667
11690
|
if (target.type === dep.DepTargetType.DATA_SOURCE) {
|
|
11668
11691
|
if (!root.dataSourceDeps) {
|
|
11669
11692
|
root.dataSourceDeps = {};
|
|
@@ -11686,15 +11709,44 @@
|
|
|
11686
11709
|
delete root.dataSourceCondDeps[id];
|
|
11687
11710
|
}
|
|
11688
11711
|
};
|
|
11689
|
-
const
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11712
|
+
const collectedHandler = (nodes, deep) => {
|
|
11713
|
+
const root = editorService.get("root");
|
|
11714
|
+
const stage = editorService.get("stage");
|
|
11715
|
+
if (!root || !stage) return;
|
|
11716
|
+
const app = getApp();
|
|
11717
|
+
if (!app) return;
|
|
11718
|
+
if (app.dsl) {
|
|
11719
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
11720
|
+
app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
|
|
11721
|
+
app.dsl.dataSources = root.dataSources;
|
|
11722
|
+
}
|
|
11723
|
+
updateDataSourceSchema();
|
|
11724
|
+
const allNodes = [];
|
|
11725
|
+
if (deep) {
|
|
11726
|
+
nodes.forEach((node) => {
|
|
11727
|
+
traverseNode(node, (node2) => {
|
|
11728
|
+
if (!allNodes.includes(node2)) {
|
|
11729
|
+
allNodes.push(node2);
|
|
11730
|
+
}
|
|
11731
|
+
});
|
|
11732
|
+
});
|
|
11733
|
+
} else {
|
|
11734
|
+
allNodes.push(...nodes);
|
|
11735
|
+
}
|
|
11736
|
+
const deps = Object.values(root.dataSourceDeps || {});
|
|
11737
|
+
deps.forEach((dep) => {
|
|
11738
|
+
Object.keys(dep).forEach((id) => {
|
|
11739
|
+
const node = allNodes.find((node2) => node2.id === id);
|
|
11740
|
+
node && stage.update({
|
|
11741
|
+
config: lodashEs.cloneDeep(node),
|
|
11742
|
+
parentId: editorService.getParentById(node.id)?.id,
|
|
11743
|
+
root: lodashEs.cloneDeep(root)
|
|
11744
|
+
});
|
|
11745
|
+
});
|
|
11746
|
+
});
|
|
11694
11747
|
};
|
|
11695
11748
|
depService.on("add-target", targetAddHandler);
|
|
11696
11749
|
depService.on("remove-target", targetRemoveHandler);
|
|
11697
|
-
depService.on("dep-update", depUpdateHandler);
|
|
11698
11750
|
depService.on("collected", collectedHandler);
|
|
11699
11751
|
const initDataSourceDepTarget = (ds) => {
|
|
11700
11752
|
depService.addTarget(dep.createDataSourceTarget(ds, vue.reactive({})));
|
|
@@ -11702,8 +11754,7 @@
|
|
|
11702
11754
|
depService.addTarget(dep.createDataSourceCondTarget(ds, vue.reactive({})));
|
|
11703
11755
|
};
|
|
11704
11756
|
const rootChangeHandler = async (value, preValue) => {
|
|
11705
|
-
if (!value)
|
|
11706
|
-
return;
|
|
11757
|
+
if (!value) return;
|
|
11707
11758
|
value.codeBlocks = value.codeBlocks || {};
|
|
11708
11759
|
value.dataSources = value.dataSources || [];
|
|
11709
11760
|
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
@@ -11716,7 +11767,9 @@
|
|
|
11716
11767
|
initDataSourceDepTarget(ds);
|
|
11717
11768
|
});
|
|
11718
11769
|
if (Array.isArray(value.items)) {
|
|
11719
|
-
|
|
11770
|
+
value.items.forEach((page) => {
|
|
11771
|
+
depService.collectIdle([page], { pageId: page.id }, true);
|
|
11772
|
+
});
|
|
11720
11773
|
} else {
|
|
11721
11774
|
depService.clear();
|
|
11722
11775
|
delete value.dataSourceDeps;
|
|
@@ -11739,17 +11792,29 @@
|
|
|
11739
11792
|
emit("update:modelValue", value);
|
|
11740
11793
|
}
|
|
11741
11794
|
};
|
|
11795
|
+
const collectIdle = (nodes, deep) => {
|
|
11796
|
+
nodes.forEach((node) => {
|
|
11797
|
+
let pageId;
|
|
11798
|
+
if (utils.isPage(node)) {
|
|
11799
|
+
pageId = node.id;
|
|
11800
|
+
} else {
|
|
11801
|
+
const info = editorService.getNodeInfo(node.id);
|
|
11802
|
+
pageId = info.page?.id;
|
|
11803
|
+
}
|
|
11804
|
+
depService.collectIdle([node], { pageId }, deep);
|
|
11805
|
+
});
|
|
11806
|
+
};
|
|
11742
11807
|
const nodeAddHandler = (nodes) => {
|
|
11743
|
-
|
|
11808
|
+
collectIdle(nodes, true);
|
|
11744
11809
|
};
|
|
11745
11810
|
const nodeUpdateHandler = (nodes) => {
|
|
11746
|
-
|
|
11811
|
+
collectIdle(nodes, false);
|
|
11747
11812
|
};
|
|
11748
11813
|
const nodeRemoveHandler = (nodes) => {
|
|
11749
11814
|
depService.clear(nodes);
|
|
11750
11815
|
};
|
|
11751
11816
|
const historyChangeHandler = (page) => {
|
|
11752
|
-
depService.
|
|
11817
|
+
depService.collectIdle([page], { pageId: page.id }, true);
|
|
11753
11818
|
};
|
|
11754
11819
|
editorService.on("history-change", historyChangeHandler);
|
|
11755
11820
|
editorService.on("root-change", rootChangeHandler);
|
|
@@ -11776,10 +11841,9 @@
|
|
|
11776
11841
|
const root = editorService.get("root");
|
|
11777
11842
|
removeDataSourceTarget(config.id);
|
|
11778
11843
|
initDataSourceDepTarget(config);
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
updateNodeWhenDataSourceChange(nodes);
|
|
11844
|
+
(root?.items || []).forEach((page) => {
|
|
11845
|
+
depService.collectIdle([page], { pageId: page.id }, true);
|
|
11846
|
+
});
|
|
11783
11847
|
};
|
|
11784
11848
|
const removeDataSourceTarget = (id) => {
|
|
11785
11849
|
depService.removeTarget(id, dep.DepTargetType.DATA_SOURCE);
|
|
@@ -11793,23 +11857,9 @@
|
|
|
11793
11857
|
dataSourceService.on("add", dataSourceAddHandler);
|
|
11794
11858
|
dataSourceService.on("update", dataSourceUpdateHandler);
|
|
11795
11859
|
dataSourceService.on("remove", dataSourceRemoveHandler);
|
|
11796
|
-
if (props.collectorOptions && !depService.hasTarget(dep.DepTargetType.RELATED_COMP_WHEN_COPY)) {
|
|
11797
|
-
depService.addTarget(dep.createRelatedTargetForCopy(props.collectorOptions, dep.DepTargetType.RELATED_COMP_WHEN_COPY));
|
|
11798
|
-
}
|
|
11799
|
-
if (props.collectorOptionsForCode && !depService.hasTarget(dep.DepTargetType.RELATED_CODE_WHEN_COPY)) {
|
|
11800
|
-
depService.addTarget(
|
|
11801
|
-
dep.createRelatedTargetForCopy(props.collectorOptionsForCode, dep.DepTargetType.RELATED_CODE_WHEN_COPY)
|
|
11802
|
-
);
|
|
11803
|
-
}
|
|
11804
|
-
if (props.collectorOptionsForDataSource && !depService.hasTarget(dep.DepTargetType.RELATED_DS_WHEN_COPY)) {
|
|
11805
|
-
depService.addTarget(
|
|
11806
|
-
dep.createRelatedTargetForCopy(props.collectorOptionsForDataSource, dep.DepTargetType.RELATED_DS_WHEN_COPY)
|
|
11807
|
-
);
|
|
11808
|
-
}
|
|
11809
11860
|
vue.onBeforeUnmount(() => {
|
|
11810
11861
|
depService.off("add-target", targetAddHandler);
|
|
11811
11862
|
depService.off("remove-target", targetRemoveHandler);
|
|
11812
|
-
depService.off("dep-update", depUpdateHandler);
|
|
11813
11863
|
depService.off("collected", collectedHandler);
|
|
11814
11864
|
editorService.off("history-change", historyChangeHandler);
|
|
11815
11865
|
editorService.off("root-change", rootChangeHandler);
|
|
@@ -11854,9 +11904,6 @@
|
|
|
11854
11904
|
stageRect: {},
|
|
11855
11905
|
codeOptions: {},
|
|
11856
11906
|
disabledDragStart: { type: Boolean },
|
|
11857
|
-
collectorOptions: {},
|
|
11858
|
-
collectorOptionsForCode: {},
|
|
11859
|
-
collectorOptionsForDataSource: {},
|
|
11860
11907
|
guidesOptions: {},
|
|
11861
11908
|
disabledMultiSelect: { type: Boolean },
|
|
11862
11909
|
disabledPageFragment: { type: Boolean },
|
|
@@ -12147,6 +12194,7 @@
|
|
|
12147
12194
|
exports.info = info;
|
|
12148
12195
|
exports.isFixed = isFixed;
|
|
12149
12196
|
exports.log = log;
|
|
12197
|
+
exports.moveItemsInContainer = moveItemsInContainer;
|
|
12150
12198
|
exports.propsService = propsService;
|
|
12151
12199
|
exports.serializeConfig = serializeConfig;
|
|
12152
12200
|
exports.setChildrenLayout = setChildrenLayout;
|