@tmagic/editor 1.8.0-beta.5 → 1.8.0-beta.7
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/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +8 -2
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +25 -8
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +6 -4
- package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +25 -12
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +27 -5
- package/dist/es/index.js +2 -2
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +10 -14
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +12 -4
- package/dist/es/layouts/history-list/composables.js +28 -77
- package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/layouts/sidebar/data-source/DataSourceConfigPanel.vue_vue_type_script_setup_true_lang.js +16 -3
- package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.vue_vue_type_script_setup_true_lang.js +23 -1
- package/dist/es/services/codeBlock.js +30 -19
- package/dist/es/services/dataSource.js +29 -21
- package/dist/es/services/editor.js +52 -33
- package/dist/es/services/history.js +10 -15
- package/dist/es/style.css +4 -1
- package/dist/es/utils/data-source/index.js +2 -0
- package/dist/es/utils/editor.js +68 -48
- package/dist/es/utils/history.js +42 -33
- package/dist/style.css +4 -1
- package/dist/tmagic-editor.umd.cjs +412 -295
- package/package.json +7 -7
- package/src/fields/CodeSelectCol.vue +7 -1
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +16 -2
- package/src/fields/DataSourceFields.vue +37 -8
- package/src/fields/DataSourceMethodSelect.vue +9 -4
- package/src/fields/DataSourceMethods.vue +42 -21
- package/src/fields/StyleSetter/components/Border.vue +15 -6
- package/src/layouts/history-list/HistoryListPanel.vue +12 -25
- package/src/layouts/history-list/InitialRow.vue +3 -0
- package/src/layouts/history-list/composables.ts +34 -94
- package/src/layouts/sidebar/Sidebar.vue +2 -2
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +31 -2
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +26 -1
- package/src/services/codeBlock.ts +28 -22
- package/src/services/dataSource.ts +29 -24
- package/src/services/editor.ts +41 -37
- package/src/services/history.ts +19 -25
- package/src/theme/style-setter/border.scss +4 -1
- package/src/type.ts +38 -26
- package/src/utils/data-source/index.ts +2 -0
- package/src/utils/editor.ts +125 -59
- package/src/utils/history.ts +48 -45
- package/types/index.d.ts +109 -112
|
@@ -7,7 +7,7 @@ import DataSourceConfigPanel_default from "./DataSourceConfigPanel.js";
|
|
|
7
7
|
import DataSourceList_default from "./DataSourceList.js";
|
|
8
8
|
import { useContentMenu } from "./useContentMenu.js";
|
|
9
9
|
import { TMagicScrollbar, tMagicMessageBox } from "@tmagic/design";
|
|
10
|
-
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, openBlock, renderSlot, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
10
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, openBlock, ref, renderSlot, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
11
11
|
import { mergeWith } from "lodash-es";
|
|
12
12
|
//#region packages/editor/src/layouts/sidebar/data-source/DataSourceListPanel.vue?vue&type=script&setup=true&lang.ts
|
|
13
13
|
var _hoisted_1 = { class: "search-wrapper" };
|
|
@@ -24,7 +24,13 @@ var DataSourceListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE
|
|
|
24
24
|
const eventBus = inject("eventBus");
|
|
25
25
|
const { dataSourceService } = useServices();
|
|
26
26
|
const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
|
|
27
|
+
/** 打开数据源详情时需要直接定位并打开的方法名,为空则正常展示「数据定义」tab */
|
|
28
|
+
const editMethodName = ref("");
|
|
29
|
+
/** 打开数据源详情时需要直接定位并打开的字段路径,为空则不自动打开字段配置 */
|
|
30
|
+
const editFieldPath = ref([]);
|
|
27
31
|
const editDialogCloseHandler = () => {
|
|
32
|
+
editMethodName.value = "";
|
|
33
|
+
editFieldPath.value = [];
|
|
28
34
|
if (dataSourceListRef.value) for (const [, status] of dataSourceListRef.value.nodeStatusMap.entries()) status.selected = false;
|
|
29
35
|
};
|
|
30
36
|
watch(dataSourceValues, (dataSourceValues) => {
|
|
@@ -62,6 +68,18 @@ var DataSourceListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE
|
|
|
62
68
|
dataSourceListRef.value?.filter(val);
|
|
63
69
|
};
|
|
64
70
|
eventBus?.on("edit-data-source", (id) => {
|
|
71
|
+
editMethodName.value = "";
|
|
72
|
+
editFieldPath.value = [];
|
|
73
|
+
editHandler(id);
|
|
74
|
+
});
|
|
75
|
+
eventBus?.on("edit-data-source-method", (id, methodName) => {
|
|
76
|
+
editMethodName.value = methodName;
|
|
77
|
+
editFieldPath.value = [];
|
|
78
|
+
editHandler(id);
|
|
79
|
+
});
|
|
80
|
+
eventBus?.on("edit-data-source-field", (id, fieldPath) => {
|
|
81
|
+
editMethodName.value = "";
|
|
82
|
+
editFieldPath.value = fieldPath;
|
|
65
83
|
editHandler(id);
|
|
66
84
|
});
|
|
67
85
|
eventBus?.on("remove-data-source", (id) => {
|
|
@@ -110,12 +128,16 @@ var DataSourceListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE
|
|
|
110
128
|
disabled: !unref(editable),
|
|
111
129
|
values: unref(dataSourceValues),
|
|
112
130
|
title: unref(dialogTitle),
|
|
131
|
+
"edit-method-name": editMethodName.value,
|
|
132
|
+
"edit-field-path": editFieldPath.value,
|
|
113
133
|
onSubmit: unref(submitDataSourceHandler),
|
|
114
134
|
onClose: editDialogCloseHandler
|
|
115
135
|
}, null, 8, [
|
|
116
136
|
"disabled",
|
|
117
137
|
"values",
|
|
118
138
|
"title",
|
|
139
|
+
"edit-method-name",
|
|
140
|
+
"edit-field-path",
|
|
119
141
|
"onSubmit"
|
|
120
142
|
]),
|
|
121
143
|
(openBlock(), createBlock(Teleport, { to: "body" }, [menuData.value.length ? (openBlock(), createBlock(ContentMenu_default, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CODE_DRAFT_STORAGE_KEY } from "../type.js";
|
|
2
2
|
import BaseService from "./BaseService.js";
|
|
3
3
|
import { getEditorConfig } from "../utils/config.js";
|
|
4
|
-
import { describeRevertStep } from "../utils/history.js";
|
|
4
|
+
import { describeRevertStep, getLastPushedHistoryIds } from "../utils/history.js";
|
|
5
5
|
import history_default from "./history.js";
|
|
6
6
|
import storage_default, { Protocol } from "./storage.js";
|
|
7
7
|
import { COPY_CODE_STORAGE_KEY } from "../utils/editor.js";
|
|
@@ -228,31 +228,40 @@ var CodeBlock = class extends BaseService {
|
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
230
|
* 下列 *AndGetHistoryId 方法与对应的写入方法行为完全一致,
|
|
231
|
-
*
|
|
231
|
+
* 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入的历史 uuid 列表,
|
|
232
232
|
* 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
|
|
233
233
|
*
|
|
234
|
-
* 当本次操作未写入历史(doNotPushHistory 为 true
|
|
234
|
+
* 当本次操作未写入历史(doNotPushHistory 为 true、或无对应记录)时 historyIds 为 `[]`。
|
|
235
235
|
*/
|
|
236
|
-
/** 等价于 {@link setCodeDslById}
|
|
236
|
+
/** 等价于 {@link setCodeDslById},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
237
237
|
async setCodeDslByIdAndGetHistoryId(id, codeConfig, options = {}) {
|
|
238
238
|
this.lastPushedHistoryId = null;
|
|
239
239
|
await this.setCodeDslById(id, codeConfig, options);
|
|
240
|
-
return
|
|
240
|
+
return {
|
|
241
|
+
result: void 0,
|
|
242
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
243
|
+
};
|
|
241
244
|
}
|
|
242
|
-
/** 等价于 {@link setCodeDslByIdSync}
|
|
245
|
+
/** 等价于 {@link setCodeDslByIdSync},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
243
246
|
setCodeDslByIdSyncAndGetHistoryId(id, codeConfig, force = true, options = {}) {
|
|
244
247
|
this.lastPushedHistoryId = null;
|
|
245
248
|
this.setCodeDslByIdSync(id, codeConfig, force, options);
|
|
246
|
-
return
|
|
249
|
+
return {
|
|
250
|
+
result: void 0,
|
|
251
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
252
|
+
};
|
|
247
253
|
}
|
|
248
254
|
/**
|
|
249
|
-
* 等价于 {@link deleteCodeDslByIds}
|
|
250
|
-
*
|
|
255
|
+
* 等价于 {@link deleteCodeDslByIds},并额外返回本次写入的全部历史记录 uuid(按删除顺序)。
|
|
256
|
+
* 一次删除多个代码块会产生多条历史记录;未写入任何历史时 historyIds 为 `[]`。
|
|
251
257
|
*/
|
|
252
258
|
async deleteCodeDslByIdsAndGetHistoryId(codeIds, options = {}) {
|
|
253
259
|
this.lastDeletedHistoryIds = [];
|
|
254
260
|
await this.deleteCodeDslByIds(codeIds, options);
|
|
255
|
-
return
|
|
261
|
+
return {
|
|
262
|
+
result: void 0,
|
|
263
|
+
historyIds: [...this.lastDeletedHistoryIds]
|
|
264
|
+
};
|
|
256
265
|
}
|
|
257
266
|
setParamsColConfig(config) {
|
|
258
267
|
this.state.paramsColConfig = config;
|
|
@@ -335,17 +344,19 @@ var CodeBlock = class extends BaseService {
|
|
|
335
344
|
return await this.applyRevertStep(entry.step, description);
|
|
336
345
|
}
|
|
337
346
|
/**
|
|
338
|
-
* 通过历史记录 uuid
|
|
339
|
-
* 仅无需调用方再传 codeBlockId 与 index:内部会按 uuid
|
|
340
|
-
*
|
|
347
|
+
* 通过历史记录 uuid 回滚代码块历史步骤,语义同 {@link revert},
|
|
348
|
+
* 仅无需调用方再传 codeBlockId 与 index:内部会按 uuid 在全部代码块栈中定位对应步骤后再回滚。
|
|
349
|
+
* 按数组顺序依次回滚,返回与入参同序的结果列表(某项失败时为 `null`)。
|
|
341
350
|
*
|
|
342
|
-
* @param
|
|
343
|
-
* @returns 反向后产生的新 step;找不到对应 uuid / 未应用时返回 null
|
|
351
|
+
* @param uuids 目标历史记录的 uuid 列表,通常由 {@link setCodeDslByIdAndGetHistoryId} 等方法返回的 `historyIds`
|
|
344
352
|
*/
|
|
345
|
-
async revertById(
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
353
|
+
async revertById(uuids) {
|
|
354
|
+
const results = [];
|
|
355
|
+
for (const uuid of uuids) {
|
|
356
|
+
const location = history_default.findCodeBlockStepLocationByUuid(uuid);
|
|
357
|
+
results.push(location ? await this.revert(location.id, location.index) : null);
|
|
358
|
+
}
|
|
359
|
+
return results;
|
|
349
360
|
}
|
|
350
361
|
/**
|
|
351
362
|
* 生成代码块唯一id
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseService from "./BaseService.js";
|
|
2
|
-
import { describeRevertStep } from "../utils/history.js";
|
|
2
|
+
import { describeRevertStep, getLastPushedHistoryIds } from "../utils/history.js";
|
|
3
3
|
import history_default from "./history.js";
|
|
4
4
|
import storage_default, { Protocol } from "./storage.js";
|
|
5
5
|
import { COPY_DS_STORAGE_KEY } from "../utils/editor.js";
|
|
@@ -150,28 +150,35 @@ var DataSource = class extends BaseService {
|
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* 下列 *AndGetHistoryId 方法与对应的 add / update / remove 行为完全一致,
|
|
153
|
-
*
|
|
154
|
-
*
|
|
153
|
+
* 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入历史栈的 uuid 列表({@link DataSourceStepValue.uuid}),
|
|
154
|
+
* 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
|
|
155
155
|
*
|
|
156
|
-
* 当本次操作未写入历史(doNotPushHistory 为 true
|
|
156
|
+
* 当本次操作未写入历史(doNotPushHistory 为 true、或无对应记录)时 historyIds 为 `[]`。
|
|
157
157
|
*/
|
|
158
|
-
/** 等价于 {@link add}
|
|
158
|
+
/** 等价于 {@link add},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
159
159
|
addAndGetHistoryId(config, options = {}) {
|
|
160
160
|
this.lastPushedHistoryId = null;
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
return {
|
|
162
|
+
result: this.add(config, options),
|
|
163
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
164
|
+
};
|
|
163
165
|
}
|
|
164
|
-
/** 等价于 {@link update}
|
|
166
|
+
/** 等价于 {@link update},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
165
167
|
updateAndGetHistoryId(config, options = {}) {
|
|
166
168
|
this.lastPushedHistoryId = null;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
return {
|
|
170
|
+
result: this.update(config, options),
|
|
171
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
172
|
+
};
|
|
169
173
|
}
|
|
170
|
-
/** 等价于 {@link remove}
|
|
174
|
+
/** 等价于 {@link remove},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
171
175
|
removeAndGetHistoryId(id, options = {}) {
|
|
172
176
|
this.lastPushedHistoryId = null;
|
|
173
177
|
this.remove(id, options);
|
|
174
|
-
return
|
|
178
|
+
return {
|
|
179
|
+
result: void 0,
|
|
180
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
181
|
+
};
|
|
175
182
|
}
|
|
176
183
|
/**
|
|
177
184
|
* 撤销指定数据源的最近一次变更。
|
|
@@ -247,17 +254,18 @@ var DataSource = class extends BaseService {
|
|
|
247
254
|
return this.applyRevertStep(entry.step, description);
|
|
248
255
|
}
|
|
249
256
|
/**
|
|
250
|
-
* 通过历史记录 uuid
|
|
251
|
-
* 仅无需调用方再传 dataSourceId 与 index:内部会按 uuid
|
|
252
|
-
*
|
|
257
|
+
* 通过历史记录 uuid 回滚数据源历史步骤,语义同 {@link revert},
|
|
258
|
+
* 仅无需调用方再传 dataSourceId 与 index:内部会按 uuid 在全部数据源栈中定位对应步骤后再回滚。
|
|
259
|
+
* 按数组顺序依次回滚,返回与入参同序的结果列表(某项失败时为 `null`)。
|
|
253
260
|
*
|
|
254
|
-
* @param
|
|
255
|
-
* @returns 反向后产生的新 step;找不到对应 uuid / 未应用时返回 null
|
|
261
|
+
* @param uuids 目标历史记录的 uuid 列表,通常由 {@link addAndGetHistoryId} 等方法返回的 `historyIds`
|
|
256
262
|
*/
|
|
257
|
-
revertById(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
263
|
+
revertById(uuids) {
|
|
264
|
+
return uuids.map((uuid) => {
|
|
265
|
+
const location = history_default.findDataSourceStepLocationByUuid(uuid);
|
|
266
|
+
if (!location) return null;
|
|
267
|
+
return this.revert(location.id, location.index);
|
|
268
|
+
});
|
|
261
269
|
}
|
|
262
270
|
createId() {
|
|
263
271
|
return `ds_${guid()}`;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Layout, canUsePluginMethods } from "../type.js";
|
|
2
2
|
import BaseService from "./BaseService.js";
|
|
3
3
|
import props_default from "./props.js";
|
|
4
|
+
import { getLastPushedHistoryIds } from "../utils/history.js";
|
|
4
5
|
import history_default from "./history.js";
|
|
5
6
|
import storage_default, { Protocol } from "./storage.js";
|
|
6
7
|
import { COPY_STORAGE_KEY, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, classifyDragSources, collectRelatedNodes, describeStepForRevert, editorNodeMergeCustomizer, fixNodePosition, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, moveItemsInContainer, resolveSelectedNode, setChildrenLayout, setLayout, toggleFixedPosition } from "../utils/editor.js";
|
|
@@ -83,7 +84,7 @@ var Editor = class extends BaseService {
|
|
|
83
84
|
this.state.pageFragmentLength = 0;
|
|
84
85
|
this.state.stageLoading = false;
|
|
85
86
|
}
|
|
86
|
-
this.emit("root-change", value, preValue);
|
|
87
|
+
this.emit("root-change", value, preValue, options);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
@@ -106,12 +107,14 @@ var Editor = class extends BaseService {
|
|
|
106
107
|
if (!root) return {
|
|
107
108
|
node: null,
|
|
108
109
|
parent: null,
|
|
109
|
-
page: null
|
|
110
|
+
page: null,
|
|
111
|
+
path: []
|
|
110
112
|
};
|
|
111
113
|
if (id === root.id) return {
|
|
112
114
|
node: root,
|
|
113
115
|
parent: null,
|
|
114
|
-
page: null
|
|
116
|
+
page: null,
|
|
117
|
+
path: []
|
|
115
118
|
};
|
|
116
119
|
const pageIdStr = `${this.get("page")?.id || ""}`;
|
|
117
120
|
const currentPageNode = root.items?.find((item) => `${item.id}` === pageIdStr);
|
|
@@ -431,13 +434,12 @@ var Editor = class extends BaseService {
|
|
|
431
434
|
this.emit("remove", nodes);
|
|
432
435
|
}
|
|
433
436
|
async doUpdate(config, { changeRecords = [], historySource } = {}) {
|
|
434
|
-
|
|
435
|
-
if (!root) throw new Error("root为空");
|
|
437
|
+
if (!this.get("root")) throw new Error("root为空");
|
|
436
438
|
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
437
439
|
const info = this.getNodeInfo(config.id, false);
|
|
438
440
|
if (!info.node) throw new Error(`获取不到id为${config.id}的节点`);
|
|
439
441
|
const node = toRaw(info.node);
|
|
440
|
-
let newConfig = await toggleFixedPosition(toRaw(config), node,
|
|
442
|
+
let newConfig = await toggleFixedPosition(toRaw(config), node, info.path, this.getLayout);
|
|
441
443
|
newConfig = mergeWith(cloneDeep$1(node), newConfig, editorNodeMergeCustomizer);
|
|
442
444
|
if (!newConfig.type) throw new Error("配置缺少type值");
|
|
443
445
|
if (newConfig.type === NodeType.ROOT) {
|
|
@@ -812,46 +814,61 @@ var Editor = class extends BaseService {
|
|
|
812
814
|
}
|
|
813
815
|
/**
|
|
814
816
|
* 下列 *AndGetHistoryId 方法与对应的普通操作(add / remove / update ...)行为完全一致,
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
+
* 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入历史栈的 uuid 列表({@link StepValue.uuid}),
|
|
818
|
+
* 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
|
|
817
819
|
*
|
|
818
|
-
* 当本次操作未写入历史(doNotPushHistory 为 true、或操作无实际变更 /
|
|
820
|
+
* 当本次操作未写入历史(doNotPushHistory 为 true、或操作无实际变更 / 提前返回)时 historyIds 为 `[]`。
|
|
819
821
|
*/
|
|
820
|
-
/** 等价于 {@link add}
|
|
822
|
+
/** 等价于 {@link add},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
821
823
|
async addAndGetHistoryId(addNode, parent, options = {}) {
|
|
822
824
|
this.lastPushedHistoryId = null;
|
|
823
|
-
|
|
824
|
-
|
|
825
|
+
return {
|
|
826
|
+
result: await this.add(addNode, parent, options),
|
|
827
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
828
|
+
};
|
|
825
829
|
}
|
|
826
|
-
/** 等价于 {@link remove}
|
|
830
|
+
/** 等价于 {@link remove},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
827
831
|
async removeAndGetHistoryId(nodeOrNodeList, options = {}) {
|
|
828
832
|
this.lastPushedHistoryId = null;
|
|
829
833
|
await this.remove(nodeOrNodeList, options);
|
|
830
|
-
return
|
|
834
|
+
return {
|
|
835
|
+
result: void 0,
|
|
836
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
837
|
+
};
|
|
831
838
|
}
|
|
832
|
-
/** 等价于 {@link update}
|
|
839
|
+
/** 等价于 {@link update},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
833
840
|
async updateAndGetHistoryId(config, data = {}) {
|
|
834
841
|
this.lastPushedHistoryId = null;
|
|
835
|
-
|
|
836
|
-
|
|
842
|
+
return {
|
|
843
|
+
result: await this.update(config, data),
|
|
844
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
845
|
+
};
|
|
837
846
|
}
|
|
838
|
-
/** 等价于 {@link moveLayer}
|
|
847
|
+
/** 等价于 {@link moveLayer},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
839
848
|
async moveLayerAndGetHistoryId(offset, options = {}) {
|
|
840
849
|
this.lastPushedHistoryId = null;
|
|
841
850
|
await this.moveLayer(offset, options);
|
|
842
|
-
return
|
|
851
|
+
return {
|
|
852
|
+
result: void 0,
|
|
853
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
854
|
+
};
|
|
843
855
|
}
|
|
844
|
-
/** 等价于 {@link moveToContainer}
|
|
856
|
+
/** 等价于 {@link moveToContainer},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
845
857
|
async moveToContainerAndGetHistoryId(config, targetId, options = {}) {
|
|
846
858
|
this.lastPushedHistoryId = null;
|
|
847
|
-
|
|
848
|
-
|
|
859
|
+
return {
|
|
860
|
+
result: await this.moveToContainer(config, targetId, options),
|
|
861
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
862
|
+
};
|
|
849
863
|
}
|
|
850
|
-
/** 等价于 {@link dragTo}
|
|
864
|
+
/** 等价于 {@link dragTo},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
851
865
|
async dragToAndGetHistoryId(config, targetParent, targetIndex, options = {}) {
|
|
852
866
|
this.lastPushedHistoryId = null;
|
|
853
867
|
await this.dragTo(config, targetParent, targetIndex, options);
|
|
854
|
-
return
|
|
868
|
+
return {
|
|
869
|
+
result: void 0,
|
|
870
|
+
historyIds: getLastPushedHistoryIds(this.lastPushedHistoryId)
|
|
871
|
+
};
|
|
855
872
|
}
|
|
856
873
|
/**
|
|
857
874
|
* 撤销当前操作
|
|
@@ -960,17 +977,19 @@ var Editor = class extends BaseService {
|
|
|
960
977
|
return revertedStep;
|
|
961
978
|
}
|
|
962
979
|
/**
|
|
963
|
-
* 通过历史记录 uuid
|
|
964
|
-
* 仅入参从 index 改为 uuid
|
|
965
|
-
*
|
|
980
|
+
* 通过历史记录 uuid 回滚当前页面的历史步骤,语义与 {@link revertPageStep} 完全一致,
|
|
981
|
+
* 仅入参从 index 改为 uuid 列表({@link StepValue.uuid})。按数组顺序依次回滚,
|
|
982
|
+
* 返回与入参同序的结果列表(某项失败时为 `null`)。
|
|
966
983
|
*
|
|
967
|
-
* @param
|
|
968
|
-
* @returns 反向后产生的新 step;找不到对应 uuid / 未应用 / 反向失败时返回 null
|
|
984
|
+
* @param uuids 目标历史记录的 uuid 列表,通常由 *AndGetHistoryId 方法返回的 `historyIds`
|
|
969
985
|
*/
|
|
970
|
-
async revertPageStepById(
|
|
971
|
-
const
|
|
972
|
-
|
|
973
|
-
|
|
986
|
+
async revertPageStepById(uuids) {
|
|
987
|
+
const results = [];
|
|
988
|
+
for (const uuid of uuids) {
|
|
989
|
+
const index = history_default.getPageStepIndexByUuid(uuid);
|
|
990
|
+
results.push(index < 0 ? null : await this.revertPageStep(index));
|
|
991
|
+
}
|
|
992
|
+
return results;
|
|
974
993
|
}
|
|
975
994
|
/**
|
|
976
995
|
* 跳转当前页面历史栈到指定游标位置。
|
|
@@ -6,13 +6,12 @@ import { idbGet, idbSet } from "../utils/indexed-db.js";
|
|
|
6
6
|
import editor_default from "./editor.js";
|
|
7
7
|
import { guid } from "@tmagic/utils";
|
|
8
8
|
import { reactive } from "vue";
|
|
9
|
-
import serialize from "serialize-javascript";
|
|
10
9
|
//#region packages/editor/src/services/history.ts
|
|
11
10
|
/** 历史记录持久化快照的默认存储位置与结构版本。 */
|
|
12
11
|
var DEFAULT_DB_NAME = "tmagic-editor";
|
|
13
12
|
var DEFAULT_STORE_NAME = "history";
|
|
14
13
|
var DEFAULT_KEY = "default";
|
|
15
|
-
var PERSIST_VERSION =
|
|
14
|
+
var PERSIST_VERSION = 2;
|
|
16
15
|
var History = class extends BaseService {
|
|
17
16
|
state = reactive({
|
|
18
17
|
pageSteps: {},
|
|
@@ -335,7 +334,7 @@ var History = class extends BaseService {
|
|
|
335
334
|
dataSourceState: serializeStacks(this.state.dataSourceState),
|
|
336
335
|
savedAt: Date.now()
|
|
337
336
|
};
|
|
338
|
-
await idbSet(this.resolveDbName(dbName, appId), storeName, key,
|
|
337
|
+
await idbSet(this.resolveDbName(dbName, appId), storeName, key, snapshot);
|
|
339
338
|
this.emit("save-to-indexed-db", snapshot);
|
|
340
339
|
return snapshot;
|
|
341
340
|
}
|
|
@@ -349,13 +348,12 @@ var History = class extends BaseService {
|
|
|
349
348
|
*/
|
|
350
349
|
async restoreFromIndexedDB(options = {}) {
|
|
351
350
|
const { dbName = DEFAULT_DB_NAME, storeName = DEFAULT_STORE_NAME, key = DEFAULT_KEY, appId } = options;
|
|
352
|
-
const
|
|
353
|
-
if (!raw) return null;
|
|
354
|
-
const snapshot = typeof raw === "string" ? getEditorConfig("parseDSL")(`(${raw})`) : raw;
|
|
351
|
+
const snapshot = await idbGet(this.resolveDbName(dbName, appId), storeName, key);
|
|
355
352
|
if (!snapshot) return null;
|
|
356
|
-
|
|
357
|
-
this.state.
|
|
358
|
-
this.state.
|
|
353
|
+
const parseDSL = getEditorConfig("parseDSL");
|
|
354
|
+
this.state.pageSteps = deserializeStacks(snapshot.pageSteps, parseDSL);
|
|
355
|
+
this.state.codeBlockState = deserializeStacks(snapshot.codeBlockState, parseDSL);
|
|
356
|
+
this.state.dataSourceState = deserializeStacks(snapshot.dataSourceState, parseDSL);
|
|
359
357
|
this.state.pageId = snapshot.pageId;
|
|
360
358
|
this.setCanUndoRedo();
|
|
361
359
|
this.emit("restore-from-indexed-db", snapshot);
|
|
@@ -395,11 +393,8 @@ var History = class extends BaseService {
|
|
|
395
393
|
return mergePageSteps(targetPageId, list, undoRedo.getCursor()).filter((group) => group.opType !== "initial");
|
|
396
394
|
}
|
|
397
395
|
/**
|
|
398
|
-
* 取出全部代码块的历史栈,按 codeBlockId
|
|
399
|
-
*
|
|
400
|
-
* - 这正是"代码块/数据源各自按 id 分栈"的天然表现,再叠加"连续修改同目标的相邻步骤合并展示"。
|
|
401
|
-
* - 合并后 group 暴露子步骤数组,UI 可展开查看每一步的 changeRecords。
|
|
402
|
-
* - applied 字段:组内最后一步是否处于已应用段。
|
|
396
|
+
* 取出全部代码块的历史栈,按 codeBlockId 分桶展示。
|
|
397
|
+
* 同一栈内每条操作记录独立成组,不做相邻 update 合并。
|
|
403
398
|
*/
|
|
404
399
|
getCodeBlockHistoryGroups() {
|
|
405
400
|
const groups = [];
|
|
@@ -496,7 +491,7 @@ var History = class extends BaseService {
|
|
|
496
491
|
return null;
|
|
497
492
|
}
|
|
498
493
|
/**
|
|
499
|
-
* 取出全部数据源的历史栈,按 dataSourceId
|
|
494
|
+
* 取出全部数据源的历史栈,按 dataSourceId 分桶展示。同上,每条操作独立成组。
|
|
500
495
|
*/
|
|
501
496
|
getDataSourceHistoryGroups() {
|
|
502
497
|
const groups = [];
|
package/dist/es/style.css
CHANGED
|
@@ -2093,9 +2093,12 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
2093
2093
|
.border-box-container .border-icon-container .border-icon + .border-icon {
|
|
2094
2094
|
margin-left: 8px;
|
|
2095
2095
|
}
|
|
2096
|
+
.border-box-container .border-icon-container .border-icon.configured {
|
|
2097
|
+
border-color: var(--el-color-success, var(--td-success-color, #2ba471));
|
|
2098
|
+
}
|
|
2096
2099
|
.border-box-container .border-icon-container .border-icon.active {
|
|
2097
2100
|
border-width: 1px;
|
|
2098
|
-
border-color: var(--el-color-primary);
|
|
2101
|
+
border-color: var(--el-color-primary, var(--td-brand-color, #0052d9));
|
|
2099
2102
|
}
|
|
2100
2103
|
.border-box-container .border-icon-container .border-icon.border-icon-top {
|
|
2101
2104
|
border-top-width: 2px;
|
|
@@ -7,6 +7,7 @@ var dataSourceFormConfig = {
|
|
|
7
7
|
items: [
|
|
8
8
|
{
|
|
9
9
|
title: "数据定义",
|
|
10
|
+
status: "fields",
|
|
10
11
|
items: [{
|
|
11
12
|
name: "fields",
|
|
12
13
|
type: "data-source-fields",
|
|
@@ -15,6 +16,7 @@ var dataSourceFormConfig = {
|
|
|
15
16
|
},
|
|
16
17
|
{
|
|
17
18
|
title: "方法定义",
|
|
19
|
+
status: "methods",
|
|
18
20
|
items: [{
|
|
19
21
|
name: "methods",
|
|
20
22
|
type: "data-source-methods",
|