@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
package/dist/tmagic-editor.js
CHANGED
|
@@ -8,9 +8,9 @@ import * as monaco from 'monaco-editor';
|
|
|
8
8
|
import { MContainer, MForm, filterFunction, createValues, MFormBox, MCascader, MSelect, MPanel } from '@tmagic/form';
|
|
9
9
|
import { HookCodeType, HookType, NodeType, ActionType } from '@tmagic/schema';
|
|
10
10
|
import { MagicTable } from '@tmagic/table';
|
|
11
|
-
import { toLine, guid, getNodePath, getValueByKeyPath, setValueByKeyPath, isPage, isPageFragment, isPop, isNumber, calcValueByFontsize, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName
|
|
11
|
+
import { toLine, guid, getNodePath, getValueByKeyPath, setValueByKeyPath, isPage, isPageFragment, isPop, isNumber, calcValueByFontsize, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName } from '@tmagic/utils';
|
|
12
12
|
import VanillaMoveable from 'moveable';
|
|
13
|
-
import { Watcher, DepTargetType,
|
|
13
|
+
import { Target, Watcher, DepTargetType, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
|
|
14
14
|
export { DepTargetType } from '@tmagic/dep';
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
16
|
import Gesto from 'gesto';
|
|
@@ -148,8 +148,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
|
148
148
|
};
|
|
149
149
|
const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
|
|
150
150
|
const init = async () => {
|
|
151
|
-
if (!codeEditor.value)
|
|
152
|
-
return;
|
|
151
|
+
if (!codeEditor.value) return;
|
|
153
152
|
const options = {
|
|
154
153
|
value: values.value,
|
|
155
154
|
language: props.language,
|
|
@@ -362,8 +361,7 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
362
361
|
}
|
|
363
362
|
);
|
|
364
363
|
const changeHandler = (v) => {
|
|
365
|
-
if (!props.name || !props.model)
|
|
366
|
-
return;
|
|
364
|
+
if (!props.name || !props.model) return;
|
|
367
365
|
try {
|
|
368
366
|
const parseDSL = getConfig("parseDSL");
|
|
369
367
|
props.model[props.name] = parseDSL(`(${v[props.name]})`);
|
|
@@ -506,11 +504,9 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
506
504
|
});
|
|
507
505
|
|
|
508
506
|
const compose = (middleware, isAsync) => {
|
|
509
|
-
if (!Array.isArray(middleware))
|
|
510
|
-
throw new TypeError("Middleware 必须是一个数组!");
|
|
507
|
+
if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
|
|
511
508
|
for (const fn of middleware) {
|
|
512
|
-
if (typeof fn !== "function")
|
|
513
|
-
throw new TypeError("Middleware 必须由函数组成!");
|
|
509
|
+
if (typeof fn !== "function") throw new TypeError("Middleware 必须由函数组成!");
|
|
514
510
|
}
|
|
515
511
|
return (args, next) => {
|
|
516
512
|
let index = -1;
|
|
@@ -525,8 +521,7 @@ const compose = (middleware, isAsync) => {
|
|
|
525
521
|
}
|
|
526
522
|
index = i;
|
|
527
523
|
let fn = middleware[i];
|
|
528
|
-
if (i === middleware.length && next)
|
|
529
|
-
fn = next;
|
|
524
|
+
if (i === middleware.length && next) fn = next;
|
|
530
525
|
if (!fn) {
|
|
531
526
|
if (isAsync) {
|
|
532
527
|
return Promise.resolve();
|
|
@@ -556,8 +551,7 @@ const doAction = (args, scope, sourceMethod, beforeMethodName, afterMethodName,
|
|
|
556
551
|
let beforeArgs = args;
|
|
557
552
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
558
553
|
beforeArgs = beforeMethod(...beforeArgs) || [];
|
|
559
|
-
if (isError(beforeArgs))
|
|
560
|
-
throw beforeArgs;
|
|
554
|
+
if (isError(beforeArgs)) throw beforeArgs;
|
|
561
555
|
if (!Array.isArray(beforeArgs)) {
|
|
562
556
|
beforeArgs = [beforeArgs];
|
|
563
557
|
}
|
|
@@ -565,8 +559,7 @@ const doAction = (args, scope, sourceMethod, beforeMethodName, afterMethodName,
|
|
|
565
559
|
let returnValue = fn(beforeArgs, sourceMethod.bind(scope));
|
|
566
560
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
567
561
|
returnValue = afterMethod(returnValue, ...beforeArgs);
|
|
568
|
-
if (isError(returnValue))
|
|
569
|
-
throw returnValue;
|
|
562
|
+
if (isError(returnValue)) throw returnValue;
|
|
570
563
|
}
|
|
571
564
|
return returnValue;
|
|
572
565
|
} catch (error) {
|
|
@@ -578,8 +571,7 @@ const doAsyncAction = async (args, scope, sourceMethod, beforeMethodName, afterM
|
|
|
578
571
|
let beforeArgs = args;
|
|
579
572
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
580
573
|
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
581
|
-
if (isError(beforeArgs))
|
|
582
|
-
throw beforeArgs;
|
|
574
|
+
if (isError(beforeArgs)) throw beforeArgs;
|
|
583
575
|
if (!Array.isArray(beforeArgs)) {
|
|
584
576
|
beforeArgs = [beforeArgs];
|
|
585
577
|
}
|
|
@@ -587,8 +579,7 @@ const doAsyncAction = async (args, scope, sourceMethod, beforeMethodName, afterM
|
|
|
587
579
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
588
580
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
589
581
|
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
590
|
-
if (isError(returnValue))
|
|
591
|
-
throw returnValue;
|
|
582
|
+
if (isError(returnValue)) throw returnValue;
|
|
592
583
|
}
|
|
593
584
|
return returnValue;
|
|
594
585
|
} catch (error) {
|
|
@@ -639,14 +630,12 @@ class BaseService extends EventEmitter {
|
|
|
639
630
|
*/
|
|
640
631
|
use(options) {
|
|
641
632
|
Object.entries(options).forEach(([methodName2, method]) => {
|
|
642
|
-
if (typeof method === "function")
|
|
643
|
-
this.middleware[methodName2].push(method);
|
|
633
|
+
if (typeof method === "function") this.middleware[methodName2].push(method);
|
|
644
634
|
});
|
|
645
635
|
}
|
|
646
636
|
usePlugin(options) {
|
|
647
637
|
Object.entries(options).forEach(([methodName2, method]) => {
|
|
648
|
-
if (typeof method === "function")
|
|
649
|
-
this.pluginOptionsList[methodName2].push(method);
|
|
638
|
+
if (typeof method === "function") this.pluginOptionsList[methodName2].push(method);
|
|
650
639
|
});
|
|
651
640
|
}
|
|
652
641
|
removeAllPlugins() {
|
|
@@ -668,48 +657,6 @@ class BaseService extends EventEmitter {
|
|
|
668
657
|
}
|
|
669
658
|
}
|
|
670
659
|
|
|
671
|
-
class Dep extends BaseService {
|
|
672
|
-
watcher = new Watcher({ initialTargets: reactive({}) });
|
|
673
|
-
removeTargets(type = DepTargetType.DEFAULT) {
|
|
674
|
-
this.watcher.removeTargets(type);
|
|
675
|
-
this.emit("remove-target");
|
|
676
|
-
}
|
|
677
|
-
getTargets(type = DepTargetType.DEFAULT) {
|
|
678
|
-
return this.watcher.getTargets(type);
|
|
679
|
-
}
|
|
680
|
-
getTarget(id, type = DepTargetType.DEFAULT) {
|
|
681
|
-
return this.watcher.getTarget(id, type);
|
|
682
|
-
}
|
|
683
|
-
addTarget(target) {
|
|
684
|
-
this.watcher.addTarget(target);
|
|
685
|
-
this.emit("add-target", target);
|
|
686
|
-
}
|
|
687
|
-
removeTarget(id, type = DepTargetType.DEFAULT) {
|
|
688
|
-
this.watcher.removeTarget(id, type);
|
|
689
|
-
this.emit("remove-target");
|
|
690
|
-
}
|
|
691
|
-
clearTargets() {
|
|
692
|
-
this.watcher.clearTargets();
|
|
693
|
-
}
|
|
694
|
-
collect(nodes, deep = false, type) {
|
|
695
|
-
this.watcher.collect(nodes, deep, type);
|
|
696
|
-
this.emit("collected", nodes, deep);
|
|
697
|
-
}
|
|
698
|
-
clear(nodes) {
|
|
699
|
-
return this.watcher.clear(nodes);
|
|
700
|
-
}
|
|
701
|
-
clearByType(type, nodes) {
|
|
702
|
-
return this.watcher.clearByType(type, nodes);
|
|
703
|
-
}
|
|
704
|
-
hasTarget(id, type = DepTargetType.DEFAULT) {
|
|
705
|
-
return this.watcher.hasTarget(id, type);
|
|
706
|
-
}
|
|
707
|
-
hasSpecifiedTypeTarget(type = DepTargetType.DEFAULT) {
|
|
708
|
-
return this.watcher.hasSpecifiedTypeTarget(type);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
const depService = new Dep();
|
|
712
|
-
|
|
713
660
|
const canUsePluginMethods$6 = {
|
|
714
661
|
async: [
|
|
715
662
|
"setPropsConfig",
|
|
@@ -743,7 +690,11 @@ class Props extends BaseService {
|
|
|
743
690
|
return fillConfig(config, typeof labelWidth !== "function" ? labelWidth : "80px");
|
|
744
691
|
}
|
|
745
692
|
async setPropsConfig(type, config) {
|
|
746
|
-
|
|
693
|
+
let c = config;
|
|
694
|
+
if (typeof config === "function") {
|
|
695
|
+
c = config({ editorService });
|
|
696
|
+
}
|
|
697
|
+
this.state.propsConfigMap[toLine(type)] = await this.fillConfig(Array.isArray(c) ? c : [c]);
|
|
747
698
|
}
|
|
748
699
|
/**
|
|
749
700
|
* 获取指点类型的组件属性表单配置
|
|
@@ -767,7 +718,11 @@ class Props extends BaseService {
|
|
|
767
718
|
* @param value 组件初始值
|
|
768
719
|
*/
|
|
769
720
|
async setPropsValue(type, value) {
|
|
770
|
-
|
|
721
|
+
let v = value;
|
|
722
|
+
if (typeof value === "function") {
|
|
723
|
+
v = value({ editorService });
|
|
724
|
+
}
|
|
725
|
+
this.state.propsValueMap[toLine(type)] = v;
|
|
771
726
|
}
|
|
772
727
|
/**
|
|
773
728
|
* 获取指定类型的组件初始值
|
|
@@ -849,30 +804,28 @@ class Props extends BaseService {
|
|
|
849
804
|
* @param originConfigs 原组件配置
|
|
850
805
|
* @param targetConfigs 待替换的组件配置
|
|
851
806
|
*/
|
|
852
|
-
replaceRelateId(originConfigs, targetConfigs) {
|
|
807
|
+
replaceRelateId(originConfigs, targetConfigs, collectorOptions) {
|
|
853
808
|
const relateIdMap = this.getRelateIdMap();
|
|
854
|
-
if (Object.keys(relateIdMap).length === 0)
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
const
|
|
859
|
-
|
|
860
|
-
|
|
809
|
+
if (Object.keys(relateIdMap).length === 0) return;
|
|
810
|
+
const target = new Target({
|
|
811
|
+
...collectorOptions
|
|
812
|
+
});
|
|
813
|
+
const coperWatcher = new Watcher();
|
|
814
|
+
coperWatcher.addTarget(target);
|
|
815
|
+
coperWatcher.collect(originConfigs, {}, true, collectorOptions.type);
|
|
861
816
|
originConfigs.forEach((config) => {
|
|
862
817
|
const newId = relateIdMap[config.id];
|
|
863
818
|
const path = getNodePath(newId, targetConfigs);
|
|
864
819
|
const targetConfig = path[path.length - 1];
|
|
865
|
-
if (!targetConfig)
|
|
866
|
-
return;
|
|
820
|
+
if (!targetConfig) return;
|
|
867
821
|
target.deps[config.id]?.keys?.forEach((fullKey) => {
|
|
868
822
|
const relateOriginId = getValueByKeyPath(fullKey, config);
|
|
869
823
|
const relateTargetId = relateIdMap[relateOriginId];
|
|
870
|
-
if (!relateTargetId)
|
|
871
|
-
return;
|
|
824
|
+
if (!relateTargetId) return;
|
|
872
825
|
setValueByKeyPath(fullKey, relateTargetId, targetConfig);
|
|
873
826
|
});
|
|
874
827
|
if (config.items && Array.isArray(config.items)) {
|
|
875
|
-
this.replaceRelateId(config.items, targetConfigs);
|
|
828
|
+
this.replaceRelateId(config.items, targetConfigs, collectorOptions);
|
|
876
829
|
}
|
|
877
830
|
});
|
|
878
831
|
}
|
|
@@ -978,8 +931,7 @@ class History extends BaseService {
|
|
|
978
931
|
this.state.canUndo = false;
|
|
979
932
|
}
|
|
980
933
|
changePage(page) {
|
|
981
|
-
if (!page)
|
|
982
|
-
return;
|
|
934
|
+
if (!page) return;
|
|
983
935
|
this.state.pageId = page.id;
|
|
984
936
|
if (!this.state.pageSteps[this.state.pageId]) {
|
|
985
937
|
const undoRedo = new UndoRedo();
|
|
@@ -1001,24 +953,21 @@ class History extends BaseService {
|
|
|
1001
953
|
}
|
|
1002
954
|
push(state) {
|
|
1003
955
|
const undoRedo = this.getUndoRedo();
|
|
1004
|
-
if (!undoRedo)
|
|
1005
|
-
return null;
|
|
956
|
+
if (!undoRedo) return null;
|
|
1006
957
|
undoRedo.pushElement(state);
|
|
1007
958
|
this.emit("change", state);
|
|
1008
959
|
return state;
|
|
1009
960
|
}
|
|
1010
961
|
undo() {
|
|
1011
962
|
const undoRedo = this.getUndoRedo();
|
|
1012
|
-
if (!undoRedo)
|
|
1013
|
-
return null;
|
|
963
|
+
if (!undoRedo) return null;
|
|
1014
964
|
const state = undoRedo.undo();
|
|
1015
965
|
this.emit("change", state);
|
|
1016
966
|
return state;
|
|
1017
967
|
}
|
|
1018
968
|
redo() {
|
|
1019
969
|
const undoRedo = this.getUndoRedo();
|
|
1020
|
-
if (!undoRedo)
|
|
1021
|
-
return null;
|
|
970
|
+
if (!undoRedo) return null;
|
|
1022
971
|
const state = undoRedo.redo();
|
|
1023
972
|
this.emit("change", state);
|
|
1024
973
|
return state;
|
|
@@ -1029,8 +978,7 @@ class History extends BaseService {
|
|
|
1029
978
|
this.removeAllPlugins();
|
|
1030
979
|
}
|
|
1031
980
|
getUndoRedo() {
|
|
1032
|
-
if (!this.state.pageId)
|
|
1033
|
-
return null;
|
|
981
|
+
if (!this.state.pageId) return null;
|
|
1034
982
|
return this.state.pageSteps[this.state.pageId];
|
|
1035
983
|
}
|
|
1036
984
|
setCanUndoRedo() {
|
|
@@ -1091,8 +1039,7 @@ class WebStorage extends BaseService {
|
|
|
1091
1039
|
const { protocol = options.protocol, item } = this.getValueAndProtocol(
|
|
1092
1040
|
storage.getItem(`${options.namespace || namespace}:${key}`)
|
|
1093
1041
|
);
|
|
1094
|
-
if (item === null)
|
|
1095
|
-
return null;
|
|
1042
|
+
if (item === null) return null;
|
|
1096
1043
|
switch (protocol) {
|
|
1097
1044
|
case "object" /* OBJECT */:
|
|
1098
1045
|
return getConfig("parseDSL")(`(${item})`);
|
|
@@ -1233,24 +1180,19 @@ const COPY_STORAGE_KEY = "$MagicEditorCopyData";
|
|
|
1233
1180
|
const COPY_CODE_STORAGE_KEY = "$MagicEditorCopyCode";
|
|
1234
1181
|
const COPY_DS_STORAGE_KEY = "$MagicEditorCopyDataSource";
|
|
1235
1182
|
const getPageList = (root) => {
|
|
1236
|
-
if (!root)
|
|
1237
|
-
|
|
1238
|
-
if (!Array.isArray(root.items))
|
|
1239
|
-
return [];
|
|
1183
|
+
if (!root) return [];
|
|
1184
|
+
if (!Array.isArray(root.items)) return [];
|
|
1240
1185
|
return root.items.filter((item) => isPage(item));
|
|
1241
1186
|
};
|
|
1242
1187
|
const getPageFragmentList = (root) => {
|
|
1243
|
-
if (!root)
|
|
1244
|
-
|
|
1245
|
-
if (!Array.isArray(root.items))
|
|
1246
|
-
return [];
|
|
1188
|
+
if (!root) return [];
|
|
1189
|
+
if (!Array.isArray(root.items)) return [];
|
|
1247
1190
|
return root.items.filter((item) => isPageFragment(item));
|
|
1248
1191
|
};
|
|
1249
1192
|
const getPageNameList = (pages) => pages.map((page) => page.name || "index");
|
|
1250
1193
|
const generatePageName = (pageNameList, type) => {
|
|
1251
1194
|
let pageLength = pageNameList.length;
|
|
1252
|
-
if (!pageLength)
|
|
1253
|
-
return `${type}_index`;
|
|
1195
|
+
if (!pageLength) return `${type}_index`;
|
|
1254
1196
|
let pageName = `${type}_${pageLength}`;
|
|
1255
1197
|
while (pageNameList.includes(pageName)) {
|
|
1256
1198
|
pageLength += 1;
|
|
@@ -1272,8 +1214,7 @@ const getRelativeStyle = (style = {}) => ({
|
|
|
1272
1214
|
});
|
|
1273
1215
|
const getMiddleTop = (node, parentNode, stage) => {
|
|
1274
1216
|
let height = node.style?.height || 0;
|
|
1275
|
-
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
1276
|
-
return node.style?.top;
|
|
1217
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style) return node.style?.top;
|
|
1277
1218
|
if (!isNumber(height)) {
|
|
1278
1219
|
height = 0;
|
|
1279
1220
|
}
|
|
@@ -1309,11 +1250,9 @@ const setChildrenLayout = (node, layout) => {
|
|
|
1309
1250
|
return node;
|
|
1310
1251
|
};
|
|
1311
1252
|
const setLayout = (node, layout) => {
|
|
1312
|
-
if (isPop(node))
|
|
1313
|
-
return;
|
|
1253
|
+
if (isPop(node)) return;
|
|
1314
1254
|
const style = node.style || {};
|
|
1315
|
-
if (style.position === "fixed")
|
|
1316
|
-
return;
|
|
1255
|
+
if (style.position === "fixed") return;
|
|
1317
1256
|
if (layout !== Layout.RELATIVE) {
|
|
1318
1257
|
style.position = "absolute";
|
|
1319
1258
|
} else {
|
|
@@ -1367,8 +1306,7 @@ const Fixed2Other = async (node, root, getLayout) => {
|
|
|
1367
1306
|
return getRelativeStyle(style);
|
|
1368
1307
|
};
|
|
1369
1308
|
const getGuideLineFromCache = (key) => {
|
|
1370
|
-
if (!key)
|
|
1371
|
-
return [];
|
|
1309
|
+
if (!key) return [];
|
|
1372
1310
|
const guideLineCacheData = globalThis.localStorage.getItem(key);
|
|
1373
1311
|
if (guideLineCacheData) {
|
|
1374
1312
|
try {
|
|
@@ -1380,8 +1318,7 @@ const getGuideLineFromCache = (key) => {
|
|
|
1380
1318
|
return [];
|
|
1381
1319
|
};
|
|
1382
1320
|
const fixNodeLeft = (config, parent, doc) => {
|
|
1383
|
-
if (!doc || !config.style || !isNumber(config.style.left))
|
|
1384
|
-
return config.style?.left;
|
|
1321
|
+
if (!doc || !config.style || !isNumber(config.style.left)) return config.style?.left;
|
|
1385
1322
|
const el = doc.getElementById(`${config.id}`);
|
|
1386
1323
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1387
1324
|
const left = Number(config.style?.left) || 0;
|
|
@@ -1410,24 +1347,39 @@ const serializeConfig = (config) => serialize(config, {
|
|
|
1410
1347
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1411
1348
|
const traverseNode = (node, cb, parents = []) => {
|
|
1412
1349
|
cb(node, parents);
|
|
1413
|
-
if (node.items
|
|
1350
|
+
if (Array.isArray(node.items) && node.items.length) {
|
|
1414
1351
|
parents.push(node);
|
|
1415
1352
|
node.items.forEach((item) => {
|
|
1416
1353
|
traverseNode(item, cb, [...parents]);
|
|
1417
1354
|
});
|
|
1418
1355
|
}
|
|
1419
1356
|
};
|
|
1357
|
+
const moveItemsInContainer = (sourceIndices, parent, targetIndex) => {
|
|
1358
|
+
sourceIndices.sort((a, b) => a - b);
|
|
1359
|
+
for (let i = sourceIndices.length - 1; i >= 0; i--) {
|
|
1360
|
+
const sourceIndex = sourceIndices[i];
|
|
1361
|
+
if (sourceIndex === targetIndex) {
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
const [item] = parent.items.splice(sourceIndex, 1);
|
|
1365
|
+
parent.items.splice(sourceIndex < targetIndex ? targetIndex - 1 : targetIndex, 0, item);
|
|
1366
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
1367
|
+
if (sourceIndices[j] >= targetIndex) {
|
|
1368
|
+
sourceIndices[j] += 1;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1420
1373
|
|
|
1421
|
-
const beforePaste = (position, config) => {
|
|
1422
|
-
if (!config[0]?.style)
|
|
1423
|
-
return config;
|
|
1374
|
+
const beforePaste = (position, config, doc) => {
|
|
1375
|
+
if (!config[0]?.style) return config;
|
|
1424
1376
|
const curNode = editorService.get("node");
|
|
1425
1377
|
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
1426
1378
|
const pasteConfigs = config.map((configItem) => {
|
|
1427
1379
|
const { offsetX = 0, offsetY = 0, ...positionClone } = position;
|
|
1428
1380
|
let pastePosition = positionClone;
|
|
1429
1381
|
if (!isEmpty(pastePosition) && curNode?.items) {
|
|
1430
|
-
pastePosition = getPositionInContainer(pastePosition, curNode.id);
|
|
1382
|
+
pastePosition = getPositionInContainer(pastePosition, curNode.id, doc);
|
|
1431
1383
|
}
|
|
1432
1384
|
if (pastePosition.left && configItem.style?.left) {
|
|
1433
1385
|
pastePosition.left = configItem.style.left - referenceLeft + pastePosition.left;
|
|
@@ -1457,12 +1409,12 @@ const beforePaste = (position, config) => {
|
|
|
1457
1409
|
});
|
|
1458
1410
|
return pasteConfigs;
|
|
1459
1411
|
};
|
|
1460
|
-
const getPositionInContainer = (position = {}, id) => {
|
|
1412
|
+
const getPositionInContainer = (position = {}, id, doc) => {
|
|
1461
1413
|
let { left = 0, top = 0 } = position;
|
|
1462
1414
|
const parentEl = editorService.get("stage")?.renderer?.contentWindow?.document.getElementById(`${id}`);
|
|
1463
1415
|
const parentElRect = parentEl?.getBoundingClientRect();
|
|
1464
|
-
left = left - (parentElRect?.left || 0);
|
|
1465
|
-
top = top - (parentElRect?.top || 0);
|
|
1416
|
+
left = left - calcValueByFontsize(doc, parentElRect?.left || 0);
|
|
1417
|
+
top = top - calcValueByFontsize(doc, parentElRect?.top || 0);
|
|
1466
1418
|
return {
|
|
1467
1419
|
left,
|
|
1468
1420
|
top
|
|
@@ -1590,15 +1542,13 @@ class Editor extends BaseService {
|
|
|
1590
1542
|
parent: null,
|
|
1591
1543
|
page: null
|
|
1592
1544
|
};
|
|
1593
|
-
if (!root)
|
|
1594
|
-
return info;
|
|
1545
|
+
if (!root) return info;
|
|
1595
1546
|
if (id === root.id) {
|
|
1596
1547
|
info.node = root;
|
|
1597
1548
|
return info;
|
|
1598
1549
|
}
|
|
1599
1550
|
const path = getNodePath(id, root.items);
|
|
1600
|
-
if (!path.length)
|
|
1601
|
-
return info;
|
|
1551
|
+
if (!path.length) return info;
|
|
1602
1552
|
path.unshift(root);
|
|
1603
1553
|
info.node = path[path.length - 1];
|
|
1604
1554
|
info.parent = path[path.length - 2];
|
|
@@ -1634,8 +1584,7 @@ class Editor extends BaseService {
|
|
|
1634
1584
|
* 只有容器拥有布局
|
|
1635
1585
|
*/
|
|
1636
1586
|
async getLayout(parent, node) {
|
|
1637
|
-
if (node && typeof node !== "function" && isFixed(node))
|
|
1638
|
-
return Layout.FIXED;
|
|
1587
|
+
if (node && typeof node !== "function" && isFixed(node)) return Layout.FIXED;
|
|
1639
1588
|
if (parent.layout) {
|
|
1640
1589
|
return parent.layout;
|
|
1641
1590
|
}
|
|
@@ -1675,11 +1624,9 @@ class Editor extends BaseService {
|
|
|
1675
1624
|
}
|
|
1676
1625
|
async selectNextNode() {
|
|
1677
1626
|
const node = toRaw(this.get("node"));
|
|
1678
|
-
if (!node || isPage(node) || node.type === NodeType.ROOT)
|
|
1679
|
-
return node;
|
|
1627
|
+
if (!node || isPage(node) || node.type === NodeType.ROOT) return node;
|
|
1680
1628
|
const parent = toRaw(this.getParentById(node.id));
|
|
1681
|
-
if (!parent)
|
|
1682
|
-
return node;
|
|
1629
|
+
if (!parent) return node;
|
|
1683
1630
|
const index = getNodeIndex(node.id, parent);
|
|
1684
1631
|
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
1685
1632
|
await this.select(nextNode);
|
|
@@ -1689,10 +1636,8 @@ class Editor extends BaseService {
|
|
|
1689
1636
|
async selectNextPage() {
|
|
1690
1637
|
const root = toRaw(this.get("root"));
|
|
1691
1638
|
const page = toRaw(this.get("page"));
|
|
1692
|
-
if (!page)
|
|
1693
|
-
|
|
1694
|
-
if (!root)
|
|
1695
|
-
throw new Error("root不能为空");
|
|
1639
|
+
if (!page) throw new Error("page不能为空");
|
|
1640
|
+
if (!root) throw new Error("root不能为空");
|
|
1696
1641
|
const index = getNodeIndex(page.id, root);
|
|
1697
1642
|
const nextPage = root.items[index + 1] || root.items[0];
|
|
1698
1643
|
await this.select(nextPage);
|
|
@@ -1707,8 +1652,7 @@ class Editor extends BaseService {
|
|
|
1707
1652
|
highlight(config) {
|
|
1708
1653
|
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1709
1654
|
const currentHighlightNode = this.get("highlightNode");
|
|
1710
|
-
if (currentHighlightNode === node)
|
|
1711
|
-
return;
|
|
1655
|
+
if (currentHighlightNode === node) return;
|
|
1712
1656
|
this.set("highlightNode", node);
|
|
1713
1657
|
}
|
|
1714
1658
|
/**
|
|
@@ -1721,16 +1665,14 @@ class Editor extends BaseService {
|
|
|
1721
1665
|
const idsUnique = uniq(ids);
|
|
1722
1666
|
idsUnique.forEach((id) => {
|
|
1723
1667
|
const { node } = this.getNodeInfo(id);
|
|
1724
|
-
if (!node)
|
|
1725
|
-
return;
|
|
1668
|
+
if (!node) return;
|
|
1726
1669
|
nodes.push(node);
|
|
1727
1670
|
});
|
|
1728
1671
|
this.set("nodes", nodes);
|
|
1729
1672
|
}
|
|
1730
1673
|
selectRoot() {
|
|
1731
1674
|
const root = this.get("root");
|
|
1732
|
-
if (!root)
|
|
1733
|
-
return;
|
|
1675
|
+
if (!root) return;
|
|
1734
1676
|
this.set("nodes", [root]);
|
|
1735
1677
|
this.set("parent", null);
|
|
1736
1678
|
this.set("page", null);
|
|
@@ -1739,12 +1681,10 @@ class Editor extends BaseService {
|
|
|
1739
1681
|
}
|
|
1740
1682
|
async doAdd(node, parent) {
|
|
1741
1683
|
const root = this.get("root");
|
|
1742
|
-
if (!root)
|
|
1743
|
-
throw new Error("root为空");
|
|
1684
|
+
if (!root) throw new Error("root为空");
|
|
1744
1685
|
const curNode = this.get("node");
|
|
1745
1686
|
const stage = this.get("stage");
|
|
1746
|
-
if (!curNode)
|
|
1747
|
-
throw new Error("当前选中节点为空");
|
|
1687
|
+
if (!curNode) throw new Error("当前选中节点为空");
|
|
1748
1688
|
if ((parent.type === NodeType.ROOT || curNode?.type === NodeType.ROOT) && !(isPage(node) || isPageFragment(node))) {
|
|
1749
1689
|
throw new Error("app下不能添加组件");
|
|
1750
1690
|
}
|
|
@@ -1781,8 +1721,7 @@ class Editor extends BaseService {
|
|
|
1781
1721
|
const addNodes = [];
|
|
1782
1722
|
if (!Array.isArray(addNode)) {
|
|
1783
1723
|
const { type, inputEvent, ...config } = addNode;
|
|
1784
|
-
if (!type)
|
|
1785
|
-
throw new Error("组件类型不能为空");
|
|
1724
|
+
if (!type) throw new Error("组件类型不能为空");
|
|
1786
1725
|
addNodes.push({ ...toRaw(await propsService.getPropsValue(type, config)) });
|
|
1787
1726
|
} else {
|
|
1788
1727
|
addNodes.push(...addNode);
|
|
@@ -1794,8 +1733,7 @@ class Editor extends BaseService {
|
|
|
1794
1733
|
return this.doAdd(node, root);
|
|
1795
1734
|
}
|
|
1796
1735
|
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1797
|
-
if (!parentNode)
|
|
1798
|
-
throw new Error("未找到父元素");
|
|
1736
|
+
if (!parentNode) throw new Error("未找到父元素");
|
|
1799
1737
|
return this.doAdd(node, parentNode);
|
|
1800
1738
|
})
|
|
1801
1739
|
);
|
|
@@ -1821,14 +1759,11 @@ class Editor extends BaseService {
|
|
|
1821
1759
|
}
|
|
1822
1760
|
async doRemove(node) {
|
|
1823
1761
|
const root = this.get("root");
|
|
1824
|
-
if (!root)
|
|
1825
|
-
throw new Error("root不能为空");
|
|
1762
|
+
if (!root) throw new Error("root不能为空");
|
|
1826
1763
|
const { parent, node: curNode } = this.getNodeInfo(node.id, false);
|
|
1827
|
-
if (!parent || !curNode)
|
|
1828
|
-
throw new Error("找不要删除的节点");
|
|
1764
|
+
if (!parent || !curNode) throw new Error("找不要删除的节点");
|
|
1829
1765
|
const index = getNodeIndex(curNode.id, parent);
|
|
1830
|
-
if (typeof index !== "number" || index === -1)
|
|
1831
|
-
throw new Error("找不要删除的节点");
|
|
1766
|
+
if (typeof index !== "number" || index === -1) throw new Error("找不要删除的节点");
|
|
1832
1767
|
parent.items?.splice(index, 1);
|
|
1833
1768
|
const stage = this.get("stage");
|
|
1834
1769
|
stage?.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
|
|
@@ -1872,13 +1807,10 @@ class Editor extends BaseService {
|
|
|
1872
1807
|
}
|
|
1873
1808
|
async doUpdate(config) {
|
|
1874
1809
|
const root = this.get("root");
|
|
1875
|
-
if (!root)
|
|
1876
|
-
|
|
1877
|
-
if (!config?.id)
|
|
1878
|
-
throw new Error("没有配置或者配置缺少id值");
|
|
1810
|
+
if (!root) throw new Error("root为空");
|
|
1811
|
+
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
1879
1812
|
const info = this.getNodeInfo(config.id, false);
|
|
1880
|
-
if (!info.node)
|
|
1881
|
-
throw new Error(`获取不到id为${config.id}的节点`);
|
|
1813
|
+
if (!info.node) throw new Error(`获取不到id为${config.id}的节点`);
|
|
1882
1814
|
const node = cloneDeep(toRaw(info.node));
|
|
1883
1815
|
let newConfig = await this.toggleFixedPosition(toRaw(config), node, root);
|
|
1884
1816
|
newConfig = mergeWith(cloneDeep(node), newConfig, (objValue, srcValue, key) => {
|
|
@@ -1892,19 +1824,16 @@ class Editor extends BaseService {
|
|
|
1892
1824
|
return srcValue;
|
|
1893
1825
|
}
|
|
1894
1826
|
});
|
|
1895
|
-
if (!newConfig.type)
|
|
1896
|
-
throw new Error("配置缺少type值");
|
|
1827
|
+
if (!newConfig.type) throw new Error("配置缺少type值");
|
|
1897
1828
|
if (newConfig.type === NodeType.ROOT) {
|
|
1898
1829
|
this.set("root", newConfig);
|
|
1899
1830
|
return newConfig;
|
|
1900
1831
|
}
|
|
1901
1832
|
const { parent } = info;
|
|
1902
|
-
if (!parent)
|
|
1903
|
-
throw new Error("获取不到父级节点");
|
|
1833
|
+
if (!parent) throw new Error("获取不到父级节点");
|
|
1904
1834
|
const parentNodeItems = parent.items;
|
|
1905
1835
|
const index = getNodeIndex(newConfig.id, parent);
|
|
1906
|
-
if (!parentNodeItems || typeof index === "undefined" || index === -1)
|
|
1907
|
-
throw new Error("更新的节点未找到");
|
|
1836
|
+
if (!parentNodeItems || typeof index === "undefined" || index === -1) throw new Error("更新的节点未找到");
|
|
1908
1837
|
const newLayout = await this.getLayout(newConfig);
|
|
1909
1838
|
const layout = await this.getLayout(node);
|
|
1910
1839
|
if (Array.isArray(newConfig.items) && newLayout !== layout) {
|
|
@@ -1948,17 +1877,13 @@ class Editor extends BaseService {
|
|
|
1948
1877
|
*/
|
|
1949
1878
|
async sort(id1, id2) {
|
|
1950
1879
|
const root = this.get("root");
|
|
1951
|
-
if (!root)
|
|
1952
|
-
throw new Error("root为空");
|
|
1880
|
+
if (!root) throw new Error("root为空");
|
|
1953
1881
|
const node = this.get("node");
|
|
1954
|
-
if (!node)
|
|
1955
|
-
throw new Error("当前节点为空");
|
|
1882
|
+
if (!node) throw new Error("当前节点为空");
|
|
1956
1883
|
const parent = cloneDeep(toRaw(this.get("parent")));
|
|
1957
|
-
if (!parent)
|
|
1958
|
-
throw new Error("父节点为空");
|
|
1884
|
+
if (!parent) throw new Error("父节点为空");
|
|
1959
1885
|
const index2 = parent.items.findIndex((node2) => `${node2.id}` === `${id2}`);
|
|
1960
|
-
if (index2 < 0)
|
|
1961
|
-
return;
|
|
1886
|
+
if (index2 < 0) return;
|
|
1962
1887
|
const index1 = parent.items.findIndex((node2) => `${node2.id}` === `${id1}`);
|
|
1963
1888
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1964
1889
|
await this.update(parent);
|
|
@@ -1986,19 +1911,18 @@ class Editor extends BaseService {
|
|
|
1986
1911
|
* @param config 组件节点配置
|
|
1987
1912
|
* @returns
|
|
1988
1913
|
*/
|
|
1989
|
-
copyWithRelated(config) {
|
|
1914
|
+
copyWithRelated(config, collectorOptions) {
|
|
1990
1915
|
const copyNodes = Array.isArray(config) ? config : [config];
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1916
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
1917
|
+
const customTarget = new Target({
|
|
1918
|
+
...collectorOptions
|
|
1919
|
+
});
|
|
1920
|
+
const coperWatcher = new Watcher();
|
|
1921
|
+
coperWatcher.addTarget(customTarget);
|
|
1922
|
+
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
1998
1923
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
1999
1924
|
const node = this.getNodeById(nodeId);
|
|
2000
|
-
if (!node)
|
|
2001
|
-
return;
|
|
1925
|
+
if (!node) return;
|
|
2002
1926
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
2003
1927
|
const relateNodeId = get(node, key);
|
|
2004
1928
|
const isExist = copyNodes.find((node2) => node2.id === relateNodeId);
|
|
@@ -2020,10 +1944,9 @@ class Editor extends BaseService {
|
|
|
2020
1944
|
* @param position 粘贴的坐标
|
|
2021
1945
|
* @returns 添加后的组件节点配置
|
|
2022
1946
|
*/
|
|
2023
|
-
async paste(position = {}) {
|
|
1947
|
+
async paste(position = {}, collectorOptions) {
|
|
2024
1948
|
const config = storageService.getItem(COPY_STORAGE_KEY);
|
|
2025
|
-
if (!Array.isArray(config))
|
|
2026
|
-
return;
|
|
1949
|
+
if (!Array.isArray(config)) return;
|
|
2027
1950
|
const node = this.get("node");
|
|
2028
1951
|
let parent = null;
|
|
2029
1952
|
if (config.length === 1 && config[0].id === node?.id) {
|
|
@@ -2033,25 +1956,26 @@ class Editor extends BaseService {
|
|
|
2033
1956
|
}
|
|
2034
1957
|
}
|
|
2035
1958
|
const pasteConfigs = await this.doPaste(config, position);
|
|
2036
|
-
|
|
1959
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
1960
|
+
propsService.replaceRelateId(config, pasteConfigs, collectorOptions);
|
|
1961
|
+
}
|
|
2037
1962
|
return this.add(pasteConfigs, parent);
|
|
2038
1963
|
}
|
|
2039
1964
|
async doPaste(config, position = {}) {
|
|
2040
1965
|
propsService.clearRelateId();
|
|
2041
|
-
const
|
|
1966
|
+
const doc = this.get("stage")?.renderer.contentWindow?.document;
|
|
1967
|
+
const pasteConfigs = beforePaste(position, cloneDeep(config), doc);
|
|
2042
1968
|
return pasteConfigs;
|
|
2043
1969
|
}
|
|
2044
1970
|
async doAlignCenter(config) {
|
|
2045
1971
|
const parent = this.getParentById(config.id);
|
|
2046
|
-
if (!parent)
|
|
2047
|
-
throw new Error("找不到父节点");
|
|
1972
|
+
if (!parent) throw new Error("找不到父节点");
|
|
2048
1973
|
const node = cloneDeep(toRaw(config));
|
|
2049
1974
|
const layout = await this.getLayout(parent, node);
|
|
2050
1975
|
if (layout === Layout.RELATIVE) {
|
|
2051
1976
|
return config;
|
|
2052
1977
|
}
|
|
2053
|
-
if (!node.style)
|
|
2054
|
-
return config;
|
|
1978
|
+
if (!node.style) return config;
|
|
2055
1979
|
const stage = this.get("stage");
|
|
2056
1980
|
const doc = stage?.renderer.contentWindow?.document;
|
|
2057
1981
|
if (doc) {
|
|
@@ -2090,14 +2014,11 @@ class Editor extends BaseService {
|
|
|
2090
2014
|
*/
|
|
2091
2015
|
async moveLayer(offset) {
|
|
2092
2016
|
const root = this.get("root");
|
|
2093
|
-
if (!root)
|
|
2094
|
-
throw new Error("root为空");
|
|
2017
|
+
if (!root) throw new Error("root为空");
|
|
2095
2018
|
const parent = this.get("parent");
|
|
2096
|
-
if (!parent)
|
|
2097
|
-
throw new Error("父节点为空");
|
|
2019
|
+
if (!parent) throw new Error("父节点为空");
|
|
2098
2020
|
const node = this.get("node");
|
|
2099
|
-
if (!node)
|
|
2100
|
-
throw new Error("当前节点为空");
|
|
2021
|
+
if (!node) throw new Error("当前节点为空");
|
|
2101
2022
|
const brothers = parent.items || [];
|
|
2102
2023
|
const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
|
|
2103
2024
|
const layout = await this.getLayout(parent, node);
|
|
@@ -2159,28 +2080,35 @@ class Editor extends BaseService {
|
|
|
2159
2080
|
}
|
|
2160
2081
|
}
|
|
2161
2082
|
async dragTo(config, targetParent, targetIndex) {
|
|
2162
|
-
if (!targetParent || !Array.isArray(targetParent.items))
|
|
2163
|
-
|
|
2164
|
-
const
|
|
2165
|
-
|
|
2166
|
-
throw new Error("找不要删除的节点");
|
|
2167
|
-
const index = getNodeIndex(curNode.id, parent);
|
|
2168
|
-
if (typeof index !== "number" || index === -1)
|
|
2169
|
-
throw new Error("找不要删除的节点");
|
|
2170
|
-
if (parent.id === targetParent.id) {
|
|
2171
|
-
if (index === targetIndex)
|
|
2172
|
-
return;
|
|
2173
|
-
if (index < targetIndex) {
|
|
2174
|
-
targetIndex -= 1;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
const layout = await this.getLayout(parent);
|
|
2083
|
+
if (!targetParent || !Array.isArray(targetParent.items)) return;
|
|
2084
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
2085
|
+
const sourceIndicesInTargetParent = [];
|
|
2086
|
+
const sourceOutTargetParent = [];
|
|
2178
2087
|
const newLayout = await this.getLayout(targetParent);
|
|
2179
|
-
|
|
2180
|
-
|
|
2088
|
+
for (const config2 of configs) {
|
|
2089
|
+
const { parent, node: curNode } = this.getNodeInfo(config2.id, false);
|
|
2090
|
+
if (!parent || !curNode) throw new Error("找不要删除的节点");
|
|
2091
|
+
const index = getNodeIndex(curNode.id, parent);
|
|
2092
|
+
if (parent.id === targetParent.id) {
|
|
2093
|
+
if (typeof index !== "number" || index === -1) {
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
sourceIndicesInTargetParent.push(index);
|
|
2097
|
+
} else {
|
|
2098
|
+
const layout = await this.getLayout(parent);
|
|
2099
|
+
if (newLayout !== layout) {
|
|
2100
|
+
setLayout(config2, newLayout);
|
|
2101
|
+
}
|
|
2102
|
+
parent.items?.splice(index, 1);
|
|
2103
|
+
sourceOutTargetParent.push(config2);
|
|
2104
|
+
this.addModifiedNodeId(parent.id);
|
|
2105
|
+
}
|
|
2181
2106
|
}
|
|
2182
|
-
|
|
2183
|
-
|
|
2107
|
+
moveItemsInContainer(sourceIndicesInTargetParent, targetParent, targetIndex);
|
|
2108
|
+
sourceOutTargetParent.forEach((config2, index) => {
|
|
2109
|
+
targetParent.items?.splice(targetIndex + index, 0, config2);
|
|
2110
|
+
this.addModifiedNodeId(config2.id);
|
|
2111
|
+
});
|
|
2184
2112
|
const page = this.get("page");
|
|
2185
2113
|
const root = this.get("root");
|
|
2186
2114
|
const stage = this.get("stage");
|
|
@@ -2191,10 +2119,8 @@ class Editor extends BaseService {
|
|
|
2191
2119
|
root: cloneDeep(root)
|
|
2192
2120
|
});
|
|
2193
2121
|
}
|
|
2194
|
-
this.addModifiedNodeId(config.id);
|
|
2195
|
-
this.addModifiedNodeId(parent.id);
|
|
2196
2122
|
this.pushHistoryState();
|
|
2197
|
-
this.emit("drag-to", {
|
|
2123
|
+
this.emit("drag-to", { targetIndex, configs, targetParent });
|
|
2198
2124
|
}
|
|
2199
2125
|
/**
|
|
2200
2126
|
* 撤销当前操作
|
|
@@ -2216,11 +2142,9 @@ class Editor extends BaseService {
|
|
|
2216
2142
|
}
|
|
2217
2143
|
async move(left, top) {
|
|
2218
2144
|
const node = toRaw(this.get("node"));
|
|
2219
|
-
if (!node || isPage(node))
|
|
2220
|
-
return;
|
|
2145
|
+
if (!node || isPage(node)) return;
|
|
2221
2146
|
const { style, id, type } = node;
|
|
2222
|
-
if (!style || !["absolute", "fixed"].includes(style.position))
|
|
2223
|
-
return;
|
|
2147
|
+
if (!style || !["absolute", "fixed"].includes(style.position)) return;
|
|
2224
2148
|
const update = (style2) => this.update({
|
|
2225
2149
|
id,
|
|
2226
2150
|
type,
|
|
@@ -2279,6 +2203,15 @@ class Editor extends BaseService {
|
|
|
2279
2203
|
usePlugin(options) {
|
|
2280
2204
|
super.usePlugin(options);
|
|
2281
2205
|
}
|
|
2206
|
+
on(eventName, listener) {
|
|
2207
|
+
return super.on(eventName, listener);
|
|
2208
|
+
}
|
|
2209
|
+
once(eventName, listener) {
|
|
2210
|
+
return super.once(eventName, listener);
|
|
2211
|
+
}
|
|
2212
|
+
emit(eventName, ...args) {
|
|
2213
|
+
return super.emit(eventName, ...args);
|
|
2214
|
+
}
|
|
2282
2215
|
addModifiedNodeId(id) {
|
|
2283
2216
|
if (!this.isHistoryStateChange) {
|
|
2284
2217
|
this.get("modifiedNodeIds").set(id, id);
|
|
@@ -2297,14 +2230,12 @@ class Editor extends BaseService {
|
|
|
2297
2230
|
this.isHistoryStateChange = false;
|
|
2298
2231
|
}
|
|
2299
2232
|
async changeHistoryState(value) {
|
|
2300
|
-
if (!value)
|
|
2301
|
-
return;
|
|
2233
|
+
if (!value) return;
|
|
2302
2234
|
this.isHistoryStateChange = true;
|
|
2303
2235
|
await this.update(value.data);
|
|
2304
2236
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2305
2237
|
setTimeout(async () => {
|
|
2306
|
-
if (!value.nodeId)
|
|
2307
|
-
return;
|
|
2238
|
+
if (!value.nodeId) return;
|
|
2308
2239
|
await this.select(value.nodeId);
|
|
2309
2240
|
this.get("stage")?.select(value.nodeId);
|
|
2310
2241
|
}, 0);
|
|
@@ -2332,8 +2263,7 @@ class Editor extends BaseService {
|
|
|
2332
2263
|
throw new Error("没有ID,无法选中");
|
|
2333
2264
|
}
|
|
2334
2265
|
const { node, parent, page } = this.getNodeInfo(id);
|
|
2335
|
-
if (!node)
|
|
2336
|
-
throw new Error("获取不到组件信息");
|
|
2266
|
+
if (!node) throw new Error("获取不到组件信息");
|
|
2337
2267
|
if (node.id === this.state.root?.id) {
|
|
2338
2268
|
throw new Error("不能选根节点");
|
|
2339
2269
|
}
|
|
@@ -2578,8 +2508,7 @@ const getDisplayField = (dataSources, key) => {
|
|
|
2578
2508
|
const matches = key.matchAll(/\$\{([\s\S]+?)\}/g);
|
|
2579
2509
|
let index = 0;
|
|
2580
2510
|
for (const match of matches) {
|
|
2581
|
-
if (typeof match.index === "undefined")
|
|
2582
|
-
break;
|
|
2511
|
+
if (typeof match.index === "undefined") break;
|
|
2583
2512
|
displayState.push({
|
|
2584
2513
|
type: "text",
|
|
2585
2514
|
value: key.substring(index, match.index)
|
|
@@ -2587,16 +2516,20 @@ const getDisplayField = (dataSources, key) => {
|
|
|
2587
2516
|
let dsText = "";
|
|
2588
2517
|
let ds;
|
|
2589
2518
|
let fields;
|
|
2590
|
-
match[1].split(".").forEach((item, index2) => {
|
|
2519
|
+
match[1].replaceAll(/\[(\d+)\]/g, ".$1").split(".").forEach((item, index2) => {
|
|
2591
2520
|
if (index2 === 0) {
|
|
2592
2521
|
ds = dataSources.find((ds2) => ds2.id === item);
|
|
2593
2522
|
dsText += ds?.title || item;
|
|
2594
2523
|
fields = ds?.fields;
|
|
2595
2524
|
return;
|
|
2596
2525
|
}
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2526
|
+
if (isNumber(item)) {
|
|
2527
|
+
dsText += `[${item}]`;
|
|
2528
|
+
} else {
|
|
2529
|
+
const field = fields?.find((field2) => field2.name === item);
|
|
2530
|
+
fields = field?.fields;
|
|
2531
|
+
dsText += `.${field?.title || item}`;
|
|
2532
|
+
}
|
|
2600
2533
|
});
|
|
2601
2534
|
displayState.push({
|
|
2602
2535
|
type: "var",
|
|
@@ -2744,17 +2677,19 @@ class DataSource extends BaseService {
|
|
|
2744
2677
|
* @param config 组件节点配置
|
|
2745
2678
|
* @returns
|
|
2746
2679
|
*/
|
|
2747
|
-
copyWithRelated(config) {
|
|
2680
|
+
copyWithRelated(config, collectorOptions) {
|
|
2748
2681
|
const copyNodes = Array.isArray(config) ? config : [config];
|
|
2749
|
-
depService.clearByType(DepTargetType.RELATED_DS_WHEN_COPY);
|
|
2750
|
-
depService.collect(copyNodes, true, DepTargetType.RELATED_DS_WHEN_COPY);
|
|
2751
|
-
const customTarget = depService.getTarget(DepTargetType.RELATED_DS_WHEN_COPY, DepTargetType.RELATED_DS_WHEN_COPY);
|
|
2752
2682
|
const copyData = [];
|
|
2753
|
-
if (
|
|
2683
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
2684
|
+
const customTarget = new Target({
|
|
2685
|
+
...collectorOptions
|
|
2686
|
+
});
|
|
2687
|
+
const coperWatcher = new Watcher();
|
|
2688
|
+
coperWatcher.addTarget(customTarget);
|
|
2689
|
+
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
2754
2690
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
2755
2691
|
const node = editorService.getNodeById(nodeId);
|
|
2756
|
-
if (!node)
|
|
2757
|
-
return;
|
|
2692
|
+
if (!node) return;
|
|
2758
2693
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
2759
2694
|
const [relateDsId] = get(node, key);
|
|
2760
2695
|
const isExist = copyData.find((dsItem) => dsItem.id === relateDsId);
|
|
@@ -3349,11 +3284,9 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
|
3349
3284
|
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
|
|
3350
3285
|
);
|
|
3351
3286
|
const getParamItemsConfig = (codeId) => {
|
|
3352
|
-
if (!codeDsl.value || !codeId)
|
|
3353
|
-
return [];
|
|
3287
|
+
if (!codeDsl.value || !codeId) return [];
|
|
3354
3288
|
const paramStatements = codeDsl.value[codeId]?.params;
|
|
3355
|
-
if (isEmpty(paramStatements))
|
|
3356
|
-
return [];
|
|
3289
|
+
if (isEmpty(paramStatements)) return [];
|
|
3357
3290
|
return paramStatements.map((paramState) => ({
|
|
3358
3291
|
labelWidth: "100px",
|
|
3359
3292
|
text: paramState.name,
|
|
@@ -3653,8 +3586,7 @@ const useCodeBlockEdit = (codeBlockService) => {
|
|
|
3653
3586
|
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3654
3587
|
};
|
|
3655
3588
|
const submitCodeBlockHandler = async (values) => {
|
|
3656
|
-
if (!codeId.value)
|
|
3657
|
-
return;
|
|
3589
|
+
if (!codeId.value) return;
|
|
3658
3590
|
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
3659
3591
|
codeBlockEditor.value?.hide();
|
|
3660
3592
|
};
|
|
@@ -3710,8 +3642,7 @@ const useDataSourceMethod = () => {
|
|
|
3710
3642
|
codeBlockEditor.value?.show();
|
|
3711
3643
|
},
|
|
3712
3644
|
deleteCode: async (model, methodName) => {
|
|
3713
|
-
if (!model.methods)
|
|
3714
|
-
return;
|
|
3645
|
+
if (!model.methods) return;
|
|
3715
3646
|
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
3716
3647
|
if (index === -1) {
|
|
3717
3648
|
return;
|
|
@@ -3719,8 +3650,7 @@ const useDataSourceMethod = () => {
|
|
|
3719
3650
|
model.methods.splice(index, 1);
|
|
3720
3651
|
},
|
|
3721
3652
|
submitCode: (values) => {
|
|
3722
|
-
if (!dataSource.value)
|
|
3723
|
-
return;
|
|
3653
|
+
if (!dataSource.value) return;
|
|
3724
3654
|
if (!dataSource.value.methods) {
|
|
3725
3655
|
dataSource.value.methods = [];
|
|
3726
3656
|
}
|
|
@@ -3804,14 +3734,12 @@ class Ui extends BaseService {
|
|
|
3804
3734
|
}
|
|
3805
3735
|
async zoom(zoom) {
|
|
3806
3736
|
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
3807
|
-
if (this.get("zoom") < 0.1)
|
|
3808
|
-
this.set("zoom", 0.1);
|
|
3737
|
+
if (this.get("zoom") < 0.1) this.set("zoom", 0.1);
|
|
3809
3738
|
}
|
|
3810
3739
|
async calcZoom() {
|
|
3811
3740
|
const { stageRect, stageContainerRect } = state;
|
|
3812
3741
|
const { height, width } = stageContainerRect;
|
|
3813
|
-
if (!width || !height)
|
|
3814
|
-
return 1;
|
|
3742
|
+
if (!width || !height) return 1;
|
|
3815
3743
|
let stageWidth = convertToNumber(stageRect.width, width);
|
|
3816
3744
|
let stageHeight = convertToNumber(stageRect.height, height);
|
|
3817
3745
|
stageWidth = stageWidth + 30;
|
|
@@ -3866,8 +3794,7 @@ const useStage = (stageOptions) => {
|
|
|
3866
3794
|
disabledDragStart: stageOptions.disabledDragStart,
|
|
3867
3795
|
renderType: stageOptions.renderType,
|
|
3868
3796
|
canSelect: (el, event, stop) => {
|
|
3869
|
-
if (!stageOptions.canSelect)
|
|
3870
|
-
return true;
|
|
3797
|
+
if (!stageOptions.canSelect) return true;
|
|
3871
3798
|
const elCanSelect = stageOptions.canSelect?.(el);
|
|
3872
3799
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
3873
3800
|
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
@@ -3898,8 +3825,7 @@ const useStage = (stageOptions) => {
|
|
|
3898
3825
|
editorService.set("stageLoading", false);
|
|
3899
3826
|
});
|
|
3900
3827
|
stage.on("select", (el) => {
|
|
3901
|
-
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
3902
|
-
return;
|
|
3828
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1) return;
|
|
3903
3829
|
editorService.select(el.id);
|
|
3904
3830
|
});
|
|
3905
3831
|
stage.on("highlight", (el) => {
|
|
@@ -3926,15 +3852,13 @@ const useStage = (stageOptions) => {
|
|
|
3926
3852
|
});
|
|
3927
3853
|
stage.on("select-parent", () => {
|
|
3928
3854
|
const parent = editorService.get("parent");
|
|
3929
|
-
if (!parent)
|
|
3930
|
-
throw new Error("父节点为空");
|
|
3855
|
+
if (!parent) throw new Error("父节点为空");
|
|
3931
3856
|
editorService.select(parent);
|
|
3932
3857
|
editorService.get("stage")?.select(parent.id);
|
|
3933
3858
|
});
|
|
3934
3859
|
stage.on("change-guides", (e) => {
|
|
3935
3860
|
uiService.set("showGuides", true);
|
|
3936
|
-
if (!root.value || !page.value)
|
|
3937
|
-
return;
|
|
3861
|
+
if (!root.value || !page.value) return;
|
|
3938
3862
|
const storageKey = getGuideLineKey(
|
|
3939
3863
|
e.type === GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
3940
3864
|
);
|
|
@@ -3977,8 +3901,7 @@ const useFloatBox = (slideKeys) => {
|
|
|
3977
3901
|
isDragging.value = false;
|
|
3978
3902
|
};
|
|
3979
3903
|
document.body.addEventListener("dragover", (e) => {
|
|
3980
|
-
if (!isDragging.value)
|
|
3981
|
-
return;
|
|
3904
|
+
if (!isDragging.value) return;
|
|
3982
3905
|
e.preventDefault();
|
|
3983
3906
|
});
|
|
3984
3907
|
watch(
|
|
@@ -4031,8 +3954,7 @@ const useEditorContentHeight = () => {
|
|
|
4031
3954
|
watch(
|
|
4032
3955
|
editorContentHeight,
|
|
4033
3956
|
() => {
|
|
4034
|
-
if (height.value > 0 && height.value === editorContentHeight.value)
|
|
4035
|
-
return;
|
|
3957
|
+
if (height.value > 0 && height.value === editorContentHeight.value) return;
|
|
4036
3958
|
height.value = editorContentHeight.value;
|
|
4037
3959
|
},
|
|
4038
3960
|
{
|
|
@@ -4225,12 +4147,9 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4225
4147
|
height: "200px",
|
|
4226
4148
|
parse: true,
|
|
4227
4149
|
type: (mForm, { model }) => {
|
|
4228
|
-
if (model.type === "number")
|
|
4229
|
-
|
|
4230
|
-
if (model.type === "
|
|
4231
|
-
return "select";
|
|
4232
|
-
if (model.type === "string")
|
|
4233
|
-
return "text";
|
|
4150
|
+
if (model.type === "number") return "number";
|
|
4151
|
+
if (model.type === "boolean") return "select";
|
|
4152
|
+
if (model.type === "string") return "text";
|
|
4234
4153
|
return "vs-code";
|
|
4235
4154
|
},
|
|
4236
4155
|
options: [
|
|
@@ -4270,23 +4189,16 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
4270
4189
|
addFromJsonDialogVisible.value = true;
|
|
4271
4190
|
};
|
|
4272
4191
|
const getValueType = (value) => {
|
|
4273
|
-
if (Array.isArray(value))
|
|
4274
|
-
|
|
4275
|
-
if (value ===
|
|
4276
|
-
|
|
4277
|
-
if (typeof value === "
|
|
4278
|
-
|
|
4279
|
-
if (typeof value === "number")
|
|
4280
|
-
return "number";
|
|
4281
|
-
if (typeof value === "boolean")
|
|
4282
|
-
return "boolean";
|
|
4283
|
-
if (typeof value === "string")
|
|
4284
|
-
return "string";
|
|
4192
|
+
if (Array.isArray(value)) return "array";
|
|
4193
|
+
if (value === null) return "null";
|
|
4194
|
+
if (typeof value === "object") return "object";
|
|
4195
|
+
if (typeof value === "number") return "number";
|
|
4196
|
+
if (typeof value === "boolean") return "boolean";
|
|
4197
|
+
if (typeof value === "string") return "string";
|
|
4285
4198
|
return "any";
|
|
4286
4199
|
};
|
|
4287
4200
|
const getFieldsConfig = (value, fields = []) => {
|
|
4288
|
-
if (!value || typeof value !== "object")
|
|
4289
|
-
throw new Error("数据格式错误");
|
|
4201
|
+
if (!value || typeof value !== "object") throw new Error("数据格式错误");
|
|
4290
4202
|
const newFields = [];
|
|
4291
4203
|
Object.entries(value).forEach(([key, value2]) => {
|
|
4292
4204
|
const type = getValueType(value2);
|
|
@@ -4476,10 +4388,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4476
4388
|
model: props.model
|
|
4477
4389
|
});
|
|
4478
4390
|
}
|
|
4479
|
-
if (type2 === "form")
|
|
4480
|
-
|
|
4481
|
-
if (type2 === "container")
|
|
4482
|
-
return "";
|
|
4391
|
+
if (type2 === "form") return "";
|
|
4392
|
+
if (type2 === "container") return "";
|
|
4483
4393
|
return type2?.replace(/([A-Z])/g, "-$1").toLowerCase() || (props.config.items ? "" : "text");
|
|
4484
4394
|
});
|
|
4485
4395
|
const tagName = computed(() => {
|
|
@@ -4487,8 +4397,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4487
4397
|
return MCascader;
|
|
4488
4398
|
}
|
|
4489
4399
|
const component = resolveComponent(`m-${props.config.items ? "form" : "fields"}-${type.value}`);
|
|
4490
|
-
if (typeof component !== "string")
|
|
4491
|
-
return component;
|
|
4400
|
+
if (typeof component !== "string") return component;
|
|
4492
4401
|
return "m-fields-text";
|
|
4493
4402
|
});
|
|
4494
4403
|
const onChangeHandler = (value) => {
|
|
@@ -4583,9 +4492,15 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
|
4583
4492
|
{ immediate: true }
|
|
4584
4493
|
);
|
|
4585
4494
|
const mouseupHandler = async () => {
|
|
4495
|
+
const selection = globalThis.document.getSelection();
|
|
4496
|
+
const anchorOffset = selection?.anchorOffset || 0;
|
|
4497
|
+
const focusOffset = selection?.focusOffset || 0;
|
|
4586
4498
|
isFocused.value = true;
|
|
4587
4499
|
await nextTick();
|
|
4588
4500
|
autocomplete.value?.focus();
|
|
4501
|
+
if (focusOffset && input.value) {
|
|
4502
|
+
input.value.setSelectionRange(anchorOffset, focusOffset);
|
|
4503
|
+
}
|
|
4589
4504
|
};
|
|
4590
4505
|
const blurHandler = () => {
|
|
4591
4506
|
isFocused.value = false;
|
|
@@ -4633,7 +4548,7 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
|
4633
4548
|
const fieldQuerySearch = (queryString, leftAngleIndex, dotIndex, cb) => {
|
|
4634
4549
|
let result = [];
|
|
4635
4550
|
const dsKey = queryString.substring(leftAngleIndex + 1, dotIndex);
|
|
4636
|
-
const keys = dsKey.split(".");
|
|
4551
|
+
const keys = dsKey.replaceAll(/\[(\d+)\]/g, ".$1").split(".");
|
|
4637
4552
|
const dsId = keys.shift();
|
|
4638
4553
|
const ds = dataSources.value.find((ds2) => ds2.id === dsId);
|
|
4639
4554
|
if (!ds) {
|
|
@@ -4643,6 +4558,10 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
|
4643
4558
|
let fields = ds.fields || [];
|
|
4644
4559
|
let key = keys.shift();
|
|
4645
4560
|
while (key) {
|
|
4561
|
+
if (isNumber(key)) {
|
|
4562
|
+
key = keys.shift();
|
|
4563
|
+
continue;
|
|
4564
|
+
}
|
|
4646
4565
|
for (const field of fields) {
|
|
4647
4566
|
if (field.name === key) {
|
|
4648
4567
|
fields = field.fields || [];
|
|
@@ -5220,11 +5139,9 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
5220
5139
|
return Boolean(dataSource?.methods.find((method) => method.name === name));
|
|
5221
5140
|
});
|
|
5222
5141
|
const getParamItemsConfig = ([dataSourceId, methodName] = ["", ""]) => {
|
|
5223
|
-
if (!dataSourceId)
|
|
5224
|
-
return [];
|
|
5142
|
+
if (!dataSourceId) return [];
|
|
5225
5143
|
const paramStatements = dataSources.value?.find((item) => item.id === dataSourceId)?.methods?.find((item) => item.name === methodName)?.params;
|
|
5226
|
-
if (!paramStatements)
|
|
5227
|
-
return [];
|
|
5144
|
+
if (!paramStatements) return [];
|
|
5228
5145
|
return paramStatements.map((paramState) => ({
|
|
5229
5146
|
text: paramState.name,
|
|
5230
5147
|
...paramState
|
|
@@ -5269,8 +5186,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
5269
5186
|
const editCodeHandler = () => {
|
|
5270
5187
|
const [id] = props.model[props.name];
|
|
5271
5188
|
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5272
|
-
if (!dataSource)
|
|
5273
|
-
return;
|
|
5189
|
+
if (!dataSource) return;
|
|
5274
5190
|
eventBus?.emit("edit-data-source", id);
|
|
5275
5191
|
};
|
|
5276
5192
|
return (_ctx, _cache) => {
|
|
@@ -5381,15 +5297,13 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5381
5297
|
defaultValue: "{}",
|
|
5382
5298
|
height: "400px",
|
|
5383
5299
|
onChange: (formState, v) => {
|
|
5384
|
-
if (typeof v !== "string")
|
|
5385
|
-
return v;
|
|
5300
|
+
if (typeof v !== "string") return v;
|
|
5386
5301
|
return JSON.parse(v);
|
|
5387
5302
|
},
|
|
5388
5303
|
rules: [
|
|
5389
5304
|
{
|
|
5390
5305
|
validator: ({ value, callback }) => {
|
|
5391
|
-
if (typeof value !== "string")
|
|
5392
|
-
return callback();
|
|
5306
|
+
if (typeof value !== "string") return callback();
|
|
5393
5307
|
try {
|
|
5394
5308
|
JSON.parse(value);
|
|
5395
5309
|
callback();
|
|
@@ -5617,12 +5531,10 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
5617
5531
|
};
|
|
5618
5532
|
const editHandler = () => {
|
|
5619
5533
|
const value = props.model[props.name];
|
|
5620
|
-
if (!value)
|
|
5621
|
-
return;
|
|
5534
|
+
if (!value) return;
|
|
5622
5535
|
const id = typeof value === "string" ? value : value.dataSourceId;
|
|
5623
5536
|
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5624
|
-
if (!dataSource)
|
|
5625
|
-
return;
|
|
5537
|
+
if (!dataSource) return;
|
|
5626
5538
|
eventBus?.emit("edit-data-source", id);
|
|
5627
5539
|
};
|
|
5628
5540
|
return (_ctx, _cache) => {
|
|
@@ -5686,20 +5598,46 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5686
5598
|
const eventsService = services?.eventsService;
|
|
5687
5599
|
const codeBlockService = services?.codeBlockService;
|
|
5688
5600
|
const eventNameConfig = computed(() => {
|
|
5689
|
-
const fieldType = props.config.src === "component" ? "select" : "cascader";
|
|
5690
5601
|
const defaultEventNameConfig = {
|
|
5691
5602
|
name: "name",
|
|
5692
5603
|
text: "事件",
|
|
5693
|
-
type:
|
|
5604
|
+
type: (mForm, { formValue }) => {
|
|
5605
|
+
if (props.config.src !== "component" || formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
|
|
5606
|
+
return "cascader";
|
|
5607
|
+
}
|
|
5608
|
+
return "select";
|
|
5609
|
+
},
|
|
5694
5610
|
labelWidth: "40px",
|
|
5695
|
-
checkStrictly:
|
|
5611
|
+
checkStrictly: () => props.config.src !== "component",
|
|
5696
5612
|
valueSeparator: ".",
|
|
5697
5613
|
options: (mForm, { formValue }) => {
|
|
5698
5614
|
let events = [];
|
|
5699
|
-
if (!eventsService || !dataSourceService)
|
|
5700
|
-
return events;
|
|
5615
|
+
if (!eventsService || !dataSourceService) return events;
|
|
5701
5616
|
if (props.config.src === "component") {
|
|
5702
5617
|
events = eventsService.getEvent(formValue.type);
|
|
5618
|
+
if (formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
|
|
5619
|
+
const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
|
|
5620
|
+
if (pageFragment) {
|
|
5621
|
+
events = [
|
|
5622
|
+
{
|
|
5623
|
+
label: pageFragment.name || "迭代器容器",
|
|
5624
|
+
value: pageFragment.id,
|
|
5625
|
+
children: events
|
|
5626
|
+
}
|
|
5627
|
+
];
|
|
5628
|
+
pageFragment.items.forEach((node) => {
|
|
5629
|
+
traverseNode(node, (node2) => {
|
|
5630
|
+
const nodeEvents = node2.type && eventsService.getEvent(node2.type) || [];
|
|
5631
|
+
events.push({
|
|
5632
|
+
label: `${node2.name}_${node2.id}`,
|
|
5633
|
+
value: `${node2.id}`,
|
|
5634
|
+
children: nodeEvents
|
|
5635
|
+
});
|
|
5636
|
+
});
|
|
5637
|
+
});
|
|
5638
|
+
return events;
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5703
5641
|
return events.map((option) => ({
|
|
5704
5642
|
text: option.label,
|
|
5705
5643
|
value: option.value
|
|
@@ -5758,7 +5696,11 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5758
5696
|
name: "to",
|
|
5759
5697
|
text: "联动组件",
|
|
5760
5698
|
type: "ui-select",
|
|
5761
|
-
display: (mForm, { model }) => model.actionType === ActionType.COMP
|
|
5699
|
+
display: (mForm, { model }) => model.actionType === ActionType.COMP,
|
|
5700
|
+
onChange: (MForm, v, { model }) => {
|
|
5701
|
+
model.method = "";
|
|
5702
|
+
return v;
|
|
5703
|
+
}
|
|
5762
5704
|
};
|
|
5763
5705
|
return { ...defaultTargetCompConfig, ...props.config.targetCompConfig };
|
|
5764
5706
|
});
|
|
@@ -5766,15 +5708,42 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5766
5708
|
const defaultCompActionConfig = {
|
|
5767
5709
|
name: "method",
|
|
5768
5710
|
text: "动作",
|
|
5769
|
-
type:
|
|
5711
|
+
type: (mForm, { model }) => {
|
|
5712
|
+
const to = editorService?.getNodeById(model.to);
|
|
5713
|
+
if (to && to.type === "page-fragment-container" && to.pageFragmentId) {
|
|
5714
|
+
return "cascader";
|
|
5715
|
+
}
|
|
5716
|
+
return "select";
|
|
5717
|
+
},
|
|
5718
|
+
checkStrictly: () => props.config.src !== "component",
|
|
5770
5719
|
display: (mForm, { model }) => model.actionType === ActionType.COMP,
|
|
5771
5720
|
options: (mForm, { model }) => {
|
|
5772
5721
|
const node = editorService?.getNodeById(model.to);
|
|
5773
|
-
if (!node?.type)
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5722
|
+
if (!node?.type) return [];
|
|
5723
|
+
let methods = [];
|
|
5724
|
+
methods = eventsService?.getMethod(node.type) || [];
|
|
5725
|
+
if (node.type === "page-fragment-container" && node.pageFragmentId) {
|
|
5726
|
+
const pageFragment = editorService?.get("root")?.items?.find((page) => page.id === node.pageFragmentId);
|
|
5727
|
+
if (pageFragment) {
|
|
5728
|
+
methods = [];
|
|
5729
|
+
pageFragment.items.forEach((node2) => {
|
|
5730
|
+
traverseNode(node2, (node3) => {
|
|
5731
|
+
const nodeMethods = node3.type && eventsService?.getMethod(node3.type) || [];
|
|
5732
|
+
if (nodeMethods.length) {
|
|
5733
|
+
methods.push({
|
|
5734
|
+
label: `${node3.name}_${node3.id}`,
|
|
5735
|
+
value: `${node3.id}`,
|
|
5736
|
+
children: nodeMethods
|
|
5737
|
+
});
|
|
5738
|
+
}
|
|
5739
|
+
});
|
|
5740
|
+
});
|
|
5741
|
+
return methods;
|
|
5742
|
+
}
|
|
5743
|
+
}
|
|
5744
|
+
return methods.map((method) => ({
|
|
5745
|
+
text: method.label,
|
|
5746
|
+
value: method.value
|
|
5778
5747
|
}));
|
|
5779
5748
|
}
|
|
5780
5749
|
};
|
|
@@ -5824,8 +5793,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5824
5793
|
type: compActionConfig.value.type,
|
|
5825
5794
|
options: (mForm, { model }) => {
|
|
5826
5795
|
const node = editorService?.getNodeById(model.to);
|
|
5827
|
-
if (!node?.type)
|
|
5828
|
-
return [];
|
|
5796
|
+
if (!node?.type) return [];
|
|
5829
5797
|
return eventsService?.getMethod(node.type).map((option) => ({
|
|
5830
5798
|
text: option.label,
|
|
5831
5799
|
value: option.value
|
|
@@ -5854,8 +5822,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5854
5822
|
]
|
|
5855
5823
|
}));
|
|
5856
5824
|
const isOldVersion = computed(() => {
|
|
5857
|
-
if (props.model[props.name].length === 0)
|
|
5858
|
-
return false;
|
|
5825
|
+
if (props.model[props.name].length === 0) return false;
|
|
5859
5826
|
return !has(props.model[props.name][0], "actions");
|
|
5860
5827
|
});
|
|
5861
5828
|
const addEvent = () => {
|
|
@@ -5870,8 +5837,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5870
5837
|
onChangeHandler();
|
|
5871
5838
|
};
|
|
5872
5839
|
const removeEvent = (index) => {
|
|
5873
|
-
if (!props.name)
|
|
5874
|
-
return;
|
|
5840
|
+
if (!props.name) return;
|
|
5875
5841
|
props.model[props.name].splice(index, 1);
|
|
5876
5842
|
onChangeHandler();
|
|
5877
5843
|
};
|
|
@@ -6196,8 +6162,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
6196
6162
|
const val = computed(() => props.model[props.name]);
|
|
6197
6163
|
const uiSelectMode = ref(false);
|
|
6198
6164
|
const cancelHandler = () => {
|
|
6199
|
-
if (!services?.uiService)
|
|
6200
|
-
return;
|
|
6165
|
+
if (!services?.uiService) return;
|
|
6201
6166
|
services.uiService.set("uiSelectMode", false);
|
|
6202
6167
|
uiSelectMode.value = false;
|
|
6203
6168
|
globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
|
|
@@ -6217,8 +6182,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
6217
6182
|
return config?.name || "";
|
|
6218
6183
|
});
|
|
6219
6184
|
const startSelect = () => {
|
|
6220
|
-
if (!services?.uiService)
|
|
6221
|
-
return;
|
|
6185
|
+
if (!services?.uiService) return;
|
|
6222
6186
|
services.uiService.set("uiSelectMode", true);
|
|
6223
6187
|
uiSelectMode.value = true;
|
|
6224
6188
|
globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
|
|
@@ -6335,14 +6299,12 @@ const useGetSo = (target, emit) => {
|
|
|
6335
6299
|
let getso;
|
|
6336
6300
|
const isDraging = ref(false);
|
|
6337
6301
|
onMounted(() => {
|
|
6338
|
-
if (!target.value)
|
|
6339
|
-
return;
|
|
6302
|
+
if (!target.value) return;
|
|
6340
6303
|
getso = new Gesto(target.value, {
|
|
6341
6304
|
container: window,
|
|
6342
6305
|
pinchOutside: true
|
|
6343
6306
|
}).on("drag", (e) => {
|
|
6344
|
-
if (!target.value)
|
|
6345
|
-
return;
|
|
6307
|
+
if (!target.value) return;
|
|
6346
6308
|
emit("change", e);
|
|
6347
6309
|
}).on("dragStart", () => {
|
|
6348
6310
|
isDraging.value = true;
|
|
@@ -6458,13 +6420,11 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
6458
6420
|
});
|
|
6459
6421
|
} else {
|
|
6460
6422
|
watchEffect(() => {
|
|
6461
|
-
if (typeof props.width === "number")
|
|
6462
|
-
widthChange(props.width);
|
|
6423
|
+
if (typeof props.width === "number") widthChange(props.width);
|
|
6463
6424
|
});
|
|
6464
6425
|
}
|
|
6465
6426
|
const changeLeft = ({ deltaX }) => {
|
|
6466
|
-
if (typeof props.left === "undefined")
|
|
6467
|
-
return;
|
|
6427
|
+
if (typeof props.left === "undefined") return;
|
|
6468
6428
|
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
6469
6429
|
emit("update:left", left);
|
|
6470
6430
|
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
@@ -6479,8 +6439,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
6479
6439
|
});
|
|
6480
6440
|
};
|
|
6481
6441
|
const changeRight = ({ deltaX }) => {
|
|
6482
|
-
if (typeof props.right === "undefined")
|
|
6483
|
-
return;
|
|
6442
|
+
if (typeof props.right === "undefined") return;
|
|
6484
6443
|
let right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
6485
6444
|
emit("update:right", right);
|
|
6486
6445
|
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
@@ -6565,28 +6524,23 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6565
6524
|
const props = __props;
|
|
6566
6525
|
const services = inject("services");
|
|
6567
6526
|
const disabled = computed(() => {
|
|
6568
|
-
if (typeof props.data === "string")
|
|
6569
|
-
|
|
6570
|
-
if (props.data.type === "component")
|
|
6571
|
-
return false;
|
|
6527
|
+
if (typeof props.data === "string") return false;
|
|
6528
|
+
if (props.data.type === "component") return false;
|
|
6572
6529
|
if (typeof props.data.disabled === "function") {
|
|
6573
6530
|
return props.data.disabled(services);
|
|
6574
6531
|
}
|
|
6575
6532
|
return props.data.disabled;
|
|
6576
6533
|
});
|
|
6577
6534
|
const display = computed(() => {
|
|
6578
|
-
if (!props.data)
|
|
6579
|
-
|
|
6580
|
-
if (typeof props.data === "string")
|
|
6581
|
-
return true;
|
|
6535
|
+
if (!props.data) return false;
|
|
6536
|
+
if (typeof props.data === "string") return true;
|
|
6582
6537
|
if (typeof props.data.display === "function") {
|
|
6583
6538
|
return props.data.display(services);
|
|
6584
6539
|
}
|
|
6585
6540
|
return props.data.display ?? true;
|
|
6586
6541
|
});
|
|
6587
6542
|
const buttonHandler = (item, event) => {
|
|
6588
|
-
if (disabled.value)
|
|
6589
|
-
return;
|
|
6543
|
+
if (disabled.value) return;
|
|
6590
6544
|
if (typeof item.handler === "function" && services) {
|
|
6591
6545
|
item.handler?.(services, event);
|
|
6592
6546
|
}
|
|
@@ -6597,22 +6551,19 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6597
6551
|
}
|
|
6598
6552
|
};
|
|
6599
6553
|
const clickHandler = (item, event) => {
|
|
6600
|
-
if (props.eventType !== "click")
|
|
6601
|
-
return;
|
|
6554
|
+
if (props.eventType !== "click") return;
|
|
6602
6555
|
if (item.type === "button") {
|
|
6603
6556
|
buttonHandler(item, event);
|
|
6604
6557
|
}
|
|
6605
6558
|
};
|
|
6606
6559
|
const mousedownHandler = (item, event) => {
|
|
6607
|
-
if (props.eventType !== "mousedown")
|
|
6608
|
-
return;
|
|
6560
|
+
if (props.eventType !== "mousedown") return;
|
|
6609
6561
|
if (item.type === "button") {
|
|
6610
6562
|
buttonHandler(item, event);
|
|
6611
6563
|
}
|
|
6612
6564
|
};
|
|
6613
6565
|
const mouseupHandler = (item, event) => {
|
|
6614
|
-
if (props.eventType !== "mouseup")
|
|
6615
|
-
return;
|
|
6566
|
+
if (props.eventType !== "mouseup") return;
|
|
6616
6567
|
if (item.type === "button") {
|
|
6617
6568
|
buttonHandler(item, event);
|
|
6618
6569
|
}
|
|
@@ -6729,11 +6680,9 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
6729
6680
|
const editorService = services?.editorService;
|
|
6730
6681
|
const showAddPageButton = computed(() => uiService?.get("showAddPageButton"));
|
|
6731
6682
|
const addPage = () => {
|
|
6732
|
-
if (!editorService)
|
|
6733
|
-
return;
|
|
6683
|
+
if (!editorService) return;
|
|
6734
6684
|
const root = toRaw(editorService.get("root"));
|
|
6735
|
-
if (!root)
|
|
6736
|
-
throw new Error("root 不能为空");
|
|
6685
|
+
if (!root) throw new Error("root 不能为空");
|
|
6737
6686
|
const pageConfig = {
|
|
6738
6687
|
type: props.type,
|
|
6739
6688
|
name: generatePageNameByApp(root, props.type),
|
|
@@ -6791,8 +6740,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
6791
6740
|
});
|
|
6792
6741
|
let translateLeft = 0;
|
|
6793
6742
|
const scroll = (type) => {
|
|
6794
|
-
if (!itemsContainer.value)
|
|
6795
|
-
return;
|
|
6743
|
+
if (!itemsContainer.value) return;
|
|
6796
6744
|
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
6797
6745
|
if (type === "left") {
|
|
6798
6746
|
translateLeft += 100;
|
|
@@ -7097,11 +7045,9 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
7097
7045
|
const services = inject("services");
|
|
7098
7046
|
const clickHandler = (type) => {
|
|
7099
7047
|
const { editorService } = services || {};
|
|
7100
|
-
if (!editorService)
|
|
7101
|
-
return;
|
|
7048
|
+
if (!editorService) return;
|
|
7102
7049
|
const root = toRaw(editorService.get("root"));
|
|
7103
|
-
if (!root)
|
|
7104
|
-
throw new Error("root 不能为空");
|
|
7050
|
+
if (!root) throw new Error("root 不能为空");
|
|
7105
7051
|
editorService.add({
|
|
7106
7052
|
type,
|
|
7107
7053
|
name: generatePageNameByApp(root, type),
|
|
@@ -7573,6 +7519,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
7573
7519
|
}, 8, ["type"])) : createCommentVNode("", true),
|
|
7574
7520
|
showSrc.value ? (openBlock(), createBlock(_sfc_main$T, {
|
|
7575
7521
|
key: 1,
|
|
7522
|
+
class: "m-editor-props-panel-src-code",
|
|
7576
7523
|
height: `${unref(editorContentHeight)}px`,
|
|
7577
7524
|
"init-values": values.value,
|
|
7578
7525
|
options: unref(codeOptions),
|
|
@@ -7628,8 +7575,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
7628
7575
|
|
|
7629
7576
|
const updateStatus = (nodeStatusMap, id, status) => {
|
|
7630
7577
|
const nodeStatus = nodeStatusMap.get(id);
|
|
7631
|
-
if (!nodeStatus)
|
|
7632
|
-
return;
|
|
7578
|
+
if (!nodeStatus) return;
|
|
7633
7579
|
getKeys(status).forEach((key) => {
|
|
7634
7580
|
if (nodeStatus[key] !== void 0 && status[key] !== void 0) {
|
|
7635
7581
|
nodeStatus[key] = Boolean(status[key]);
|
|
@@ -7670,7 +7616,9 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
7670
7616
|
const selected = computed(() => nodeStatus.value.selected);
|
|
7671
7617
|
const visible = computed(() => nodeStatus.value.visible);
|
|
7672
7618
|
const draggable = computed(() => nodeStatus.value.draggable);
|
|
7673
|
-
const hasChildren = computed(
|
|
7619
|
+
const hasChildren = computed(
|
|
7620
|
+
() => Array.isArray(props.data.items) && props.data.items.some((item) => props.nodeStatusMap.get(item.id)?.visible)
|
|
7621
|
+
);
|
|
7674
7622
|
const handleDragStart = (event) => {
|
|
7675
7623
|
treeEmit?.("node-dragstart", event, props.data);
|
|
7676
7624
|
};
|
|
@@ -7823,12 +7771,10 @@ const useFilter = (nodeData, nodeStatusMap, filterNodeMethod) => {
|
|
|
7823
7771
|
return string.some((v) => filterNodeMethod(v, data));
|
|
7824
7772
|
};
|
|
7825
7773
|
const filter = (text) => {
|
|
7826
|
-
if (!nodeData.value.length)
|
|
7827
|
-
return;
|
|
7774
|
+
if (!nodeData.value.length) return;
|
|
7828
7775
|
nodeData.value.forEach((node) => {
|
|
7829
7776
|
traverseNode(node, (node2, parents) => {
|
|
7830
|
-
if (!nodeStatusMap.value)
|
|
7831
|
-
return;
|
|
7777
|
+
if (!nodeStatusMap.value) return;
|
|
7832
7778
|
const visible = filterIsMatch(text, node2);
|
|
7833
7779
|
if (visible && parents.length) {
|
|
7834
7780
|
parents.forEach((parent) => {
|
|
@@ -7901,24 +7847,38 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
7901
7847
|
const services = inject("services");
|
|
7902
7848
|
const { codeBlockService, depService, editorService } = services || {};
|
|
7903
7849
|
const codeList = computed(
|
|
7904
|
-
() => Object.
|
|
7905
|
-
const
|
|
7906
|
-
|
|
7850
|
+
() => Object.entries(codeBlockService?.getCodeDsl() || {}).map(([codeId, code]) => {
|
|
7851
|
+
const target = depService?.getTarget(codeId, DepTargetType.CODE_BLOCK);
|
|
7852
|
+
const pageList = editorService?.get("root")?.items.map((page) => ({
|
|
7853
|
+
name: page.devconfig?.tabName || page.name,
|
|
7907
7854
|
type: "node",
|
|
7908
|
-
id: `${
|
|
7909
|
-
key: id,
|
|
7910
|
-
items:
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7855
|
+
id: `${codeId}_${page.id}`,
|
|
7856
|
+
key: page.id,
|
|
7857
|
+
items: []
|
|
7858
|
+
})) || [];
|
|
7859
|
+
if (target) {
|
|
7860
|
+
Object.entries(target.deps).forEach(([id, dep]) => {
|
|
7861
|
+
const page = pageList.find((page2) => page2.key === dep.data?.pageId);
|
|
7862
|
+
page?.items?.push({
|
|
7863
|
+
name: dep.name,
|
|
7864
|
+
type: "node",
|
|
7865
|
+
id: `${page.id}_${id}`,
|
|
7866
|
+
key: id,
|
|
7867
|
+
items: dep.keys.map((key) => {
|
|
7868
|
+
const data2 = { name: `${key}`, id: `${target.id}_${id}_${key}`, type: "key" };
|
|
7869
|
+
return data2;
|
|
7870
|
+
})
|
|
7871
|
+
});
|
|
7872
|
+
});
|
|
7873
|
+
}
|
|
7915
7874
|
const data = {
|
|
7916
|
-
id:
|
|
7917
|
-
key:
|
|
7918
|
-
name:
|
|
7875
|
+
id: codeId,
|
|
7876
|
+
key: codeId,
|
|
7877
|
+
name: code.name,
|
|
7919
7878
|
type: "code",
|
|
7920
|
-
codeBlockContent: codeBlockService?.getCodeContentById(
|
|
7921
|
-
|
|
7879
|
+
codeBlockContent: codeBlockService?.getCodeContentById(codeId),
|
|
7880
|
+
// 只有一个页面不显示页面分类
|
|
7881
|
+
items: pageList.length > 1 ? pageList.filter((page) => page.items?.length) : pageList[0]?.items || []
|
|
7922
7882
|
};
|
|
7923
7883
|
return data;
|
|
7924
7884
|
})
|
|
@@ -8104,8 +8064,7 @@ const useDataSourceEdit = (dataSourceService) => {
|
|
|
8104
8064
|
const dataSourceValues = ref({});
|
|
8105
8065
|
const editable = computed(() => dataSourceService?.get("editable") ?? true);
|
|
8106
8066
|
const editHandler = (id) => {
|
|
8107
|
-
if (!editDialog.value)
|
|
8108
|
-
return;
|
|
8067
|
+
if (!editDialog.value) return;
|
|
8109
8068
|
dataSourceValues.value = {
|
|
8110
8069
|
...dataSourceService?.getDataSourceById(id)
|
|
8111
8070
|
};
|
|
@@ -8233,13 +8192,14 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
8233
8192
|
key: id,
|
|
8234
8193
|
items: getKeyTreeConfig(dep, type, `${parentKey}_${id}`)
|
|
8235
8194
|
});
|
|
8236
|
-
const mergeChildren = (dsId,
|
|
8195
|
+
const mergeChildren = (dsId, pageItems, deps, type) => {
|
|
8237
8196
|
Object.entries(deps).forEach(([id, dep]) => {
|
|
8238
|
-
const
|
|
8197
|
+
const page = pageItems.find((page2) => page2.key === dep.data?.pageId);
|
|
8198
|
+
const nodeItem = page?.items.find((item) => item.key === id);
|
|
8239
8199
|
if (nodeItem) {
|
|
8240
8200
|
nodeItem.items = nodeItem.items.concat(getKeyTreeConfig(dep, type, nodeItem.key));
|
|
8241
8201
|
} else {
|
|
8242
|
-
items.push(getNodeTreeConfig(id, dep, type,
|
|
8202
|
+
page?.items.push(getNodeTreeConfig(id, dep, type, page.id));
|
|
8243
8203
|
}
|
|
8244
8204
|
});
|
|
8245
8205
|
};
|
|
@@ -8248,7 +8208,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
8248
8208
|
const dsDeps = dsDep.value[ds.id]?.deps || {};
|
|
8249
8209
|
const dsMethodDeps = dsMethodDep.value[ds.id]?.deps || {};
|
|
8250
8210
|
const dsCondDeps = dsCondDep.value[ds.id]?.deps || {};
|
|
8251
|
-
const items =
|
|
8211
|
+
const items = editorService?.get("root")?.items.map((page) => ({
|
|
8212
|
+
name: page.devconfig?.tabName || page.name,
|
|
8213
|
+
type: "node",
|
|
8214
|
+
id: `${ds.id}_${page.id}`,
|
|
8215
|
+
key: page.id,
|
|
8216
|
+
items: []
|
|
8217
|
+
})) || [];
|
|
8252
8218
|
mergeChildren(ds.id, items, dsDeps);
|
|
8253
8219
|
mergeChildren(ds.id, items, dsMethodDeps, "method");
|
|
8254
8220
|
mergeChildren(ds.id, items, dsCondDeps, "cond");
|
|
@@ -8257,7 +8223,8 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
8257
8223
|
key: ds.id,
|
|
8258
8224
|
name: ds.title,
|
|
8259
8225
|
type: "ds",
|
|
8260
|
-
|
|
8226
|
+
// 只有一个页面不显示页面分类
|
|
8227
|
+
items: items.length > 1 ? items.filter((page) => page.items.length) : items[0]?.items || []
|
|
8261
8228
|
};
|
|
8262
8229
|
})
|
|
8263
8230
|
);
|
|
@@ -8365,8 +8332,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8365
8332
|
].concat(dataSourceService?.get("datasourceTypeList") ?? [])
|
|
8366
8333
|
);
|
|
8367
8334
|
const addHandler = (type) => {
|
|
8368
|
-
if (!editDialog.value)
|
|
8369
|
-
return;
|
|
8335
|
+
if (!editDialog.value) return;
|
|
8370
8336
|
const datasourceType = datasourceTypeList.value.find((item) => item.type === type);
|
|
8371
8337
|
dataSourceValues.value = mergeWith(
|
|
8372
8338
|
{ type, title: datasourceType?.text },
|
|
@@ -8483,20 +8449,17 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
8483
8449
|
}));
|
|
8484
8450
|
const contains = (el) => menu.value?.contains(el) || subMenu.value?.contains(el);
|
|
8485
8451
|
const hide = () => {
|
|
8486
|
-
if (!visible.value)
|
|
8487
|
-
return;
|
|
8452
|
+
if (!visible.value) return;
|
|
8488
8453
|
visible.value = false;
|
|
8489
8454
|
subMenu.value?.hide();
|
|
8490
8455
|
emit("hide");
|
|
8491
8456
|
};
|
|
8492
8457
|
const clickHandler = () => {
|
|
8493
|
-
if (!props.autoHide)
|
|
8494
|
-
return;
|
|
8458
|
+
if (!props.autoHide) return;
|
|
8495
8459
|
hide();
|
|
8496
8460
|
};
|
|
8497
8461
|
const outsideClickHideHandler = (e) => {
|
|
8498
|
-
if (!props.autoHide)
|
|
8499
|
-
return;
|
|
8462
|
+
if (!props.autoHide) return;
|
|
8500
8463
|
const target = e.target;
|
|
8501
8464
|
if (!visible.value || !target) {
|
|
8502
8465
|
return;
|
|
@@ -8553,13 +8516,11 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
8553
8516
|
emit("mouseenter");
|
|
8554
8517
|
};
|
|
8555
8518
|
onMounted(() => {
|
|
8556
|
-
if (props.isSubMenu)
|
|
8557
|
-
return;
|
|
8519
|
+
if (props.isSubMenu) return;
|
|
8558
8520
|
globalThis.addEventListener("mousedown", outsideClickHideHandler, true);
|
|
8559
8521
|
});
|
|
8560
8522
|
onBeforeUnmount(() => {
|
|
8561
|
-
if (props.isSubMenu)
|
|
8562
|
-
return;
|
|
8523
|
+
if (props.isSubMenu) return;
|
|
8563
8524
|
globalThis.removeEventListener("mousedown", outsideClickHideHandler, true);
|
|
8564
8525
|
});
|
|
8565
8526
|
__expose({
|
|
@@ -8680,8 +8641,7 @@ const usePasteMenu = (menu) => ({
|
|
|
8680
8641
|
display: (services) => !!services?.storageService?.getItem(COPY_STORAGE_KEY),
|
|
8681
8642
|
handler: (services) => {
|
|
8682
8643
|
const nodes = services?.editorService?.get("nodes");
|
|
8683
|
-
if (!nodes || nodes.length === 0)
|
|
8684
|
-
return;
|
|
8644
|
+
if (!nodes || nodes.length === 0) return;
|
|
8685
8645
|
if (menu?.value?.$el) {
|
|
8686
8646
|
const stage = services?.editorService?.get("stage");
|
|
8687
8647
|
const rect = menu.value.$el.getBoundingClientRect();
|
|
@@ -8695,12 +8655,10 @@ const usePasteMenu = (menu) => ({
|
|
|
8695
8655
|
}
|
|
8696
8656
|
});
|
|
8697
8657
|
const moveTo = (id, services) => {
|
|
8698
|
-
if (!services?.editorService)
|
|
8699
|
-
return;
|
|
8658
|
+
if (!services?.editorService) return;
|
|
8700
8659
|
const nodes = services.editorService.get("nodes") || [];
|
|
8701
8660
|
const parent = services.editorService.getNodeById(id);
|
|
8702
|
-
if (!parent)
|
|
8703
|
-
return;
|
|
8661
|
+
if (!parent) return;
|
|
8704
8662
|
services?.editorService.add(nodes, parent);
|
|
8705
8663
|
services?.editorService.remove(nodes);
|
|
8706
8664
|
};
|
|
@@ -8840,8 +8798,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
8840
8798
|
const services = inject("services");
|
|
8841
8799
|
const editorService = services?.editorService;
|
|
8842
8800
|
const setNodeVisible = (visible) => {
|
|
8843
|
-
if (!editorService)
|
|
8844
|
-
return;
|
|
8801
|
+
if (!editorService) return;
|
|
8845
8802
|
editorService.update({
|
|
8846
8803
|
id: props.data.id,
|
|
8847
8804
|
visible
|
|
@@ -8899,17 +8856,19 @@ const useClick = (services, isCtrlKeyDown, nodeStatusMap) => {
|
|
|
8899
8856
|
services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
|
|
8900
8857
|
};
|
|
8901
8858
|
const throttleTime = 300;
|
|
8902
|
-
const highlightHandler = throttle(
|
|
8903
|
-
|
|
8904
|
-
|
|
8859
|
+
const highlightHandler = throttle(
|
|
8860
|
+
(event, data) => {
|
|
8861
|
+
highlight(data);
|
|
8862
|
+
},
|
|
8863
|
+
throttleTime
|
|
8864
|
+
);
|
|
8905
8865
|
const highlight = (data) => {
|
|
8906
8866
|
services?.editorService?.highlight(data);
|
|
8907
8867
|
services?.editorService?.get("stage")?.highlight(data.id);
|
|
8908
8868
|
services?.stageOverlayService?.get("stage")?.highlight(data.id);
|
|
8909
8869
|
};
|
|
8910
8870
|
const nodeClickHandler = (event, data) => {
|
|
8911
|
-
if (!nodeStatusMap?.value)
|
|
8912
|
-
return;
|
|
8871
|
+
if (!nodeStatusMap?.value) return;
|
|
8913
8872
|
if (services?.uiService.get("uiSelectMode")) {
|
|
8914
8873
|
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: data }));
|
|
8915
8874
|
return;
|
|
@@ -8953,8 +8912,7 @@ const getNodeEl = (el) => {
|
|
|
8953
8912
|
}
|
|
8954
8913
|
};
|
|
8955
8914
|
const removeStatusClass = (el) => {
|
|
8956
|
-
if (!el)
|
|
8957
|
-
return;
|
|
8915
|
+
if (!el) return;
|
|
8958
8916
|
["drag-before", "drag-after", "drag-inner"].forEach((className) => {
|
|
8959
8917
|
el.querySelectorAll(`.${className}`).forEach((el2) => {
|
|
8960
8918
|
removeClassName(el2, className);
|
|
@@ -8963,11 +8921,9 @@ const removeStatusClass = (el) => {
|
|
|
8963
8921
|
};
|
|
8964
8922
|
const useDrag = (services) => {
|
|
8965
8923
|
const handleDragStart = (event) => {
|
|
8966
|
-
if (!event.dataTransfer || !event.target || !event.currentTarget)
|
|
8967
|
-
return;
|
|
8924
|
+
if (!event.dataTransfer || !event.target || !event.currentTarget) return;
|
|
8968
8925
|
const targetEl = getNodeEl(event.target);
|
|
8969
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
8970
|
-
return;
|
|
8926
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
8971
8927
|
event.dataTransfer.effectAllowed = "move";
|
|
8972
8928
|
try {
|
|
8973
8929
|
event.dataTransfer.setData(
|
|
@@ -8980,14 +8936,11 @@ const useDrag = (services) => {
|
|
|
8980
8936
|
}
|
|
8981
8937
|
};
|
|
8982
8938
|
const handleDragOver = (event) => {
|
|
8983
|
-
if (!event.target)
|
|
8984
|
-
return;
|
|
8939
|
+
if (!event.target) return;
|
|
8985
8940
|
const targetEl = getNodeEl(event.target);
|
|
8986
|
-
if (!targetEl?.draggable)
|
|
8987
|
-
return;
|
|
8941
|
+
if (!targetEl?.draggable) return;
|
|
8988
8942
|
const labelEl = targetEl.children[0];
|
|
8989
|
-
if (!labelEl)
|
|
8990
|
-
return;
|
|
8943
|
+
if (!labelEl) return;
|
|
8991
8944
|
const { top: targetTop, height: targetHeight } = labelEl.getBoundingClientRect();
|
|
8992
8945
|
const distance = event.clientY - targetTop;
|
|
8993
8946
|
const isContainer = targetEl.dataset.isContainer === "true";
|
|
@@ -9012,20 +8965,16 @@ const useDrag = (services) => {
|
|
|
9012
8965
|
event.preventDefault();
|
|
9013
8966
|
};
|
|
9014
8967
|
const handleDragLeave = (event) => {
|
|
9015
|
-
if (!event.target || !event.currentTarget)
|
|
9016
|
-
return;
|
|
8968
|
+
if (!event.target || !event.currentTarget) return;
|
|
9017
8969
|
const targetEl = getNodeEl(event.target);
|
|
9018
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
9019
|
-
return;
|
|
8970
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
9020
8971
|
const labelEl = targetEl.children[0];
|
|
9021
8972
|
removeClassName(labelEl, "drag-before", "drag-after", "drag-inner");
|
|
9022
8973
|
};
|
|
9023
8974
|
const handleDragEnd = (event, node) => {
|
|
9024
|
-
if (!event.target || !event.currentTarget)
|
|
9025
|
-
return;
|
|
8975
|
+
if (!event.target || !event.currentTarget) return;
|
|
9026
8976
|
const targetEl = getNodeEl(event.target);
|
|
9027
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
9028
|
-
return;
|
|
8977
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
9029
8978
|
removeStatusClass(dragState.container);
|
|
9030
8979
|
if (node && dragState.dragOverNodeId && dragState.dropType && services) {
|
|
9031
8980
|
if (dragState.dragOverNodeId === node.id) {
|
|
@@ -9034,8 +8983,7 @@ const useDrag = (services) => {
|
|
|
9034
8983
|
const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
|
|
9035
8984
|
const targetNode = targetInfo.node;
|
|
9036
8985
|
let targetParent = targetInfo.parent;
|
|
9037
|
-
if (!targetParent || !targetNode)
|
|
9038
|
-
return;
|
|
8986
|
+
if (!targetParent || !targetNode) return;
|
|
9039
8987
|
let targetIndex = -1;
|
|
9040
8988
|
if (Array.isArray(targetNode.items) && dragState.dropType === "inner") {
|
|
9041
8989
|
targetIndex = targetNode.items.length;
|
|
@@ -9046,7 +8994,12 @@ const useDrag = (services) => {
|
|
|
9046
8994
|
if (dragState.dropType === "after") {
|
|
9047
8995
|
targetIndex += 1;
|
|
9048
8996
|
}
|
|
9049
|
-
services
|
|
8997
|
+
const selectedNodes = services.editorService.get("nodes");
|
|
8998
|
+
if (selectedNodes.find((n) => `${n.id}` === `${node.id}`)) {
|
|
8999
|
+
services.editorService.dragTo(selectedNodes, targetParent, targetIndex);
|
|
9000
|
+
} else {
|
|
9001
|
+
services.editorService.dragTo([node], targetParent, targetIndex);
|
|
9002
|
+
}
|
|
9050
9003
|
}
|
|
9051
9004
|
dragState.dragOverNodeId = "";
|
|
9052
9005
|
dragState.dropType = "";
|
|
@@ -9267,8 +9220,7 @@ const useNodeStatus = (services) => {
|
|
|
9267
9220
|
watch(
|
|
9268
9221
|
nodes,
|
|
9269
9222
|
(nodes2) => {
|
|
9270
|
-
if (!nodeStatusMap.value)
|
|
9271
|
-
return;
|
|
9223
|
+
if (!nodeStatusMap.value) return;
|
|
9272
9224
|
for (const [id, status] of nodeStatusMap.value.entries()) {
|
|
9273
9225
|
status.selected = nodes2.some((node) => node.id === id);
|
|
9274
9226
|
if (status.selected) {
|
|
@@ -9286,8 +9238,7 @@ const useNodeStatus = (services) => {
|
|
|
9286
9238
|
);
|
|
9287
9239
|
services?.editorService.on("add", (newNodes) => {
|
|
9288
9240
|
newNodes.forEach((node) => {
|
|
9289
|
-
if (isPage(node) || isPageFragment(node))
|
|
9290
|
-
return;
|
|
9241
|
+
if (isPage(node) || isPageFragment(node)) return;
|
|
9291
9242
|
traverseNode(node, (node2) => {
|
|
9292
9243
|
nodeStatusMap.value?.set(node2.id, {
|
|
9293
9244
|
visible: true,
|
|
@@ -9339,8 +9290,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9339
9290
|
};
|
|
9340
9291
|
const { filterTextChangeHandler } = useFilter(nodeData, nodeStatusMap, filterNodeMethod);
|
|
9341
9292
|
const collapseAllHandler = () => {
|
|
9342
|
-
if (!page.value || !nodeStatusMap.value)
|
|
9343
|
-
return;
|
|
9293
|
+
if (!page.value || !nodeStatusMap.value) return;
|
|
9344
9294
|
const items = nodeStatusMap.value.entries();
|
|
9345
9295
|
for (const [id, status] of items) {
|
|
9346
9296
|
if (id === page.value.id) {
|
|
@@ -9474,8 +9424,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
9474
9424
|
}
|
|
9475
9425
|
return;
|
|
9476
9426
|
}
|
|
9477
|
-
if (timeout || !stage.value)
|
|
9478
|
-
return;
|
|
9427
|
+
if (timeout || !stage.value) return;
|
|
9479
9428
|
timeout = stage.value.delayedMarkContainer(e);
|
|
9480
9429
|
};
|
|
9481
9430
|
return (_ctx, _cache) => {
|
|
@@ -9639,8 +9588,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9639
9588
|
const isActiveTabShow = showingBoxKeys.value.some(
|
|
9640
9589
|
(key) => activeTabName.value === sideBarItems.value.find((v) => v.$key === key)?.text
|
|
9641
9590
|
);
|
|
9642
|
-
if (!isActiveTabShow && activeTabName.value)
|
|
9643
|
-
return;
|
|
9591
|
+
if (!isActiveTabShow && activeTabName.value) return;
|
|
9644
9592
|
const nextSlideBarItem = sideBarItems.value.find((sideBarItem) => !showingBoxKeys.value.includes(sideBarItem.$key));
|
|
9645
9593
|
if (!nextSlideBarItem) {
|
|
9646
9594
|
activeTabName.value = "";
|
|
@@ -9895,8 +9843,7 @@ class ScrollViewer extends EventEmitter {
|
|
|
9895
9843
|
}
|
|
9896
9844
|
wheelHandler = (event) => {
|
|
9897
9845
|
const { deltaX, deltaY, currentTarget } = event;
|
|
9898
|
-
if (currentTarget !== this.container)
|
|
9899
|
-
return;
|
|
9846
|
+
if (currentTarget !== this.container) return;
|
|
9900
9847
|
let top;
|
|
9901
9848
|
if (this.scrollHeight > this.height) {
|
|
9902
9849
|
top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
|
|
@@ -9989,8 +9936,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
9989
9936
|
}));
|
|
9990
9937
|
let gesto;
|
|
9991
9938
|
onMounted(() => {
|
|
9992
|
-
if (!thumb.value)
|
|
9993
|
-
return;
|
|
9939
|
+
if (!thumb.value) return;
|
|
9994
9940
|
const thumbEl = thumb.value;
|
|
9995
9941
|
gesto = new Gesto(thumbEl, {
|
|
9996
9942
|
container: window
|
|
@@ -10004,8 +9950,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
10004
9950
|
bar.value?.addEventListener("wheel", wheelHandler, false);
|
|
10005
9951
|
});
|
|
10006
9952
|
onBeforeUnmount(() => {
|
|
10007
|
-
if (gesto)
|
|
10008
|
-
gesto.off();
|
|
9953
|
+
if (gesto) gesto.off();
|
|
10009
9954
|
bar.value?.removeEventListener("wheel", wheelHandler, false);
|
|
10010
9955
|
});
|
|
10011
9956
|
const wheelHandler = (e) => {
|
|
@@ -10084,8 +10029,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
10084
10029
|
const scrollHeight = ref(0);
|
|
10085
10030
|
let scrollViewer;
|
|
10086
10031
|
onMounted(() => {
|
|
10087
|
-
if (!container.value || !el.value)
|
|
10088
|
-
return;
|
|
10032
|
+
if (!container.value || !el.value) return;
|
|
10089
10033
|
scrollViewer = new ScrollViewer({
|
|
10090
10034
|
container: container.value,
|
|
10091
10035
|
target: el.value,
|
|
@@ -10178,8 +10122,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
10178
10122
|
const unWatch = watch(
|
|
10179
10123
|
stage,
|
|
10180
10124
|
(stage2) => {
|
|
10181
|
-
if (!stage2)
|
|
10182
|
-
return;
|
|
10125
|
+
if (!stage2) return;
|
|
10183
10126
|
nextTick(() => unWatch());
|
|
10184
10127
|
stage2.on("select", (el, event) => {
|
|
10185
10128
|
const els = stage2.renderer.getElementsFromPoint(event) || [];
|
|
@@ -10195,8 +10138,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
10195
10138
|
watch(
|
|
10196
10139
|
nodes,
|
|
10197
10140
|
(nodes2) => {
|
|
10198
|
-
if (!nodeStatusMap.value)
|
|
10199
|
-
return;
|
|
10141
|
+
if (!nodeStatusMap.value) return;
|
|
10200
10142
|
for (const [id, status] of nodeStatusMap.value.entries()) {
|
|
10201
10143
|
status.selected = nodes2.some((node) => node.id === id);
|
|
10202
10144
|
}
|
|
@@ -10290,8 +10232,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
10290
10232
|
}
|
|
10291
10233
|
});
|
|
10292
10234
|
watch(stageOverlay, (stageOverlay2) => {
|
|
10293
|
-
if (!services)
|
|
10294
|
-
return;
|
|
10235
|
+
if (!services) return;
|
|
10295
10236
|
const subStage = services.stageOverlayService.createStage(stageOptions);
|
|
10296
10237
|
services?.stageOverlayService.set("stage", subStage);
|
|
10297
10238
|
if (stageOverlay2 && subStage) {
|
|
@@ -10406,8 +10347,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
10406
10347
|
icon: markRaw(_sfc_main$5),
|
|
10407
10348
|
display: () => canCenter.value,
|
|
10408
10349
|
handler: () => {
|
|
10409
|
-
if (!nodes.value)
|
|
10410
|
-
return;
|
|
10350
|
+
if (!nodes.value) return;
|
|
10411
10351
|
editorService?.alignCenter(nodes.value);
|
|
10412
10352
|
}
|
|
10413
10353
|
},
|
|
@@ -10417,8 +10357,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
10417
10357
|
type: "divider",
|
|
10418
10358
|
direction: "horizontal",
|
|
10419
10359
|
display: () => {
|
|
10420
|
-
if (!node.value)
|
|
10421
|
-
return false;
|
|
10360
|
+
if (!node.value) return false;
|
|
10422
10361
|
return !isPage(node.value) && !isPageFragment(node.value);
|
|
10423
10362
|
}
|
|
10424
10363
|
},
|
|
@@ -10484,8 +10423,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
10484
10423
|
watch(
|
|
10485
10424
|
parent,
|
|
10486
10425
|
async () => {
|
|
10487
|
-
if (!parent.value || !editorService)
|
|
10488
|
-
return canCenter.value = false;
|
|
10426
|
+
if (!parent.value || !editorService) return canCenter.value = false;
|
|
10489
10427
|
const layout = await editorService.getLayout(parent.value);
|
|
10490
10428
|
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
10491
10429
|
const isTypeConform = nodes.value?.every(
|
|
@@ -10536,12 +10474,9 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
10536
10474
|
const zoom = computed(() => services?.uiService.get("zoom") || 1);
|
|
10537
10475
|
const node = computed(() => services?.editorService.get("node"));
|
|
10538
10476
|
watchEffect(() => {
|
|
10539
|
-
if (stage || !page.value)
|
|
10540
|
-
|
|
10541
|
-
if (!
|
|
10542
|
-
return;
|
|
10543
|
-
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
10544
|
-
return;
|
|
10477
|
+
if (stage || !page.value) return;
|
|
10478
|
+
if (!stageContainer.value) return;
|
|
10479
|
+
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value) return;
|
|
10545
10480
|
stage = useStage(stageOptions);
|
|
10546
10481
|
stage.on("select", () => {
|
|
10547
10482
|
stageWrap.value?.container?.focus();
|
|
@@ -10561,8 +10496,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
10561
10496
|
});
|
|
10562
10497
|
});
|
|
10563
10498
|
watch(zoom, (zoom2) => {
|
|
10564
|
-
if (!stage || !zoom2)
|
|
10565
|
-
return;
|
|
10499
|
+
if (!stage || !zoom2) return;
|
|
10566
10500
|
stage.setZoom(zoom2);
|
|
10567
10501
|
});
|
|
10568
10502
|
watch(page, (page2) => {
|
|
@@ -10607,20 +10541,16 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
10607
10541
|
menu.value?.show(e);
|
|
10608
10542
|
};
|
|
10609
10543
|
const dragoverHandler = (e) => {
|
|
10610
|
-
if (!e.dataTransfer)
|
|
10611
|
-
return;
|
|
10544
|
+
if (!e.dataTransfer) return;
|
|
10612
10545
|
e.preventDefault();
|
|
10613
10546
|
e.dataTransfer.dropEffect = "move";
|
|
10614
10547
|
};
|
|
10615
10548
|
const dropHandler = async (e) => {
|
|
10616
|
-
if (!e.dataTransfer)
|
|
10617
|
-
return;
|
|
10549
|
+
if (!e.dataTransfer) return;
|
|
10618
10550
|
const data = e.dataTransfer.getData("text/json");
|
|
10619
|
-
if (!data)
|
|
10620
|
-
return;
|
|
10551
|
+
if (!data) return;
|
|
10621
10552
|
const config = parseDSL(`(${data})`);
|
|
10622
|
-
if (!config || config.dragType !== DragType.COMPONENT_LIST)
|
|
10623
|
-
return;
|
|
10553
|
+
if (!config || config.dragType !== DragType.COMPONENT_LIST) return;
|
|
10624
10554
|
e.preventDefault();
|
|
10625
10555
|
const doc = stage?.renderer.contentWindow?.document;
|
|
10626
10556
|
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
@@ -10825,11 +10755,9 @@ class CodeBlock extends BaseService {
|
|
|
10825
10755
|
* @returns {CodeBlockContent | null}
|
|
10826
10756
|
*/
|
|
10827
10757
|
getCodeContentById(id) {
|
|
10828
|
-
if (!id)
|
|
10829
|
-
return null;
|
|
10758
|
+
if (!id) return null;
|
|
10830
10759
|
const totalCodeDsl = this.getCodeDsl();
|
|
10831
|
-
if (!totalCodeDsl)
|
|
10832
|
-
return null;
|
|
10760
|
+
if (!totalCodeDsl) return null;
|
|
10833
10761
|
return totalCodeDsl[id] ?? null;
|
|
10834
10762
|
}
|
|
10835
10763
|
/**
|
|
@@ -10854,8 +10782,7 @@ class CodeBlock extends BaseService {
|
|
|
10854
10782
|
if (!codeDsl) {
|
|
10855
10783
|
throw new Error("dsl中没有codeBlocks");
|
|
10856
10784
|
}
|
|
10857
|
-
if (codeDsl[id] && !force)
|
|
10858
|
-
return;
|
|
10785
|
+
if (codeDsl[id] && !force) return;
|
|
10859
10786
|
const codeConfigProcessed = cloneDeep(codeConfig);
|
|
10860
10787
|
if (codeConfigProcessed.content) {
|
|
10861
10788
|
const parseDSL = getConfig("parseDSL");
|
|
@@ -10948,8 +10875,7 @@ class CodeBlock extends BaseService {
|
|
|
10948
10875
|
*/
|
|
10949
10876
|
async deleteCodeDslByIds(codeIds) {
|
|
10950
10877
|
const currentDsl = await this.getCodeDsl();
|
|
10951
|
-
if (!currentDsl)
|
|
10952
|
-
return;
|
|
10878
|
+
if (!currentDsl) return;
|
|
10953
10879
|
codeIds.forEach((id) => {
|
|
10954
10880
|
delete currentDsl[id];
|
|
10955
10881
|
this.emit("remove", id);
|
|
@@ -10969,8 +10895,7 @@ class CodeBlock extends BaseService {
|
|
|
10969
10895
|
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
10970
10896
|
const dsl = await this.getCodeDsl();
|
|
10971
10897
|
const existedIds = keys(dsl);
|
|
10972
|
-
if (!existedIds.includes(newId))
|
|
10973
|
-
return newId;
|
|
10898
|
+
if (!existedIds.includes(newId)) return newId;
|
|
10974
10899
|
return await this.getUniqueId();
|
|
10975
10900
|
}
|
|
10976
10901
|
/**
|
|
@@ -10978,20 +10903,19 @@ class CodeBlock extends BaseService {
|
|
|
10978
10903
|
* @param config 组件节点配置
|
|
10979
10904
|
* @returns
|
|
10980
10905
|
*/
|
|
10981
|
-
copyWithRelated(config) {
|
|
10906
|
+
copyWithRelated(config, collectorOptions) {
|
|
10982
10907
|
const copyNodes = Array.isArray(config) ? config : [config];
|
|
10983
|
-
depService.clearByType(DepTargetType.RELATED_CODE_WHEN_COPY);
|
|
10984
|
-
depService.collect(copyNodes, true, DepTargetType.RELATED_CODE_WHEN_COPY);
|
|
10985
|
-
const customTarget = depService.getTarget(
|
|
10986
|
-
DepTargetType.RELATED_CODE_WHEN_COPY,
|
|
10987
|
-
DepTargetType.RELATED_CODE_WHEN_COPY
|
|
10988
|
-
);
|
|
10989
10908
|
const copyData = {};
|
|
10990
|
-
if (
|
|
10909
|
+
if (collectorOptions && typeof collectorOptions.isTarget === "function") {
|
|
10910
|
+
const customTarget = new Target({
|
|
10911
|
+
...collectorOptions
|
|
10912
|
+
});
|
|
10913
|
+
const coperWatcher = new Watcher();
|
|
10914
|
+
coperWatcher.addTarget(customTarget);
|
|
10915
|
+
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
10991
10916
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
10992
10917
|
const node = editorService.getNodeById(nodeId);
|
|
10993
|
-
if (!node)
|
|
10994
|
-
return;
|
|
10918
|
+
if (!node) return;
|
|
10995
10919
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
10996
10920
|
const relateCodeId = get(node, key);
|
|
10997
10921
|
const isExist = Object.keys(copyData).find((codeId) => codeId === relateCodeId);
|
|
@@ -11062,6 +10986,139 @@ class ComponentList extends BaseService {
|
|
|
11062
10986
|
}
|
|
11063
10987
|
const componentListService = new ComponentList();
|
|
11064
10988
|
|
|
10989
|
+
globalThis.requestIdleCallback = globalThis.requestIdleCallback || function(cb) {
|
|
10990
|
+
const start = Date.now();
|
|
10991
|
+
return setTimeout(() => {
|
|
10992
|
+
cb({
|
|
10993
|
+
didTimeout: false,
|
|
10994
|
+
timeRemaining() {
|
|
10995
|
+
return Math.max(0, 50 - (Date.now() - start));
|
|
10996
|
+
}
|
|
10997
|
+
});
|
|
10998
|
+
}, 1);
|
|
10999
|
+
};
|
|
11000
|
+
class IdleTask extends EventEmitter {
|
|
11001
|
+
taskList = [];
|
|
11002
|
+
taskHandle = null;
|
|
11003
|
+
enqueueTask(taskHandler, taskData) {
|
|
11004
|
+
this.taskList.push({
|
|
11005
|
+
handler: taskHandler,
|
|
11006
|
+
data: taskData
|
|
11007
|
+
});
|
|
11008
|
+
if (!this.taskHandle) {
|
|
11009
|
+
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
|
|
11010
|
+
}
|
|
11011
|
+
}
|
|
11012
|
+
on(eventName, listener) {
|
|
11013
|
+
return super.on(eventName, listener);
|
|
11014
|
+
}
|
|
11015
|
+
once(eventName, listener) {
|
|
11016
|
+
return super.once(eventName, listener);
|
|
11017
|
+
}
|
|
11018
|
+
emit(eventName, ...args) {
|
|
11019
|
+
return super.emit(eventName, ...args);
|
|
11020
|
+
}
|
|
11021
|
+
runTaskQueue(deadline) {
|
|
11022
|
+
while ((deadline.timeRemaining() > 15 || deadline.didTimeout) && this.taskList.length) {
|
|
11023
|
+
const task = this.taskList.shift();
|
|
11024
|
+
task.handler(task.data);
|
|
11025
|
+
}
|
|
11026
|
+
if (this.taskList.length) {
|
|
11027
|
+
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
|
|
11028
|
+
} else {
|
|
11029
|
+
this.taskHandle = 0;
|
|
11030
|
+
this.emit("finish");
|
|
11031
|
+
}
|
|
11032
|
+
}
|
|
11033
|
+
}
|
|
11034
|
+
|
|
11035
|
+
const idleTask = new IdleTask();
|
|
11036
|
+
class Dep extends BaseService {
|
|
11037
|
+
watcher = new Watcher({ initialTargets: reactive({}) });
|
|
11038
|
+
removeTargets(type = DepTargetType.DEFAULT) {
|
|
11039
|
+
this.watcher.removeTargets(type);
|
|
11040
|
+
const targets = this.watcher.getTargets(type);
|
|
11041
|
+
if (!targets) return;
|
|
11042
|
+
for (const target of Object.values(targets)) {
|
|
11043
|
+
this.emit("remove-target", target.id);
|
|
11044
|
+
}
|
|
11045
|
+
}
|
|
11046
|
+
getTargets(type = DepTargetType.DEFAULT) {
|
|
11047
|
+
return this.watcher.getTargets(type);
|
|
11048
|
+
}
|
|
11049
|
+
getTarget(id, type = DepTargetType.DEFAULT) {
|
|
11050
|
+
return this.watcher.getTarget(id, type);
|
|
11051
|
+
}
|
|
11052
|
+
addTarget(target) {
|
|
11053
|
+
this.watcher.addTarget(target);
|
|
11054
|
+
this.emit("add-target", target);
|
|
11055
|
+
}
|
|
11056
|
+
removeTarget(id, type = DepTargetType.DEFAULT) {
|
|
11057
|
+
this.watcher.removeTarget(id, type);
|
|
11058
|
+
this.emit("remove-target", id);
|
|
11059
|
+
}
|
|
11060
|
+
clearTargets() {
|
|
11061
|
+
this.watcher.clearTargets();
|
|
11062
|
+
}
|
|
11063
|
+
collect(nodes, depExtendedData = {}, deep = false, type) {
|
|
11064
|
+
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
|
11065
|
+
this.collectNode(node, target, depExtendedData, deep);
|
|
11066
|
+
});
|
|
11067
|
+
this.emit("collected", nodes, deep);
|
|
11068
|
+
}
|
|
11069
|
+
collectIdle(nodes, depExtendedData = {}, deep = false, type) {
|
|
11070
|
+
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
|
11071
|
+
idleTask.enqueueTask(
|
|
11072
|
+
({ node: node2, deep: deep2, target: target2 }) => {
|
|
11073
|
+
this.collectNode(node2, target2, depExtendedData, deep2);
|
|
11074
|
+
},
|
|
11075
|
+
{
|
|
11076
|
+
node,
|
|
11077
|
+
deep,
|
|
11078
|
+
target
|
|
11079
|
+
}
|
|
11080
|
+
);
|
|
11081
|
+
});
|
|
11082
|
+
idleTask.once("finish", () => {
|
|
11083
|
+
this.emit("collected", nodes, deep);
|
|
11084
|
+
});
|
|
11085
|
+
}
|
|
11086
|
+
collectNode(node, target, depExtendedData = {}, deep = false) {
|
|
11087
|
+
if (isPage(node)) {
|
|
11088
|
+
Object.entries(target.deps).forEach(([depKey, dep]) => {
|
|
11089
|
+
if (dep.data?.pageId && dep.data.pageId === depExtendedData.pageId) {
|
|
11090
|
+
delete target.deps[depKey];
|
|
11091
|
+
}
|
|
11092
|
+
});
|
|
11093
|
+
} else {
|
|
11094
|
+
this.watcher.removeTargetDep(target, node);
|
|
11095
|
+
}
|
|
11096
|
+
this.watcher.collectItem(node, target, depExtendedData, deep);
|
|
11097
|
+
}
|
|
11098
|
+
clear(nodes) {
|
|
11099
|
+
return this.watcher.clear(nodes);
|
|
11100
|
+
}
|
|
11101
|
+
clearByType(type, nodes) {
|
|
11102
|
+
return this.watcher.clearByType(type, nodes);
|
|
11103
|
+
}
|
|
11104
|
+
hasTarget(id, type = DepTargetType.DEFAULT) {
|
|
11105
|
+
return this.watcher.hasTarget(id, type);
|
|
11106
|
+
}
|
|
11107
|
+
hasSpecifiedTypeTarget(type = DepTargetType.DEFAULT) {
|
|
11108
|
+
return this.watcher.hasSpecifiedTypeTarget(type);
|
|
11109
|
+
}
|
|
11110
|
+
on(eventName, listener) {
|
|
11111
|
+
return super.on(eventName, listener);
|
|
11112
|
+
}
|
|
11113
|
+
once(eventName, listener) {
|
|
11114
|
+
return super.once(eventName, listener);
|
|
11115
|
+
}
|
|
11116
|
+
emit(eventName, ...args) {
|
|
11117
|
+
return super.emit(eventName, ...args);
|
|
11118
|
+
}
|
|
11119
|
+
}
|
|
11120
|
+
const depService = new Dep();
|
|
11121
|
+
|
|
11065
11122
|
let eventMap = reactive({});
|
|
11066
11123
|
let methodMap = reactive({});
|
|
11067
11124
|
class Events extends BaseService {
|
|
@@ -11122,8 +11179,7 @@ class Keybinding extends BaseService {
|
|
|
11122
11179
|
commands = {
|
|
11123
11180
|
[KeyBindingCommand.DELETE_NODE]: () => {
|
|
11124
11181
|
const nodes = editorService.get("nodes");
|
|
11125
|
-
if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0]))
|
|
11126
|
-
return;
|
|
11182
|
+
if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0])) return;
|
|
11127
11183
|
editorService.remove(nodes);
|
|
11128
11184
|
},
|
|
11129
11185
|
[KeyBindingCommand.COPY_NODE]: () => {
|
|
@@ -11132,8 +11188,7 @@ class Keybinding extends BaseService {
|
|
|
11132
11188
|
},
|
|
11133
11189
|
[KeyBindingCommand.CUT_NODE]: () => {
|
|
11134
11190
|
const nodes = editorService.get("nodes");
|
|
11135
|
-
if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0]))
|
|
11136
|
-
return;
|
|
11191
|
+
if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0])) return;
|
|
11137
11192
|
editorService.copy(nodes);
|
|
11138
11193
|
editorService.remove(nodes);
|
|
11139
11194
|
},
|
|
@@ -11322,8 +11377,7 @@ class StageOverlay extends BaseService {
|
|
|
11322
11377
|
}
|
|
11323
11378
|
openOverlay(el) {
|
|
11324
11379
|
const stageOptions = this.get("stageOptions");
|
|
11325
|
-
if (!el || !stageOptions)
|
|
11326
|
-
return;
|
|
11380
|
+
if (!el || !stageOptions) return;
|
|
11327
11381
|
this.set("sourceEl", el);
|
|
11328
11382
|
this.createContentEl();
|
|
11329
11383
|
this.set("stageOverlayVisible", true);
|
|
@@ -11350,8 +11404,7 @@ class StageOverlay extends BaseService {
|
|
|
11350
11404
|
}
|
|
11351
11405
|
updateOverlay() {
|
|
11352
11406
|
const sourceEl = this.get("sourceEl");
|
|
11353
|
-
if (!sourceEl)
|
|
11354
|
-
return;
|
|
11407
|
+
if (!sourceEl) return;
|
|
11355
11408
|
const { scrollWidth, scrollHeight } = sourceEl;
|
|
11356
11409
|
this.set("wrapWidth", scrollWidth);
|
|
11357
11410
|
this.set("wrapHeight", scrollHeight);
|
|
@@ -11384,8 +11437,7 @@ class StageOverlay extends BaseService {
|
|
|
11384
11437
|
}
|
|
11385
11438
|
createContentEl() {
|
|
11386
11439
|
const sourceEl = this.get("sourceEl");
|
|
11387
|
-
if (!sourceEl)
|
|
11388
|
-
return;
|
|
11440
|
+
if (!sourceEl) return;
|
|
11389
11441
|
const contentEl = sourceEl.cloneNode(true);
|
|
11390
11442
|
this.set("contentEl", contentEl);
|
|
11391
11443
|
contentEl.style.position = "static";
|
|
@@ -11407,8 +11459,7 @@ class StageOverlay extends BaseService {
|
|
|
11407
11459
|
const wrapDiv = this.get("wrapDiv");
|
|
11408
11460
|
const subStage = this.get("stage");
|
|
11409
11461
|
const stageOptions = this.get("stageOptions");
|
|
11410
|
-
if (!contentEl)
|
|
11411
|
-
return;
|
|
11462
|
+
if (!contentEl) return;
|
|
11412
11463
|
wrapDiv.style.cssText = `
|
|
11413
11464
|
width: ${sourceEl?.scrollWidth}px;
|
|
11414
11465
|
height: ${sourceEl?.scrollHeight}px;
|
|
@@ -11628,37 +11679,9 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
11628
11679
|
getApp()?.dataSourceManager?.updateSchema(root.dataSources);
|
|
11629
11680
|
}
|
|
11630
11681
|
};
|
|
11631
|
-
const updateNodeWhenDataSourceChange = (nodes) => {
|
|
11632
|
-
const root = editorService.get("root");
|
|
11633
|
-
const stage = editorService.get("stage");
|
|
11634
|
-
if (!root || !stage)
|
|
11635
|
-
return;
|
|
11636
|
-
const app = getApp();
|
|
11637
|
-
if (!app)
|
|
11638
|
-
return;
|
|
11639
|
-
if (app.dsl) {
|
|
11640
|
-
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
11641
|
-
app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
|
|
11642
|
-
app.dsl.dataSources = root.dataSources;
|
|
11643
|
-
}
|
|
11644
|
-
updateDataSourceSchema();
|
|
11645
|
-
nodes.forEach((node) => {
|
|
11646
|
-
const deps = Object.values(root.dataSourceDeps || {});
|
|
11647
|
-
deps.forEach((dep) => {
|
|
11648
|
-
if (dep[node.id]) {
|
|
11649
|
-
stage.update({
|
|
11650
|
-
config: cloneDeep(node),
|
|
11651
|
-
parentId: editorService.getParentById(node.id)?.id,
|
|
11652
|
-
root: cloneDeep(root)
|
|
11653
|
-
});
|
|
11654
|
-
}
|
|
11655
|
-
});
|
|
11656
|
-
});
|
|
11657
|
-
};
|
|
11658
11682
|
const targetAddHandler = (target) => {
|
|
11659
11683
|
const root = editorService.get("root");
|
|
11660
|
-
if (!root)
|
|
11661
|
-
return;
|
|
11684
|
+
if (!root) return;
|
|
11662
11685
|
if (target.type === DepTargetType.DATA_SOURCE) {
|
|
11663
11686
|
if (!root.dataSourceDeps) {
|
|
11664
11687
|
root.dataSourceDeps = {};
|
|
@@ -11681,15 +11704,44 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
11681
11704
|
delete root.dataSourceCondDeps[id];
|
|
11682
11705
|
}
|
|
11683
11706
|
};
|
|
11684
|
-
const
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11707
|
+
const collectedHandler = (nodes, deep) => {
|
|
11708
|
+
const root = editorService.get("root");
|
|
11709
|
+
const stage = editorService.get("stage");
|
|
11710
|
+
if (!root || !stage) return;
|
|
11711
|
+
const app = getApp();
|
|
11712
|
+
if (!app) return;
|
|
11713
|
+
if (app.dsl) {
|
|
11714
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
11715
|
+
app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
|
|
11716
|
+
app.dsl.dataSources = root.dataSources;
|
|
11717
|
+
}
|
|
11718
|
+
updateDataSourceSchema();
|
|
11719
|
+
const allNodes = [];
|
|
11720
|
+
if (deep) {
|
|
11721
|
+
nodes.forEach((node) => {
|
|
11722
|
+
traverseNode(node, (node2) => {
|
|
11723
|
+
if (!allNodes.includes(node2)) {
|
|
11724
|
+
allNodes.push(node2);
|
|
11725
|
+
}
|
|
11726
|
+
});
|
|
11727
|
+
});
|
|
11728
|
+
} else {
|
|
11729
|
+
allNodes.push(...nodes);
|
|
11730
|
+
}
|
|
11731
|
+
const deps = Object.values(root.dataSourceDeps || {});
|
|
11732
|
+
deps.forEach((dep) => {
|
|
11733
|
+
Object.keys(dep).forEach((id) => {
|
|
11734
|
+
const node = allNodes.find((node2) => node2.id === id);
|
|
11735
|
+
node && stage.update({
|
|
11736
|
+
config: cloneDeep(node),
|
|
11737
|
+
parentId: editorService.getParentById(node.id)?.id,
|
|
11738
|
+
root: cloneDeep(root)
|
|
11739
|
+
});
|
|
11740
|
+
});
|
|
11741
|
+
});
|
|
11689
11742
|
};
|
|
11690
11743
|
depService.on("add-target", targetAddHandler);
|
|
11691
11744
|
depService.on("remove-target", targetRemoveHandler);
|
|
11692
|
-
depService.on("dep-update", depUpdateHandler);
|
|
11693
11745
|
depService.on("collected", collectedHandler);
|
|
11694
11746
|
const initDataSourceDepTarget = (ds) => {
|
|
11695
11747
|
depService.addTarget(createDataSourceTarget(ds, reactive({})));
|
|
@@ -11697,8 +11749,7 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
11697
11749
|
depService.addTarget(createDataSourceCondTarget(ds, reactive({})));
|
|
11698
11750
|
};
|
|
11699
11751
|
const rootChangeHandler = async (value, preValue) => {
|
|
11700
|
-
if (!value)
|
|
11701
|
-
return;
|
|
11752
|
+
if (!value) return;
|
|
11702
11753
|
value.codeBlocks = value.codeBlocks || {};
|
|
11703
11754
|
value.dataSources = value.dataSources || [];
|
|
11704
11755
|
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
@@ -11711,7 +11762,9 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
11711
11762
|
initDataSourceDepTarget(ds);
|
|
11712
11763
|
});
|
|
11713
11764
|
if (Array.isArray(value.items)) {
|
|
11714
|
-
|
|
11765
|
+
value.items.forEach((page) => {
|
|
11766
|
+
depService.collectIdle([page], { pageId: page.id }, true);
|
|
11767
|
+
});
|
|
11715
11768
|
} else {
|
|
11716
11769
|
depService.clear();
|
|
11717
11770
|
delete value.dataSourceDeps;
|
|
@@ -11734,17 +11787,29 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
11734
11787
|
emit("update:modelValue", value);
|
|
11735
11788
|
}
|
|
11736
11789
|
};
|
|
11790
|
+
const collectIdle = (nodes, deep) => {
|
|
11791
|
+
nodes.forEach((node) => {
|
|
11792
|
+
let pageId;
|
|
11793
|
+
if (isPage(node)) {
|
|
11794
|
+
pageId = node.id;
|
|
11795
|
+
} else {
|
|
11796
|
+
const info = editorService.getNodeInfo(node.id);
|
|
11797
|
+
pageId = info.page?.id;
|
|
11798
|
+
}
|
|
11799
|
+
depService.collectIdle([node], { pageId }, deep);
|
|
11800
|
+
});
|
|
11801
|
+
};
|
|
11737
11802
|
const nodeAddHandler = (nodes) => {
|
|
11738
|
-
|
|
11803
|
+
collectIdle(nodes, true);
|
|
11739
11804
|
};
|
|
11740
11805
|
const nodeUpdateHandler = (nodes) => {
|
|
11741
|
-
|
|
11806
|
+
collectIdle(nodes, false);
|
|
11742
11807
|
};
|
|
11743
11808
|
const nodeRemoveHandler = (nodes) => {
|
|
11744
11809
|
depService.clear(nodes);
|
|
11745
11810
|
};
|
|
11746
11811
|
const historyChangeHandler = (page) => {
|
|
11747
|
-
depService.
|
|
11812
|
+
depService.collectIdle([page], { pageId: page.id }, true);
|
|
11748
11813
|
};
|
|
11749
11814
|
editorService.on("history-change", historyChangeHandler);
|
|
11750
11815
|
editorService.on("root-change", rootChangeHandler);
|
|
@@ -11771,10 +11836,9 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
11771
11836
|
const root = editorService.get("root");
|
|
11772
11837
|
removeDataSourceTarget(config.id);
|
|
11773
11838
|
initDataSourceDepTarget(config);
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
updateNodeWhenDataSourceChange(nodes);
|
|
11839
|
+
(root?.items || []).forEach((page) => {
|
|
11840
|
+
depService.collectIdle([page], { pageId: page.id }, true);
|
|
11841
|
+
});
|
|
11778
11842
|
};
|
|
11779
11843
|
const removeDataSourceTarget = (id) => {
|
|
11780
11844
|
depService.removeTarget(id, DepTargetType.DATA_SOURCE);
|
|
@@ -11788,23 +11852,9 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
11788
11852
|
dataSourceService.on("add", dataSourceAddHandler);
|
|
11789
11853
|
dataSourceService.on("update", dataSourceUpdateHandler);
|
|
11790
11854
|
dataSourceService.on("remove", dataSourceRemoveHandler);
|
|
11791
|
-
if (props.collectorOptions && !depService.hasTarget(DepTargetType.RELATED_COMP_WHEN_COPY)) {
|
|
11792
|
-
depService.addTarget(createRelatedTargetForCopy(props.collectorOptions, DepTargetType.RELATED_COMP_WHEN_COPY));
|
|
11793
|
-
}
|
|
11794
|
-
if (props.collectorOptionsForCode && !depService.hasTarget(DepTargetType.RELATED_CODE_WHEN_COPY)) {
|
|
11795
|
-
depService.addTarget(
|
|
11796
|
-
createRelatedTargetForCopy(props.collectorOptionsForCode, DepTargetType.RELATED_CODE_WHEN_COPY)
|
|
11797
|
-
);
|
|
11798
|
-
}
|
|
11799
|
-
if (props.collectorOptionsForDataSource && !depService.hasTarget(DepTargetType.RELATED_DS_WHEN_COPY)) {
|
|
11800
|
-
depService.addTarget(
|
|
11801
|
-
createRelatedTargetForCopy(props.collectorOptionsForDataSource, DepTargetType.RELATED_DS_WHEN_COPY)
|
|
11802
|
-
);
|
|
11803
|
-
}
|
|
11804
11855
|
onBeforeUnmount(() => {
|
|
11805
11856
|
depService.off("add-target", targetAddHandler);
|
|
11806
11857
|
depService.off("remove-target", targetRemoveHandler);
|
|
11807
|
-
depService.off("dep-update", depUpdateHandler);
|
|
11808
11858
|
depService.off("collected", collectedHandler);
|
|
11809
11859
|
editorService.off("history-change", historyChangeHandler);
|
|
11810
11860
|
editorService.off("root-change", rootChangeHandler);
|
|
@@ -11849,9 +11899,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11849
11899
|
stageRect: {},
|
|
11850
11900
|
codeOptions: {},
|
|
11851
11901
|
disabledDragStart: { type: Boolean },
|
|
11852
|
-
collectorOptions: {},
|
|
11853
|
-
collectorOptionsForCode: {},
|
|
11854
|
-
collectorOptionsForDataSource: {},
|
|
11855
11902
|
guidesOptions: {},
|
|
11856
11903
|
disabledMultiSelect: { type: Boolean },
|
|
11857
11904
|
disabledPageFragment: { type: Boolean },
|
|
@@ -12057,4 +12104,4 @@ const index = {
|
|
|
12057
12104
|
}
|
|
12058
12105
|
};
|
|
12059
12106
|
|
|
12060
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$J as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$O as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, _sfc_main$N as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, SideItemKey, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };
|
|
12107
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$J as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$O as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, _sfc_main$N as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, SideItemKey, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, moveItemsInContainer, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };
|