@tmagic/editor 1.3.0-beta.7 → 1.3.0
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 +87 -69
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +87 -69
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/components/ContentMenu.vue +2 -6
- package/src/components/SplitView.vue +22 -6
- package/src/initService.ts +21 -21
- package/src/layouts/Framework.vue +11 -21
- package/src/layouts/sidebar/data-source/DataSourceList.vue +24 -15
- package/src/layouts/workspace/viewer/NodeListMenu.vue +11 -2
- package/src/layouts/workspace/viewer/Stage.vue +10 -7
- package/src/services/dep.ts +1 -1
- package/src/utils/dep.ts +7 -2
- package/types/components/ContentMenu.vue.d.ts +4 -1
- package/types/components/SplitView.vue.d.ts +3 -1
|
@@ -4990,19 +4990,22 @@
|
|
|
4990
4990
|
centerClass: {}
|
|
4991
4991
|
},
|
|
4992
4992
|
emits: ["update:left", "change", "update:right"],
|
|
4993
|
-
setup(__props, { emit }) {
|
|
4993
|
+
setup(__props, { expose: __expose, emit }) {
|
|
4994
4994
|
const props = __props;
|
|
4995
4995
|
const el = vue.ref();
|
|
4996
4996
|
const hasLeft = vue.computed(() => typeof props.left !== "undefined");
|
|
4997
4997
|
const hasRight = vue.computed(() => typeof props.right !== "undefined");
|
|
4998
|
-
const getCenterWidth = (clientWidth2,
|
|
4998
|
+
const getCenterWidth = (clientWidth2, l = 0, r = 0) => {
|
|
4999
|
+
let right = r > 0 ? r : 0;
|
|
5000
|
+
let left = l > 0 ? l : 0;
|
|
4999
5001
|
let center2 = clientWidth2 - left - right;
|
|
5000
5002
|
if (center2 < props.minCenter) {
|
|
5001
5003
|
center2 = props.minCenter;
|
|
5002
|
-
if (
|
|
5003
|
-
right = clientWidth2 - left -
|
|
5004
|
+
if (right > center2 + props.minRight) {
|
|
5005
|
+
right = clientWidth2 - left - center2;
|
|
5004
5006
|
} else {
|
|
5005
|
-
|
|
5007
|
+
right = props.minRight;
|
|
5008
|
+
left = clientWidth2 - right - center2;
|
|
5006
5009
|
}
|
|
5007
5010
|
}
|
|
5008
5011
|
return {
|
|
@@ -5065,7 +5068,7 @@
|
|
|
5065
5068
|
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
5066
5069
|
right = props.right;
|
|
5067
5070
|
}
|
|
5068
|
-
const columnWidth = getCenterWidth(clientWidth, props.left
|
|
5071
|
+
const columnWidth = getCenterWidth(clientWidth, props.left, right);
|
|
5069
5072
|
center.value = columnWidth.center;
|
|
5070
5073
|
emit("change", {
|
|
5071
5074
|
left: columnWidth.left,
|
|
@@ -5073,11 +5076,22 @@
|
|
|
5073
5076
|
right: columnWidth.right
|
|
5074
5077
|
});
|
|
5075
5078
|
};
|
|
5079
|
+
__expose({
|
|
5080
|
+
updateWidth() {
|
|
5081
|
+
const columnWidth = getCenterWidth(el.value?.clientWidth || clientWidth, props.left, props.right);
|
|
5082
|
+
emit("change", {
|
|
5083
|
+
left: columnWidth.left,
|
|
5084
|
+
center: center.value,
|
|
5085
|
+
right: columnWidth.right
|
|
5086
|
+
});
|
|
5087
|
+
}
|
|
5088
|
+
});
|
|
5076
5089
|
return (_ctx, _cache) => {
|
|
5077
5090
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
5078
5091
|
ref_key: "el",
|
|
5079
5092
|
ref: el,
|
|
5080
|
-
class: "m-editor-layout"
|
|
5093
|
+
class: "m-editor-layout",
|
|
5094
|
+
style: vue.normalizeStyle(`min-width: ${props.minCenter + props.minLeft + props.minRight}px`)
|
|
5081
5095
|
}, [
|
|
5082
5096
|
hasLeft.value && _ctx.$slots.left ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
5083
5097
|
vue.createElementVNode("div", {
|
|
@@ -5103,7 +5117,7 @@
|
|
|
5103
5117
|
vue.renderSlot(_ctx.$slots, "right")
|
|
5104
5118
|
], 6)
|
|
5105
5119
|
], 64)) : vue.createCommentVNode("", true)
|
|
5106
|
-
],
|
|
5120
|
+
], 4);
|
|
5107
5121
|
};
|
|
5108
5122
|
}
|
|
5109
5123
|
});
|
|
@@ -5161,31 +5175,21 @@
|
|
|
5161
5175
|
const codeOptions = vue.inject("codeOptions", {});
|
|
5162
5176
|
const { editorService, uiService } = vue.inject("services") || {};
|
|
5163
5177
|
const content = vue.ref();
|
|
5178
|
+
const splitView = vue.ref();
|
|
5164
5179
|
const root = vue.computed(() => editorService?.get("root"));
|
|
5165
5180
|
const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
|
|
5166
5181
|
const showSrc = vue.computed(() => uiService?.get("showSrc"));
|
|
5167
|
-
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
|
|
5168
|
-
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
|
|
5182
|
+
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
5183
|
+
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
5169
5184
|
const columnWidth = vue.ref({
|
|
5170
5185
|
left: leftColumnWidthCacheData,
|
|
5171
5186
|
center: 0,
|
|
5172
5187
|
right: RightColumnWidthCacheData
|
|
5173
5188
|
});
|
|
5174
5189
|
vue.watch(
|
|
5175
|
-
pageLength,
|
|
5176
|
-
(
|
|
5177
|
-
|
|
5178
|
-
columnWidth.value.left = left;
|
|
5179
|
-
const container = content.value || document.body;
|
|
5180
|
-
if (length <= 0) {
|
|
5181
|
-
columnWidth.value.right = void 0;
|
|
5182
|
-
columnWidth.value.center = container.clientWidth - left;
|
|
5183
|
-
} else {
|
|
5184
|
-
const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
5185
|
-
columnWidth.value.right = right;
|
|
5186
|
-
columnWidth.value.center = container.clientWidth - left - right;
|
|
5187
|
-
}
|
|
5188
|
-
uiService?.set("columnWidth", columnWidth.value);
|
|
5190
|
+
[pageLength, splitView],
|
|
5191
|
+
() => {
|
|
5192
|
+
splitView.value?.updateWidth();
|
|
5189
5193
|
},
|
|
5190
5194
|
{
|
|
5191
5195
|
immediate: true
|
|
@@ -5223,7 +5227,8 @@
|
|
|
5223
5227
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
5224
5228
|
class: "m-editor",
|
|
5225
5229
|
ref_key: "content",
|
|
5226
|
-
ref: content
|
|
5230
|
+
ref: content,
|
|
5231
|
+
style: { "min-width": "180px" }
|
|
5227
5232
|
}, [
|
|
5228
5233
|
vue.renderSlot(_ctx.$slots, "header"),
|
|
5229
5234
|
vue.renderSlot(_ctx.$slots, "nav"),
|
|
@@ -5237,6 +5242,8 @@
|
|
|
5237
5242
|
}, null, 8, ["init-values", "options"])
|
|
5238
5243
|
]) : (vue.openBlock(), vue.createBlock(_sfc_main$A, {
|
|
5239
5244
|
key: 1,
|
|
5245
|
+
ref_key: "splitView",
|
|
5246
|
+
ref: splitView,
|
|
5240
5247
|
class: "m-editor-content",
|
|
5241
5248
|
"left-class": "m-editor-framework-left",
|
|
5242
5249
|
"center-class": "m-editor-framework-center",
|
|
@@ -5247,6 +5254,7 @@
|
|
|
5247
5254
|
"onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
|
|
5248
5255
|
"min-left": 65,
|
|
5249
5256
|
"min-right": 20,
|
|
5257
|
+
"min-center": 100,
|
|
5250
5258
|
onChange: columnWidthChange
|
|
5251
5259
|
}, vue.createSlots({
|
|
5252
5260
|
left: vue.withCtx(() => [
|
|
@@ -6091,25 +6099,25 @@
|
|
|
6091
6099
|
id,
|
|
6092
6100
|
children: getKeyTreeConfig(dep, type)
|
|
6093
6101
|
});
|
|
6102
|
+
const mergeChildren = (children, deps, type) => {
|
|
6103
|
+
Object.entries(deps).forEach(([id, dep]) => {
|
|
6104
|
+
const nodeItem = children.find((item) => item.id === id);
|
|
6105
|
+
if (nodeItem) {
|
|
6106
|
+
nodeItem.children = nodeItem.children.concat(getKeyTreeConfig(dep, type));
|
|
6107
|
+
} else {
|
|
6108
|
+
children.push(getNodeTreeConfig(id, dep, type));
|
|
6109
|
+
}
|
|
6110
|
+
});
|
|
6111
|
+
};
|
|
6094
6112
|
const list = vue.computed(
|
|
6095
6113
|
() => dataSources.value.map((ds) => {
|
|
6096
6114
|
const dsDeps = dsDep.value[ds.id].deps;
|
|
6097
6115
|
const dsMethodDeps = dsMethodDep.value[ds.id].deps;
|
|
6098
6116
|
const dsCondDeps = dsCondDep.value[ds.id].deps;
|
|
6099
6117
|
const children = [];
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
if (nodeItem) {
|
|
6104
|
-
nodeItem.children = nodeItem.children.concat(getKeyTreeConfig(dep, type));
|
|
6105
|
-
} else {
|
|
6106
|
-
children.push(getNodeTreeConfig(id, dep, type));
|
|
6107
|
-
}
|
|
6108
|
-
});
|
|
6109
|
-
};
|
|
6110
|
-
mergeChildren(dsDeps);
|
|
6111
|
-
mergeChildren(dsMethodDeps, "method");
|
|
6112
|
-
mergeChildren(dsCondDeps, "cond");
|
|
6118
|
+
mergeChildren(children, dsDeps);
|
|
6119
|
+
mergeChildren(children, dsMethodDeps, "method");
|
|
6120
|
+
mergeChildren(children, dsCondDeps, "cond");
|
|
6113
6121
|
return {
|
|
6114
6122
|
id: ds.id,
|
|
6115
6123
|
name: ds.title,
|
|
@@ -6583,11 +6591,8 @@
|
|
|
6583
6591
|
const show = (e) => {
|
|
6584
6592
|
setTimeout(() => {
|
|
6585
6593
|
visible.value = true;
|
|
6586
|
-
if (!e) {
|
|
6587
|
-
return;
|
|
6588
|
-
}
|
|
6589
6594
|
vue.nextTick(() => {
|
|
6590
|
-
setPosition(e);
|
|
6595
|
+
e && setPosition(e);
|
|
6591
6596
|
emit("show");
|
|
6592
6597
|
});
|
|
6593
6598
|
}, 300);
|
|
@@ -8448,6 +8453,7 @@
|
|
|
8448
8453
|
}
|
|
8449
8454
|
});
|
|
8450
8455
|
|
|
8456
|
+
const PINNED_STATUE_CACHE_KEY = "tmagic-pinned-node-list-pinned-status";
|
|
8451
8457
|
const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
8452
8458
|
__name: "NodeListMenu",
|
|
8453
8459
|
props: {
|
|
@@ -8457,7 +8463,8 @@
|
|
|
8457
8463
|
const props = __props;
|
|
8458
8464
|
const menu = vue.ref();
|
|
8459
8465
|
const nodeList = vue.ref([]);
|
|
8460
|
-
const pinned = vue.ref(
|
|
8466
|
+
const pinned = vue.ref(Boolean(globalThis.localStorage.getItem(PINNED_STATUE_CACHE_KEY)));
|
|
8467
|
+
const firstShow = vue.ref(true);
|
|
8461
8468
|
const services = vue.inject("services");
|
|
8462
8469
|
const editorService = services?.editorService;
|
|
8463
8470
|
const componentListService = services?.componentListService;
|
|
@@ -8506,7 +8513,8 @@
|
|
|
8506
8513
|
}
|
|
8507
8514
|
nodeList.value = nodes;
|
|
8508
8515
|
if (nodeList.value.length > 1) {
|
|
8509
|
-
menu.value?.show(pinned.value ? void 0 : event);
|
|
8516
|
+
menu.value?.show(pinned.value && !firstShow.value ? void 0 : event);
|
|
8517
|
+
firstShow.value = false;
|
|
8510
8518
|
}
|
|
8511
8519
|
}, 1500);
|
|
8512
8520
|
});
|
|
@@ -8564,6 +8572,9 @@
|
|
|
8564
8572
|
const closeHandler = () => {
|
|
8565
8573
|
menu.value?.hide();
|
|
8566
8574
|
};
|
|
8575
|
+
vue.watch(pinned, () => {
|
|
8576
|
+
globalThis.localStorage.setItem(PINNED_STATUE_CACHE_KEY, pinned.value.toString());
|
|
8577
|
+
});
|
|
8567
8578
|
return (_ctx, _cache) => {
|
|
8568
8579
|
return vue.openBlock(), vue.createBlock(_sfc_main$k, {
|
|
8569
8580
|
ref_key: "menu",
|
|
@@ -8813,11 +8824,6 @@
|
|
|
8813
8824
|
return;
|
|
8814
8825
|
stage.setZoom(zoom2);
|
|
8815
8826
|
});
|
|
8816
|
-
vue.watch(root, (root2) => {
|
|
8817
|
-
if (runtime && root2) {
|
|
8818
|
-
runtime.updateRootConfig?.(lodashEs.cloneDeep(vue.toRaw(root2)));
|
|
8819
|
-
}
|
|
8820
|
-
});
|
|
8821
8827
|
vue.watch(page, (page2) => {
|
|
8822
8828
|
if (runtime && page2) {
|
|
8823
8829
|
runtime.updatePageId?.(page2.id);
|
|
@@ -8826,6 +8832,12 @@
|
|
|
8826
8832
|
});
|
|
8827
8833
|
}
|
|
8828
8834
|
});
|
|
8835
|
+
const rootChangeHandler = (root2) => {
|
|
8836
|
+
if (runtime && root2) {
|
|
8837
|
+
runtime.updateRootConfig?.(lodashEs.cloneDeep(vue.toRaw(root2)));
|
|
8838
|
+
}
|
|
8839
|
+
};
|
|
8840
|
+
services?.editorService.on("root-change", rootChangeHandler);
|
|
8829
8841
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
8830
8842
|
for (const { contentRect } of entries) {
|
|
8831
8843
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -8845,6 +8857,7 @@
|
|
|
8845
8857
|
resizeObserver.disconnect();
|
|
8846
8858
|
services?.editorService.set("stage", null);
|
|
8847
8859
|
services?.keybindingService.unregisteEl("stage");
|
|
8860
|
+
services?.editorService.off("root-change", rootChangeHandler);
|
|
8848
8861
|
});
|
|
8849
8862
|
const parseDSL = getConfig("parseDSL");
|
|
8850
8863
|
const contextmenuHandler = (e) => {
|
|
@@ -9677,7 +9690,7 @@
|
|
|
9677
9690
|
const doCollect = (key, value) => {
|
|
9678
9691
|
const keyIsItems = key === "items";
|
|
9679
9692
|
const fullKey = prop ? `${prop}.${key}` : key;
|
|
9680
|
-
if (target.isTarget(
|
|
9693
|
+
if (target.isTarget(fullKey, value)) {
|
|
9681
9694
|
target.updateDep(node, fullKey);
|
|
9682
9695
|
this.emit("update-dep", node, fullKey);
|
|
9683
9696
|
} else if (!keyIsItems && Array.isArray(value)) {
|
|
@@ -9965,7 +9978,12 @@
|
|
|
9965
9978
|
const createDataSourceCondTarget = (id) => new Target({
|
|
9966
9979
|
type: DepTargetType.DATA_SOURCE_COND,
|
|
9967
9980
|
id,
|
|
9968
|
-
isTarget: (key, value) =>
|
|
9981
|
+
isTarget: (key, value) => {
|
|
9982
|
+
if (!Array.isArray(value) || value[0] !== id || !`${key}`.startsWith("displayConds"))
|
|
9983
|
+
return false;
|
|
9984
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
9985
|
+
return Boolean(ds?.fields?.find((field) => field.name === value[1]));
|
|
9986
|
+
}
|
|
9969
9987
|
});
|
|
9970
9988
|
const createDataSourceMethodTarget = (id) => new Target({
|
|
9971
9989
|
type: DepTargetType.DATA_SOURCE_METHOD,
|
|
@@ -10188,23 +10206,6 @@
|
|
|
10188
10206
|
depService.addTarget(createDataSourceCondTarget(ds.id));
|
|
10189
10207
|
};
|
|
10190
10208
|
const rootChangeHandler = async (value, preValue) => {
|
|
10191
|
-
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10192
|
-
let node;
|
|
10193
|
-
if (nodeId) {
|
|
10194
|
-
node = editorService.getNodeById(nodeId);
|
|
10195
|
-
}
|
|
10196
|
-
if (node && node !== value) {
|
|
10197
|
-
await editorService.select(node.id);
|
|
10198
|
-
} else if (value?.items?.length) {
|
|
10199
|
-
await editorService.select(value.items[0]);
|
|
10200
|
-
} else if (value?.id) {
|
|
10201
|
-
editorService.set("nodes", [value]);
|
|
10202
|
-
editorService.set("parent", null);
|
|
10203
|
-
editorService.set("page", null);
|
|
10204
|
-
}
|
|
10205
|
-
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
10206
|
-
emit("update:modelValue", value);
|
|
10207
|
-
}
|
|
10208
10209
|
if (!value)
|
|
10209
10210
|
return;
|
|
10210
10211
|
value.codeBlocks = value.codeBlocks || {};
|
|
@@ -10218,12 +10219,29 @@
|
|
|
10218
10219
|
value.dataSources.forEach((ds) => {
|
|
10219
10220
|
initDataSourceDepTarget(ds);
|
|
10220
10221
|
});
|
|
10221
|
-
if (
|
|
10222
|
+
if (Array.isArray(value.items)) {
|
|
10222
10223
|
depService.collect(value.items, true);
|
|
10223
10224
|
} else {
|
|
10224
10225
|
depService.clear();
|
|
10225
10226
|
delete value.dataSourceDeps;
|
|
10226
10227
|
}
|
|
10228
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10229
|
+
let node;
|
|
10230
|
+
if (nodeId) {
|
|
10231
|
+
node = editorService.getNodeById(nodeId);
|
|
10232
|
+
}
|
|
10233
|
+
if (node && node !== value) {
|
|
10234
|
+
await editorService.select(node.id);
|
|
10235
|
+
} else if (value.items?.length) {
|
|
10236
|
+
await editorService.select(value.items[0]);
|
|
10237
|
+
} else if (value.id) {
|
|
10238
|
+
editorService.set("nodes", [value]);
|
|
10239
|
+
editorService.set("parent", null);
|
|
10240
|
+
editorService.set("page", null);
|
|
10241
|
+
}
|
|
10242
|
+
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
10243
|
+
emit("update:modelValue", value);
|
|
10244
|
+
}
|
|
10227
10245
|
};
|
|
10228
10246
|
const nodeAddHandler = (nodes) => {
|
|
10229
10247
|
depService.collect(nodes);
|