@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
package/dist/tmagic-editor.js
CHANGED
|
@@ -1626,23 +1626,27 @@ const getInitPositionStyle = (style = {}, layout) => {
|
|
|
1626
1626
|
}
|
|
1627
1627
|
return style;
|
|
1628
1628
|
};
|
|
1629
|
-
const
|
|
1629
|
+
const setChilrenLayout = (node, layout) => {
|
|
1630
1630
|
node.items?.forEach((child) => {
|
|
1631
|
-
|
|
1632
|
-
return;
|
|
1633
|
-
const style = child.style || {};
|
|
1634
|
-
if (style.position === "fixed")
|
|
1635
|
-
return;
|
|
1636
|
-
if (layout !== Layout.RELATIVE) {
|
|
1637
|
-
style.position = "absolute";
|
|
1638
|
-
} else {
|
|
1639
|
-
child.style = getRelativeStyle(style);
|
|
1640
|
-
child.style.right = "auto";
|
|
1641
|
-
child.style.bottom = "auto";
|
|
1642
|
-
}
|
|
1631
|
+
setLayout(child, layout);
|
|
1643
1632
|
});
|
|
1644
1633
|
return node;
|
|
1645
1634
|
};
|
|
1635
|
+
const setLayout = (node, layout) => {
|
|
1636
|
+
if (isPop(node))
|
|
1637
|
+
return;
|
|
1638
|
+
const style = node.style || {};
|
|
1639
|
+
if (style.position === "fixed")
|
|
1640
|
+
return;
|
|
1641
|
+
if (layout !== Layout.RELATIVE) {
|
|
1642
|
+
style.position = "absolute";
|
|
1643
|
+
} else {
|
|
1644
|
+
node.style = getRelativeStyle(style);
|
|
1645
|
+
node.style.right = "auto";
|
|
1646
|
+
node.style.bottom = "auto";
|
|
1647
|
+
}
|
|
1648
|
+
return node;
|
|
1649
|
+
};
|
|
1646
1650
|
const change2Fixed = (node, root) => {
|
|
1647
1651
|
const path = getNodePath(node.id, root.items);
|
|
1648
1652
|
const offset = {
|
|
@@ -2497,8 +2501,8 @@ class Editor extends BaseService {
|
|
|
2497
2501
|
throw new Error("更新的节点未找到");
|
|
2498
2502
|
const newLayout = await this.getLayout(newConfig);
|
|
2499
2503
|
const layout = await this.getLayout(node);
|
|
2500
|
-
if (newLayout !== layout) {
|
|
2501
|
-
newConfig =
|
|
2504
|
+
if (Array.isArray(newConfig.items) && newLayout !== layout) {
|
|
2505
|
+
newConfig = setChilrenLayout(newConfig, newLayout);
|
|
2502
2506
|
}
|
|
2503
2507
|
parentNodeItems[index] = newConfig;
|
|
2504
2508
|
const nodes = this.get("nodes");
|
|
@@ -2720,6 +2724,11 @@ class Editor extends BaseService {
|
|
|
2720
2724
|
targetIndex -= 1;
|
|
2721
2725
|
}
|
|
2722
2726
|
}
|
|
2727
|
+
const layout = await this.getLayout(parent);
|
|
2728
|
+
const newLayout = await this.getLayout(targetParent);
|
|
2729
|
+
if (newLayout !== layout) {
|
|
2730
|
+
setLayout(config, newLayout);
|
|
2731
|
+
}
|
|
2723
2732
|
parent.items?.splice(index, 1);
|
|
2724
2733
|
targetParent.items?.splice(targetIndex, 0, config);
|
|
2725
2734
|
const page = this.get("page");
|
|
@@ -6143,7 +6152,6 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
6143
6152
|
const tree = ref();
|
|
6144
6153
|
__expose({
|
|
6145
6154
|
filter(val) {
|
|
6146
|
-
debugger;
|
|
6147
6155
|
tree.value?.filter(val);
|
|
6148
6156
|
}
|
|
6149
6157
|
});
|
|
@@ -8815,11 +8823,6 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
8815
8823
|
return;
|
|
8816
8824
|
stage.setZoom(zoom2);
|
|
8817
8825
|
});
|
|
8818
|
-
watch(root, (root2) => {
|
|
8819
|
-
if (runtime && root2) {
|
|
8820
|
-
runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
|
|
8821
|
-
}
|
|
8822
|
-
});
|
|
8823
8826
|
watch(page, (page2) => {
|
|
8824
8827
|
if (runtime && page2) {
|
|
8825
8828
|
runtime.updatePageId?.(page2.id);
|
|
@@ -8828,6 +8831,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
8828
8831
|
});
|
|
8829
8832
|
}
|
|
8830
8833
|
});
|
|
8834
|
+
const rootChangeHandler = (root2) => {
|
|
8835
|
+
if (runtime && root2) {
|
|
8836
|
+
runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
|
|
8837
|
+
}
|
|
8838
|
+
};
|
|
8839
|
+
services?.editorService.on("root-change", rootChangeHandler);
|
|
8831
8840
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
8832
8841
|
for (const { contentRect } of entries) {
|
|
8833
8842
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -8847,6 +8856,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
8847
8856
|
resizeObserver.disconnect();
|
|
8848
8857
|
services?.editorService.set("stage", null);
|
|
8849
8858
|
services?.keybindingService.unregisteEl("stage");
|
|
8859
|
+
services?.editorService.off("root-change", rootChangeHandler);
|
|
8850
8860
|
});
|
|
8851
8861
|
const parseDSL = getConfig("parseDSL");
|
|
8852
8862
|
const contextmenuHandler = (e) => {
|
|
@@ -10195,23 +10205,6 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
10195
10205
|
depService.addTarget(createDataSourceCondTarget(ds.id));
|
|
10196
10206
|
};
|
|
10197
10207
|
const rootChangeHandler = async (value, preValue) => {
|
|
10198
|
-
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10199
|
-
let node;
|
|
10200
|
-
if (nodeId) {
|
|
10201
|
-
node = editorService.getNodeById(nodeId);
|
|
10202
|
-
}
|
|
10203
|
-
if (node && node !== value) {
|
|
10204
|
-
await editorService.select(node.id);
|
|
10205
|
-
} else if (value?.items?.length) {
|
|
10206
|
-
await editorService.select(value.items[0]);
|
|
10207
|
-
} else if (value?.id) {
|
|
10208
|
-
editorService.set("nodes", [value]);
|
|
10209
|
-
editorService.set("parent", null);
|
|
10210
|
-
editorService.set("page", null);
|
|
10211
|
-
}
|
|
10212
|
-
if (toRaw(value) !== toRaw(preValue)) {
|
|
10213
|
-
emit("update:modelValue", value);
|
|
10214
|
-
}
|
|
10215
10208
|
if (!value)
|
|
10216
10209
|
return;
|
|
10217
10210
|
value.codeBlocks = value.codeBlocks || {};
|
|
@@ -10225,12 +10218,29 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
10225
10218
|
value.dataSources.forEach((ds) => {
|
|
10226
10219
|
initDataSourceDepTarget(ds);
|
|
10227
10220
|
});
|
|
10228
|
-
if (
|
|
10221
|
+
if (Array.isArray(value.items)) {
|
|
10229
10222
|
depService.collect(value.items, true);
|
|
10230
10223
|
} else {
|
|
10231
10224
|
depService.clear();
|
|
10232
10225
|
delete value.dataSourceDeps;
|
|
10233
10226
|
}
|
|
10227
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10228
|
+
let node;
|
|
10229
|
+
if (nodeId) {
|
|
10230
|
+
node = editorService.getNodeById(nodeId);
|
|
10231
|
+
}
|
|
10232
|
+
if (node && node !== value) {
|
|
10233
|
+
await editorService.select(node.id);
|
|
10234
|
+
} else if (value.items?.length) {
|
|
10235
|
+
await editorService.select(value.items[0]);
|
|
10236
|
+
} else if (value.id) {
|
|
10237
|
+
editorService.set("nodes", [value]);
|
|
10238
|
+
editorService.set("parent", null);
|
|
10239
|
+
editorService.set("page", null);
|
|
10240
|
+
}
|
|
10241
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
10242
|
+
emit("update:modelValue", value);
|
|
10243
|
+
}
|
|
10234
10244
|
};
|
|
10235
10245
|
const nodeAddHandler = (nodes) => {
|
|
10236
10246
|
depService.collect(nodes);
|
|
@@ -10500,5 +10510,5 @@ const index = {
|
|
|
10500
10510
|
}
|
|
10501
10511
|
};
|
|
10502
10512
|
|
|
10503
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$P as CodeBlockEditor, _sfc_main$r as CodeBlockList, _sfc_main$q as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$M as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$k as ContentMenu, _sfc_main$K as DataSourceFieldSelect, _sfc_main$L as DataSourceFields, _sfc_main$J as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DepTargetType, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$N as Icon, KeyBindingCommand, _sfc_main$D as KeyValue, Keys, LayerOffset, _sfc_main$g as LayerPanel, Layout, _sfc_main$A as LayoutContainer, _sfc_main$v as PropsPanel, _sfc_main$B as Resizer, _sfc_main$A 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, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useStage, warn };
|
|
10513
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$P as CodeBlockEditor, _sfc_main$r as CodeBlockList, _sfc_main$q as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$M as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$k as ContentMenu, _sfc_main$K as DataSourceFieldSelect, _sfc_main$L as DataSourceFields, _sfc_main$J as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DepTargetType, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$N as Icon, KeyBindingCommand, _sfc_main$D as KeyValue, Keys, LayerOffset, _sfc_main$g as LayerPanel, Layout, _sfc_main$A as LayoutContainer, _sfc_main$v as PropsPanel, _sfc_main$B as Resizer, _sfc_main$A 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, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChilrenLayout, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useStage, warn };
|
|
10504
10514
|
//# sourceMappingURL=tmagic-editor.js.map
|