@tmagic/editor 1.4.7 → 1.4.9
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 +314 -452
- package/dist/tmagic-editor.umd.cjs +313 -450
- package/package.json +16 -12
- package/src/fields/DataSourceInput.vue +8 -0
- package/src/initService.ts +46 -41
- package/src/layouts/PropsPanel.vue +1 -0
- package/src/layouts/sidebar/layer/use-click.ts +8 -5
- package/src/layouts/sidebar/layer/use-drag.ts +7 -1
- package/src/services/editor.ts +61 -22
- package/src/services/props.ts +22 -7
- package/src/theme/props-panel.scss +1 -1
- package/src/type.ts +3 -0
- package/src/utils/editor.ts +20 -1
- package/types/layouts/sidebar/layer/use-click.d.ts +1 -1
- package/types/services/editor.d.ts +19 -2
- package/types/services/props.d.ts +5 -5
- package/types/type.d.ts +6 -0
- package/types/utils/editor.d.ts +1 -0
- package/tsconfig.build.json +0 -16
|
@@ -153,8 +153,7 @@
|
|
|
153
153
|
};
|
|
154
154
|
const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
|
|
155
155
|
const init = async () => {
|
|
156
|
-
if (!codeEditor.value)
|
|
157
|
-
return;
|
|
156
|
+
if (!codeEditor.value) return;
|
|
158
157
|
const options = {
|
|
159
158
|
value: values.value,
|
|
160
159
|
language: props.language,
|
|
@@ -367,8 +366,7 @@
|
|
|
367
366
|
}
|
|
368
367
|
);
|
|
369
368
|
const changeHandler = (v) => {
|
|
370
|
-
if (!props.name || !props.model)
|
|
371
|
-
return;
|
|
369
|
+
if (!props.name || !props.model) return;
|
|
372
370
|
try {
|
|
373
371
|
const parseDSL = getConfig("parseDSL");
|
|
374
372
|
props.model[props.name] = parseDSL(`(${v[props.name]})`);
|
|
@@ -511,11 +509,9 @@
|
|
|
511
509
|
});
|
|
512
510
|
|
|
513
511
|
const compose = (middleware, isAsync) => {
|
|
514
|
-
if (!Array.isArray(middleware))
|
|
515
|
-
throw new TypeError("Middleware 必须是一个数组!");
|
|
512
|
+
if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
|
|
516
513
|
for (const fn of middleware) {
|
|
517
|
-
if (typeof fn !== "function")
|
|
518
|
-
throw new TypeError("Middleware 必须由函数组成!");
|
|
514
|
+
if (typeof fn !== "function") throw new TypeError("Middleware 必须由函数组成!");
|
|
519
515
|
}
|
|
520
516
|
return (args, next) => {
|
|
521
517
|
let index = -1;
|
|
@@ -530,8 +526,7 @@
|
|
|
530
526
|
}
|
|
531
527
|
index = i;
|
|
532
528
|
let fn = middleware[i];
|
|
533
|
-
if (i === middleware.length && next)
|
|
534
|
-
fn = next;
|
|
529
|
+
if (i === middleware.length && next) fn = next;
|
|
535
530
|
if (!fn) {
|
|
536
531
|
if (isAsync) {
|
|
537
532
|
return Promise.resolve();
|
|
@@ -561,8 +556,7 @@
|
|
|
561
556
|
let beforeArgs = args;
|
|
562
557
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
563
558
|
beforeArgs = beforeMethod(...beforeArgs) || [];
|
|
564
|
-
if (isError(beforeArgs))
|
|
565
|
-
throw beforeArgs;
|
|
559
|
+
if (isError(beforeArgs)) throw beforeArgs;
|
|
566
560
|
if (!Array.isArray(beforeArgs)) {
|
|
567
561
|
beforeArgs = [beforeArgs];
|
|
568
562
|
}
|
|
@@ -570,8 +564,7 @@
|
|
|
570
564
|
let returnValue = fn(beforeArgs, sourceMethod.bind(scope));
|
|
571
565
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
572
566
|
returnValue = afterMethod(returnValue, ...beforeArgs);
|
|
573
|
-
if (isError(returnValue))
|
|
574
|
-
throw returnValue;
|
|
567
|
+
if (isError(returnValue)) throw returnValue;
|
|
575
568
|
}
|
|
576
569
|
return returnValue;
|
|
577
570
|
} catch (error) {
|
|
@@ -583,8 +576,7 @@
|
|
|
583
576
|
let beforeArgs = args;
|
|
584
577
|
for (const beforeMethod of scope.pluginOptionsList[beforeMethodName]) {
|
|
585
578
|
beforeArgs = await beforeMethod(...beforeArgs) || [];
|
|
586
|
-
if (isError(beforeArgs))
|
|
587
|
-
throw beforeArgs;
|
|
579
|
+
if (isError(beforeArgs)) throw beforeArgs;
|
|
588
580
|
if (!Array.isArray(beforeArgs)) {
|
|
589
581
|
beforeArgs = [beforeArgs];
|
|
590
582
|
}
|
|
@@ -592,8 +584,7 @@
|
|
|
592
584
|
let returnValue = await fn(beforeArgs, sourceMethod.bind(scope));
|
|
593
585
|
for (const afterMethod of scope.pluginOptionsList[afterMethodName]) {
|
|
594
586
|
returnValue = await afterMethod(returnValue, ...beforeArgs);
|
|
595
|
-
if (isError(returnValue))
|
|
596
|
-
throw returnValue;
|
|
587
|
+
if (isError(returnValue)) throw returnValue;
|
|
597
588
|
}
|
|
598
589
|
return returnValue;
|
|
599
590
|
} catch (error) {
|
|
@@ -644,14 +635,12 @@
|
|
|
644
635
|
*/
|
|
645
636
|
use(options) {
|
|
646
637
|
Object.entries(options).forEach(([methodName2, method]) => {
|
|
647
|
-
if (typeof method === "function")
|
|
648
|
-
this.middleware[methodName2].push(method);
|
|
638
|
+
if (typeof method === "function") this.middleware[methodName2].push(method);
|
|
649
639
|
});
|
|
650
640
|
}
|
|
651
641
|
usePlugin(options) {
|
|
652
642
|
Object.entries(options).forEach(([methodName2, method]) => {
|
|
653
|
-
if (typeof method === "function")
|
|
654
|
-
this.pluginOptionsList[methodName2].push(method);
|
|
643
|
+
if (typeof method === "function") this.pluginOptionsList[methodName2].push(method);
|
|
655
644
|
});
|
|
656
645
|
}
|
|
657
646
|
removeAllPlugins() {
|
|
@@ -706,7 +695,11 @@
|
|
|
706
695
|
return fillConfig(config, typeof labelWidth !== "function" ? labelWidth : "80px");
|
|
707
696
|
}
|
|
708
697
|
async setPropsConfig(type, config) {
|
|
709
|
-
|
|
698
|
+
let c = config;
|
|
699
|
+
if (typeof config === "function") {
|
|
700
|
+
c = config({ editorService });
|
|
701
|
+
}
|
|
702
|
+
this.state.propsConfigMap[utils.toLine(type)] = await this.fillConfig(Array.isArray(c) ? c : [c]);
|
|
710
703
|
}
|
|
711
704
|
/**
|
|
712
705
|
* 获取指点类型的组件属性表单配置
|
|
@@ -730,7 +723,11 @@
|
|
|
730
723
|
* @param value 组件初始值
|
|
731
724
|
*/
|
|
732
725
|
async setPropsValue(type, value) {
|
|
733
|
-
|
|
726
|
+
let v = value;
|
|
727
|
+
if (typeof value === "function") {
|
|
728
|
+
v = value({ editorService });
|
|
729
|
+
}
|
|
730
|
+
this.state.propsValueMap[utils.toLine(type)] = v;
|
|
734
731
|
}
|
|
735
732
|
/**
|
|
736
733
|
* 获取指定类型的组件初始值
|
|
@@ -814,8 +811,7 @@
|
|
|
814
811
|
*/
|
|
815
812
|
replaceRelateId(originConfigs, targetConfigs, collectorOptions) {
|
|
816
813
|
const relateIdMap = this.getRelateIdMap();
|
|
817
|
-
if (Object.keys(relateIdMap).length === 0)
|
|
818
|
-
return;
|
|
814
|
+
if (Object.keys(relateIdMap).length === 0) return;
|
|
819
815
|
const target = new dep.Target({
|
|
820
816
|
...collectorOptions
|
|
821
817
|
});
|
|
@@ -826,13 +822,11 @@
|
|
|
826
822
|
const newId = relateIdMap[config.id];
|
|
827
823
|
const path = utils.getNodePath(newId, targetConfigs);
|
|
828
824
|
const targetConfig = path[path.length - 1];
|
|
829
|
-
if (!targetConfig)
|
|
830
|
-
return;
|
|
825
|
+
if (!targetConfig) return;
|
|
831
826
|
target.deps[config.id]?.keys?.forEach((fullKey) => {
|
|
832
827
|
const relateOriginId = utils.getValueByKeyPath(fullKey, config);
|
|
833
828
|
const relateTargetId = relateIdMap[relateOriginId];
|
|
834
|
-
if (!relateTargetId)
|
|
835
|
-
return;
|
|
829
|
+
if (!relateTargetId) return;
|
|
836
830
|
utils.setValueByKeyPath(fullKey, relateTargetId, targetConfig);
|
|
837
831
|
});
|
|
838
832
|
if (config.items && Array.isArray(config.items)) {
|
|
@@ -942,8 +936,7 @@
|
|
|
942
936
|
this.state.canUndo = false;
|
|
943
937
|
}
|
|
944
938
|
changePage(page) {
|
|
945
|
-
if (!page)
|
|
946
|
-
return;
|
|
939
|
+
if (!page) return;
|
|
947
940
|
this.state.pageId = page.id;
|
|
948
941
|
if (!this.state.pageSteps[this.state.pageId]) {
|
|
949
942
|
const undoRedo = new UndoRedo();
|
|
@@ -965,24 +958,21 @@
|
|
|
965
958
|
}
|
|
966
959
|
push(state) {
|
|
967
960
|
const undoRedo = this.getUndoRedo();
|
|
968
|
-
if (!undoRedo)
|
|
969
|
-
return null;
|
|
961
|
+
if (!undoRedo) return null;
|
|
970
962
|
undoRedo.pushElement(state);
|
|
971
963
|
this.emit("change", state);
|
|
972
964
|
return state;
|
|
973
965
|
}
|
|
974
966
|
undo() {
|
|
975
967
|
const undoRedo = this.getUndoRedo();
|
|
976
|
-
if (!undoRedo)
|
|
977
|
-
return null;
|
|
968
|
+
if (!undoRedo) return null;
|
|
978
969
|
const state = undoRedo.undo();
|
|
979
970
|
this.emit("change", state);
|
|
980
971
|
return state;
|
|
981
972
|
}
|
|
982
973
|
redo() {
|
|
983
974
|
const undoRedo = this.getUndoRedo();
|
|
984
|
-
if (!undoRedo)
|
|
985
|
-
return null;
|
|
975
|
+
if (!undoRedo) return null;
|
|
986
976
|
const state = undoRedo.redo();
|
|
987
977
|
this.emit("change", state);
|
|
988
978
|
return state;
|
|
@@ -993,8 +983,7 @@
|
|
|
993
983
|
this.removeAllPlugins();
|
|
994
984
|
}
|
|
995
985
|
getUndoRedo() {
|
|
996
|
-
if (!this.state.pageId)
|
|
997
|
-
return null;
|
|
986
|
+
if (!this.state.pageId) return null;
|
|
998
987
|
return this.state.pageSteps[this.state.pageId];
|
|
999
988
|
}
|
|
1000
989
|
setCanUndoRedo() {
|
|
@@ -1055,8 +1044,7 @@
|
|
|
1055
1044
|
const { protocol = options.protocol, item } = this.getValueAndProtocol(
|
|
1056
1045
|
storage.getItem(`${options.namespace || namespace}:${key}`)
|
|
1057
1046
|
);
|
|
1058
|
-
if (item === null)
|
|
1059
|
-
return null;
|
|
1047
|
+
if (item === null) return null;
|
|
1060
1048
|
switch (protocol) {
|
|
1061
1049
|
case "object" /* OBJECT */:
|
|
1062
1050
|
return getConfig("parseDSL")(`(${item})`);
|
|
@@ -1197,24 +1185,19 @@
|
|
|
1197
1185
|
const COPY_CODE_STORAGE_KEY = "$MagicEditorCopyCode";
|
|
1198
1186
|
const COPY_DS_STORAGE_KEY = "$MagicEditorCopyDataSource";
|
|
1199
1187
|
const getPageList = (root) => {
|
|
1200
|
-
if (!root)
|
|
1201
|
-
|
|
1202
|
-
if (!Array.isArray(root.items))
|
|
1203
|
-
return [];
|
|
1188
|
+
if (!root) return [];
|
|
1189
|
+
if (!Array.isArray(root.items)) return [];
|
|
1204
1190
|
return root.items.filter((item) => utils.isPage(item));
|
|
1205
1191
|
};
|
|
1206
1192
|
const getPageFragmentList = (root) => {
|
|
1207
|
-
if (!root)
|
|
1208
|
-
|
|
1209
|
-
if (!Array.isArray(root.items))
|
|
1210
|
-
return [];
|
|
1193
|
+
if (!root) return [];
|
|
1194
|
+
if (!Array.isArray(root.items)) return [];
|
|
1211
1195
|
return root.items.filter((item) => utils.isPageFragment(item));
|
|
1212
1196
|
};
|
|
1213
1197
|
const getPageNameList = (pages) => pages.map((page) => page.name || "index");
|
|
1214
1198
|
const generatePageName = (pageNameList, type) => {
|
|
1215
1199
|
let pageLength = pageNameList.length;
|
|
1216
|
-
if (!pageLength)
|
|
1217
|
-
return `${type}_index`;
|
|
1200
|
+
if (!pageLength) return `${type}_index`;
|
|
1218
1201
|
let pageName = `${type}_${pageLength}`;
|
|
1219
1202
|
while (pageNameList.includes(pageName)) {
|
|
1220
1203
|
pageLength += 1;
|
|
@@ -1236,8 +1219,7 @@
|
|
|
1236
1219
|
});
|
|
1237
1220
|
const getMiddleTop = (node, parentNode, stage) => {
|
|
1238
1221
|
let height = node.style?.height || 0;
|
|
1239
|
-
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style)
|
|
1240
|
-
return node.style?.top;
|
|
1222
|
+
if (!stage || typeof node.style?.top !== "undefined" || !parentNode.style) return node.style?.top;
|
|
1241
1223
|
if (!utils.isNumber(height)) {
|
|
1242
1224
|
height = 0;
|
|
1243
1225
|
}
|
|
@@ -1273,11 +1255,9 @@
|
|
|
1273
1255
|
return node;
|
|
1274
1256
|
};
|
|
1275
1257
|
const setLayout = (node, layout) => {
|
|
1276
|
-
if (utils.isPop(node))
|
|
1277
|
-
return;
|
|
1258
|
+
if (utils.isPop(node)) return;
|
|
1278
1259
|
const style = node.style || {};
|
|
1279
|
-
if (style.position === "fixed")
|
|
1280
|
-
return;
|
|
1260
|
+
if (style.position === "fixed") return;
|
|
1281
1261
|
if (layout !== Layout.RELATIVE) {
|
|
1282
1262
|
style.position = "absolute";
|
|
1283
1263
|
} else {
|
|
@@ -1331,8 +1311,7 @@
|
|
|
1331
1311
|
return getRelativeStyle(style);
|
|
1332
1312
|
};
|
|
1333
1313
|
const getGuideLineFromCache = (key) => {
|
|
1334
|
-
if (!key)
|
|
1335
|
-
return [];
|
|
1314
|
+
if (!key) return [];
|
|
1336
1315
|
const guideLineCacheData = globalThis.localStorage.getItem(key);
|
|
1337
1316
|
if (guideLineCacheData) {
|
|
1338
1317
|
try {
|
|
@@ -1344,8 +1323,7 @@
|
|
|
1344
1323
|
return [];
|
|
1345
1324
|
};
|
|
1346
1325
|
const fixNodeLeft = (config, parent, doc) => {
|
|
1347
|
-
if (!doc || !config.style || !utils.isNumber(config.style.left))
|
|
1348
|
-
return config.style?.left;
|
|
1326
|
+
if (!doc || !config.style || !utils.isNumber(config.style.left)) return config.style?.left;
|
|
1349
1327
|
const el = doc.getElementById(`${config.id}`);
|
|
1350
1328
|
const parentEl = doc.getElementById(`${parent.id}`);
|
|
1351
1329
|
const left = Number(config.style?.left) || 0;
|
|
@@ -1374,17 +1352,32 @@
|
|
|
1374
1352
|
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1375
1353
|
const traverseNode = (node, cb, parents = []) => {
|
|
1376
1354
|
cb(node, parents);
|
|
1377
|
-
if (node.items
|
|
1355
|
+
if (Array.isArray(node.items) && node.items.length) {
|
|
1378
1356
|
parents.push(node);
|
|
1379
1357
|
node.items.forEach((item) => {
|
|
1380
1358
|
traverseNode(item, cb, [...parents]);
|
|
1381
1359
|
});
|
|
1382
1360
|
}
|
|
1383
1361
|
};
|
|
1362
|
+
const moveItemsInContainer = (sourceIndices, parent, targetIndex) => {
|
|
1363
|
+
sourceIndices.sort((a, b) => a - b);
|
|
1364
|
+
for (let i = sourceIndices.length - 1; i >= 0; i--) {
|
|
1365
|
+
const sourceIndex = sourceIndices[i];
|
|
1366
|
+
if (sourceIndex === targetIndex) {
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
const [item] = parent.items.splice(sourceIndex, 1);
|
|
1370
|
+
parent.items.splice(sourceIndex < targetIndex ? targetIndex - 1 : targetIndex, 0, item);
|
|
1371
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
1372
|
+
if (sourceIndices[j] >= targetIndex) {
|
|
1373
|
+
sourceIndices[j] += 1;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1384
1378
|
|
|
1385
1379
|
const beforePaste = (position, config, doc) => {
|
|
1386
|
-
if (!config[0]?.style)
|
|
1387
|
-
return config;
|
|
1380
|
+
if (!config[0]?.style) return config;
|
|
1388
1381
|
const curNode = editorService.get("node");
|
|
1389
1382
|
const { left: referenceLeft, top: referenceTop } = config[0].style;
|
|
1390
1383
|
const pasteConfigs = config.map((configItem) => {
|
|
@@ -1554,15 +1547,13 @@
|
|
|
1554
1547
|
parent: null,
|
|
1555
1548
|
page: null
|
|
1556
1549
|
};
|
|
1557
|
-
if (!root)
|
|
1558
|
-
return info;
|
|
1550
|
+
if (!root) return info;
|
|
1559
1551
|
if (id === root.id) {
|
|
1560
1552
|
info.node = root;
|
|
1561
1553
|
return info;
|
|
1562
1554
|
}
|
|
1563
1555
|
const path = utils.getNodePath(id, root.items);
|
|
1564
|
-
if (!path.length)
|
|
1565
|
-
return info;
|
|
1556
|
+
if (!path.length) return info;
|
|
1566
1557
|
path.unshift(root);
|
|
1567
1558
|
info.node = path[path.length - 1];
|
|
1568
1559
|
info.parent = path[path.length - 2];
|
|
@@ -1598,8 +1589,7 @@
|
|
|
1598
1589
|
* 只有容器拥有布局
|
|
1599
1590
|
*/
|
|
1600
1591
|
async getLayout(parent, node) {
|
|
1601
|
-
if (node && typeof node !== "function" && isFixed(node))
|
|
1602
|
-
return Layout.FIXED;
|
|
1592
|
+
if (node && typeof node !== "function" && isFixed(node)) return Layout.FIXED;
|
|
1603
1593
|
if (parent.layout) {
|
|
1604
1594
|
return parent.layout;
|
|
1605
1595
|
}
|
|
@@ -1639,11 +1629,9 @@
|
|
|
1639
1629
|
}
|
|
1640
1630
|
async selectNextNode() {
|
|
1641
1631
|
const node = vue.toRaw(this.get("node"));
|
|
1642
|
-
if (!node || utils.isPage(node) || node.type === schema.NodeType.ROOT)
|
|
1643
|
-
return node;
|
|
1632
|
+
if (!node || utils.isPage(node) || node.type === schema.NodeType.ROOT) return node;
|
|
1644
1633
|
const parent = vue.toRaw(this.getParentById(node.id));
|
|
1645
|
-
if (!parent)
|
|
1646
|
-
return node;
|
|
1634
|
+
if (!parent) return node;
|
|
1647
1635
|
const index = getNodeIndex(node.id, parent);
|
|
1648
1636
|
const nextNode = parent.items[index + 1] || parent.items[0];
|
|
1649
1637
|
await this.select(nextNode);
|
|
@@ -1653,10 +1641,8 @@
|
|
|
1653
1641
|
async selectNextPage() {
|
|
1654
1642
|
const root = vue.toRaw(this.get("root"));
|
|
1655
1643
|
const page = vue.toRaw(this.get("page"));
|
|
1656
|
-
if (!page)
|
|
1657
|
-
|
|
1658
|
-
if (!root)
|
|
1659
|
-
throw new Error("root不能为空");
|
|
1644
|
+
if (!page) throw new Error("page不能为空");
|
|
1645
|
+
if (!root) throw new Error("root不能为空");
|
|
1660
1646
|
const index = getNodeIndex(page.id, root);
|
|
1661
1647
|
const nextPage = root.items[index + 1] || root.items[0];
|
|
1662
1648
|
await this.select(nextPage);
|
|
@@ -1671,8 +1657,7 @@
|
|
|
1671
1657
|
highlight(config) {
|
|
1672
1658
|
const { node } = this.selectedConfigExceptionHandler(config);
|
|
1673
1659
|
const currentHighlightNode = this.get("highlightNode");
|
|
1674
|
-
if (currentHighlightNode === node)
|
|
1675
|
-
return;
|
|
1660
|
+
if (currentHighlightNode === node) return;
|
|
1676
1661
|
this.set("highlightNode", node);
|
|
1677
1662
|
}
|
|
1678
1663
|
/**
|
|
@@ -1685,16 +1670,14 @@
|
|
|
1685
1670
|
const idsUnique = lodashEs.uniq(ids);
|
|
1686
1671
|
idsUnique.forEach((id) => {
|
|
1687
1672
|
const { node } = this.getNodeInfo(id);
|
|
1688
|
-
if (!node)
|
|
1689
|
-
return;
|
|
1673
|
+
if (!node) return;
|
|
1690
1674
|
nodes.push(node);
|
|
1691
1675
|
});
|
|
1692
1676
|
this.set("nodes", nodes);
|
|
1693
1677
|
}
|
|
1694
1678
|
selectRoot() {
|
|
1695
1679
|
const root = this.get("root");
|
|
1696
|
-
if (!root)
|
|
1697
|
-
return;
|
|
1680
|
+
if (!root) return;
|
|
1698
1681
|
this.set("nodes", [root]);
|
|
1699
1682
|
this.set("parent", null);
|
|
1700
1683
|
this.set("page", null);
|
|
@@ -1703,12 +1686,10 @@
|
|
|
1703
1686
|
}
|
|
1704
1687
|
async doAdd(node, parent) {
|
|
1705
1688
|
const root = this.get("root");
|
|
1706
|
-
if (!root)
|
|
1707
|
-
throw new Error("root为空");
|
|
1689
|
+
if (!root) throw new Error("root为空");
|
|
1708
1690
|
const curNode = this.get("node");
|
|
1709
1691
|
const stage = this.get("stage");
|
|
1710
|
-
if (!curNode)
|
|
1711
|
-
throw new Error("当前选中节点为空");
|
|
1692
|
+
if (!curNode) throw new Error("当前选中节点为空");
|
|
1712
1693
|
if ((parent.type === schema.NodeType.ROOT || curNode?.type === schema.NodeType.ROOT) && !(utils.isPage(node) || utils.isPageFragment(node))) {
|
|
1713
1694
|
throw new Error("app下不能添加组件");
|
|
1714
1695
|
}
|
|
@@ -1745,8 +1726,7 @@
|
|
|
1745
1726
|
const addNodes = [];
|
|
1746
1727
|
if (!Array.isArray(addNode)) {
|
|
1747
1728
|
const { type, inputEvent, ...config } = addNode;
|
|
1748
|
-
if (!type)
|
|
1749
|
-
throw new Error("组件类型不能为空");
|
|
1729
|
+
if (!type) throw new Error("组件类型不能为空");
|
|
1750
1730
|
addNodes.push({ ...vue.toRaw(await propsService.getPropsValue(type, config)) });
|
|
1751
1731
|
} else {
|
|
1752
1732
|
addNodes.push(...addNode);
|
|
@@ -1758,8 +1738,7 @@
|
|
|
1758
1738
|
return this.doAdd(node, root);
|
|
1759
1739
|
}
|
|
1760
1740
|
const parentNode = parent && typeof parent !== "function" ? parent : getAddParent(node);
|
|
1761
|
-
if (!parentNode)
|
|
1762
|
-
throw new Error("未找到父元素");
|
|
1741
|
+
if (!parentNode) throw new Error("未找到父元素");
|
|
1763
1742
|
return this.doAdd(node, parentNode);
|
|
1764
1743
|
})
|
|
1765
1744
|
);
|
|
@@ -1785,14 +1764,11 @@
|
|
|
1785
1764
|
}
|
|
1786
1765
|
async doRemove(node) {
|
|
1787
1766
|
const root = this.get("root");
|
|
1788
|
-
if (!root)
|
|
1789
|
-
throw new Error("root不能为空");
|
|
1767
|
+
if (!root) throw new Error("root不能为空");
|
|
1790
1768
|
const { parent, node: curNode } = this.getNodeInfo(node.id, false);
|
|
1791
|
-
if (!parent || !curNode)
|
|
1792
|
-
throw new Error("找不要删除的节点");
|
|
1769
|
+
if (!parent || !curNode) throw new Error("找不要删除的节点");
|
|
1793
1770
|
const index = getNodeIndex(curNode.id, parent);
|
|
1794
|
-
if (typeof index !== "number" || index === -1)
|
|
1795
|
-
throw new Error("找不要删除的节点");
|
|
1771
|
+
if (typeof index !== "number" || index === -1) throw new Error("找不要删除的节点");
|
|
1796
1772
|
parent.items?.splice(index, 1);
|
|
1797
1773
|
const stage = this.get("stage");
|
|
1798
1774
|
stage?.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
@@ -1836,13 +1812,10 @@
|
|
|
1836
1812
|
}
|
|
1837
1813
|
async doUpdate(config) {
|
|
1838
1814
|
const root = this.get("root");
|
|
1839
|
-
if (!root)
|
|
1840
|
-
|
|
1841
|
-
if (!config?.id)
|
|
1842
|
-
throw new Error("没有配置或者配置缺少id值");
|
|
1815
|
+
if (!root) throw new Error("root为空");
|
|
1816
|
+
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
1843
1817
|
const info = this.getNodeInfo(config.id, false);
|
|
1844
|
-
if (!info.node)
|
|
1845
|
-
throw new Error(`获取不到id为${config.id}的节点`);
|
|
1818
|
+
if (!info.node) throw new Error(`获取不到id为${config.id}的节点`);
|
|
1846
1819
|
const node = lodashEs.cloneDeep(vue.toRaw(info.node));
|
|
1847
1820
|
let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, root);
|
|
1848
1821
|
newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue, key) => {
|
|
@@ -1856,19 +1829,16 @@
|
|
|
1856
1829
|
return srcValue;
|
|
1857
1830
|
}
|
|
1858
1831
|
});
|
|
1859
|
-
if (!newConfig.type)
|
|
1860
|
-
throw new Error("配置缺少type值");
|
|
1832
|
+
if (!newConfig.type) throw new Error("配置缺少type值");
|
|
1861
1833
|
if (newConfig.type === schema.NodeType.ROOT) {
|
|
1862
1834
|
this.set("root", newConfig);
|
|
1863
1835
|
return newConfig;
|
|
1864
1836
|
}
|
|
1865
1837
|
const { parent } = info;
|
|
1866
|
-
if (!parent)
|
|
1867
|
-
throw new Error("获取不到父级节点");
|
|
1838
|
+
if (!parent) throw new Error("获取不到父级节点");
|
|
1868
1839
|
const parentNodeItems = parent.items;
|
|
1869
1840
|
const index = getNodeIndex(newConfig.id, parent);
|
|
1870
|
-
if (!parentNodeItems || typeof index === "undefined" || index === -1)
|
|
1871
|
-
throw new Error("更新的节点未找到");
|
|
1841
|
+
if (!parentNodeItems || typeof index === "undefined" || index === -1) throw new Error("更新的节点未找到");
|
|
1872
1842
|
const newLayout = await this.getLayout(newConfig);
|
|
1873
1843
|
const layout = await this.getLayout(node);
|
|
1874
1844
|
if (Array.isArray(newConfig.items) && newLayout !== layout) {
|
|
@@ -1912,17 +1882,13 @@
|
|
|
1912
1882
|
*/
|
|
1913
1883
|
async sort(id1, id2) {
|
|
1914
1884
|
const root = this.get("root");
|
|
1915
|
-
if (!root)
|
|
1916
|
-
throw new Error("root为空");
|
|
1885
|
+
if (!root) throw new Error("root为空");
|
|
1917
1886
|
const node = this.get("node");
|
|
1918
|
-
if (!node)
|
|
1919
|
-
throw new Error("当前节点为空");
|
|
1887
|
+
if (!node) throw new Error("当前节点为空");
|
|
1920
1888
|
const parent = lodashEs.cloneDeep(vue.toRaw(this.get("parent")));
|
|
1921
|
-
if (!parent)
|
|
1922
|
-
throw new Error("父节点为空");
|
|
1889
|
+
if (!parent) throw new Error("父节点为空");
|
|
1923
1890
|
const index2 = parent.items.findIndex((node2) => `${node2.id}` === `${id2}`);
|
|
1924
|
-
if (index2 < 0)
|
|
1925
|
-
return;
|
|
1891
|
+
if (index2 < 0) return;
|
|
1926
1892
|
const index1 = parent.items.findIndex((node2) => `${node2.id}` === `${id1}`);
|
|
1927
1893
|
parent.items.splice(index2, 0, ...parent.items.splice(index1, 1));
|
|
1928
1894
|
await this.update(parent);
|
|
@@ -1961,8 +1927,7 @@
|
|
|
1961
1927
|
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
1962
1928
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
1963
1929
|
const node = this.getNodeById(nodeId);
|
|
1964
|
-
if (!node)
|
|
1965
|
-
return;
|
|
1930
|
+
if (!node) return;
|
|
1966
1931
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
1967
1932
|
const relateNodeId = lodashEs.get(node, key);
|
|
1968
1933
|
const isExist = copyNodes.find((node2) => node2.id === relateNodeId);
|
|
@@ -1986,8 +1951,7 @@
|
|
|
1986
1951
|
*/
|
|
1987
1952
|
async paste(position = {}, collectorOptions) {
|
|
1988
1953
|
const config = storageService.getItem(COPY_STORAGE_KEY);
|
|
1989
|
-
if (!Array.isArray(config))
|
|
1990
|
-
return;
|
|
1954
|
+
if (!Array.isArray(config)) return;
|
|
1991
1955
|
const node = this.get("node");
|
|
1992
1956
|
let parent = null;
|
|
1993
1957
|
if (config.length === 1 && config[0].id === node?.id) {
|
|
@@ -2010,15 +1974,13 @@
|
|
|
2010
1974
|
}
|
|
2011
1975
|
async doAlignCenter(config) {
|
|
2012
1976
|
const parent = this.getParentById(config.id);
|
|
2013
|
-
if (!parent)
|
|
2014
|
-
throw new Error("找不到父节点");
|
|
1977
|
+
if (!parent) throw new Error("找不到父节点");
|
|
2015
1978
|
const node = lodashEs.cloneDeep(vue.toRaw(config));
|
|
2016
1979
|
const layout = await this.getLayout(parent, node);
|
|
2017
1980
|
if (layout === Layout.RELATIVE) {
|
|
2018
1981
|
return config;
|
|
2019
1982
|
}
|
|
2020
|
-
if (!node.style)
|
|
2021
|
-
return config;
|
|
1983
|
+
if (!node.style) return config;
|
|
2022
1984
|
const stage = this.get("stage");
|
|
2023
1985
|
const doc = stage?.renderer.contentWindow?.document;
|
|
2024
1986
|
if (doc) {
|
|
@@ -2057,14 +2019,11 @@
|
|
|
2057
2019
|
*/
|
|
2058
2020
|
async moveLayer(offset) {
|
|
2059
2021
|
const root = this.get("root");
|
|
2060
|
-
if (!root)
|
|
2061
|
-
throw new Error("root为空");
|
|
2022
|
+
if (!root) throw new Error("root为空");
|
|
2062
2023
|
const parent = this.get("parent");
|
|
2063
|
-
if (!parent)
|
|
2064
|
-
throw new Error("父节点为空");
|
|
2024
|
+
if (!parent) throw new Error("父节点为空");
|
|
2065
2025
|
const node = this.get("node");
|
|
2066
|
-
if (!node)
|
|
2067
|
-
throw new Error("当前节点为空");
|
|
2026
|
+
if (!node) throw new Error("当前节点为空");
|
|
2068
2027
|
const brothers = parent.items || [];
|
|
2069
2028
|
const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
|
|
2070
2029
|
const layout = await this.getLayout(parent, node);
|
|
@@ -2126,28 +2085,35 @@
|
|
|
2126
2085
|
}
|
|
2127
2086
|
}
|
|
2128
2087
|
async dragTo(config, targetParent, targetIndex) {
|
|
2129
|
-
if (!targetParent || !Array.isArray(targetParent.items))
|
|
2130
|
-
|
|
2131
|
-
const
|
|
2132
|
-
|
|
2133
|
-
throw new Error("找不要删除的节点");
|
|
2134
|
-
const index = getNodeIndex(curNode.id, parent);
|
|
2135
|
-
if (typeof index !== "number" || index === -1)
|
|
2136
|
-
throw new Error("找不要删除的节点");
|
|
2137
|
-
if (parent.id === targetParent.id) {
|
|
2138
|
-
if (index === targetIndex)
|
|
2139
|
-
return;
|
|
2140
|
-
if (index < targetIndex) {
|
|
2141
|
-
targetIndex -= 1;
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
const layout = await this.getLayout(parent);
|
|
2088
|
+
if (!targetParent || !Array.isArray(targetParent.items)) return;
|
|
2089
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
2090
|
+
const sourceIndicesInTargetParent = [];
|
|
2091
|
+
const sourceOutTargetParent = [];
|
|
2145
2092
|
const newLayout = await this.getLayout(targetParent);
|
|
2146
|
-
|
|
2147
|
-
|
|
2093
|
+
for (const config2 of configs) {
|
|
2094
|
+
const { parent, node: curNode } = this.getNodeInfo(config2.id, false);
|
|
2095
|
+
if (!parent || !curNode) throw new Error("找不要删除的节点");
|
|
2096
|
+
const index = getNodeIndex(curNode.id, parent);
|
|
2097
|
+
if (parent.id === targetParent.id) {
|
|
2098
|
+
if (typeof index !== "number" || index === -1) {
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
sourceIndicesInTargetParent.push(index);
|
|
2102
|
+
} else {
|
|
2103
|
+
const layout = await this.getLayout(parent);
|
|
2104
|
+
if (newLayout !== layout) {
|
|
2105
|
+
setLayout(config2, newLayout);
|
|
2106
|
+
}
|
|
2107
|
+
parent.items?.splice(index, 1);
|
|
2108
|
+
sourceOutTargetParent.push(config2);
|
|
2109
|
+
this.addModifiedNodeId(parent.id);
|
|
2110
|
+
}
|
|
2148
2111
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
2112
|
+
moveItemsInContainer(sourceIndicesInTargetParent, targetParent, targetIndex);
|
|
2113
|
+
sourceOutTargetParent.forEach((config2, index) => {
|
|
2114
|
+
targetParent.items?.splice(targetIndex + index, 0, config2);
|
|
2115
|
+
this.addModifiedNodeId(config2.id);
|
|
2116
|
+
});
|
|
2151
2117
|
const page = this.get("page");
|
|
2152
2118
|
const root = this.get("root");
|
|
2153
2119
|
const stage = this.get("stage");
|
|
@@ -2158,10 +2124,8 @@
|
|
|
2158
2124
|
root: lodashEs.cloneDeep(root)
|
|
2159
2125
|
});
|
|
2160
2126
|
}
|
|
2161
|
-
this.addModifiedNodeId(config.id);
|
|
2162
|
-
this.addModifiedNodeId(parent.id);
|
|
2163
2127
|
this.pushHistoryState();
|
|
2164
|
-
this.emit("drag-to", {
|
|
2128
|
+
this.emit("drag-to", { targetIndex, configs, targetParent });
|
|
2165
2129
|
}
|
|
2166
2130
|
/**
|
|
2167
2131
|
* 撤销当前操作
|
|
@@ -2183,11 +2147,9 @@
|
|
|
2183
2147
|
}
|
|
2184
2148
|
async move(left, top) {
|
|
2185
2149
|
const node = vue.toRaw(this.get("node"));
|
|
2186
|
-
if (!node || utils.isPage(node))
|
|
2187
|
-
return;
|
|
2150
|
+
if (!node || utils.isPage(node)) return;
|
|
2188
2151
|
const { style, id, type } = node;
|
|
2189
|
-
if (!style || !["absolute", "fixed"].includes(style.position))
|
|
2190
|
-
return;
|
|
2152
|
+
if (!style || !["absolute", "fixed"].includes(style.position)) return;
|
|
2191
2153
|
const update = (style2) => this.update({
|
|
2192
2154
|
id,
|
|
2193
2155
|
type,
|
|
@@ -2246,6 +2208,15 @@
|
|
|
2246
2208
|
usePlugin(options) {
|
|
2247
2209
|
super.usePlugin(options);
|
|
2248
2210
|
}
|
|
2211
|
+
on(eventName, listener) {
|
|
2212
|
+
return super.on(eventName, listener);
|
|
2213
|
+
}
|
|
2214
|
+
once(eventName, listener) {
|
|
2215
|
+
return super.once(eventName, listener);
|
|
2216
|
+
}
|
|
2217
|
+
emit(eventName, ...args) {
|
|
2218
|
+
return super.emit(eventName, ...args);
|
|
2219
|
+
}
|
|
2249
2220
|
addModifiedNodeId(id) {
|
|
2250
2221
|
if (!this.isHistoryStateChange) {
|
|
2251
2222
|
this.get("modifiedNodeIds").set(id, id);
|
|
@@ -2264,14 +2235,12 @@
|
|
|
2264
2235
|
this.isHistoryStateChange = false;
|
|
2265
2236
|
}
|
|
2266
2237
|
async changeHistoryState(value) {
|
|
2267
|
-
if (!value)
|
|
2268
|
-
return;
|
|
2238
|
+
if (!value) return;
|
|
2269
2239
|
this.isHistoryStateChange = true;
|
|
2270
2240
|
await this.update(value.data);
|
|
2271
2241
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2272
2242
|
setTimeout(async () => {
|
|
2273
|
-
if (!value.nodeId)
|
|
2274
|
-
return;
|
|
2243
|
+
if (!value.nodeId) return;
|
|
2275
2244
|
await this.select(value.nodeId);
|
|
2276
2245
|
this.get("stage")?.select(value.nodeId);
|
|
2277
2246
|
}, 0);
|
|
@@ -2299,8 +2268,7 @@
|
|
|
2299
2268
|
throw new Error("没有ID,无法选中");
|
|
2300
2269
|
}
|
|
2301
2270
|
const { node, parent, page } = this.getNodeInfo(id);
|
|
2302
|
-
if (!node)
|
|
2303
|
-
throw new Error("获取不到组件信息");
|
|
2271
|
+
if (!node) throw new Error("获取不到组件信息");
|
|
2304
2272
|
if (node.id === this.state.root?.id) {
|
|
2305
2273
|
throw new Error("不能选根节点");
|
|
2306
2274
|
}
|
|
@@ -2545,8 +2513,7 @@
|
|
|
2545
2513
|
const matches = key.matchAll(/\$\{([\s\S]+?)\}/g);
|
|
2546
2514
|
let index = 0;
|
|
2547
2515
|
for (const match of matches) {
|
|
2548
|
-
if (typeof match.index === "undefined")
|
|
2549
|
-
break;
|
|
2516
|
+
if (typeof match.index === "undefined") break;
|
|
2550
2517
|
displayState.push({
|
|
2551
2518
|
type: "text",
|
|
2552
2519
|
value: key.substring(index, match.index)
|
|
@@ -2727,8 +2694,7 @@
|
|
|
2727
2694
|
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
2728
2695
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
2729
2696
|
const node = editorService.getNodeById(nodeId);
|
|
2730
|
-
if (!node)
|
|
2731
|
-
return;
|
|
2697
|
+
if (!node) return;
|
|
2732
2698
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
2733
2699
|
const [relateDsId] = lodashEs.get(node, key);
|
|
2734
2700
|
const isExist = copyData.find((dsItem) => dsItem.id === relateDsId);
|
|
@@ -3323,11 +3289,9 @@
|
|
|
3323
3289
|
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
|
|
3324
3290
|
);
|
|
3325
3291
|
const getParamItemsConfig = (codeId) => {
|
|
3326
|
-
if (!codeDsl.value || !codeId)
|
|
3327
|
-
return [];
|
|
3292
|
+
if (!codeDsl.value || !codeId) return [];
|
|
3328
3293
|
const paramStatements = codeDsl.value[codeId]?.params;
|
|
3329
|
-
if (lodashEs.isEmpty(paramStatements))
|
|
3330
|
-
return [];
|
|
3294
|
+
if (lodashEs.isEmpty(paramStatements)) return [];
|
|
3331
3295
|
return paramStatements.map((paramState) => ({
|
|
3332
3296
|
labelWidth: "100px",
|
|
3333
3297
|
text: paramState.name,
|
|
@@ -3627,8 +3591,7 @@
|
|
|
3627
3591
|
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3628
3592
|
};
|
|
3629
3593
|
const submitCodeBlockHandler = async (values) => {
|
|
3630
|
-
if (!codeId.value)
|
|
3631
|
-
return;
|
|
3594
|
+
if (!codeId.value) return;
|
|
3632
3595
|
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
3633
3596
|
codeBlockEditor.value?.hide();
|
|
3634
3597
|
};
|
|
@@ -3684,8 +3647,7 @@
|
|
|
3684
3647
|
codeBlockEditor.value?.show();
|
|
3685
3648
|
},
|
|
3686
3649
|
deleteCode: async (model, methodName) => {
|
|
3687
|
-
if (!model.methods)
|
|
3688
|
-
return;
|
|
3650
|
+
if (!model.methods) return;
|
|
3689
3651
|
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
3690
3652
|
if (index === -1) {
|
|
3691
3653
|
return;
|
|
@@ -3693,8 +3655,7 @@
|
|
|
3693
3655
|
model.methods.splice(index, 1);
|
|
3694
3656
|
},
|
|
3695
3657
|
submitCode: (values) => {
|
|
3696
|
-
if (!dataSource.value)
|
|
3697
|
-
return;
|
|
3658
|
+
if (!dataSource.value) return;
|
|
3698
3659
|
if (!dataSource.value.methods) {
|
|
3699
3660
|
dataSource.value.methods = [];
|
|
3700
3661
|
}
|
|
@@ -3778,14 +3739,12 @@
|
|
|
3778
3739
|
}
|
|
3779
3740
|
async zoom(zoom) {
|
|
3780
3741
|
this.set("zoom", (this.get("zoom") * 100 + zoom * 100) / 100);
|
|
3781
|
-
if (this.get("zoom") < 0.1)
|
|
3782
|
-
this.set("zoom", 0.1);
|
|
3742
|
+
if (this.get("zoom") < 0.1) this.set("zoom", 0.1);
|
|
3783
3743
|
}
|
|
3784
3744
|
async calcZoom() {
|
|
3785
3745
|
const { stageRect, stageContainerRect } = state;
|
|
3786
3746
|
const { height, width } = stageContainerRect;
|
|
3787
|
-
if (!width || !height)
|
|
3788
|
-
return 1;
|
|
3747
|
+
if (!width || !height) return 1;
|
|
3789
3748
|
let stageWidth = utils.convertToNumber(stageRect.width, width);
|
|
3790
3749
|
let stageHeight = utils.convertToNumber(stageRect.height, height);
|
|
3791
3750
|
stageWidth = stageWidth + 30;
|
|
@@ -3840,8 +3799,7 @@
|
|
|
3840
3799
|
disabledDragStart: stageOptions.disabledDragStart,
|
|
3841
3800
|
renderType: stageOptions.renderType,
|
|
3842
3801
|
canSelect: (el, event, stop) => {
|
|
3843
|
-
if (!stageOptions.canSelect)
|
|
3844
|
-
return true;
|
|
3802
|
+
if (!stageOptions.canSelect) return true;
|
|
3845
3803
|
const elCanSelect = stageOptions.canSelect?.(el);
|
|
3846
3804
|
if (uiSelectMode.value && elCanSelect && event.type === "mousedown") {
|
|
3847
3805
|
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: el }));
|
|
@@ -3872,8 +3830,7 @@
|
|
|
3872
3830
|
editorService.set("stageLoading", false);
|
|
3873
3831
|
});
|
|
3874
3832
|
stage.on("select", (el) => {
|
|
3875
|
-
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1)
|
|
3876
|
-
return;
|
|
3833
|
+
if (`${editorService.get("node")?.id}` === el.id && editorService.get("nodes").length === 1) return;
|
|
3877
3834
|
editorService.select(el.id);
|
|
3878
3835
|
});
|
|
3879
3836
|
stage.on("highlight", (el) => {
|
|
@@ -3900,15 +3857,13 @@
|
|
|
3900
3857
|
});
|
|
3901
3858
|
stage.on("select-parent", () => {
|
|
3902
3859
|
const parent = editorService.get("parent");
|
|
3903
|
-
if (!parent)
|
|
3904
|
-
throw new Error("父节点为空");
|
|
3860
|
+
if (!parent) throw new Error("父节点为空");
|
|
3905
3861
|
editorService.select(parent);
|
|
3906
3862
|
editorService.get("stage")?.select(parent.id);
|
|
3907
3863
|
});
|
|
3908
3864
|
stage.on("change-guides", (e) => {
|
|
3909
3865
|
uiService.set("showGuides", true);
|
|
3910
|
-
if (!root.value || !page.value)
|
|
3911
|
-
return;
|
|
3866
|
+
if (!root.value || !page.value) return;
|
|
3912
3867
|
const storageKey = getGuideLineKey(
|
|
3913
3868
|
e.type === StageCore.GuidesType.HORIZONTAL ? H_GUIDE_LINE_STORAGE_KEY : V_GUIDE_LINE_STORAGE_KEY
|
|
3914
3869
|
);
|
|
@@ -3951,8 +3906,7 @@
|
|
|
3951
3906
|
isDragging.value = false;
|
|
3952
3907
|
};
|
|
3953
3908
|
document.body.addEventListener("dragover", (e) => {
|
|
3954
|
-
if (!isDragging.value)
|
|
3955
|
-
return;
|
|
3909
|
+
if (!isDragging.value) return;
|
|
3956
3910
|
e.preventDefault();
|
|
3957
3911
|
});
|
|
3958
3912
|
vue.watch(
|
|
@@ -4005,8 +3959,7 @@
|
|
|
4005
3959
|
vue.watch(
|
|
4006
3960
|
editorContentHeight,
|
|
4007
3961
|
() => {
|
|
4008
|
-
if (height.value > 0 && height.value === editorContentHeight.value)
|
|
4009
|
-
return;
|
|
3962
|
+
if (height.value > 0 && height.value === editorContentHeight.value) return;
|
|
4010
3963
|
height.value = editorContentHeight.value;
|
|
4011
3964
|
},
|
|
4012
3965
|
{
|
|
@@ -4199,12 +4152,9 @@
|
|
|
4199
4152
|
height: "200px",
|
|
4200
4153
|
parse: true,
|
|
4201
4154
|
type: (mForm, { model }) => {
|
|
4202
|
-
if (model.type === "number")
|
|
4203
|
-
|
|
4204
|
-
if (model.type === "
|
|
4205
|
-
return "select";
|
|
4206
|
-
if (model.type === "string")
|
|
4207
|
-
return "text";
|
|
4155
|
+
if (model.type === "number") return "number";
|
|
4156
|
+
if (model.type === "boolean") return "select";
|
|
4157
|
+
if (model.type === "string") return "text";
|
|
4208
4158
|
return "vs-code";
|
|
4209
4159
|
},
|
|
4210
4160
|
options: [
|
|
@@ -4244,23 +4194,16 @@
|
|
|
4244
4194
|
addFromJsonDialogVisible.value = true;
|
|
4245
4195
|
};
|
|
4246
4196
|
const getValueType = (value) => {
|
|
4247
|
-
if (Array.isArray(value))
|
|
4248
|
-
|
|
4249
|
-
if (value ===
|
|
4250
|
-
|
|
4251
|
-
if (typeof value === "
|
|
4252
|
-
|
|
4253
|
-
if (typeof value === "number")
|
|
4254
|
-
return "number";
|
|
4255
|
-
if (typeof value === "boolean")
|
|
4256
|
-
return "boolean";
|
|
4257
|
-
if (typeof value === "string")
|
|
4258
|
-
return "string";
|
|
4197
|
+
if (Array.isArray(value)) return "array";
|
|
4198
|
+
if (value === null) return "null";
|
|
4199
|
+
if (typeof value === "object") return "object";
|
|
4200
|
+
if (typeof value === "number") return "number";
|
|
4201
|
+
if (typeof value === "boolean") return "boolean";
|
|
4202
|
+
if (typeof value === "string") return "string";
|
|
4259
4203
|
return "any";
|
|
4260
4204
|
};
|
|
4261
4205
|
const getFieldsConfig = (value, fields = []) => {
|
|
4262
|
-
if (!value || typeof value !== "object")
|
|
4263
|
-
throw new Error("数据格式错误");
|
|
4206
|
+
if (!value || typeof value !== "object") throw new Error("数据格式错误");
|
|
4264
4207
|
const newFields = [];
|
|
4265
4208
|
Object.entries(value).forEach(([key, value2]) => {
|
|
4266
4209
|
const type = getValueType(value2);
|
|
@@ -4450,10 +4393,8 @@
|
|
|
4450
4393
|
model: props.model
|
|
4451
4394
|
});
|
|
4452
4395
|
}
|
|
4453
|
-
if (type2 === "form")
|
|
4454
|
-
|
|
4455
|
-
if (type2 === "container")
|
|
4456
|
-
return "";
|
|
4396
|
+
if (type2 === "form") return "";
|
|
4397
|
+
if (type2 === "container") return "";
|
|
4457
4398
|
return type2?.replace(/([A-Z])/g, "-$1").toLowerCase() || (props.config.items ? "" : "text");
|
|
4458
4399
|
});
|
|
4459
4400
|
const tagName = vue.computed(() => {
|
|
@@ -4461,8 +4402,7 @@
|
|
|
4461
4402
|
return form.MCascader;
|
|
4462
4403
|
}
|
|
4463
4404
|
const component = vue.resolveComponent(`m-${props.config.items ? "form" : "fields"}-${type.value}`);
|
|
4464
|
-
if (typeof component !== "string")
|
|
4465
|
-
return component;
|
|
4405
|
+
if (typeof component !== "string") return component;
|
|
4466
4406
|
return "m-fields-text";
|
|
4467
4407
|
});
|
|
4468
4408
|
const onChangeHandler = (value) => {
|
|
@@ -4557,9 +4497,15 @@
|
|
|
4557
4497
|
{ immediate: true }
|
|
4558
4498
|
);
|
|
4559
4499
|
const mouseupHandler = async () => {
|
|
4500
|
+
const selection = globalThis.document.getSelection();
|
|
4501
|
+
const anchorOffset = selection?.anchorOffset || 0;
|
|
4502
|
+
const focusOffset = selection?.focusOffset || 0;
|
|
4560
4503
|
isFocused.value = true;
|
|
4561
4504
|
await vue.nextTick();
|
|
4562
4505
|
autocomplete.value?.focus();
|
|
4506
|
+
if (focusOffset && input.value) {
|
|
4507
|
+
input.value.setSelectionRange(anchorOffset, focusOffset);
|
|
4508
|
+
}
|
|
4563
4509
|
};
|
|
4564
4510
|
const blurHandler = () => {
|
|
4565
4511
|
isFocused.value = false;
|
|
@@ -5198,11 +5144,9 @@
|
|
|
5198
5144
|
return Boolean(dataSource?.methods.find((method) => method.name === name));
|
|
5199
5145
|
});
|
|
5200
5146
|
const getParamItemsConfig = ([dataSourceId, methodName] = ["", ""]) => {
|
|
5201
|
-
if (!dataSourceId)
|
|
5202
|
-
return [];
|
|
5147
|
+
if (!dataSourceId) return [];
|
|
5203
5148
|
const paramStatements = dataSources.value?.find((item) => item.id === dataSourceId)?.methods?.find((item) => item.name === methodName)?.params;
|
|
5204
|
-
if (!paramStatements)
|
|
5205
|
-
return [];
|
|
5149
|
+
if (!paramStatements) return [];
|
|
5206
5150
|
return paramStatements.map((paramState) => ({
|
|
5207
5151
|
text: paramState.name,
|
|
5208
5152
|
...paramState
|
|
@@ -5247,8 +5191,7 @@
|
|
|
5247
5191
|
const editCodeHandler = () => {
|
|
5248
5192
|
const [id] = props.model[props.name];
|
|
5249
5193
|
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5250
|
-
if (!dataSource)
|
|
5251
|
-
return;
|
|
5194
|
+
if (!dataSource) return;
|
|
5252
5195
|
eventBus?.emit("edit-data-source", id);
|
|
5253
5196
|
};
|
|
5254
5197
|
return (_ctx, _cache) => {
|
|
@@ -5359,15 +5302,13 @@
|
|
|
5359
5302
|
defaultValue: "{}",
|
|
5360
5303
|
height: "400px",
|
|
5361
5304
|
onChange: (formState, v) => {
|
|
5362
|
-
if (typeof v !== "string")
|
|
5363
|
-
return v;
|
|
5305
|
+
if (typeof v !== "string") return v;
|
|
5364
5306
|
return JSON.parse(v);
|
|
5365
5307
|
},
|
|
5366
5308
|
rules: [
|
|
5367
5309
|
{
|
|
5368
5310
|
validator: ({ value, callback }) => {
|
|
5369
|
-
if (typeof value !== "string")
|
|
5370
|
-
return callback();
|
|
5311
|
+
if (typeof value !== "string") return callback();
|
|
5371
5312
|
try {
|
|
5372
5313
|
JSON.parse(value);
|
|
5373
5314
|
callback();
|
|
@@ -5595,12 +5536,10 @@
|
|
|
5595
5536
|
};
|
|
5596
5537
|
const editHandler = () => {
|
|
5597
5538
|
const value = props.model[props.name];
|
|
5598
|
-
if (!value)
|
|
5599
|
-
return;
|
|
5539
|
+
if (!value) return;
|
|
5600
5540
|
const id = typeof value === "string" ? value : value.dataSourceId;
|
|
5601
5541
|
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5602
|
-
if (!dataSource)
|
|
5603
|
-
return;
|
|
5542
|
+
if (!dataSource) return;
|
|
5604
5543
|
eventBus?.emit("edit-data-source", id);
|
|
5605
5544
|
};
|
|
5606
5545
|
return (_ctx, _cache) => {
|
|
@@ -5678,8 +5617,7 @@
|
|
|
5678
5617
|
valueSeparator: ".",
|
|
5679
5618
|
options: (mForm, { formValue }) => {
|
|
5680
5619
|
let events = [];
|
|
5681
|
-
if (!eventsService || !dataSourceService)
|
|
5682
|
-
return events;
|
|
5620
|
+
if (!eventsService || !dataSourceService) return events;
|
|
5683
5621
|
if (props.config.src === "component") {
|
|
5684
5622
|
events = eventsService.getEvent(formValue.type);
|
|
5685
5623
|
if (formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
|
|
@@ -5786,8 +5724,7 @@
|
|
|
5786
5724
|
display: (mForm, { model }) => model.actionType === schema.ActionType.COMP,
|
|
5787
5725
|
options: (mForm, { model }) => {
|
|
5788
5726
|
const node = editorService?.getNodeById(model.to);
|
|
5789
|
-
if (!node?.type)
|
|
5790
|
-
return [];
|
|
5727
|
+
if (!node?.type) return [];
|
|
5791
5728
|
let methods = [];
|
|
5792
5729
|
methods = eventsService?.getMethod(node.type) || [];
|
|
5793
5730
|
if (node.type === "page-fragment-container" && node.pageFragmentId) {
|
|
@@ -5861,8 +5798,7 @@
|
|
|
5861
5798
|
type: compActionConfig.value.type,
|
|
5862
5799
|
options: (mForm, { model }) => {
|
|
5863
5800
|
const node = editorService?.getNodeById(model.to);
|
|
5864
|
-
if (!node?.type)
|
|
5865
|
-
return [];
|
|
5801
|
+
if (!node?.type) return [];
|
|
5866
5802
|
return eventsService?.getMethod(node.type).map((option) => ({
|
|
5867
5803
|
text: option.label,
|
|
5868
5804
|
value: option.value
|
|
@@ -5891,8 +5827,7 @@
|
|
|
5891
5827
|
]
|
|
5892
5828
|
}));
|
|
5893
5829
|
const isOldVersion = vue.computed(() => {
|
|
5894
|
-
if (props.model[props.name].length === 0)
|
|
5895
|
-
return false;
|
|
5830
|
+
if (props.model[props.name].length === 0) return false;
|
|
5896
5831
|
return !lodashEs.has(props.model[props.name][0], "actions");
|
|
5897
5832
|
});
|
|
5898
5833
|
const addEvent = () => {
|
|
@@ -5907,8 +5842,7 @@
|
|
|
5907
5842
|
onChangeHandler();
|
|
5908
5843
|
};
|
|
5909
5844
|
const removeEvent = (index) => {
|
|
5910
|
-
if (!props.name)
|
|
5911
|
-
return;
|
|
5845
|
+
if (!props.name) return;
|
|
5912
5846
|
props.model[props.name].splice(index, 1);
|
|
5913
5847
|
onChangeHandler();
|
|
5914
5848
|
};
|
|
@@ -6233,8 +6167,7 @@
|
|
|
6233
6167
|
const val = vue.computed(() => props.model[props.name]);
|
|
6234
6168
|
const uiSelectMode = vue.ref(false);
|
|
6235
6169
|
const cancelHandler = () => {
|
|
6236
|
-
if (!services?.uiService)
|
|
6237
|
-
return;
|
|
6170
|
+
if (!services?.uiService) return;
|
|
6238
6171
|
services.uiService.set("uiSelectMode", false);
|
|
6239
6172
|
uiSelectMode.value = false;
|
|
6240
6173
|
globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
|
|
@@ -6254,8 +6187,7 @@
|
|
|
6254
6187
|
return config?.name || "";
|
|
6255
6188
|
});
|
|
6256
6189
|
const startSelect = () => {
|
|
6257
|
-
if (!services?.uiService)
|
|
6258
|
-
return;
|
|
6190
|
+
if (!services?.uiService) return;
|
|
6259
6191
|
services.uiService.set("uiSelectMode", true);
|
|
6260
6192
|
uiSelectMode.value = true;
|
|
6261
6193
|
globalThis.document.addEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
|
|
@@ -6372,14 +6304,12 @@
|
|
|
6372
6304
|
let getso;
|
|
6373
6305
|
const isDraging = vue.ref(false);
|
|
6374
6306
|
vue.onMounted(() => {
|
|
6375
|
-
if (!target.value)
|
|
6376
|
-
return;
|
|
6307
|
+
if (!target.value) return;
|
|
6377
6308
|
getso = new Gesto(target.value, {
|
|
6378
6309
|
container: window,
|
|
6379
6310
|
pinchOutside: true
|
|
6380
6311
|
}).on("drag", (e) => {
|
|
6381
|
-
if (!target.value)
|
|
6382
|
-
return;
|
|
6312
|
+
if (!target.value) return;
|
|
6383
6313
|
emit("change", e);
|
|
6384
6314
|
}).on("dragStart", () => {
|
|
6385
6315
|
isDraging.value = true;
|
|
@@ -6495,13 +6425,11 @@
|
|
|
6495
6425
|
});
|
|
6496
6426
|
} else {
|
|
6497
6427
|
vue.watchEffect(() => {
|
|
6498
|
-
if (typeof props.width === "number")
|
|
6499
|
-
widthChange(props.width);
|
|
6428
|
+
if (typeof props.width === "number") widthChange(props.width);
|
|
6500
6429
|
});
|
|
6501
6430
|
}
|
|
6502
6431
|
const changeLeft = ({ deltaX }) => {
|
|
6503
|
-
if (typeof props.left === "undefined")
|
|
6504
|
-
return;
|
|
6432
|
+
if (typeof props.left === "undefined") return;
|
|
6505
6433
|
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
6506
6434
|
emit("update:left", left);
|
|
6507
6435
|
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
@@ -6516,8 +6444,7 @@
|
|
|
6516
6444
|
});
|
|
6517
6445
|
};
|
|
6518
6446
|
const changeRight = ({ deltaX }) => {
|
|
6519
|
-
if (typeof props.right === "undefined")
|
|
6520
|
-
return;
|
|
6447
|
+
if (typeof props.right === "undefined") return;
|
|
6521
6448
|
let right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
6522
6449
|
emit("update:right", right);
|
|
6523
6450
|
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
@@ -6602,28 +6529,23 @@
|
|
|
6602
6529
|
const props = __props;
|
|
6603
6530
|
const services = vue.inject("services");
|
|
6604
6531
|
const disabled = vue.computed(() => {
|
|
6605
|
-
if (typeof props.data === "string")
|
|
6606
|
-
|
|
6607
|
-
if (props.data.type === "component")
|
|
6608
|
-
return false;
|
|
6532
|
+
if (typeof props.data === "string") return false;
|
|
6533
|
+
if (props.data.type === "component") return false;
|
|
6609
6534
|
if (typeof props.data.disabled === "function") {
|
|
6610
6535
|
return props.data.disabled(services);
|
|
6611
6536
|
}
|
|
6612
6537
|
return props.data.disabled;
|
|
6613
6538
|
});
|
|
6614
6539
|
const display = vue.computed(() => {
|
|
6615
|
-
if (!props.data)
|
|
6616
|
-
|
|
6617
|
-
if (typeof props.data === "string")
|
|
6618
|
-
return true;
|
|
6540
|
+
if (!props.data) return false;
|
|
6541
|
+
if (typeof props.data === "string") return true;
|
|
6619
6542
|
if (typeof props.data.display === "function") {
|
|
6620
6543
|
return props.data.display(services);
|
|
6621
6544
|
}
|
|
6622
6545
|
return props.data.display ?? true;
|
|
6623
6546
|
});
|
|
6624
6547
|
const buttonHandler = (item, event) => {
|
|
6625
|
-
if (disabled.value)
|
|
6626
|
-
return;
|
|
6548
|
+
if (disabled.value) return;
|
|
6627
6549
|
if (typeof item.handler === "function" && services) {
|
|
6628
6550
|
item.handler?.(services, event);
|
|
6629
6551
|
}
|
|
@@ -6634,22 +6556,19 @@
|
|
|
6634
6556
|
}
|
|
6635
6557
|
};
|
|
6636
6558
|
const clickHandler = (item, event) => {
|
|
6637
|
-
if (props.eventType !== "click")
|
|
6638
|
-
return;
|
|
6559
|
+
if (props.eventType !== "click") return;
|
|
6639
6560
|
if (item.type === "button") {
|
|
6640
6561
|
buttonHandler(item, event);
|
|
6641
6562
|
}
|
|
6642
6563
|
};
|
|
6643
6564
|
const mousedownHandler = (item, event) => {
|
|
6644
|
-
if (props.eventType !== "mousedown")
|
|
6645
|
-
return;
|
|
6565
|
+
if (props.eventType !== "mousedown") return;
|
|
6646
6566
|
if (item.type === "button") {
|
|
6647
6567
|
buttonHandler(item, event);
|
|
6648
6568
|
}
|
|
6649
6569
|
};
|
|
6650
6570
|
const mouseupHandler = (item, event) => {
|
|
6651
|
-
if (props.eventType !== "mouseup")
|
|
6652
|
-
return;
|
|
6571
|
+
if (props.eventType !== "mouseup") return;
|
|
6653
6572
|
if (item.type === "button") {
|
|
6654
6573
|
buttonHandler(item, event);
|
|
6655
6574
|
}
|
|
@@ -6766,11 +6685,9 @@
|
|
|
6766
6685
|
const editorService = services?.editorService;
|
|
6767
6686
|
const showAddPageButton = vue.computed(() => uiService?.get("showAddPageButton"));
|
|
6768
6687
|
const addPage = () => {
|
|
6769
|
-
if (!editorService)
|
|
6770
|
-
return;
|
|
6688
|
+
if (!editorService) return;
|
|
6771
6689
|
const root = vue.toRaw(editorService.get("root"));
|
|
6772
|
-
if (!root)
|
|
6773
|
-
throw new Error("root 不能为空");
|
|
6690
|
+
if (!root) throw new Error("root 不能为空");
|
|
6774
6691
|
const pageConfig = {
|
|
6775
6692
|
type: props.type,
|
|
6776
6693
|
name: generatePageNameByApp(root, props.type),
|
|
@@ -6828,8 +6745,7 @@
|
|
|
6828
6745
|
});
|
|
6829
6746
|
let translateLeft = 0;
|
|
6830
6747
|
const scroll = (type) => {
|
|
6831
|
-
if (!itemsContainer.value)
|
|
6832
|
-
return;
|
|
6748
|
+
if (!itemsContainer.value) return;
|
|
6833
6749
|
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
6834
6750
|
if (type === "left") {
|
|
6835
6751
|
translateLeft += 100;
|
|
@@ -7134,11 +7050,9 @@
|
|
|
7134
7050
|
const services = vue.inject("services");
|
|
7135
7051
|
const clickHandler = (type) => {
|
|
7136
7052
|
const { editorService } = services || {};
|
|
7137
|
-
if (!editorService)
|
|
7138
|
-
return;
|
|
7053
|
+
if (!editorService) return;
|
|
7139
7054
|
const root = vue.toRaw(editorService.get("root"));
|
|
7140
|
-
if (!root)
|
|
7141
|
-
throw new Error("root 不能为空");
|
|
7055
|
+
if (!root) throw new Error("root 不能为空");
|
|
7142
7056
|
editorService.add({
|
|
7143
7057
|
type,
|
|
7144
7058
|
name: generatePageNameByApp(root, type),
|
|
@@ -7610,6 +7524,7 @@
|
|
|
7610
7524
|
}, 8, ["type"])) : vue.createCommentVNode("", true),
|
|
7611
7525
|
showSrc.value ? (vue.openBlock(), vue.createBlock(_sfc_main$T, {
|
|
7612
7526
|
key: 1,
|
|
7527
|
+
class: "m-editor-props-panel-src-code",
|
|
7613
7528
|
height: `${vue.unref(editorContentHeight)}px`,
|
|
7614
7529
|
"init-values": values.value,
|
|
7615
7530
|
options: vue.unref(codeOptions),
|
|
@@ -7665,8 +7580,7 @@
|
|
|
7665
7580
|
|
|
7666
7581
|
const updateStatus = (nodeStatusMap, id, status) => {
|
|
7667
7582
|
const nodeStatus = nodeStatusMap.get(id);
|
|
7668
|
-
if (!nodeStatus)
|
|
7669
|
-
return;
|
|
7583
|
+
if (!nodeStatus) return;
|
|
7670
7584
|
utils.getKeys(status).forEach((key) => {
|
|
7671
7585
|
if (nodeStatus[key] !== void 0 && status[key] !== void 0) {
|
|
7672
7586
|
nodeStatus[key] = Boolean(status[key]);
|
|
@@ -7862,12 +7776,10 @@
|
|
|
7862
7776
|
return string.some((v) => filterNodeMethod(v, data));
|
|
7863
7777
|
};
|
|
7864
7778
|
const filter = (text) => {
|
|
7865
|
-
if (!nodeData.value.length)
|
|
7866
|
-
return;
|
|
7779
|
+
if (!nodeData.value.length) return;
|
|
7867
7780
|
nodeData.value.forEach((node) => {
|
|
7868
7781
|
traverseNode(node, (node2, parents) => {
|
|
7869
|
-
if (!nodeStatusMap.value)
|
|
7870
|
-
return;
|
|
7782
|
+
if (!nodeStatusMap.value) return;
|
|
7871
7783
|
const visible = filterIsMatch(text, node2);
|
|
7872
7784
|
if (visible && parents.length) {
|
|
7873
7785
|
parents.forEach((parent) => {
|
|
@@ -8157,8 +8069,7 @@
|
|
|
8157
8069
|
const dataSourceValues = vue.ref({});
|
|
8158
8070
|
const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
|
|
8159
8071
|
const editHandler = (id) => {
|
|
8160
|
-
if (!editDialog.value)
|
|
8161
|
-
return;
|
|
8072
|
+
if (!editDialog.value) return;
|
|
8162
8073
|
dataSourceValues.value = {
|
|
8163
8074
|
...dataSourceService?.getDataSourceById(id)
|
|
8164
8075
|
};
|
|
@@ -8426,8 +8337,7 @@
|
|
|
8426
8337
|
].concat(dataSourceService?.get("datasourceTypeList") ?? [])
|
|
8427
8338
|
);
|
|
8428
8339
|
const addHandler = (type) => {
|
|
8429
|
-
if (!editDialog.value)
|
|
8430
|
-
return;
|
|
8340
|
+
if (!editDialog.value) return;
|
|
8431
8341
|
const datasourceType = datasourceTypeList.value.find((item) => item.type === type);
|
|
8432
8342
|
dataSourceValues.value = lodashEs.mergeWith(
|
|
8433
8343
|
{ type, title: datasourceType?.text },
|
|
@@ -8544,20 +8454,17 @@
|
|
|
8544
8454
|
}));
|
|
8545
8455
|
const contains = (el) => menu.value?.contains(el) || subMenu.value?.contains(el);
|
|
8546
8456
|
const hide = () => {
|
|
8547
|
-
if (!visible.value)
|
|
8548
|
-
return;
|
|
8457
|
+
if (!visible.value) return;
|
|
8549
8458
|
visible.value = false;
|
|
8550
8459
|
subMenu.value?.hide();
|
|
8551
8460
|
emit("hide");
|
|
8552
8461
|
};
|
|
8553
8462
|
const clickHandler = () => {
|
|
8554
|
-
if (!props.autoHide)
|
|
8555
|
-
return;
|
|
8463
|
+
if (!props.autoHide) return;
|
|
8556
8464
|
hide();
|
|
8557
8465
|
};
|
|
8558
8466
|
const outsideClickHideHandler = (e) => {
|
|
8559
|
-
if (!props.autoHide)
|
|
8560
|
-
return;
|
|
8467
|
+
if (!props.autoHide) return;
|
|
8561
8468
|
const target = e.target;
|
|
8562
8469
|
if (!visible.value || !target) {
|
|
8563
8470
|
return;
|
|
@@ -8614,13 +8521,11 @@
|
|
|
8614
8521
|
emit("mouseenter");
|
|
8615
8522
|
};
|
|
8616
8523
|
vue.onMounted(() => {
|
|
8617
|
-
if (props.isSubMenu)
|
|
8618
|
-
return;
|
|
8524
|
+
if (props.isSubMenu) return;
|
|
8619
8525
|
globalThis.addEventListener("mousedown", outsideClickHideHandler, true);
|
|
8620
8526
|
});
|
|
8621
8527
|
vue.onBeforeUnmount(() => {
|
|
8622
|
-
if (props.isSubMenu)
|
|
8623
|
-
return;
|
|
8528
|
+
if (props.isSubMenu) return;
|
|
8624
8529
|
globalThis.removeEventListener("mousedown", outsideClickHideHandler, true);
|
|
8625
8530
|
});
|
|
8626
8531
|
__expose({
|
|
@@ -8741,8 +8646,7 @@
|
|
|
8741
8646
|
display: (services) => !!services?.storageService?.getItem(COPY_STORAGE_KEY),
|
|
8742
8647
|
handler: (services) => {
|
|
8743
8648
|
const nodes = services?.editorService?.get("nodes");
|
|
8744
|
-
if (!nodes || nodes.length === 0)
|
|
8745
|
-
return;
|
|
8649
|
+
if (!nodes || nodes.length === 0) return;
|
|
8746
8650
|
if (menu?.value?.$el) {
|
|
8747
8651
|
const stage = services?.editorService?.get("stage");
|
|
8748
8652
|
const rect = menu.value.$el.getBoundingClientRect();
|
|
@@ -8756,12 +8660,10 @@
|
|
|
8756
8660
|
}
|
|
8757
8661
|
});
|
|
8758
8662
|
const moveTo = (id, services) => {
|
|
8759
|
-
if (!services?.editorService)
|
|
8760
|
-
return;
|
|
8663
|
+
if (!services?.editorService) return;
|
|
8761
8664
|
const nodes = services.editorService.get("nodes") || [];
|
|
8762
8665
|
const parent = services.editorService.getNodeById(id);
|
|
8763
|
-
if (!parent)
|
|
8764
|
-
return;
|
|
8666
|
+
if (!parent) return;
|
|
8765
8667
|
services?.editorService.add(nodes, parent);
|
|
8766
8668
|
services?.editorService.remove(nodes);
|
|
8767
8669
|
};
|
|
@@ -8901,8 +8803,7 @@
|
|
|
8901
8803
|
const services = vue.inject("services");
|
|
8902
8804
|
const editorService = services?.editorService;
|
|
8903
8805
|
const setNodeVisible = (visible) => {
|
|
8904
|
-
if (!editorService)
|
|
8905
|
-
return;
|
|
8806
|
+
if (!editorService) return;
|
|
8906
8807
|
editorService.update({
|
|
8907
8808
|
id: props.data.id,
|
|
8908
8809
|
visible
|
|
@@ -8960,17 +8861,19 @@
|
|
|
8960
8861
|
services?.stageOverlayService.get("stage")?.multiSelect(newNodes);
|
|
8961
8862
|
};
|
|
8962
8863
|
const throttleTime = 300;
|
|
8963
|
-
const highlightHandler = lodashEs.throttle(
|
|
8964
|
-
|
|
8965
|
-
|
|
8864
|
+
const highlightHandler = lodashEs.throttle(
|
|
8865
|
+
(event, data) => {
|
|
8866
|
+
highlight(data);
|
|
8867
|
+
},
|
|
8868
|
+
throttleTime
|
|
8869
|
+
);
|
|
8966
8870
|
const highlight = (data) => {
|
|
8967
8871
|
services?.editorService?.highlight(data);
|
|
8968
8872
|
services?.editorService?.get("stage")?.highlight(data.id);
|
|
8969
8873
|
services?.stageOverlayService?.get("stage")?.highlight(data.id);
|
|
8970
8874
|
};
|
|
8971
8875
|
const nodeClickHandler = (event, data) => {
|
|
8972
|
-
if (!nodeStatusMap?.value)
|
|
8973
|
-
return;
|
|
8876
|
+
if (!nodeStatusMap?.value) return;
|
|
8974
8877
|
if (services?.uiService.get("uiSelectMode")) {
|
|
8975
8878
|
document.dispatchEvent(new CustomEvent(UI_SELECT_MODE_EVENT_NAME, { detail: data }));
|
|
8976
8879
|
return;
|
|
@@ -9014,8 +8917,7 @@
|
|
|
9014
8917
|
}
|
|
9015
8918
|
};
|
|
9016
8919
|
const removeStatusClass = (el) => {
|
|
9017
|
-
if (!el)
|
|
9018
|
-
return;
|
|
8920
|
+
if (!el) return;
|
|
9019
8921
|
["drag-before", "drag-after", "drag-inner"].forEach((className) => {
|
|
9020
8922
|
el.querySelectorAll(`.${className}`).forEach((el2) => {
|
|
9021
8923
|
utils.removeClassName(el2, className);
|
|
@@ -9024,11 +8926,9 @@
|
|
|
9024
8926
|
};
|
|
9025
8927
|
const useDrag = (services) => {
|
|
9026
8928
|
const handleDragStart = (event) => {
|
|
9027
|
-
if (!event.dataTransfer || !event.target || !event.currentTarget)
|
|
9028
|
-
return;
|
|
8929
|
+
if (!event.dataTransfer || !event.target || !event.currentTarget) return;
|
|
9029
8930
|
const targetEl = getNodeEl(event.target);
|
|
9030
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
9031
|
-
return;
|
|
8931
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
9032
8932
|
event.dataTransfer.effectAllowed = "move";
|
|
9033
8933
|
try {
|
|
9034
8934
|
event.dataTransfer.setData(
|
|
@@ -9041,14 +8941,11 @@
|
|
|
9041
8941
|
}
|
|
9042
8942
|
};
|
|
9043
8943
|
const handleDragOver = (event) => {
|
|
9044
|
-
if (!event.target)
|
|
9045
|
-
return;
|
|
8944
|
+
if (!event.target) return;
|
|
9046
8945
|
const targetEl = getNodeEl(event.target);
|
|
9047
|
-
if (!targetEl?.draggable)
|
|
9048
|
-
return;
|
|
8946
|
+
if (!targetEl?.draggable) return;
|
|
9049
8947
|
const labelEl = targetEl.children[0];
|
|
9050
|
-
if (!labelEl)
|
|
9051
|
-
return;
|
|
8948
|
+
if (!labelEl) return;
|
|
9052
8949
|
const { top: targetTop, height: targetHeight } = labelEl.getBoundingClientRect();
|
|
9053
8950
|
const distance = event.clientY - targetTop;
|
|
9054
8951
|
const isContainer = targetEl.dataset.isContainer === "true";
|
|
@@ -9073,20 +8970,16 @@
|
|
|
9073
8970
|
event.preventDefault();
|
|
9074
8971
|
};
|
|
9075
8972
|
const handleDragLeave = (event) => {
|
|
9076
|
-
if (!event.target || !event.currentTarget)
|
|
9077
|
-
return;
|
|
8973
|
+
if (!event.target || !event.currentTarget) return;
|
|
9078
8974
|
const targetEl = getNodeEl(event.target);
|
|
9079
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
9080
|
-
return;
|
|
8975
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
9081
8976
|
const labelEl = targetEl.children[0];
|
|
9082
8977
|
utils.removeClassName(labelEl, "drag-before", "drag-after", "drag-inner");
|
|
9083
8978
|
};
|
|
9084
8979
|
const handleDragEnd = (event, node) => {
|
|
9085
|
-
if (!event.target || !event.currentTarget)
|
|
9086
|
-
return;
|
|
8980
|
+
if (!event.target || !event.currentTarget) return;
|
|
9087
8981
|
const targetEl = getNodeEl(event.target);
|
|
9088
|
-
if (!targetEl || targetEl !== event.currentTarget)
|
|
9089
|
-
return;
|
|
8982
|
+
if (!targetEl || targetEl !== event.currentTarget) return;
|
|
9090
8983
|
removeStatusClass(dragState.container);
|
|
9091
8984
|
if (node && dragState.dragOverNodeId && dragState.dropType && services) {
|
|
9092
8985
|
if (dragState.dragOverNodeId === node.id) {
|
|
@@ -9095,8 +8988,7 @@
|
|
|
9095
8988
|
const targetInfo = services.editorService.getNodeInfo(dragState.dragOverNodeId, false);
|
|
9096
8989
|
const targetNode = targetInfo.node;
|
|
9097
8990
|
let targetParent = targetInfo.parent;
|
|
9098
|
-
if (!targetParent || !targetNode)
|
|
9099
|
-
return;
|
|
8991
|
+
if (!targetParent || !targetNode) return;
|
|
9100
8992
|
let targetIndex = -1;
|
|
9101
8993
|
if (Array.isArray(targetNode.items) && dragState.dropType === "inner") {
|
|
9102
8994
|
targetIndex = targetNode.items.length;
|
|
@@ -9107,7 +8999,12 @@
|
|
|
9107
8999
|
if (dragState.dropType === "after") {
|
|
9108
9000
|
targetIndex += 1;
|
|
9109
9001
|
}
|
|
9110
|
-
services
|
|
9002
|
+
const selectedNodes = services.editorService.get("nodes");
|
|
9003
|
+
if (selectedNodes.find((n) => `${n.id}` === `${node.id}`)) {
|
|
9004
|
+
services.editorService.dragTo(selectedNodes, targetParent, targetIndex);
|
|
9005
|
+
} else {
|
|
9006
|
+
services.editorService.dragTo([node], targetParent, targetIndex);
|
|
9007
|
+
}
|
|
9111
9008
|
}
|
|
9112
9009
|
dragState.dragOverNodeId = "";
|
|
9113
9010
|
dragState.dropType = "";
|
|
@@ -9328,8 +9225,7 @@
|
|
|
9328
9225
|
vue.watch(
|
|
9329
9226
|
nodes,
|
|
9330
9227
|
(nodes2) => {
|
|
9331
|
-
if (!nodeStatusMap.value)
|
|
9332
|
-
return;
|
|
9228
|
+
if (!nodeStatusMap.value) return;
|
|
9333
9229
|
for (const [id, status] of nodeStatusMap.value.entries()) {
|
|
9334
9230
|
status.selected = nodes2.some((node) => node.id === id);
|
|
9335
9231
|
if (status.selected) {
|
|
@@ -9347,8 +9243,7 @@
|
|
|
9347
9243
|
);
|
|
9348
9244
|
services?.editorService.on("add", (newNodes) => {
|
|
9349
9245
|
newNodes.forEach((node) => {
|
|
9350
|
-
if (utils.isPage(node) || utils.isPageFragment(node))
|
|
9351
|
-
return;
|
|
9246
|
+
if (utils.isPage(node) || utils.isPageFragment(node)) return;
|
|
9352
9247
|
traverseNode(node, (node2) => {
|
|
9353
9248
|
nodeStatusMap.value?.set(node2.id, {
|
|
9354
9249
|
visible: true,
|
|
@@ -9400,8 +9295,7 @@
|
|
|
9400
9295
|
};
|
|
9401
9296
|
const { filterTextChangeHandler } = useFilter(nodeData, nodeStatusMap, filterNodeMethod);
|
|
9402
9297
|
const collapseAllHandler = () => {
|
|
9403
|
-
if (!page.value || !nodeStatusMap.value)
|
|
9404
|
-
return;
|
|
9298
|
+
if (!page.value || !nodeStatusMap.value) return;
|
|
9405
9299
|
const items = nodeStatusMap.value.entries();
|
|
9406
9300
|
for (const [id, status] of items) {
|
|
9407
9301
|
if (id === page.value.id) {
|
|
@@ -9535,8 +9429,7 @@
|
|
|
9535
9429
|
}
|
|
9536
9430
|
return;
|
|
9537
9431
|
}
|
|
9538
|
-
if (timeout || !stage.value)
|
|
9539
|
-
return;
|
|
9432
|
+
if (timeout || !stage.value) return;
|
|
9540
9433
|
timeout = stage.value.delayedMarkContainer(e);
|
|
9541
9434
|
};
|
|
9542
9435
|
return (_ctx, _cache) => {
|
|
@@ -9700,8 +9593,7 @@
|
|
|
9700
9593
|
const isActiveTabShow = showingBoxKeys.value.some(
|
|
9701
9594
|
(key) => activeTabName.value === sideBarItems.value.find((v) => v.$key === key)?.text
|
|
9702
9595
|
);
|
|
9703
|
-
if (!isActiveTabShow && activeTabName.value)
|
|
9704
|
-
return;
|
|
9596
|
+
if (!isActiveTabShow && activeTabName.value) return;
|
|
9705
9597
|
const nextSlideBarItem = sideBarItems.value.find((sideBarItem) => !showingBoxKeys.value.includes(sideBarItem.$key));
|
|
9706
9598
|
if (!nextSlideBarItem) {
|
|
9707
9599
|
activeTabName.value = "";
|
|
@@ -9956,8 +9848,7 @@
|
|
|
9956
9848
|
}
|
|
9957
9849
|
wheelHandler = (event) => {
|
|
9958
9850
|
const { deltaX, deltaY, currentTarget } = event;
|
|
9959
|
-
if (currentTarget !== this.container)
|
|
9960
|
-
return;
|
|
9851
|
+
if (currentTarget !== this.container) return;
|
|
9961
9852
|
let top;
|
|
9962
9853
|
if (this.scrollHeight > this.height) {
|
|
9963
9854
|
top = this.scrollTop + this.getPos(deltaY, this.scrollTop, this.scrollHeight, this.height);
|
|
@@ -10050,8 +9941,7 @@
|
|
|
10050
9941
|
}));
|
|
10051
9942
|
let gesto;
|
|
10052
9943
|
vue.onMounted(() => {
|
|
10053
|
-
if (!thumb.value)
|
|
10054
|
-
return;
|
|
9944
|
+
if (!thumb.value) return;
|
|
10055
9945
|
const thumbEl = thumb.value;
|
|
10056
9946
|
gesto = new Gesto(thumbEl, {
|
|
10057
9947
|
container: window
|
|
@@ -10065,8 +9955,7 @@
|
|
|
10065
9955
|
bar.value?.addEventListener("wheel", wheelHandler, false);
|
|
10066
9956
|
});
|
|
10067
9957
|
vue.onBeforeUnmount(() => {
|
|
10068
|
-
if (gesto)
|
|
10069
|
-
gesto.off();
|
|
9958
|
+
if (gesto) gesto.off();
|
|
10070
9959
|
bar.value?.removeEventListener("wheel", wheelHandler, false);
|
|
10071
9960
|
});
|
|
10072
9961
|
const wheelHandler = (e) => {
|
|
@@ -10145,8 +10034,7 @@
|
|
|
10145
10034
|
const scrollHeight = vue.ref(0);
|
|
10146
10035
|
let scrollViewer;
|
|
10147
10036
|
vue.onMounted(() => {
|
|
10148
|
-
if (!container.value || !el.value)
|
|
10149
|
-
return;
|
|
10037
|
+
if (!container.value || !el.value) return;
|
|
10150
10038
|
scrollViewer = new ScrollViewer({
|
|
10151
10039
|
container: container.value,
|
|
10152
10040
|
target: el.value,
|
|
@@ -10239,8 +10127,7 @@
|
|
|
10239
10127
|
const unWatch = vue.watch(
|
|
10240
10128
|
stage,
|
|
10241
10129
|
(stage2) => {
|
|
10242
|
-
if (!stage2)
|
|
10243
|
-
return;
|
|
10130
|
+
if (!stage2) return;
|
|
10244
10131
|
vue.nextTick(() => unWatch());
|
|
10245
10132
|
stage2.on("select", (el, event) => {
|
|
10246
10133
|
const els = stage2.renderer.getElementsFromPoint(event) || [];
|
|
@@ -10256,8 +10143,7 @@
|
|
|
10256
10143
|
vue.watch(
|
|
10257
10144
|
nodes,
|
|
10258
10145
|
(nodes2) => {
|
|
10259
|
-
if (!nodeStatusMap.value)
|
|
10260
|
-
return;
|
|
10146
|
+
if (!nodeStatusMap.value) return;
|
|
10261
10147
|
for (const [id, status] of nodeStatusMap.value.entries()) {
|
|
10262
10148
|
status.selected = nodes2.some((node) => node.id === id);
|
|
10263
10149
|
}
|
|
@@ -10351,8 +10237,7 @@
|
|
|
10351
10237
|
}
|
|
10352
10238
|
});
|
|
10353
10239
|
vue.watch(stageOverlay, (stageOverlay2) => {
|
|
10354
|
-
if (!services)
|
|
10355
|
-
return;
|
|
10240
|
+
if (!services) return;
|
|
10356
10241
|
const subStage = services.stageOverlayService.createStage(stageOptions);
|
|
10357
10242
|
services?.stageOverlayService.set("stage", subStage);
|
|
10358
10243
|
if (stageOverlay2 && subStage) {
|
|
@@ -10467,8 +10352,7 @@
|
|
|
10467
10352
|
icon: vue.markRaw(_sfc_main$5),
|
|
10468
10353
|
display: () => canCenter.value,
|
|
10469
10354
|
handler: () => {
|
|
10470
|
-
if (!nodes.value)
|
|
10471
|
-
return;
|
|
10355
|
+
if (!nodes.value) return;
|
|
10472
10356
|
editorService?.alignCenter(nodes.value);
|
|
10473
10357
|
}
|
|
10474
10358
|
},
|
|
@@ -10478,8 +10362,7 @@
|
|
|
10478
10362
|
type: "divider",
|
|
10479
10363
|
direction: "horizontal",
|
|
10480
10364
|
display: () => {
|
|
10481
|
-
if (!node.value)
|
|
10482
|
-
return false;
|
|
10365
|
+
if (!node.value) return false;
|
|
10483
10366
|
return !utils.isPage(node.value) && !utils.isPageFragment(node.value);
|
|
10484
10367
|
}
|
|
10485
10368
|
},
|
|
@@ -10545,8 +10428,7 @@
|
|
|
10545
10428
|
vue.watch(
|
|
10546
10429
|
parent,
|
|
10547
10430
|
async () => {
|
|
10548
|
-
if (!parent.value || !editorService)
|
|
10549
|
-
return canCenter.value = false;
|
|
10431
|
+
if (!parent.value || !editorService) return canCenter.value = false;
|
|
10550
10432
|
const layout = await editorService.getLayout(parent.value);
|
|
10551
10433
|
const isLayoutConform = [Layout.ABSOLUTE, Layout.FIXED].includes(layout);
|
|
10552
10434
|
const isTypeConform = nodes.value?.every(
|
|
@@ -10597,12 +10479,9 @@
|
|
|
10597
10479
|
const zoom = vue.computed(() => services?.uiService.get("zoom") || 1);
|
|
10598
10480
|
const node = vue.computed(() => services?.editorService.get("node"));
|
|
10599
10481
|
vue.watchEffect(() => {
|
|
10600
|
-
if (stage || !page.value)
|
|
10601
|
-
|
|
10602
|
-
if (!
|
|
10603
|
-
return;
|
|
10604
|
-
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value)
|
|
10605
|
-
return;
|
|
10482
|
+
if (stage || !page.value) return;
|
|
10483
|
+
if (!stageContainer.value) return;
|
|
10484
|
+
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value) return;
|
|
10606
10485
|
stage = useStage(stageOptions);
|
|
10607
10486
|
stage.on("select", () => {
|
|
10608
10487
|
stageWrap.value?.container?.focus();
|
|
@@ -10622,8 +10501,7 @@
|
|
|
10622
10501
|
});
|
|
10623
10502
|
});
|
|
10624
10503
|
vue.watch(zoom, (zoom2) => {
|
|
10625
|
-
if (!stage || !zoom2)
|
|
10626
|
-
return;
|
|
10504
|
+
if (!stage || !zoom2) return;
|
|
10627
10505
|
stage.setZoom(zoom2);
|
|
10628
10506
|
});
|
|
10629
10507
|
vue.watch(page, (page2) => {
|
|
@@ -10668,20 +10546,16 @@
|
|
|
10668
10546
|
menu.value?.show(e);
|
|
10669
10547
|
};
|
|
10670
10548
|
const dragoverHandler = (e) => {
|
|
10671
|
-
if (!e.dataTransfer)
|
|
10672
|
-
return;
|
|
10549
|
+
if (!e.dataTransfer) return;
|
|
10673
10550
|
e.preventDefault();
|
|
10674
10551
|
e.dataTransfer.dropEffect = "move";
|
|
10675
10552
|
};
|
|
10676
10553
|
const dropHandler = async (e) => {
|
|
10677
|
-
if (!e.dataTransfer)
|
|
10678
|
-
return;
|
|
10554
|
+
if (!e.dataTransfer) return;
|
|
10679
10555
|
const data = e.dataTransfer.getData("text/json");
|
|
10680
|
-
if (!data)
|
|
10681
|
-
return;
|
|
10556
|
+
if (!data) return;
|
|
10682
10557
|
const config = parseDSL(`(${data})`);
|
|
10683
|
-
if (!config || config.dragType !== DragType.COMPONENT_LIST)
|
|
10684
|
-
return;
|
|
10558
|
+
if (!config || config.dragType !== DragType.COMPONENT_LIST) return;
|
|
10685
10559
|
e.preventDefault();
|
|
10686
10560
|
const doc = stage?.renderer.contentWindow?.document;
|
|
10687
10561
|
const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
|
|
@@ -10886,11 +10760,9 @@
|
|
|
10886
10760
|
* @returns {CodeBlockContent | null}
|
|
10887
10761
|
*/
|
|
10888
10762
|
getCodeContentById(id) {
|
|
10889
|
-
if (!id)
|
|
10890
|
-
return null;
|
|
10763
|
+
if (!id) return null;
|
|
10891
10764
|
const totalCodeDsl = this.getCodeDsl();
|
|
10892
|
-
if (!totalCodeDsl)
|
|
10893
|
-
return null;
|
|
10765
|
+
if (!totalCodeDsl) return null;
|
|
10894
10766
|
return totalCodeDsl[id] ?? null;
|
|
10895
10767
|
}
|
|
10896
10768
|
/**
|
|
@@ -10915,8 +10787,7 @@
|
|
|
10915
10787
|
if (!codeDsl) {
|
|
10916
10788
|
throw new Error("dsl中没有codeBlocks");
|
|
10917
10789
|
}
|
|
10918
|
-
if (codeDsl[id] && !force)
|
|
10919
|
-
return;
|
|
10790
|
+
if (codeDsl[id] && !force) return;
|
|
10920
10791
|
const codeConfigProcessed = lodashEs.cloneDeep(codeConfig);
|
|
10921
10792
|
if (codeConfigProcessed.content) {
|
|
10922
10793
|
const parseDSL = getConfig("parseDSL");
|
|
@@ -11009,8 +10880,7 @@
|
|
|
11009
10880
|
*/
|
|
11010
10881
|
async deleteCodeDslByIds(codeIds) {
|
|
11011
10882
|
const currentDsl = await this.getCodeDsl();
|
|
11012
|
-
if (!currentDsl)
|
|
11013
|
-
return;
|
|
10883
|
+
if (!currentDsl) return;
|
|
11014
10884
|
codeIds.forEach((id) => {
|
|
11015
10885
|
delete currentDsl[id];
|
|
11016
10886
|
this.emit("remove", id);
|
|
@@ -11030,8 +10900,7 @@
|
|
|
11030
10900
|
const newId = `code_${Math.random().toString(10).substring(2).substring(0, 4)}`;
|
|
11031
10901
|
const dsl = await this.getCodeDsl();
|
|
11032
10902
|
const existedIds = lodashEs.keys(dsl);
|
|
11033
|
-
if (!existedIds.includes(newId))
|
|
11034
|
-
return newId;
|
|
10903
|
+
if (!existedIds.includes(newId)) return newId;
|
|
11035
10904
|
return await this.getUniqueId();
|
|
11036
10905
|
}
|
|
11037
10906
|
/**
|
|
@@ -11051,8 +10920,7 @@
|
|
|
11051
10920
|
coperWatcher.collect(copyNodes, {}, true, collectorOptions.type);
|
|
11052
10921
|
Object.keys(customTarget.deps).forEach((nodeId) => {
|
|
11053
10922
|
const node = editorService.getNodeById(nodeId);
|
|
11054
|
-
if (!node)
|
|
11055
|
-
return;
|
|
10923
|
+
if (!node) return;
|
|
11056
10924
|
customTarget.deps[nodeId].keys.forEach((key) => {
|
|
11057
10925
|
const relateCodeId = lodashEs.get(node, key);
|
|
11058
10926
|
const isExist = Object.keys(copyData).find((codeId) => codeId === relateCodeId);
|
|
@@ -11175,8 +11043,7 @@
|
|
|
11175
11043
|
removeTargets(type = dep.DepTargetType.DEFAULT) {
|
|
11176
11044
|
this.watcher.removeTargets(type);
|
|
11177
11045
|
const targets = this.watcher.getTargets(type);
|
|
11178
|
-
if (!targets)
|
|
11179
|
-
return;
|
|
11046
|
+
if (!targets) return;
|
|
11180
11047
|
for (const target of Object.values(targets)) {
|
|
11181
11048
|
this.emit("remove-target", target.id);
|
|
11182
11049
|
}
|
|
@@ -11317,8 +11184,7 @@
|
|
|
11317
11184
|
commands = {
|
|
11318
11185
|
[KeyBindingCommand.DELETE_NODE]: () => {
|
|
11319
11186
|
const nodes = editorService.get("nodes");
|
|
11320
|
-
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0]))
|
|
11321
|
-
return;
|
|
11187
|
+
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0])) return;
|
|
11322
11188
|
editorService.remove(nodes);
|
|
11323
11189
|
},
|
|
11324
11190
|
[KeyBindingCommand.COPY_NODE]: () => {
|
|
@@ -11327,8 +11193,7 @@
|
|
|
11327
11193
|
},
|
|
11328
11194
|
[KeyBindingCommand.CUT_NODE]: () => {
|
|
11329
11195
|
const nodes = editorService.get("nodes");
|
|
11330
|
-
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0]))
|
|
11331
|
-
return;
|
|
11196
|
+
if (!nodes || utils.isPage(nodes[0]) || utils.isPageFragment(nodes[0])) return;
|
|
11332
11197
|
editorService.copy(nodes);
|
|
11333
11198
|
editorService.remove(nodes);
|
|
11334
11199
|
},
|
|
@@ -11517,8 +11382,7 @@
|
|
|
11517
11382
|
}
|
|
11518
11383
|
openOverlay(el) {
|
|
11519
11384
|
const stageOptions = this.get("stageOptions");
|
|
11520
|
-
if (!el || !stageOptions)
|
|
11521
|
-
return;
|
|
11385
|
+
if (!el || !stageOptions) return;
|
|
11522
11386
|
this.set("sourceEl", el);
|
|
11523
11387
|
this.createContentEl();
|
|
11524
11388
|
this.set("stageOverlayVisible", true);
|
|
@@ -11545,8 +11409,7 @@
|
|
|
11545
11409
|
}
|
|
11546
11410
|
updateOverlay() {
|
|
11547
11411
|
const sourceEl = this.get("sourceEl");
|
|
11548
|
-
if (!sourceEl)
|
|
11549
|
-
return;
|
|
11412
|
+
if (!sourceEl) return;
|
|
11550
11413
|
const { scrollWidth, scrollHeight } = sourceEl;
|
|
11551
11414
|
this.set("wrapWidth", scrollWidth);
|
|
11552
11415
|
this.set("wrapHeight", scrollHeight);
|
|
@@ -11579,8 +11442,7 @@
|
|
|
11579
11442
|
}
|
|
11580
11443
|
createContentEl() {
|
|
11581
11444
|
const sourceEl = this.get("sourceEl");
|
|
11582
|
-
if (!sourceEl)
|
|
11583
|
-
return;
|
|
11445
|
+
if (!sourceEl) return;
|
|
11584
11446
|
const contentEl = sourceEl.cloneNode(true);
|
|
11585
11447
|
this.set("contentEl", contentEl);
|
|
11586
11448
|
contentEl.style.position = "static";
|
|
@@ -11602,8 +11464,7 @@
|
|
|
11602
11464
|
const wrapDiv = this.get("wrapDiv");
|
|
11603
11465
|
const subStage = this.get("stage");
|
|
11604
11466
|
const stageOptions = this.get("stageOptions");
|
|
11605
|
-
if (!contentEl)
|
|
11606
|
-
return;
|
|
11467
|
+
if (!contentEl) return;
|
|
11607
11468
|
wrapDiv.style.cssText = `
|
|
11608
11469
|
width: ${sourceEl?.scrollWidth}px;
|
|
11609
11470
|
height: ${sourceEl?.scrollHeight}px;
|
|
@@ -11823,37 +11684,9 @@
|
|
|
11823
11684
|
getApp()?.dataSourceManager?.updateSchema(root.dataSources);
|
|
11824
11685
|
}
|
|
11825
11686
|
};
|
|
11826
|
-
const updateNodeWhenDataSourceChange = (nodes) => {
|
|
11827
|
-
const root = editorService.get("root");
|
|
11828
|
-
const stage = editorService.get("stage");
|
|
11829
|
-
if (!root || !stage)
|
|
11830
|
-
return;
|
|
11831
|
-
const app = getApp();
|
|
11832
|
-
if (!app)
|
|
11833
|
-
return;
|
|
11834
|
-
if (app.dsl) {
|
|
11835
|
-
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
11836
|
-
app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
|
|
11837
|
-
app.dsl.dataSources = root.dataSources;
|
|
11838
|
-
}
|
|
11839
|
-
updateDataSourceSchema();
|
|
11840
|
-
nodes.forEach((node) => {
|
|
11841
|
-
const deps = Object.values(root.dataSourceDeps || {});
|
|
11842
|
-
deps.forEach((dep) => {
|
|
11843
|
-
if (dep[node.id]) {
|
|
11844
|
-
stage.update({
|
|
11845
|
-
config: lodashEs.cloneDeep(node),
|
|
11846
|
-
parentId: editorService.getParentById(node.id)?.id,
|
|
11847
|
-
root: lodashEs.cloneDeep(root)
|
|
11848
|
-
});
|
|
11849
|
-
}
|
|
11850
|
-
});
|
|
11851
|
-
});
|
|
11852
|
-
};
|
|
11853
11687
|
const targetAddHandler = (target) => {
|
|
11854
11688
|
const root = editorService.get("root");
|
|
11855
|
-
if (!root)
|
|
11856
|
-
return;
|
|
11689
|
+
if (!root) return;
|
|
11857
11690
|
if (target.type === dep.DepTargetType.DATA_SOURCE) {
|
|
11858
11691
|
if (!root.dataSourceDeps) {
|
|
11859
11692
|
root.dataSourceDeps = {};
|
|
@@ -11876,8 +11709,41 @@
|
|
|
11876
11709
|
delete root.dataSourceCondDeps[id];
|
|
11877
11710
|
}
|
|
11878
11711
|
};
|
|
11879
|
-
const collectedHandler = (nodes) => {
|
|
11880
|
-
|
|
11712
|
+
const collectedHandler = (nodes, deep) => {
|
|
11713
|
+
const root = editorService.get("root");
|
|
11714
|
+
const stage = editorService.get("stage");
|
|
11715
|
+
if (!root || !stage) return;
|
|
11716
|
+
const app = getApp();
|
|
11717
|
+
if (!app) return;
|
|
11718
|
+
if (app.dsl) {
|
|
11719
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
11720
|
+
app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
|
|
11721
|
+
app.dsl.dataSources = root.dataSources;
|
|
11722
|
+
}
|
|
11723
|
+
updateDataSourceSchema();
|
|
11724
|
+
const allNodes = [];
|
|
11725
|
+
if (deep) {
|
|
11726
|
+
nodes.forEach((node) => {
|
|
11727
|
+
traverseNode(node, (node2) => {
|
|
11728
|
+
if (!allNodes.includes(node2)) {
|
|
11729
|
+
allNodes.push(node2);
|
|
11730
|
+
}
|
|
11731
|
+
});
|
|
11732
|
+
});
|
|
11733
|
+
} else {
|
|
11734
|
+
allNodes.push(...nodes);
|
|
11735
|
+
}
|
|
11736
|
+
const deps = Object.values(root.dataSourceDeps || {});
|
|
11737
|
+
deps.forEach((dep) => {
|
|
11738
|
+
Object.keys(dep).forEach((id) => {
|
|
11739
|
+
const node = allNodes.find((node2) => node2.id === id);
|
|
11740
|
+
node && stage.update({
|
|
11741
|
+
config: lodashEs.cloneDeep(node),
|
|
11742
|
+
parentId: editorService.getParentById(node.id)?.id,
|
|
11743
|
+
root: lodashEs.cloneDeep(root)
|
|
11744
|
+
});
|
|
11745
|
+
});
|
|
11746
|
+
});
|
|
11881
11747
|
};
|
|
11882
11748
|
depService.on("add-target", targetAddHandler);
|
|
11883
11749
|
depService.on("remove-target", targetRemoveHandler);
|
|
@@ -11888,8 +11754,7 @@
|
|
|
11888
11754
|
depService.addTarget(dep.createDataSourceCondTarget(ds, vue.reactive({})));
|
|
11889
11755
|
};
|
|
11890
11756
|
const rootChangeHandler = async (value, preValue) => {
|
|
11891
|
-
if (!value)
|
|
11892
|
-
return;
|
|
11757
|
+
if (!value) return;
|
|
11893
11758
|
value.codeBlocks = value.codeBlocks || {};
|
|
11894
11759
|
value.dataSources = value.dataSources || [];
|
|
11895
11760
|
codeBlockService.setCodeDsl(value.codeBlocks);
|
|
@@ -11979,9 +11844,6 @@
|
|
|
11979
11844
|
(root?.items || []).forEach((page) => {
|
|
11980
11845
|
depService.collectIdle([page], { pageId: page.id }, true);
|
|
11981
11846
|
});
|
|
11982
|
-
const targets = depService.getTargets(dep.DepTargetType.DATA_SOURCE);
|
|
11983
|
-
const nodes = utils.getNodes(Object.keys(targets[config.id].deps), root?.items);
|
|
11984
|
-
updateNodeWhenDataSourceChange(nodes);
|
|
11985
11847
|
};
|
|
11986
11848
|
const removeDataSourceTarget = (id) => {
|
|
11987
11849
|
depService.removeTarget(id, dep.DepTargetType.DATA_SOURCE);
|
|
@@ -12332,6 +12194,7 @@
|
|
|
12332
12194
|
exports.info = info;
|
|
12333
12195
|
exports.isFixed = isFixed;
|
|
12334
12196
|
exports.log = log;
|
|
12197
|
+
exports.moveItemsInContainer = moveItemsInContainer;
|
|
12335
12198
|
exports.propsService = propsService;
|
|
12336
12199
|
exports.serializeConfig = serializeConfig;
|
|
12337
12200
|
exports.setChildrenLayout = setChildrenLayout;
|