@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
|
@@ -5264,13 +5264,11 @@
|
|
|
5264
5264
|
{ value: core.HookCodeType.DATA_SOURCE_METHOD, text: "数据源方法" }
|
|
5265
5265
|
],
|
|
5266
5266
|
defaultValue: "code",
|
|
5267
|
-
onChange: (
|
|
5267
|
+
onChange: (_mForm, v, { setModel }) => {
|
|
5268
5268
|
if (v === core.HookCodeType.DATA_SOURCE_METHOD) {
|
|
5269
|
-
|
|
5270
|
-
changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: [] });
|
|
5269
|
+
setModel("codeId", []);
|
|
5271
5270
|
} else {
|
|
5272
|
-
|
|
5273
|
-
changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: "" });
|
|
5271
|
+
setModel("codeId", "");
|
|
5274
5272
|
}
|
|
5275
5273
|
return v;
|
|
5276
5274
|
}
|
|
@@ -5280,7 +5278,7 @@
|
|
|
5280
5278
|
name: "codeId",
|
|
5281
5279
|
span: 18,
|
|
5282
5280
|
labelWidth: 0,
|
|
5283
|
-
display: (
|
|
5281
|
+
display: (_mForm, { model }) => model.codeType !== core.HookCodeType.DATA_SOURCE_METHOD,
|
|
5284
5282
|
notEditable: () => !codeBlockService.getEditStatus()
|
|
5285
5283
|
},
|
|
5286
5284
|
{
|
|
@@ -5288,7 +5286,7 @@
|
|
|
5288
5286
|
name: "codeId",
|
|
5289
5287
|
span: 18,
|
|
5290
5288
|
labelWidth: 0,
|
|
5291
|
-
display: (
|
|
5289
|
+
display: (_mForm, { model }) => model.codeType === core.HookCodeType.DATA_SOURCE_METHOD,
|
|
5292
5290
|
notEditable: () => !dataSourceService.get("editable")
|
|
5293
5291
|
}
|
|
5294
5292
|
]
|
|
@@ -5486,13 +5484,12 @@
|
|
|
5486
5484
|
append: {
|
|
5487
5485
|
type: "button",
|
|
5488
5486
|
text: "复制",
|
|
5489
|
-
handler:
|
|
5490
|
-
|
|
5491
|
-
await navigator.clipboard.writeText(`${model.id}`);
|
|
5487
|
+
handler: (vm, { model }) => {
|
|
5488
|
+
navigator.clipboard.writeText(`${model.id}`).then(() => {
|
|
5492
5489
|
designPlugin.tMagicMessage.success("已复制");
|
|
5493
|
-
}
|
|
5490
|
+
}).catch(() => {
|
|
5494
5491
|
designPlugin.tMagicMessage.error("复制失败");
|
|
5495
|
-
}
|
|
5492
|
+
});
|
|
5496
5493
|
}
|
|
5497
5494
|
}
|
|
5498
5495
|
},
|
|
@@ -7230,10 +7227,11 @@
|
|
|
7230
7227
|
this.isHistoryStateChange = true;
|
|
7231
7228
|
await this.update(value.data);
|
|
7232
7229
|
this.set("modifiedNodeIds", value.modifiedNodeIds);
|
|
7233
|
-
setTimeout(
|
|
7230
|
+
setTimeout(() => {
|
|
7234
7231
|
if (!value.nodeId) return;
|
|
7235
|
-
|
|
7236
|
-
|
|
7232
|
+
this.select(value.nodeId).then(() => {
|
|
7233
|
+
this.get("stage")?.select(value.nodeId);
|
|
7234
|
+
});
|
|
7237
7235
|
}, 0);
|
|
7238
7236
|
this.emit("history-change", value.data);
|
|
7239
7237
|
}
|
|
@@ -8005,20 +8003,23 @@
|
|
|
8005
8003
|
}
|
|
8006
8004
|
return [];
|
|
8007
8005
|
},
|
|
8008
|
-
onChange: (formState, codeId, { model }) => {
|
|
8006
|
+
onChange: (formState, codeId, { setModel, model }) => {
|
|
8009
8007
|
paramsConfig.value = getParamItemsConfig(codeId);
|
|
8010
8008
|
if (paramsConfig.value.length) {
|
|
8011
|
-
|
|
8009
|
+
setModel("params", formPlugin.createValues(formState, paramsConfig.value, {}, model.params));
|
|
8012
8010
|
} else {
|
|
8013
|
-
|
|
8011
|
+
setModel("params", {});
|
|
8014
8012
|
}
|
|
8015
8013
|
return codeId;
|
|
8016
8014
|
}
|
|
8017
8015
|
};
|
|
8018
|
-
const onCodeIdChangeHandler = (value) => {
|
|
8016
|
+
const onCodeIdChangeHandler = (value, eventData) => {
|
|
8019
8017
|
props.model.params = value.params;
|
|
8020
8018
|
emit("change", props.model, {
|
|
8021
|
-
changeRecords:
|
|
8019
|
+
changeRecords: eventData.changeRecords?.map((item) => ({
|
|
8020
|
+
prop: `${props.prop.replace(props.name, "")}${item.propPath}`,
|
|
8021
|
+
value: item.value
|
|
8022
|
+
})) || [
|
|
8022
8023
|
{
|
|
8023
8024
|
propPath: props.prop,
|
|
8024
8025
|
value: value[props.name]
|
|
@@ -8383,9 +8384,7 @@
|
|
|
8383
8384
|
const createCodeBlock = async () => {
|
|
8384
8385
|
codeConfig.value = {
|
|
8385
8386
|
name: "",
|
|
8386
|
-
content:
|
|
8387
|
-
// place your code here
|
|
8388
|
-
}`,
|
|
8387
|
+
content: "({app, params, flowState}) => {\n // place your code here\n}",
|
|
8389
8388
|
params: []
|
|
8390
8389
|
};
|
|
8391
8390
|
codeId.value = await codeBlockService.getUniqueId();
|
|
@@ -8957,6 +8956,7 @@
|
|
|
8957
8956
|
try {
|
|
8958
8957
|
return JSON.stringify(row.defaultValue);
|
|
8959
8958
|
} catch (e) {
|
|
8959
|
+
error(e);
|
|
8960
8960
|
return row.defaultValue;
|
|
8961
8961
|
}
|
|
8962
8962
|
}
|
|
@@ -9005,9 +9005,9 @@
|
|
|
9005
9005
|
{ text: "null", value: "null" },
|
|
9006
9006
|
{ text: "any", value: "any" }
|
|
9007
9007
|
],
|
|
9008
|
-
onChange: (
|
|
9008
|
+
onChange: (_formState, v, { setModel }) => {
|
|
9009
9009
|
if (!["any", "array", "object"].includes(v)) {
|
|
9010
|
-
|
|
9010
|
+
setModel("fields", []);
|
|
9011
9011
|
}
|
|
9012
9012
|
return v;
|
|
9013
9013
|
}
|
|
@@ -10226,9 +10226,7 @@
|
|
|
10226
10226
|
{
|
|
10227
10227
|
text: "编辑",
|
|
10228
10228
|
handler: (method, index) => {
|
|
10229
|
-
let codeContent = method.content ||
|
|
10230
|
-
// place your code here
|
|
10231
|
-
}`;
|
|
10229
|
+
let codeContent = method.content || "({ params, dataSource, app }) => {\n // place your code here\n}";
|
|
10232
10230
|
if (typeof codeContent !== "string") {
|
|
10233
10231
|
codeContent = codeContent.toString();
|
|
10234
10232
|
}
|
|
@@ -10257,9 +10255,7 @@
|
|
|
10257
10255
|
const createCodeHandler = () => {
|
|
10258
10256
|
codeConfig.value = {
|
|
10259
10257
|
name: "",
|
|
10260
|
-
content:
|
|
10261
|
-
// place your code here
|
|
10262
|
-
}`,
|
|
10258
|
+
content: "({ params, dataSource, app, flowState }) => {\n // place your code here\n}",
|
|
10263
10259
|
params: []
|
|
10264
10260
|
};
|
|
10265
10261
|
editIndex = -1;
|
|
@@ -10378,12 +10374,12 @@
|
|
|
10378
10374
|
}));
|
|
10379
10375
|
};
|
|
10380
10376
|
const paramsConfig = vue.ref(getParamItemsConfig(props.model[props.name || "dataSourceMethod"]));
|
|
10381
|
-
const setParamsConfig = (dataSourceMethod, formState = {}) => {
|
|
10377
|
+
const setParamsConfig = (dataSourceMethod, formState = {}, setModel) => {
|
|
10382
10378
|
paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
|
|
10383
10379
|
if (paramsConfig.value.length) {
|
|
10384
|
-
|
|
10380
|
+
setModel("params", formPlugin.createValues(formState, paramsConfig.value, {}, props.model.params));
|
|
10385
10381
|
} else {
|
|
10386
|
-
|
|
10382
|
+
setModel("params", {});
|
|
10387
10383
|
}
|
|
10388
10384
|
};
|
|
10389
10385
|
const methodsOptions = vue.computed(
|
|
@@ -10404,8 +10400,8 @@
|
|
|
10404
10400
|
name: props.name,
|
|
10405
10401
|
options: methodsOptions.value,
|
|
10406
10402
|
disable: props.disabled,
|
|
10407
|
-
onChange: (formState, dataSourceMethod) => {
|
|
10408
|
-
setParamsConfig(dataSourceMethod, formState);
|
|
10403
|
+
onChange: (formState, dataSourceMethod, { setModel }) => {
|
|
10404
|
+
setParamsConfig(dataSourceMethod, formState, setModel);
|
|
10409
10405
|
return dataSourceMethod;
|
|
10410
10406
|
}
|
|
10411
10407
|
}));
|
|
@@ -11073,8 +11069,8 @@
|
|
|
11073
11069
|
text: "联动组件",
|
|
11074
11070
|
type: "ui-select",
|
|
11075
11071
|
display: (mForm, { model }) => model.actionType === core.ActionType.COMP,
|
|
11076
|
-
onChange: (MForm, v, {
|
|
11077
|
-
|
|
11072
|
+
onChange: (MForm, v, { setModel }) => {
|
|
11073
|
+
setModel("method", "");
|
|
11078
11074
|
return v;
|
|
11079
11075
|
}
|
|
11080
11076
|
};
|
|
@@ -14165,7 +14161,7 @@
|
|
|
14165
14161
|
type: "button",
|
|
14166
14162
|
className: "delete",
|
|
14167
14163
|
icon: vue.markRaw(iconsVue.Delete),
|
|
14168
|
-
tooltip:
|
|
14164
|
+
tooltip: "刪除(Delete)",
|
|
14169
14165
|
disabled: () => editorService.get("node")?.type === core.NodeType.PAGE,
|
|
14170
14166
|
handler: () => {
|
|
14171
14167
|
const node = editorService.get("node");
|
|
@@ -15400,13 +15396,13 @@
|
|
|
15400
15396
|
eventBus?.on("edit-code", (id) => {
|
|
15401
15397
|
editCode(id);
|
|
15402
15398
|
});
|
|
15403
|
-
|
|
15399
|
+
vue.watch(codeId, () => {
|
|
15404
15400
|
if (codeBlockListRef.value) {
|
|
15405
15401
|
for (const [statusId, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
|
|
15406
15402
|
status.selected = statusId === codeId.value;
|
|
15407
15403
|
}
|
|
15408
15404
|
}
|
|
15409
|
-
};
|
|
15405
|
+
});
|
|
15410
15406
|
const editDialogCloseHandler = () => {
|
|
15411
15407
|
if (codeBlockListRef.value) {
|
|
15412
15408
|
for (const [, status] of codeBlockListRef.value.nodeStatusMap.entries()) {
|
|
@@ -15478,8 +15474,7 @@
|
|
|
15478
15474
|
disabled: !editable.value,
|
|
15479
15475
|
content: vue.unref(codeConfig),
|
|
15480
15476
|
onSubmit: vue.unref(submitCodeBlockHandler),
|
|
15481
|
-
onClose: editDialogCloseHandler
|
|
15482
|
-
onOpen: editDialogOpenHandler
|
|
15477
|
+
onClose: editDialogCloseHandler
|
|
15483
15478
|
}, null, 8, ["disabled", "content", "onSubmit"])) : vue.createCommentVNode("v-if", true),
|
|
15484
15479
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
15485
15480
|
menuData.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$o, {
|
|
@@ -15866,20 +15861,20 @@
|
|
|
15866
15861
|
const eventBus = vue.inject("eventBus");
|
|
15867
15862
|
const { dataSourceService } = useServices();
|
|
15868
15863
|
const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
|
|
15869
|
-
const editDialogOpenHandler = (id) => {
|
|
15870
|
-
if (dataSourceList.value) {
|
|
15871
|
-
for (const [statusId, status] of dataSourceList.value.nodeStatusMap.entries()) {
|
|
15872
|
-
status.selected = statusId === id;
|
|
15873
|
-
}
|
|
15874
|
-
}
|
|
15875
|
-
};
|
|
15876
15864
|
const editDialogCloseHandler = () => {
|
|
15877
|
-
if (
|
|
15878
|
-
for (const [, status] of
|
|
15865
|
+
if (dataSourceListRef.value) {
|
|
15866
|
+
for (const [, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
15879
15867
|
status.selected = false;
|
|
15880
15868
|
}
|
|
15881
15869
|
}
|
|
15882
15870
|
};
|
|
15871
|
+
vue.watch(dataSourceValues, (dataSourceValues2) => {
|
|
15872
|
+
if (dataSourceListRef.value && dataSourceValues2.id) {
|
|
15873
|
+
for (const [statusId, status] of dataSourceListRef.value.nodeStatusMap.entries()) {
|
|
15874
|
+
status.selected = statusId === dataSourceValues2.id;
|
|
15875
|
+
}
|
|
15876
|
+
}
|
|
15877
|
+
});
|
|
15883
15878
|
const datasourceTypeList = vue.computed(
|
|
15884
15879
|
() => [
|
|
15885
15880
|
{ text: "基础", type: "base" },
|
|
@@ -15909,9 +15904,9 @@
|
|
|
15909
15904
|
});
|
|
15910
15905
|
dataSourceService.remove(id);
|
|
15911
15906
|
};
|
|
15912
|
-
const
|
|
15907
|
+
const dataSourceListRef = vue.useTemplateRef("dataSourceList");
|
|
15913
15908
|
const filterTextChangeHandler = (val) => {
|
|
15914
|
-
|
|
15909
|
+
dataSourceListRef.value?.filter(val);
|
|
15915
15910
|
};
|
|
15916
15911
|
eventBus?.on("edit-data-source", (id) => {
|
|
15917
15912
|
editHandler(id);
|
|
@@ -15978,8 +15973,7 @@
|
|
|
15978
15973
|
]),
|
|
15979
15974
|
vue.createCommentVNode(" 数据源列表 "),
|
|
15980
15975
|
vue.createVNode(_sfc_main$h, {
|
|
15981
|
-
|
|
15982
|
-
ref: dataSourceList,
|
|
15976
|
+
ref: "dataSourceList",
|
|
15983
15977
|
indent: _ctx.indent,
|
|
15984
15978
|
"next-level-indent-increment": _ctx.nextLevelIndentIncrement,
|
|
15985
15979
|
onEdit: vue.unref(editHandler),
|
|
@@ -15997,8 +15991,7 @@
|
|
|
15997
15991
|
values: vue.unref(dataSourceValues),
|
|
15998
15992
|
title: vue.unref(dialogTitle),
|
|
15999
15993
|
onSubmit: vue.unref(submitDataSourceHandler),
|
|
16000
|
-
onClose: editDialogCloseHandler
|
|
16001
|
-
onOpen: editDialogOpenHandler
|
|
15994
|
+
onClose: editDialogCloseHandler
|
|
16002
15995
|
}, null, 8, ["disabled", "values", "title", "onSubmit"]),
|
|
16003
15996
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
16004
15997
|
menuData.value.length ? (vue.openBlock(), vue.createBlock(_sfc_main$o, {
|
|
@@ -19451,10 +19444,10 @@
|
|
|
19451
19444
|
const getTMagicApp = () => {
|
|
19452
19445
|
const renderer = editorService.get("stage")?.renderer;
|
|
19453
19446
|
if (!renderer) {
|
|
19454
|
-
return void 0;
|
|
19447
|
+
return Promise.resolve(void 0);
|
|
19455
19448
|
}
|
|
19456
19449
|
if (renderer.runtime) {
|
|
19457
|
-
return renderer.runtime.getApp?.();
|
|
19450
|
+
return Promise.resolve(renderer.runtime.getApp?.());
|
|
19458
19451
|
}
|
|
19459
19452
|
return new Promise((resolve) => {
|
|
19460
19453
|
const timeout = globalThis.setTimeout(() => {
|
|
@@ -19492,12 +19485,13 @@
|
|
|
19492
19485
|
app.dsl.dataSources = root.dataSources;
|
|
19493
19486
|
}
|
|
19494
19487
|
};
|
|
19495
|
-
const dsDepCollectedHandler =
|
|
19488
|
+
const dsDepCollectedHandler = () => {
|
|
19496
19489
|
const root = editorService.get("root");
|
|
19497
|
-
|
|
19498
|
-
|
|
19499
|
-
|
|
19500
|
-
|
|
19490
|
+
getTMagicApp()?.then((app) => {
|
|
19491
|
+
if (root && app?.dsl) {
|
|
19492
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
19493
|
+
}
|
|
19494
|
+
});
|
|
19501
19495
|
};
|
|
19502
19496
|
const collectIdle = (nodes, deep, type) => Promise.all(
|
|
19503
19497
|
nodes.map((node) => {
|
|
@@ -19530,7 +19524,7 @@
|
|
|
19530
19524
|
depService.addTarget(core.createDataSourceMethodTarget(ds, vue.reactive({})));
|
|
19531
19525
|
depService.addTarget(core.createDataSourceCondTarget(ds, vue.reactive({})));
|
|
19532
19526
|
};
|
|
19533
|
-
const rootChangeHandler =
|
|
19527
|
+
const rootChangeHandler = (value, preValue) => {
|
|
19534
19528
|
if (!value) return;
|
|
19535
19529
|
value.codeBlocks = value.codeBlocks || {};
|
|
19536
19530
|
value.dataSources = value.dataSources || [];
|
|
@@ -19553,29 +19547,33 @@
|
|
|
19553
19547
|
delete value.dataSourceDeps;
|
|
19554
19548
|
delete value.dataSourceCondDeps;
|
|
19555
19549
|
}
|
|
19556
|
-
const
|
|
19557
|
-
|
|
19558
|
-
|
|
19559
|
-
|
|
19560
|
-
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
|
|
19571
|
-
|
|
19572
|
-
|
|
19550
|
+
const handler = async () => {
|
|
19551
|
+
const nodeId = editorService.get("node")?.id || props.defaultSelected;
|
|
19552
|
+
let node;
|
|
19553
|
+
if (nodeId) {
|
|
19554
|
+
node = editorService.getNodeById(nodeId);
|
|
19555
|
+
}
|
|
19556
|
+
if (node && node !== value) {
|
|
19557
|
+
await editorService.select(node.id);
|
|
19558
|
+
} else if (value.items?.length) {
|
|
19559
|
+
await editorService.select(value.items[0]);
|
|
19560
|
+
} else if (value.id) {
|
|
19561
|
+
editorService.set("nodes", [value]);
|
|
19562
|
+
editorService.set("parent", null);
|
|
19563
|
+
editorService.set("page", null);
|
|
19564
|
+
}
|
|
19565
|
+
if (vue.toRaw(value) !== vue.toRaw(preValue)) {
|
|
19566
|
+
emit("update:modelValue", value);
|
|
19567
|
+
}
|
|
19568
|
+
};
|
|
19569
|
+
handler();
|
|
19573
19570
|
};
|
|
19574
|
-
const nodeAddHandler =
|
|
19575
|
-
|
|
19576
|
-
|
|
19571
|
+
const nodeAddHandler = (nodes) => {
|
|
19572
|
+
collectIdle(nodes, true).then(() => {
|
|
19573
|
+
updateStageNodes(nodes);
|
|
19574
|
+
});
|
|
19577
19575
|
};
|
|
19578
|
-
const nodeUpdateHandler =
|
|
19576
|
+
const nodeUpdateHandler = (data) => {
|
|
19579
19577
|
const needRecollectNodes = [];
|
|
19580
19578
|
const normalNodes = [];
|
|
19581
19579
|
for (const { newNode, oldNode, changeRecords } of data) {
|
|
@@ -19607,9 +19605,12 @@
|
|
|
19607
19605
|
}
|
|
19608
19606
|
}
|
|
19609
19607
|
if (needRecollectNodes.length) {
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19608
|
+
const handler = async () => {
|
|
19609
|
+
await collectIdle(needRecollectNodes, true, core.DepTargetType.DATA_SOURCE);
|
|
19610
|
+
await collectIdle(needRecollectNodes, true, core.DepTargetType.DATA_SOURCE_COND);
|
|
19611
|
+
updateStageNodes(needRecollectNodes);
|
|
19612
|
+
};
|
|
19613
|
+
handler();
|
|
19613
19614
|
} else {
|
|
19614
19615
|
updateStageNodes(normalNodes);
|
|
19615
19616
|
Promise.all([
|
|
@@ -19621,28 +19622,32 @@
|
|
|
19621
19622
|
const nodeRemoveHandler = (nodes) => {
|
|
19622
19623
|
depService.clear(nodes);
|
|
19623
19624
|
};
|
|
19624
|
-
const historyChangeHandler =
|
|
19625
|
-
|
|
19626
|
-
|
|
19625
|
+
const historyChangeHandler = (page) => {
|
|
19626
|
+
collectIdle([page], true).then(() => {
|
|
19627
|
+
updateStageNode(page);
|
|
19628
|
+
});
|
|
19627
19629
|
};
|
|
19628
19630
|
editorService.on("history-change", historyChangeHandler);
|
|
19629
19631
|
editorService.on("root-change", rootChangeHandler);
|
|
19630
19632
|
editorService.on("add", nodeAddHandler);
|
|
19631
19633
|
editorService.on("remove", nodeRemoveHandler);
|
|
19632
19634
|
editorService.on("update", nodeUpdateHandler);
|
|
19633
|
-
const dataSourceAddHandler =
|
|
19634
|
-
|
|
19635
|
-
|
|
19636
|
-
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
|
|
19643
|
-
|
|
19635
|
+
const dataSourceAddHandler = (config) => {
|
|
19636
|
+
const handler = async () => {
|
|
19637
|
+
initDataSourceDepTarget(config);
|
|
19638
|
+
const app = await getTMagicApp();
|
|
19639
|
+
if (!app?.dataSourceManager) {
|
|
19640
|
+
return;
|
|
19641
|
+
}
|
|
19642
|
+
app.dataSourceManager.addDataSource(config);
|
|
19643
|
+
const newDs = app.dataSourceManager.get(config.id);
|
|
19644
|
+
if (newDs) {
|
|
19645
|
+
app.dataSourceManager.init(newDs);
|
|
19646
|
+
}
|
|
19647
|
+
};
|
|
19648
|
+
handler();
|
|
19644
19649
|
};
|
|
19645
|
-
const dataSourceUpdateHandler =
|
|
19650
|
+
const dataSourceUpdateHandler = (config, { changeRecords }) => {
|
|
19646
19651
|
const updateDsData = async () => {
|
|
19647
19652
|
const app = await getTMagicApp();
|
|
19648
19653
|
if (!app?.dataSourceManager) {
|
|
@@ -19703,23 +19708,26 @@
|
|
|
19703
19708
|
depService.removeTarget(id, core.DepTargetType.DATA_SOURCE_COND);
|
|
19704
19709
|
depService.removeTarget(id, core.DepTargetType.DATA_SOURCE_METHOD);
|
|
19705
19710
|
};
|
|
19706
|
-
const dataSourceRemoveHandler =
|
|
19711
|
+
const dataSourceRemoveHandler = (id) => {
|
|
19707
19712
|
const root = editorService.get("root");
|
|
19708
19713
|
if (!root) {
|
|
19709
19714
|
return;
|
|
19710
19715
|
}
|
|
19711
|
-
const
|
|
19712
|
-
|
|
19713
|
-
|
|
19714
|
-
|
|
19715
|
-
|
|
19716
|
-
|
|
19717
|
-
|
|
19718
|
-
|
|
19719
|
-
|
|
19720
|
-
|
|
19721
|
-
|
|
19722
|
-
|
|
19716
|
+
const handler = async () => {
|
|
19717
|
+
const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
|
|
19718
|
+
const nodes = utils.getNodes(nodeIds, root.items);
|
|
19719
|
+
await Promise.all([
|
|
19720
|
+
collectIdle(nodes, false, core.DepTargetType.DATA_SOURCE),
|
|
19721
|
+
collectIdle(nodes, false, core.DepTargetType.DATA_SOURCE_COND),
|
|
19722
|
+
collectIdle(nodes, false, core.DepTargetType.DATA_SOURCE_METHOD)
|
|
19723
|
+
]);
|
|
19724
|
+
updateDataSourceSchema();
|
|
19725
|
+
const app = await getTMagicApp();
|
|
19726
|
+
app?.dataSourceManager?.removeDataSource(id);
|
|
19727
|
+
updateStageNodes(nodes);
|
|
19728
|
+
removeDataSourceTarget(id);
|
|
19729
|
+
};
|
|
19730
|
+
handler();
|
|
19723
19731
|
};
|
|
19724
19732
|
dataSourceService.on("add", dataSourceAddHandler);
|
|
19725
19733
|
dataSourceService.on("update", dataSourceUpdateHandler);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.15",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^6.0.0",
|
|
60
60
|
"sortablejs": "^1.15.2",
|
|
61
|
-
"@tmagic/
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/utils": "1.5.
|
|
61
|
+
"@tmagic/stage": "1.5.15",
|
|
62
|
+
"@tmagic/form": "1.5.15",
|
|
63
|
+
"@tmagic/table": "1.5.15",
|
|
64
|
+
"@tmagic/design": "1.5.15",
|
|
65
|
+
"@tmagic/utils": "1.5.15"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"monaco-editor": "^0.48.0",
|
|
77
77
|
"typescript": "*",
|
|
78
78
|
"vue": ">=3.5.0",
|
|
79
|
-
"@tmagic/core": "1.5.
|
|
79
|
+
"@tmagic/core": "1.5.15"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -142,7 +142,7 @@ import codeBlockService from './services/codeBlock';
|
|
|
142
142
|
import componentListService from './services/componentList';
|
|
143
143
|
import dataSourceService from './services/dataSource';
|
|
144
144
|
import depService from './services/dep';
|
|
145
|
-
import editorService
|
|
145
|
+
import editorService from './services/editor';
|
|
146
146
|
import eventsService from './services/events';
|
|
147
147
|
import historyService from './services/history';
|
|
148
148
|
import keybindingService from './services/keybinding';
|
|
@@ -153,25 +153,9 @@ import uiService from './services/ui';
|
|
|
153
153
|
import keybindingConfig from './utils/keybinding-config';
|
|
154
154
|
import { defaultEditorProps, EditorProps } from './editorProps';
|
|
155
155
|
import { initServiceEvents, initServiceState } from './initService';
|
|
156
|
-
import type {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
PropsPanelSlots,
|
|
160
|
-
Services,
|
|
161
|
-
SidebarSlots,
|
|
162
|
-
StageOptions,
|
|
163
|
-
WorkspaceSlots,
|
|
164
|
-
} from './type';
|
|
165
|
-
|
|
166
|
-
defineSlots<
|
|
167
|
-
FrameworkSlots &
|
|
168
|
-
WorkspaceSlots &
|
|
169
|
-
SidebarSlots &
|
|
170
|
-
PropsPanelSlots & {
|
|
171
|
-
workspace(props: { editorService: EditorService }): any;
|
|
172
|
-
'workspace-content'(props: { editorService: EditorService }): any;
|
|
173
|
-
}
|
|
174
|
-
>();
|
|
156
|
+
import type { EditorSlots, EventBus, Services, StageOptions } from './type';
|
|
157
|
+
|
|
158
|
+
defineSlots<EditorSlots>();
|
|
175
159
|
|
|
176
160
|
defineOptions({
|
|
177
161
|
name: 'MEditor',
|
|
@@ -233,7 +233,7 @@ const changeHandler = (values: CodeBlockContent) => {
|
|
|
233
233
|
changedValue.value = values;
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
-
const beforeClose = (done: (
|
|
236
|
+
const beforeClose = (done: (_cancel?: boolean) => void) => {
|
|
237
237
|
if (!changedValue.value) {
|
|
238
238
|
done();
|
|
239
239
|
return;
|
|
@@ -93,7 +93,9 @@ const scrollBy = (delta: number) => {
|
|
|
93
93
|
position: absolute;
|
|
94
94
|
background-color: transparent;
|
|
95
95
|
opacity: 0.3;
|
|
96
|
-
transition:
|
|
96
|
+
transition:
|
|
97
|
+
background-color 0.2s linear,
|
|
98
|
+
opacity 0.2s linear;
|
|
97
99
|
|
|
98
100
|
.m-editor-scroll-bar-thumb {
|
|
99
101
|
background-color: #aaa;
|
|
@@ -108,7 +110,9 @@ const scrollBy = (delta: number) => {
|
|
|
108
110
|
|
|
109
111
|
.m-editor-scroll-bar-thumb {
|
|
110
112
|
height: 6px;
|
|
111
|
-
transition:
|
|
113
|
+
transition:
|
|
114
|
+
background-color 0.2s linear,
|
|
115
|
+
height 0.2s ease-in-out;
|
|
112
116
|
bottom: 2px;
|
|
113
117
|
}
|
|
114
118
|
}
|
|
@@ -120,7 +124,9 @@ const scrollBy = (delta: number) => {
|
|
|
120
124
|
|
|
121
125
|
.m-editor-scroll-bar-thumb {
|
|
122
126
|
width: 6px;
|
|
123
|
-
transition:
|
|
127
|
+
transition:
|
|
128
|
+
background-color 0.2s linear,
|
|
129
|
+
width 0.2s ease-in-out;
|
|
124
130
|
right: 2px;
|
|
125
131
|
}
|
|
126
132
|
}
|
|
@@ -27,7 +27,7 @@ const emit = defineEmits(['search']);
|
|
|
27
27
|
|
|
28
28
|
const filterText = ref('');
|
|
29
29
|
|
|
30
|
-
let timer:
|
|
30
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
31
31
|
const filterTextChangeHandler = () => {
|
|
32
32
|
timer && clearTimeout(timer);
|
|
33
33
|
timer = setTimeout(() => {
|
package/src/components/Tree.vue
CHANGED
|
@@ -38,9 +38,9 @@ import type { LayerNodeStatus, TreeNodeData } from '@editor/type';
|
|
|
38
38
|
import TreeNode from './TreeNode.vue';
|
|
39
39
|
|
|
40
40
|
defineSlots<{
|
|
41
|
-
'tree-node-content'(
|
|
42
|
-
'tree-node-label'(
|
|
43
|
-
'tree-node-tool'(
|
|
41
|
+
'tree-node-content'(_props: { data: TreeNodeData }): any;
|
|
42
|
+
'tree-node-label'(_props: { data: TreeNodeData }): any;
|
|
43
|
+
'tree-node-tool'(_props: { data: TreeNodeData }): any;
|
|
44
44
|
}>();
|
|
45
45
|
|
|
46
46
|
defineOptions({
|
|
@@ -72,9 +72,9 @@ import type { LayerNodeStatus, TreeNodeData } from '@editor/type';
|
|
|
72
72
|
import { updateStatus } from '@editor/utils/tree';
|
|
73
73
|
|
|
74
74
|
defineSlots<{
|
|
75
|
-
'tree-node-label'(
|
|
76
|
-
'tree-node-tool'(
|
|
77
|
-
'tree-node-content'(
|
|
75
|
+
'tree-node-label'(_props: { data: TreeNodeData }): any;
|
|
76
|
+
'tree-node-tool'(_props: { data: TreeNodeData }): any;
|
|
77
|
+
'tree-node-content'(_props: { data: TreeNodeData }): any;
|
|
78
78
|
}>();
|
|
79
79
|
|
|
80
80
|
defineOptions({
|