@tmagic/editor 1.5.13 → 1.5.15
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 +126 -118
- package/dist/tmagic-editor.umd.cjs +126 -118
- package/package.json +7 -7
- package/src/Editor.vue +4 -20
- package/src/components/CodeBlockEditor.vue +1 -1
- package/src/components/FloatingBox.vue +1 -1
- package/src/components/ScrollBar.vue +9 -3
- package/src/components/SearchInput.vue +1 -1
- package/src/components/Tree.vue +3 -3
- package/src/components/TreeNode.vue +3 -3
- package/src/fields/CodeSelect.vue +5 -7
- package/src/fields/CodeSelectCol.vue +9 -5
- package/src/fields/DataSourceFields.vue +4 -2
- package/src/fields/DataSourceInput.vue +7 -3
- package/src/fields/DataSourceMethodSelect.vue +17 -6
- package/src/fields/DataSourceMethods.vue +3 -3
- package/src/fields/EventSelect.vue +3 -2
- package/src/fields/UISelect.vue +2 -2
- package/src/hooks/use-code-block-edit.ts +1 -1
- package/src/index.ts +0 -1
- package/src/initService.ts +79 -69
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/page-bar/PageBar.vue +1 -1
- package/src/layouts/props-panel/FormPanel.vue +2 -2
- package/src/layouts/props-panel/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +1 -1
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +4 -5
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +12 -13
- package/src/layouts/workspace/viewer/Stage.vue +1 -1
- package/src/services/BaseService.ts +1 -0
- package/src/services/editor.ts +4 -3
- package/src/type.ts +9 -0
- package/src/utils/props.ts +9 -7
- package/types/index.d.ts +57 -55
package/dist/tmagic-editor.js
CHANGED
|
@@ -471,13 +471,11 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
|
|
|
471
471
|
{ value: HookCodeType.DATA_SOURCE_METHOD, text: "数据源方法" }
|
|
472
472
|
],
|
|
473
473
|
defaultValue: "code",
|
|
474
|
-
onChange: (
|
|
474
|
+
onChange: (_mForm, v, { setModel }) => {
|
|
475
475
|
if (v === HookCodeType.DATA_SOURCE_METHOD) {
|
|
476
|
-
|
|
477
|
-
changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: [] });
|
|
476
|
+
setModel("codeId", []);
|
|
478
477
|
} else {
|
|
479
|
-
|
|
480
|
-
changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: "" });
|
|
478
|
+
setModel("codeId", "");
|
|
481
479
|
}
|
|
482
480
|
return v;
|
|
483
481
|
}
|
|
@@ -487,7 +485,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
|
|
|
487
485
|
name: "codeId",
|
|
488
486
|
span: 18,
|
|
489
487
|
labelWidth: 0,
|
|
490
|
-
display: (
|
|
488
|
+
display: (_mForm, { model }) => model.codeType !== HookCodeType.DATA_SOURCE_METHOD,
|
|
491
489
|
notEditable: () => !codeBlockService.getEditStatus()
|
|
492
490
|
},
|
|
493
491
|
{
|
|
@@ -495,7 +493,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
|
|
|
495
493
|
name: "codeId",
|
|
496
494
|
span: 18,
|
|
497
495
|
labelWidth: 0,
|
|
498
|
-
display: (
|
|
496
|
+
display: (_mForm, { model }) => model.codeType === HookCodeType.DATA_SOURCE_METHOD,
|
|
499
497
|
notEditable: () => !dataSourceService.get("editable")
|
|
500
498
|
}
|
|
501
499
|
]
|
|
@@ -693,13 +691,12 @@ const fillConfig$1 = (config = [], labelWidth = "80px") => [
|
|
|
693
691
|
append: {
|
|
694
692
|
type: "button",
|
|
695
693
|
text: "复制",
|
|
696
|
-
handler:
|
|
697
|
-
|
|
698
|
-
await navigator.clipboard.writeText(`${model.id}`);
|
|
694
|
+
handler: (vm, { model }) => {
|
|
695
|
+
navigator.clipboard.writeText(`${model.id}`).then(() => {
|
|
699
696
|
tMagicMessage.success("已复制");
|
|
700
|
-
}
|
|
697
|
+
}).catch(() => {
|
|
701
698
|
tMagicMessage.error("复制失败");
|
|
702
|
-
}
|
|
699
|
+
});
|
|
703
700
|
}
|
|
704
701
|
}
|
|
705
702
|
},
|
|
@@ -2437,10 +2434,11 @@ class Editor extends BaseService {
|
|
|
2437
2434
|
this.isHistoryStateChange = true;
|
|
2438
2435
|
await this.update(value.data);
|
|
2439
2436
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
2440
|
-
setTimeout(
|
|
2437
|
+
setTimeout(() => {
|
|
2441
2438
|
if (!value.nodeId) return;
|
|
2442
|
-
|
|
2443
|
-
|
|
2439
|
+
this.select(value.nodeId).then(() => {
|
|
2440
|
+
this.get("stage")?.select(value.nodeId);
|
|
2441
|
+
});
|
|
2444
2442
|
}, 0);
|
|
2445
2443
|
this.emit("history-change", value.data);
|
|
2446
2444
|
}
|
|
@@ -3212,20 +3210,23 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
|
|
|
3212
3210
|
}
|
|
3213
3211
|
return [];
|
|
3214
3212
|
},
|
|
3215
|
-
onChange: (formState, codeId, { model }) => {
|
|
3213
|
+
onChange: (formState, codeId, { setModel, model }) => {
|
|
3216
3214
|
paramsConfig.value = getParamItemsConfig(codeId);
|
|
3217
3215
|
if (paramsConfig.value.length) {
|
|
3218
|
-
|
|
3216
|
+
setModel("params", createValues(formState, paramsConfig.value, {}, model.params));
|
|
3219
3217
|
} else {
|
|
3220
|
-
|
|
3218
|
+
setModel("params", {});
|
|
3221
3219
|
}
|
|
3222
3220
|
return codeId;
|
|
3223
3221
|
}
|
|
3224
3222
|
};
|
|
3225
|
-
const onCodeIdChangeHandler = (value) => {
|
|
3223
|
+
const onCodeIdChangeHandler = (value, eventData) => {
|
|
3226
3224
|
props.model.params = value.params;
|
|
3227
3225
|
emit("change", props.model, {
|
|
3228
|
-
changeRecords:
|
|
3226
|
+
changeRecords: eventData.changeRecords?.map((item) => ({
|
|
3227
|
+
prop: `${props.prop.replace(props.name, "")}${item.propPath}`,
|
|
3228
|
+
value: item.value
|
|
3229
|
+
})) || [
|
|
3229
3230
|
{
|
|
3230
3231
|
propPath: props.prop,
|
|
3231
3232
|
value: value[props.name]
|
|
@@ -3590,9 +3591,7 @@ const useCodeBlockEdit = (codeBlockService) => {
|
|
|
3590
3591
|
const createCodeBlock = async () => {
|
|
3591
3592
|
codeConfig.value = {
|
|
3592
3593
|
name: "",
|
|
3593
|
-
content:
|
|
3594
|
-
// place your code here
|
|
3595
|
-
}`,
|
|
3594
|
+
content: "({app, params, flowState}) => {\n // place your code here\n}",
|
|
3596
3595
|
params: []
|
|
3597
3596
|
};
|
|
3598
3597
|
codeId.value = await codeBlockService.getUniqueId();
|
|
@@ -4164,6 +4163,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
|
|
|
4164
4163
|
try {
|
|
4165
4164
|
return JSON.stringify(row.defaultValue);
|
|
4166
4165
|
} catch (e) {
|
|
4166
|
+
error(e);
|
|
4167
4167
|
return row.defaultValue;
|
|
4168
4168
|
}
|
|
4169
4169
|
}
|
|
@@ -4212,9 +4212,9 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
|
|
|
4212
4212
|
{ text: "null", value: "null" },
|
|
4213
4213
|
{ text: "any", value: "any" }
|
|
4214
4214
|
],
|
|
4215
|
-
onChange: (
|
|
4215
|
+
onChange: (_formState, v, { setModel }) => {
|
|
4216
4216
|
if (!["any", "array", "object"].includes(v)) {
|
|
4217
|
-
|
|
4217
|
+
setModel("fields", []);
|
|
4218
4218
|
}
|
|
4219
4219
|
return v;
|
|
4220
4220
|
}
|
|
@@ -5433,9 +5433,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
|
|
|
5433
5433
|
{
|
|
5434
5434
|
text: "编辑",
|
|
5435
5435
|
handler: (method, index) => {
|
|
5436
|
-
let codeContent = method.content ||
|
|
5437
|
-
// place your code here
|
|
5438
|
-
}`;
|
|
5436
|
+
let codeContent = method.content || "({ params, dataSource, app }) => {\n // place your code here\n}";
|
|
5439
5437
|
if (typeof codeContent !== "string") {
|
|
5440
5438
|
codeContent = codeContent.toString();
|
|
5441
5439
|
}
|
|
@@ -5464,9 +5462,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
|
|
|
5464
5462
|
const createCodeHandler = () => {
|
|
5465
5463
|
codeConfig.value = {
|
|
5466
5464
|
name: "",
|
|
5467
|
-
content:
|
|
5468
|
-
// place your code here
|
|
5469
|
-
}`,
|
|
5465
|
+
content: "({ params, dataSource, app, flowState }) => {\n // place your code here\n}",
|
|
5470
5466
|
params: []
|
|
5471
5467
|
};
|
|
5472
5468
|
editIndex = -1;
|
|
@@ -5585,12 +5581,12 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
|
|
|
5585
5581
|
}));
|
|
5586
5582
|
};
|
|
5587
5583
|
const paramsConfig = ref(getParamItemsConfig(props.model[props.name || "dataSourceMethod"]));
|
|
5588
|
-
const setParamsConfig = (dataSourceMethod, formState = {}) => {
|
|
5584
|
+
const setParamsConfig = (dataSourceMethod, formState = {}, setModel) => {
|
|
5589
5585
|
paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
|
|
5590
5586
|
if (paramsConfig.value.length) {
|
|
5591
|
-
|
|
5587
|
+
setModel("params", createValues(formState, paramsConfig.value, {}, props.model.params));
|
|
5592
5588
|
} else {
|
|
5593
|
-
|
|
5589
|
+
setModel("params", {});
|
|
5594
5590
|
}
|
|
5595
5591
|
};
|
|
5596
5592
|
const methodsOptions = computed(
|
|
@@ -5611,8 +5607,8 @@ const _sfc_main$1c = /* @__PURE__ */ defineComponent({
|
|
|
5611
5607
|
name: props.name,
|
|
5612
5608
|
options: methodsOptions.value,
|
|
5613
5609
|
disable: props.disabled,
|
|
5614
|
-
onChange: (formState, dataSourceMethod) => {
|
|
5615
|
-
setParamsConfig(dataSourceMethod, formState);
|
|
5610
|
+
onChange: (formState, dataSourceMethod, { setModel }) => {
|
|
5611
|
+
setParamsConfig(dataSourceMethod, formState, setModel);
|
|
5616
5612
|
return dataSourceMethod;
|
|
5617
5613
|
}
|
|
5618
5614
|
}));
|
|
@@ -6280,8 +6276,8 @@ const _sfc_main$18 = /* @__PURE__ */ defineComponent({
|
|
|
6280
6276
|
text: "联动组件",
|
|
6281
6277
|
type: "ui-select",
|
|
6282
6278
|
display: (mForm, { model }) => model.actionType === ActionType.COMP,
|
|
6283
|
-
onChange: (MForm, v, {
|
|
6284
|
-
|
|
6279
|
+
onChange: (MForm, v, { setModel }) => {
|
|
6280
|
+
setModel("method", "");
|
|
6285
6281
|
return v;
|
|
6286
6282
|
}
|
|
6287
6283
|
};
|
|
@@ -9372,7 +9368,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
9372
9368
|
type: "button",
|
|
9373
9369
|
className: "delete",
|
|
9374
9370
|
icon: markRaw(Delete),
|
|
9375
|
-
tooltip:
|
|
9371
|
+
tooltip: "刪除(Delete)",
|
|
9376
9372
|
disabled: () => editorService.get("node")?.type === NodeType.PAGE,
|
|
9377
9373
|
handler: () => {
|
|
9378
9374
|
const node = editorService.get("node");
|
|
@@ -10607,13 +10603,13 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
10607
10603
|
eventBus?.on("edit-code", (id) => {
|
|
10608
10604
|
editCode(id);
|
|
10609
10605
|
});
|
|
10610
|
-
|
|
10606
|
+
watch(codeId, () => {
|
|
10611
10607
|
if (codeBlockListRef.value) {
|
|
10612
10608
|
for (const [statusId, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
|
|
10613
10609
|
status.selected = statusId === codeId.value;
|
|
10614
10610
|
}
|
|
10615
10611
|
}
|
|
10616
|
-
};
|
|
10612
|
+
});
|
|
10617
10613
|
const editDialogCloseHandler = () => {
|
|
10618
10614
|
if (codeBlockListRef.value) {
|
|
10619
10615
|
for (const [, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
|
|
@@ -10685,8 +10681,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
10685
10681
|
disabled: !editable.value,
|
|
10686
10682
|
content: unref(codeConfig),
|
|
10687
10683
|
onSubmit: unref(submitCodeBlockHandler),
|
|
10688
|
-
onClose: editDialogCloseHandler
|
|
10689
|
-
onOpen: editDialogOpenHandler
|
|
10684
|
+
onClose: editDialogCloseHandler
|
|
10690
10685
|
}, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("v-if", true),
|
|
10691
10686
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
10692
10687
|
menuData.value.length ? (openBlock(), createBlock(_sfc_main$o, {
|
|
@@ -11073,20 +11068,20 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
11073
11068
|
const eventBus = inject("eventBus");
|
|
11074
11069
|
const { dataSourceService } = useServices();
|
|
11075
11070
|
const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
|
|
11076
|
-
const editDialogOpenHandler = (id) => {
|
|
11077
|
-
if (dataSourceList.value) {
|
|
11078
|
-
for (const [statusId, status] of dataSourceList.value.nodeStatusMap.entries()) {
|
|
11079
|
-
status.selected = statusId === id;
|
|
11080
|
-
}
|
|
11081
|
-
}
|
|
11082
|
-
};
|
|
11083
11071
|
const editDialogCloseHandler = () => {
|
|
11084
|
-
if (
|
|
11085
|
-
for (const [, status] of
|
|
11072
|
+
if (dataSourceListRef.value) {
|
|
11073
|
+
for (const [, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
11086
11074
|
status.selected = false;
|
|
11087
11075
|
}
|
|
11088
11076
|
}
|
|
11089
11077
|
};
|
|
11078
|
+
watch(dataSourceValues, (dataSourceValues2) => {
|
|
11079
|
+
if (dataSourceListRef.value && dataSourceValues2.id) {
|
|
11080
|
+
for (const [statusId, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
11081
|
+
status.selected = statusId === dataSourceValues2.id;
|
|
11082
|
+
}
|
|
11083
|
+
}
|
|
11084
|
+
});
|
|
11090
11085
|
const datasourceTypeList = computed(
|
|
11091
11086
|
() => [
|
|
11092
11087
|
{ text: "基础", type: "base" },
|
|
@@ -11116,9 +11111,9 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
11116
11111
|
});
|
|
11117
11112
|
dataSourceService.remove(id);
|
|
11118
11113
|
};
|
|
11119
|
-
const
|
|
11114
|
+
const dataSourceListRef = useTemplateRef("dataSourceList");
|
|
11120
11115
|
const filterTextChangeHandler = (val) => {
|
|
11121
|
-
|
|
11116
|
+
dataSourceListRef.value?.filter(val);
|
|
11122
11117
|
};
|
|
11123
11118
|
eventBus?.on("edit-data-source", (id) => {
|
|
11124
11119
|
editHandler(id);
|
|
@@ -11185,8 +11180,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
11185
11180
|
]),
|
|
11186
11181
|
createCommentVNode(" 数据源列表 "),
|
|
11187
11182
|
createVNode(_sfc_main$h, {
|
|
11188
|
-
|
|
11189
|
-
ref: dataSourceList,
|
|
11183
|
+
ref: "dataSourceList",
|
|
11190
11184
|
indent: _ctx.indent,
|
|
11191
11185
|
"next-level-indent-increment": _ctx.nextLevelIndentIncrement,
|
|
11192
11186
|
onEdit: unref(editHandler),
|
|
@@ -11204,8 +11198,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
11204
11198
|
values: unref(dataSourceValues),
|
|
11205
11199
|
title: unref(dialogTitle),
|
|
11206
11200
|
onSubmit: unref(submitDataSourceHandler),
|
|
11207
|
-
onClose: editDialogCloseHandler
|
|
11208
|
-
onOpen: editDialogOpenHandler
|
|
11201
|
+
onClose: editDialogCloseHandler
|
|
11209
11202
|
}, null, 8, ["disabled", "values", "title", "onSubmit"]),
|
|
11210
11203
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
11211
11204
|
menuData.value.length ? (openBlock(), createBlock(_sfc_main$o, {
|
|
@@ -14658,10 +14651,10 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14658
14651
|
const getTMagicApp = () => {
|
|
14659
14652
|
const renderer = editorService.get("stage")?.renderer;
|
|
14660
14653
|
if (!renderer) {
|
|
14661
|
-
return void 0;
|
|
14654
|
+
return Promise.resolve(void 0);
|
|
14662
14655
|
}
|
|
14663
14656
|
if (renderer.runtime) {
|
|
14664
|
-
return renderer.runtime.getApp?.();
|
|
14657
|
+
return Promise.resolve(renderer.runtime.getApp?.());
|
|
14665
14658
|
}
|
|
14666
14659
|
return new Promise((resolve) => {
|
|
14667
14660
|
const timeout = globalThis.setTimeout(() => {
|
|
@@ -14699,12 +14692,13 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14699
14692
|
app.dsl.dataSources = root.dataSources;
|
|
14700
14693
|
}
|
|
14701
14694
|
};
|
|
14702
|
-
const dsDepCollectedHandler =
|
|
14695
|
+
const dsDepCollectedHandler = () => {
|
|
14703
14696
|
const root = editorService.get("root");
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
|
|
14707
|
-
|
|
14697
|
+
getTMagicApp()?.then((app) => {
|
|
14698
|
+
if (root && app?.dsl) {
|
|
14699
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
14700
|
+
}
|
|
14701
|
+
});
|
|
14708
14702
|
};
|
|
14709
14703
|
const collectIdle = (nodes, deep, type) => Promise.all(
|
|
14710
14704
|
nodes.map((node) => {
|
|
@@ -14737,7 +14731,7 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14737
14731
|
depService.addTarget(createDataSourceMethodTarget(ds, reactive({})));
|
|
14738
14732
|
depService.addTarget(createDataSourceCondTarget(ds, reactive({})));
|
|
14739
14733
|
};
|
|
14740
|
-
const rootChangeHandler =
|
|
14734
|
+
const rootChangeHandler = (value, preValue) => {
|
|
14741
14735
|
if (!value) return;
|
|
14742
14736
|
value.codeBlocks = value.codeBlocks || {};
|
|
14743
14737
|
value.dataSources = value.dataSources || [];
|
|
@@ -14760,29 +14754,33 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14760
14754
|
delete value.dataSourceDeps;
|
|
14761
14755
|
delete value.dataSourceCondDeps;
|
|
14762
14756
|
}
|
|
14763
|
-
const
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14757
|
+
const handler = async () => {
|
|
14758
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
14759
|
+
let node;
|
|
14760
|
+
if (nodeId) {
|
|
14761
|
+
node = editorService.getNodeById(nodeId);
|
|
14762
|
+
}
|
|
14763
|
+
if (node && node !== value) {
|
|
14764
|
+
await editorService.select(node.id);
|
|
14765
|
+
} else if (value.items?.length) {
|
|
14766
|
+
await editorService.select(value.items[0]);
|
|
14767
|
+
} else if (value.id) {
|
|
14768
|
+
editorService.set("nodes", [value]);
|
|
14769
|
+
editorService.set("parent", null);
|
|
14770
|
+
editorService.set("page", null);
|
|
14771
|
+
}
|
|
14772
|
+
if (toRaw(value) !== toRaw(preValue)) {
|
|
14773
|
+
emit("update:modelValue", value);
|
|
14774
|
+
}
|
|
14775
|
+
};
|
|
14776
|
+
handler();
|
|
14780
14777
|
};
|
|
14781
|
-
const nodeAddHandler =
|
|
14782
|
-
|
|
14783
|
-
|
|
14778
|
+
const nodeAddHandler = (nodes) => {
|
|
14779
|
+
collectIdle(nodes, true).then(() => {
|
|
14780
|
+
updateStageNodes(nodes);
|
|
14781
|
+
});
|
|
14784
14782
|
};
|
|
14785
|
-
const nodeUpdateHandler =
|
|
14783
|
+
const nodeUpdateHandler = (data) => {
|
|
14786
14784
|
const needRecollectNodes = [];
|
|
14787
14785
|
const normalNodes = [];
|
|
14788
14786
|
for (const { newNode, oldNode, changeRecords } of data) {
|
|
@@ -14814,9 +14812,12 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14814
14812
|
}
|
|
14815
14813
|
}
|
|
14816
14814
|
if (needRecollectNodes.length) {
|
|
14817
|
-
|
|
14818
|
-
|
|
14819
|
-
|
|
14815
|
+
const handler = async () => {
|
|
14816
|
+
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE);
|
|
14817
|
+
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE_COND);
|
|
14818
|
+
updateStageNodes(needRecollectNodes);
|
|
14819
|
+
};
|
|
14820
|
+
handler();
|
|
14820
14821
|
} else {
|
|
14821
14822
|
updateStageNodes(normalNodes);
|
|
14822
14823
|
Promise.all([
|
|
@@ -14828,28 +14829,32 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14828
14829
|
const nodeRemoveHandler = (nodes) => {
|
|
14829
14830
|
depService.clear(nodes);
|
|
14830
14831
|
};
|
|
14831
|
-
const historyChangeHandler =
|
|
14832
|
-
|
|
14833
|
-
|
|
14832
|
+
const historyChangeHandler = (page) => {
|
|
14833
|
+
collectIdle([page], true).then(() => {
|
|
14834
|
+
updateStageNode(page);
|
|
14835
|
+
});
|
|
14834
14836
|
};
|
|
14835
14837
|
editorService.on("history-change", historyChangeHandler);
|
|
14836
14838
|
editorService.on("root-change", rootChangeHandler);
|
|
14837
14839
|
editorService.on("add", nodeAddHandler);
|
|
14838
14840
|
editorService.on("remove", nodeRemoveHandler);
|
|
14839
14841
|
editorService.on("update", nodeUpdateHandler);
|
|
14840
|
-
const dataSourceAddHandler =
|
|
14841
|
-
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14842
|
+
const dataSourceAddHandler = (config) => {
|
|
14843
|
+
const handler = async () => {
|
|
14844
|
+
initDataSourceDepTarget(config);
|
|
14845
|
+
const app = await getTMagicApp();
|
|
14846
|
+
if (!app?.dataSourceManager) {
|
|
14847
|
+
return;
|
|
14848
|
+
}
|
|
14849
|
+
app.dataSourceManager.addDataSource(config);
|
|
14850
|
+
const newDs = app.dataSourceManager.get(config.id);
|
|
14851
|
+
if (newDs) {
|
|
14852
|
+
app.dataSourceManager.init(newDs);
|
|
14853
|
+
}
|
|
14854
|
+
};
|
|
14855
|
+
handler();
|
|
14851
14856
|
};
|
|
14852
|
-
const dataSourceUpdateHandler =
|
|
14857
|
+
const dataSourceUpdateHandler = (config, { changeRecords }) => {
|
|
14853
14858
|
const updateDsData = async () => {
|
|
14854
14859
|
const app = await getTMagicApp();
|
|
14855
14860
|
if (!app?.dataSourceManager) {
|
|
@@ -14910,23 +14915,26 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
14910
14915
|
depService.removeTarget(id, DepTargetType.DATA_SOURCE_COND);
|
|
14911
14916
|
depService.removeTarget(id, DepTargetType.DATA_SOURCE_METHOD);
|
|
14912
14917
|
};
|
|
14913
|
-
const dataSourceRemoveHandler =
|
|
14918
|
+
const dataSourceRemoveHandler = (id) => {
|
|
14914
14919
|
const root = editorService.get("root");
|
|
14915
14920
|
if (!root) {
|
|
14916
14921
|
return;
|
|
14917
14922
|
}
|
|
14918
|
-
const
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14923
|
+
const handler = async () => {
|
|
14924
|
+
const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
|
|
14925
|
+
const nodes = getNodes(nodeIds, root.items);
|
|
14926
|
+
await Promise.all([
|
|
14927
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE),
|
|
14928
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_COND),
|
|
14929
|
+
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_METHOD)
|
|
14930
|
+
]);
|
|
14931
|
+
updateDataSourceSchema();
|
|
14932
|
+
const app = await getTMagicApp();
|
|
14933
|
+
app?.dataSourceManager?.removeDataSource(id);
|
|
14934
|
+
updateStageNodes(nodes);
|
|
14935
|
+
removeDataSourceTarget(id);
|
|
14936
|
+
};
|
|
14937
|
+
handler();
|
|
14930
14938
|
};
|
|
14931
14939
|
dataSourceService.on("add", dataSourceAddHandler);
|
|
14932
14940
|
dataSourceService.on("update", dataSourceUpdateHandler);
|