@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
package/dist/tmagic-editor.js
CHANGED
|
@@ -4981,19 +4981,22 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
4981
4981
|
centerClass: {}
|
|
4982
4982
|
},
|
|
4983
4983
|
emits: ["update:left", "change", "update:right"],
|
|
4984
|
-
setup(__props, { emit }) {
|
|
4984
|
+
setup(__props, { expose: __expose, emit }) {
|
|
4985
4985
|
const props = __props;
|
|
4986
4986
|
const el = ref();
|
|
4987
4987
|
const hasLeft = computed(() => typeof props.left !== "undefined");
|
|
4988
4988
|
const hasRight = computed(() => typeof props.right !== "undefined");
|
|
4989
|
-
const getCenterWidth = (clientWidth2,
|
|
4989
|
+
const getCenterWidth = (clientWidth2, l = 0, r = 0) => {
|
|
4990
|
+
let right = r > 0 ? r : 0;
|
|
4991
|
+
let left = l > 0 ? l : 0;
|
|
4990
4992
|
let center2 = clientWidth2 - left - right;
|
|
4991
4993
|
if (center2 < props.minCenter) {
|
|
4992
4994
|
center2 = props.minCenter;
|
|
4993
|
-
if (
|
|
4994
|
-
right = clientWidth2 - left -
|
|
4995
|
+
if (right > center2 + props.minRight) {
|
|
4996
|
+
right = clientWidth2 - left - center2;
|
|
4995
4997
|
} else {
|
|
4996
|
-
|
|
4998
|
+
right = props.minRight;
|
|
4999
|
+
left = clientWidth2 - right - center2;
|
|
4997
5000
|
}
|
|
4998
5001
|
}
|
|
4999
5002
|
return {
|
|
@@ -5056,7 +5059,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5056
5059
|
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
5057
5060
|
right = props.right;
|
|
5058
5061
|
}
|
|
5059
|
-
const columnWidth = getCenterWidth(clientWidth, props.left
|
|
5062
|
+
const columnWidth = getCenterWidth(clientWidth, props.left, right);
|
|
5060
5063
|
center.value = columnWidth.center;
|
|
5061
5064
|
emit("change", {
|
|
5062
5065
|
left: columnWidth.left,
|
|
@@ -5064,11 +5067,22 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5064
5067
|
right: columnWidth.right
|
|
5065
5068
|
});
|
|
5066
5069
|
};
|
|
5070
|
+
__expose({
|
|
5071
|
+
updateWidth() {
|
|
5072
|
+
const columnWidth = getCenterWidth(el.value?.clientWidth || clientWidth, props.left, props.right);
|
|
5073
|
+
emit("change", {
|
|
5074
|
+
left: columnWidth.left,
|
|
5075
|
+
center: center.value,
|
|
5076
|
+
right: columnWidth.right
|
|
5077
|
+
});
|
|
5078
|
+
}
|
|
5079
|
+
});
|
|
5067
5080
|
return (_ctx, _cache) => {
|
|
5068
5081
|
return openBlock(), createElementBlock("div", {
|
|
5069
5082
|
ref_key: "el",
|
|
5070
5083
|
ref: el,
|
|
5071
|
-
class: "m-editor-layout"
|
|
5084
|
+
class: "m-editor-layout",
|
|
5085
|
+
style: normalizeStyle(`min-width: ${props.minCenter + props.minLeft + props.minRight}px`)
|
|
5072
5086
|
}, [
|
|
5073
5087
|
hasLeft.value && _ctx.$slots.left ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
5074
5088
|
createElementVNode("div", {
|
|
@@ -5094,7 +5108,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
5094
5108
|
renderSlot(_ctx.$slots, "right")
|
|
5095
5109
|
], 6)
|
|
5096
5110
|
], 64)) : createCommentVNode("", true)
|
|
5097
|
-
],
|
|
5111
|
+
], 4);
|
|
5098
5112
|
};
|
|
5099
5113
|
}
|
|
5100
5114
|
});
|
|
@@ -5152,31 +5166,21 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5152
5166
|
const codeOptions = inject("codeOptions", {});
|
|
5153
5167
|
const { editorService, uiService } = inject("services") || {};
|
|
5154
5168
|
const content = ref();
|
|
5169
|
+
const splitView = ref();
|
|
5155
5170
|
const root = computed(() => editorService?.get("root"));
|
|
5156
5171
|
const pageLength = computed(() => editorService?.get("pageLength") || 0);
|
|
5157
5172
|
const showSrc = computed(() => uiService?.get("showSrc"));
|
|
5158
|
-
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY));
|
|
5159
|
-
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY));
|
|
5173
|
+
const leftColumnWidthCacheData = Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
5174
|
+
const RightColumnWidthCacheData = Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
5160
5175
|
const columnWidth = ref({
|
|
5161
5176
|
left: leftColumnWidthCacheData,
|
|
5162
5177
|
center: 0,
|
|
5163
5178
|
right: RightColumnWidthCacheData
|
|
5164
5179
|
});
|
|
5165
5180
|
watch(
|
|
5166
|
-
pageLength,
|
|
5167
|
-
(
|
|
5168
|
-
|
|
5169
|
-
columnWidth.value.left = left;
|
|
5170
|
-
const container = content.value || document.body;
|
|
5171
|
-
if (length <= 0) {
|
|
5172
|
-
columnWidth.value.right = void 0;
|
|
5173
|
-
columnWidth.value.center = container.clientWidth - left;
|
|
5174
|
-
} else {
|
|
5175
|
-
const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
5176
|
-
columnWidth.value.right = right;
|
|
5177
|
-
columnWidth.value.center = container.clientWidth - left - right;
|
|
5178
|
-
}
|
|
5179
|
-
uiService?.set("columnWidth", columnWidth.value);
|
|
5181
|
+
[pageLength, splitView],
|
|
5182
|
+
() => {
|
|
5183
|
+
splitView.value?.updateWidth();
|
|
5180
5184
|
},
|
|
5181
5185
|
{
|
|
5182
5186
|
immediate: true
|
|
@@ -5214,7 +5218,8 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5214
5218
|
return openBlock(), createElementBlock("div", {
|
|
5215
5219
|
class: "m-editor",
|
|
5216
5220
|
ref_key: "content",
|
|
5217
|
-
ref: content
|
|
5221
|
+
ref: content,
|
|
5222
|
+
style: { "min-width": "180px" }
|
|
5218
5223
|
}, [
|
|
5219
5224
|
renderSlot(_ctx.$slots, "header"),
|
|
5220
5225
|
renderSlot(_ctx.$slots, "nav"),
|
|
@@ -5228,6 +5233,8 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5228
5233
|
}, null, 8, ["init-values", "options"])
|
|
5229
5234
|
]) : (openBlock(), createBlock(_sfc_main$A, {
|
|
5230
5235
|
key: 1,
|
|
5236
|
+
ref_key: "splitView",
|
|
5237
|
+
ref: splitView,
|
|
5231
5238
|
class: "m-editor-content",
|
|
5232
5239
|
"left-class": "m-editor-framework-left",
|
|
5233
5240
|
"center-class": "m-editor-framework-center",
|
|
@@ -5238,6 +5245,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
5238
5245
|
"onUpdate:right": _cache[1] || (_cache[1] = ($event) => columnWidth.value.right = $event),
|
|
5239
5246
|
"min-left": 65,
|
|
5240
5247
|
"min-right": 20,
|
|
5248
|
+
"min-center": 100,
|
|
5241
5249
|
onChange: columnWidthChange
|
|
5242
5250
|
}, createSlots({
|
|
5243
5251
|
left: withCtx(() => [
|
|
@@ -6082,25 +6090,25 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
6082
6090
|
id,
|
|
6083
6091
|
children: getKeyTreeConfig(dep, type)
|
|
6084
6092
|
});
|
|
6093
|
+
const mergeChildren = (children, deps, type) => {
|
|
6094
|
+
Object.entries(deps).forEach(([id, dep]) => {
|
|
6095
|
+
const nodeItem = children.find((item) => item.id === id);
|
|
6096
|
+
if (nodeItem) {
|
|
6097
|
+
nodeItem.children = nodeItem.children.concat(getKeyTreeConfig(dep, type));
|
|
6098
|
+
} else {
|
|
6099
|
+
children.push(getNodeTreeConfig(id, dep, type));
|
|
6100
|
+
}
|
|
6101
|
+
});
|
|
6102
|
+
};
|
|
6085
6103
|
const list = computed(
|
|
6086
6104
|
() => dataSources.value.map((ds) => {
|
|
6087
6105
|
const dsDeps = dsDep.value[ds.id].deps;
|
|
6088
6106
|
const dsMethodDeps = dsMethodDep.value[ds.id].deps;
|
|
6089
6107
|
const dsCondDeps = dsCondDep.value[ds.id].deps;
|
|
6090
6108
|
const children = [];
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
if (nodeItem) {
|
|
6095
|
-
nodeItem.children = nodeItem.children.concat(getKeyTreeConfig(dep, type));
|
|
6096
|
-
} else {
|
|
6097
|
-
children.push(getNodeTreeConfig(id, dep, type));
|
|
6098
|
-
}
|
|
6099
|
-
});
|
|
6100
|
-
};
|
|
6101
|
-
mergeChildren(dsDeps);
|
|
6102
|
-
mergeChildren(dsMethodDeps, "method");
|
|
6103
|
-
mergeChildren(dsCondDeps, "cond");
|
|
6109
|
+
mergeChildren(children, dsDeps);
|
|
6110
|
+
mergeChildren(children, dsMethodDeps, "method");
|
|
6111
|
+
mergeChildren(children, dsCondDeps, "cond");
|
|
6104
6112
|
return {
|
|
6105
6113
|
id: ds.id,
|
|
6106
6114
|
name: ds.title,
|
|
@@ -6574,11 +6582,8 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
6574
6582
|
const show = (e) => {
|
|
6575
6583
|
setTimeout(() => {
|
|
6576
6584
|
visible.value = true;
|
|
6577
|
-
if (!e) {
|
|
6578
|
-
return;
|
|
6579
|
-
}
|
|
6580
6585
|
nextTick(() => {
|
|
6581
|
-
setPosition(e);
|
|
6586
|
+
e && setPosition(e);
|
|
6582
6587
|
emit("show");
|
|
6583
6588
|
});
|
|
6584
6589
|
}, 300);
|
|
@@ -8439,6 +8444,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
8439
8444
|
}
|
|
8440
8445
|
});
|
|
8441
8446
|
|
|
8447
|
+
const PINNED_STATUE_CACHE_KEY = "tmagic-pinned-node-list-pinned-status";
|
|
8442
8448
|
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
8443
8449
|
__name: "NodeListMenu",
|
|
8444
8450
|
props: {
|
|
@@ -8448,7 +8454,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
8448
8454
|
const props = __props;
|
|
8449
8455
|
const menu = ref();
|
|
8450
8456
|
const nodeList = ref([]);
|
|
8451
|
-
const pinned = ref(
|
|
8457
|
+
const pinned = ref(Boolean(globalThis.localStorage.getItem(PINNED_STATUE_CACHE_KEY)));
|
|
8458
|
+
const firstShow = ref(true);
|
|
8452
8459
|
const services = inject("services");
|
|
8453
8460
|
const editorService = services?.editorService;
|
|
8454
8461
|
const componentListService = services?.componentListService;
|
|
@@ -8497,7 +8504,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
8497
8504
|
}
|
|
8498
8505
|
nodeList.value = nodes;
|
|
8499
8506
|
if (nodeList.value.length > 1) {
|
|
8500
|
-
menu.value?.show(pinned.value ? void 0 : event);
|
|
8507
|
+
menu.value?.show(pinned.value && !firstShow.value ? void 0 : event);
|
|
8508
|
+
firstShow.value = false;
|
|
8501
8509
|
}
|
|
8502
8510
|
}, 1500);
|
|
8503
8511
|
});
|
|
@@ -8555,6 +8563,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
8555
8563
|
const closeHandler = () => {
|
|
8556
8564
|
menu.value?.hide();
|
|
8557
8565
|
};
|
|
8566
|
+
watch(pinned, () => {
|
|
8567
|
+
globalThis.localStorage.setItem(PINNED_STATUE_CACHE_KEY, pinned.value.toString());
|
|
8568
|
+
});
|
|
8558
8569
|
return (_ctx, _cache) => {
|
|
8559
8570
|
return openBlock(), createBlock(_sfc_main$k, {
|
|
8560
8571
|
ref_key: "menu",
|
|
@@ -8804,11 +8815,6 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
8804
8815
|
return;
|
|
8805
8816
|
stage.setZoom(zoom2);
|
|
8806
8817
|
});
|
|
8807
|
-
watch(root, (root2) => {
|
|
8808
|
-
if (runtime && root2) {
|
|
8809
|
-
runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
|
|
8810
|
-
}
|
|
8811
|
-
});
|
|
8812
8818
|
watch(page, (page2) => {
|
|
8813
8819
|
if (runtime && page2) {
|
|
8814
8820
|
runtime.updatePageId?.(page2.id);
|
|
@@ -8817,6 +8823,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
8817
8823
|
});
|
|
8818
8824
|
}
|
|
8819
8825
|
});
|
|
8826
|
+
const rootChangeHandler = (root2) => {
|
|
8827
|
+
if (runtime && root2) {
|
|
8828
|
+
runtime.updateRootConfig?.(cloneDeep(toRaw(root2)));
|
|
8829
|
+
}
|
|
8830
|
+
};
|
|
8831
|
+
services?.editorService.on("root-change", rootChangeHandler);
|
|
8820
8832
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
8821
8833
|
for (const { contentRect } of entries) {
|
|
8822
8834
|
services?.uiService.set("stageContainerRect", {
|
|
@@ -8836,6 +8848,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
8836
8848
|
resizeObserver.disconnect();
|
|
8837
8849
|
services?.editorService.set("stage", null);
|
|
8838
8850
|
services?.keybindingService.unregisteEl("stage");
|
|
8851
|
+
services?.editorService.off("root-change", rootChangeHandler);
|
|
8839
8852
|
});
|
|
8840
8853
|
const parseDSL = getConfig("parseDSL");
|
|
8841
8854
|
const contextmenuHandler = (e) => {
|
|
@@ -9668,7 +9681,7 @@ class Watcher extends EventEmitter {
|
|
|
9668
9681
|
const doCollect = (key, value) => {
|
|
9669
9682
|
const keyIsItems = key === "items";
|
|
9670
9683
|
const fullKey = prop ? `${prop}.${key}` : key;
|
|
9671
|
-
if (target.isTarget(
|
|
9684
|
+
if (target.isTarget(fullKey, value)) {
|
|
9672
9685
|
target.updateDep(node, fullKey);
|
|
9673
9686
|
this.emit("update-dep", node, fullKey);
|
|
9674
9687
|
} else if (!keyIsItems && Array.isArray(value)) {
|
|
@@ -9956,7 +9969,12 @@ const createDataSourceTarget = (id) => new Target({
|
|
|
9956
9969
|
const createDataSourceCondTarget = (id) => new Target({
|
|
9957
9970
|
type: DepTargetType.DATA_SOURCE_COND,
|
|
9958
9971
|
id,
|
|
9959
|
-
isTarget: (key, value) =>
|
|
9972
|
+
isTarget: (key, value) => {
|
|
9973
|
+
if (!Array.isArray(value) || value[0] !== id || !`${key}`.startsWith("displayConds"))
|
|
9974
|
+
return false;
|
|
9975
|
+
const ds = dataSourceService.getDataSourceById(id);
|
|
9976
|
+
return Boolean(ds?.fields?.find((field) => field.name === value[1]));
|
|
9977
|
+
}
|
|
9960
9978
|
});
|
|
9961
9979
|
const createDataSourceMethodTarget = (id) => new Target({
|
|
9962
9980
|
type: DepTargetType.DATA_SOURCE_METHOD,
|
|
@@ -10179,23 +10197,6 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
10179
10197
|
depService.addTarget(createDataSourceCondTarget(ds.id));
|
|
10180
10198
|
};
|
|
10181
10199
|
const rootChangeHandler = async (value, preValue) => {
|
|
10182
|
-
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10183
|
-
let node;
|
|
10184
|
-
if (nodeId) {
|
|
10185
|
-
node = editorService.getNodeById(nodeId);
|
|
10186
|
-
}
|
|
10187
|
-
if (node && node !== value) {
|
|
10188
|
-
await editorService.select(node.id);
|
|
10189
|
-
} else if (value?.items?.length) {
|
|
10190
|
-
await editorService.select(value.items[0]);
|
|
10191
|
-
} else if (value?.id) {
|
|
10192
|
-
editorService.set("nodes", [value]);
|
|
10193
|
-
editorService.set("parent", null);
|
|
10194
|
-
editorService.set("page", null);
|
|
10195
|
-
}
|
|
10196
|
-
if (toRaw(value) !== toRaw(preValue)) {
|
|
10197
|
-
emit("update:modelValue", value);
|
|
10198
|
-
}
|
|
10199
10200
|
if (!value)
|
|
10200
10201
|
return;
|
|
10201
10202
|
value.codeBlocks = value.codeBlocks || {};
|
|
@@ -10209,12 +10210,29 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
10209
10210
|
value.dataSources.forEach((ds) => {
|
|
10210
10211
|
initDataSourceDepTarget(ds);
|
|
10211
10212
|
});
|
|
10212
|
-
if (
|
|
10213
|
+
if (Array.isArray(value.items)) {
|
|
10213
10214
|
depService.collect(value.items, true);
|
|
10214
10215
|
} else {
|
|
10215
10216
|
depService.clear();
|
|
10216
10217
|
delete value.dataSourceDeps;
|
|
10217
10218
|
}
|
|
10219
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
10220
|
+
let node;
|
|
10221
|
+
if (nodeId) {
|
|
10222
|
+
node = editorService.getNodeById(nodeId);
|
|
10223
|
+
}
|
|
10224
|
+
if (node && node !== value) {
|
|
10225
|
+
await editorService.select(node.id);
|
|
10226
|
+
} else if (value.items?.length) {
|
|
10227
|
+
await editorService.select(value.items[0]);
|
|
10228
|
+
} else if (value.id) {
|
|
10229
|
+
editorService.set("nodes", [value]);
|
|
10230
|
+
editorService.set("parent", null);
|
|
10231
|
+
editorService.set("page", null);
|
|
10232
|
+
}
|
|
10233
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
10234
|
+
emit("update:modelValue", value);
|
|
10235
|
+
}
|
|
10218
10236
|
};
|
|
10219
10237
|
const nodeAddHandler = (nodes) => {
|
|
10220
10238
|
depService.collect(nodes);
|