@tmagic/editor 1.3.0-beta.8 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tmagic-editor.js +50 -40
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +50 -39
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/initService.ts +21 -21
- package/src/layouts/sidebar/data-source/DataSourceList.vue +0 -1
- package/src/layouts/workspace/viewer/Stage.vue +10 -7
- package/src/services/editor.ts +11 -2
- package/src/utils/editor.ts +18 -13
- package/types/utils/editor.d.ts +2 -1
|
@@ -1635,23 +1635,27 @@
|
|
|
1635
1635
|
}
|
|
1636
1636
|
return style;
|
|
1637
1637
|
};
|
|
1638
|
-
const
|
|
1638
|
+
const setChilrenLayout = (node, layout) => {
|
|
1639
1639
|
node.items?.forEach((child) => {
|
|
1640
|
-
|
|
1641
|
-
return;
|
|
1642
|
-
const style = child.style || {};
|
|
1643
|
-
if (style.position === "fixed")
|
|
1644
|
-
return;
|
|
1645
|
-
if (layout !== Layout.RELATIVE) {
|
|
1646
|
-
style.position = "absolute";
|
|
1647
|
-
} else {
|
|
1648
|
-
child.style = getRelativeStyle(style);
|
|
1649
|
-
child.style.right = "auto";
|
|
1650
|
-
child.style.bottom = "auto";
|
|
1651
|
-
}
|
|
1640
|
+
setLayout(child, layout);
|
|
1652
1641
|
});
|
|
1653
1642
|
return node;
|
|
1654
1643
|
};
|
|
1644
|
+
const setLayout = (node, layout) => {
|
|
1645
|
+
if (utils.isPop(node))
|
|
1646
|
+
return;
|
|
1647
|
+
const style = node.style || {};
|
|
1648
|
+
if (style.position === "fixed")
|
|
1649
|
+
return;
|
|
1650
|
+
if (layout !== Layout.RELATIVE) {
|
|
1651
|
+
style.position = "absolute";
|
|
1652
|
+
} else {
|
|
1653
|
+
node.style = getRelativeStyle(style);
|
|
1654
|
+
node.style.right = "auto";
|
|
1655
|
+
node.style.bottom = "auto";
|
|
1656
|
+
}
|
|
1657
|
+
return node;
|
|
1658
|
+
};
|
|
1655
1659
|
const change2Fixed = (node, root) => {
|
|
1656
1660
|
const path = utils.getNodePath(node.id, root.items);
|
|
1657
1661
|
const offset = {
|
|
@@ -2506,8 +2510,8 @@
|
|
|
2506
2510
|
throw new Error("更新的节点未找到");
|
|
2507
2511
|
const newLayout = await this.getLayout(newConfig);
|
|
2508
2512
|
const layout = await this.getLayout(node);
|
|
2509
|
-
if (newLayout !== layout) {
|
|
2510
|
-
newConfig =
|
|
2513
|
+
if (Array.isArray(newConfig.items) && newLayout !== layout) {
|
|
2514
|
+
newConfig = setChilrenLayout(newConfig, newLayout);
|
|
2511
2515
|
}
|
|
2512
2516
|
parentNodeItems[index] = newConfig;
|
|
2513
2517
|
const nodes = this.get("nodes");
|
|
@@ -2729,6 +2733,11 @@
|
|
|
2729
2733
|
targetIndex -= 1;
|
|
2730
2734
|
}
|
|
2731
2735
|
}
|
|
2736
|
+
const layout = await this.getLayout(parent);
|
|
2737
|
+
const newLayout = await this.getLayout(targetParent);
|
|
2738
|
+
if (newLayout !== layout) {
|
|
2739
|
+
setLayout(config, newLayout);
|
|
2740
|
+
}
|
|
2732
2741
|
parent.items?.splice(index, 1);
|
|
2733
2742
|
targetParent.items?.splice(targetIndex, 0, config);
|
|
2734
2743
|
const page = this.get("page");
|
|
@@ -6152,7 +6161,6 @@
|
|
|
6152
6161
|
const tree = vue.ref();
|
|
6153
6162
|
__expose({
|
|
6154
6163
|
filter(val) {
|
|
6155
|
-
debugger;
|
|
6156
6164
|
tree.value?.filter(val);
|
|
6157
6165
|
}
|
|
6158
6166
|
});
|
|
@@ -8824,11 +8832,6 @@
|
|
|
8824
8832
|
return;
|
|
8825
8833
|
stage.setZoom(zoom2);
|
|
8826
8834
|
});
|
|
8827
|
-
vue.watch(root, (root2) => {
|
|
8828
|
-
if (runtime && root2) {
|
|
8829
|
-
runtime.updateRootConfig?.(lodashEs.cloneDeep(vue.toRaw(root2)));
|
|
8830
|
-
}
|
|
8831
|
-
});
|
|
8832
8835
|
vue.watch(page, (page2) => {
|
|
8833
8836
|
if (runtime && page2) {
|
|
8834
8837
|
runtime.updatePageId?.(page2.id);
|
|
@@ -8837,6 +8840,12 @@
|
|
|
8837
8840
|
});
|
|
8838
8841
|
}
|
|
8839
8842
|
});
|
|
8843
|
+
const rootChangeHandler = (root2) => {
|
|
8844
|
+
if (runtime && root2) {
|
|
8845
|
+
runtime.updateRootConfig?.(lodashEs.cloneDeep(vue.toRaw(root2)));
|
|
8846
|
+
}
|
|
8847
|
+
};
|
|
8848
|
+
services?.editorService.on("root-change", rootChangeHandler);
|
|
8840
8849
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
8841
8850
|
for (const { contentRect } of entries) {
|
|
8842
8851
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -8856,6 +8865,7 @@
|
|
|
8856
8865
|
resizeObserver.disconnect();
|
|
8857
8866
|
services?.editorService.set("stage", null);
|
|
8858
8867
|
services?.keybindingService.unregisteEl("stage");
|
|
8868
|
+
services?.editorService.off("root-change", rootChangeHandler);
|
|
8859
8869
|
});
|
|
8860
8870
|
const parseDSL = getConfig("parseDSL");
|
|
8861
8871
|
const contextmenuHandler = (e) => {
|
|
@@ -10204,23 +10214,6 @@
|
|
|
10204
10214
|
depService.addTarget(createDataSourceCondTarget(ds.id));
|
|
10205
10215
|
};
|
|
10206
10216
|
const rootChangeHandler = async (value, preValue) => {
|
|
10207
|
-
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10208
|
-
let node;
|
|
10209
|
-
if (nodeId) {
|
|
10210
|
-
node = editorService.getNodeById(nodeId);
|
|
10211
|
-
}
|
|
10212
|
-
if (node && node !== value) {
|
|
10213
|
-
await editorService.select(node.id);
|
|
10214
|
-
} else if (value?.items?.length) {
|
|
10215
|
-
await editorService.select(value.items[0]);
|
|
10216
|
-
} else if (value?.id) {
|
|
10217
|
-
editorService.set("nodes", [value]);
|
|
10218
|
-
editorService.set("parent", null);
|
|
10219
|
-
editorService.set("page", null);
|
|
10220
|
-
}
|
|
10221
|
-
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
10222
|
-
emit("update:modelValue", value);
|
|
10223
|
-
}
|
|
10224
10217
|
if (!value)
|
|
10225
10218
|
return;
|
|
10226
10219
|
value.codeBlocks = value.codeBlocks || {};
|
|
@@ -10234,12 +10227,29 @@
|
|
|
10234
10227
|
value.dataSources.forEach((ds) => {
|
|
10235
10228
|
initDataSourceDepTarget(ds);
|
|
10236
10229
|
});
|
|
10237
|
-
if (
|
|
10230
|
+
if (Array.isArray(value.items)) {
|
|
10238
10231
|
depService.collect(value.items, true);
|
|
10239
10232
|
} else {
|
|
10240
10233
|
depService.clear();
|
|
10241
10234
|
delete value.dataSourceDeps;
|
|
10242
10235
|
}
|
|
10236
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10237
|
+
let node;
|
|
10238
|
+
if (nodeId) {
|
|
10239
|
+
node = editorService.getNodeById(nodeId);
|
|
10240
|
+
}
|
|
10241
|
+
if (node && node !== value) {
|
|
10242
|
+
await editorService.select(node.id);
|
|
10243
|
+
} else if (value.items?.length) {
|
|
10244
|
+
await editorService.select(value.items[0]);
|
|
10245
|
+
} else if (value.id) {
|
|
10246
|
+
editorService.set("nodes", [value]);
|
|
10247
|
+
editorService.set("parent", null);
|
|
10248
|
+
editorService.set("page", null);
|
|
10249
|
+
}
|
|
10250
|
+
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
10251
|
+
emit("update:modelValue", value);
|
|
10252
|
+
}
|
|
10243
10253
|
};
|
|
10244
10254
|
const nodeAddHandler = (nodes) => {
|
|
10245
10255
|
depService.collect(nodes);
|
|
@@ -10585,6 +10595,7 @@
|
|
|
10585
10595
|
exports.log = log;
|
|
10586
10596
|
exports.propsService = propsService;
|
|
10587
10597
|
exports.serializeConfig = serializeConfig;
|
|
10598
|
+
exports.setChilrenLayout = setChilrenLayout;
|
|
10588
10599
|
exports.setConfig = setConfig;
|
|
10589
10600
|
exports.setLayout = setLayout;
|
|
10590
10601
|
exports.storageService = storageService;
|