@tmagic/editor 1.8.0-beta.5 → 1.8.0-beta.6
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 +2 -2
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +12 -4
- 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 +376 -206
- 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 +2 -2
- package/src/layouts/history-list/InitialRow.vue +3 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +30 -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 +14 -19
- package/src/theme/style-setter/border.scss +4 -1
- package/src/type.ts +16 -1
- package/src/utils/data-source/index.ts +2 -0
- package/src/utils/editor.ts +125 -59
- package/src/utils/history.ts +46 -36
- package/types/index.d.ts +87 -68
|
@@ -47,7 +47,8 @@ var CodeSelectCol_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
47
47
|
*/
|
|
48
48
|
const isCompareMode = computed(() => Boolean(props.isCompare && props.lastValues));
|
|
49
49
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
50
|
-
const
|
|
50
|
+
const codeBlockSidePanel = computed(() => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK));
|
|
51
|
+
const hasCodeBlockSidePanel = computed(() => codeBlockSidePanel.value);
|
|
51
52
|
/**
|
|
52
53
|
* 根据代码块id获取代码块参数配置
|
|
53
54
|
* @param codeId 代码块ID
|
|
@@ -102,6 +103,8 @@ var CodeSelectCol_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
102
103
|
emit("change", props.model[props.name], eventData);
|
|
103
104
|
};
|
|
104
105
|
const editCode = (id) => {
|
|
106
|
+
const sideBarItem = codeBlockSidePanel.value;
|
|
107
|
+
if (sideBarItem) uiService.set("sideBarActiveTabName", sideBarItem.text || sideBarItem.$key || SideItemKey.CODE_BLOCK);
|
|
105
108
|
eventBus?.emit("edit-code", id);
|
|
106
109
|
};
|
|
107
110
|
return (_ctx, _cache) => {
|
package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -89,9 +89,15 @@ var FieldSelect_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
89
89
|
modelValue.value = v;
|
|
90
90
|
emit("change", v);
|
|
91
91
|
};
|
|
92
|
-
const
|
|
92
|
+
const dataSourceSidePanel = computed(() => uiService.get("sideBarItems").find((item) => item.$key === SideItemKey.DATA_SOURCE));
|
|
93
|
+
const hasDataSourceSidePanel = computed(() => dataSourceSidePanel.value);
|
|
93
94
|
const editHandler = (id) => {
|
|
94
|
-
|
|
95
|
+
const sideBarItem = dataSourceSidePanel.value;
|
|
96
|
+
if (sideBarItem) uiService.set("sideBarActiveTabName", sideBarItem.text || sideBarItem.$key || SideItemKey.DATA_SOURCE);
|
|
97
|
+
const dataSourceId = removeDataSourceFieldPrefix(id);
|
|
98
|
+
const fieldPath = selectFieldsId.value;
|
|
99
|
+
if (fieldPath.length) eventBus?.emit("edit-data-source-field", dataSourceId, [...fieldPath]);
|
|
100
|
+
else eventBus?.emit("edit-data-source", dataSourceId);
|
|
95
101
|
};
|
|
96
102
|
return (_ctx, _cache) => {
|
|
97
103
|
return openBlock(), createElementBlock("div", _hoisted_1, [__props.dataSourceId ? (openBlock(), createBlock(unref(TMagicCascader), {
|
|
@@ -7,7 +7,7 @@ import { MFormBox } from "@tmagic/form";
|
|
|
7
7
|
import { MagicTable } from "@tmagic/table";
|
|
8
8
|
import { TMagicButton, tMagicMessage, tMagicMessageBox } from "@tmagic/design";
|
|
9
9
|
import { getDefaultValueFromFields } from "@tmagic/utils";
|
|
10
|
-
import { computed, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, isRef, mergeModels, openBlock, ref, unref, useModel, withCtx } from "vue";
|
|
10
|
+
import { computed, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, isRef, mergeModels, onMounted, openBlock, provide, ref, unref, useModel, withCtx } from "vue";
|
|
11
11
|
//#region packages/editor/src/fields/DataSourceFields.vue?vue&type=script&setup=true&lang.ts
|
|
12
12
|
var _hoisted_1 = { class: "m-editor-data-source-fields" };
|
|
13
13
|
var _hoisted_2 = {
|
|
@@ -66,6 +66,15 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
66
66
|
calcBoxPosition();
|
|
67
67
|
addDialogVisible.value = true;
|
|
68
68
|
};
|
|
69
|
+
const editField = (row, index) => {
|
|
70
|
+
fieldValues.value = {
|
|
71
|
+
...row,
|
|
72
|
+
index
|
|
73
|
+
};
|
|
74
|
+
fieldTitle.value = `编辑${row.title}`;
|
|
75
|
+
calcBoxPosition();
|
|
76
|
+
addDialogVisible.value = true;
|
|
77
|
+
};
|
|
69
78
|
const fieldChange = ({ index, ...value }, data) => {
|
|
70
79
|
addDialogVisible.value = false;
|
|
71
80
|
if (index > -1) emit("change", value, {
|
|
@@ -117,13 +126,7 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
117
126
|
actions: [{
|
|
118
127
|
text: "编辑",
|
|
119
128
|
handler: (row, index) => {
|
|
120
|
-
|
|
121
|
-
...row,
|
|
122
|
-
index
|
|
123
|
-
};
|
|
124
|
-
fieldTitle.value = `编辑${row.title}`;
|
|
125
|
-
calcBoxPosition();
|
|
126
|
-
addDialogVisible.value = true;
|
|
129
|
+
editField(row, index);
|
|
127
130
|
}
|
|
128
131
|
}, {
|
|
129
132
|
text: "删除",
|
|
@@ -310,6 +313,20 @@ var DataSourceFields_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
310
313
|
const addFromJsonDialogVisible = useModel(__props, "visible1");
|
|
311
314
|
const { height: editorHeight } = useEditorContentHeight();
|
|
312
315
|
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, inject("parentFloating", ref(null)));
|
|
316
|
+
/**
|
|
317
|
+
* 由 DataSourceConfigPanel 注入:打开数据源详情后需要直接打开的字段路径(字段名数组)。
|
|
318
|
+
* 当前层消费 path[0],并把剩余路径下发给嵌套字段,实现逐层打开。
|
|
319
|
+
*/
|
|
320
|
+
const editingFieldPath = inject("editingDataSourceFieldPath", computed(() => []));
|
|
321
|
+
provide("editingDataSourceFieldPath", computed(() => editingFieldPath.value.slice(1)));
|
|
322
|
+
onMounted(() => {
|
|
323
|
+
const path = editingFieldPath.value;
|
|
324
|
+
if (!path.length) return;
|
|
325
|
+
const fields = props.model[props.name] || [];
|
|
326
|
+
const index = fields.findIndex((field) => field.name === path[0]);
|
|
327
|
+
if (index === -1) return;
|
|
328
|
+
editField(fields[index], index);
|
|
329
|
+
});
|
|
313
330
|
return (_ctx, _cache) => {
|
|
314
331
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
315
332
|
createVNode(unref(MagicTable), {
|
package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js
CHANGED
|
@@ -36,7 +36,7 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
36
36
|
const eventBus = inject("eventBus");
|
|
37
37
|
const emit = __emit;
|
|
38
38
|
const props = __props;
|
|
39
|
-
const
|
|
39
|
+
const dataSourceSidePanel = computed(() => (uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE));
|
|
40
40
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
41
41
|
/** 对比模式下隐藏查看/编辑操作按钮,仅保留只读展示。 */
|
|
42
42
|
const isCompare = computed(() => Boolean(mForm?.isCompare));
|
|
@@ -124,9 +124,11 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
124
124
|
emit("change", props.model[props.name], eventData);
|
|
125
125
|
};
|
|
126
126
|
const editCodeHandler = () => {
|
|
127
|
-
const [id] = props.model[props.name];
|
|
127
|
+
const [id, methodName] = props.model[props.name];
|
|
128
128
|
if (!dataSourceService.getDataSourceById(id)) return;
|
|
129
|
-
|
|
129
|
+
const sideBarItem = dataSourceSidePanel.value;
|
|
130
|
+
if (sideBarItem) uiService.set("sideBarActiveTabName", sideBarItem.text || sideBarItem.$key || SideItemKey.DATA_SOURCE);
|
|
131
|
+
eventBus?.emit("edit-data-source-method", id, methodName);
|
|
130
132
|
};
|
|
131
133
|
return (_ctx, _cache) => {
|
|
132
134
|
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createVNode(unref(MCascader), {
|
|
@@ -145,7 +147,7 @@ var DataSourceMethodSelect_vue_vue_type_script_setup_true_name_true_lang_default
|
|
|
145
147
|
"size",
|
|
146
148
|
"disabled",
|
|
147
149
|
"prop"
|
|
148
|
-
]), __props.model[__props.name] && isCustomMethod.value &&
|
|
150
|
+
]), __props.model[__props.name] && isCustomMethod.value && dataSourceSidePanel.value && !isCompare.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
149
151
|
key: 0,
|
|
150
152
|
content: notEditable.value ? "查看" : "编辑"
|
|
151
153
|
}, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import CodeBlockEditor_default from "../components/CodeBlockEditor.js";
|
|
2
2
|
import { MagicTable } from "@tmagic/table";
|
|
3
3
|
import { TMagicButton, tMagicMessageBox } from "@tmagic/design";
|
|
4
|
-
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, nextTick, openBlock, ref, unref, useTemplateRef, withCtx } from "vue";
|
|
4
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, inject, nextTick, onMounted, openBlock, ref, unref, useTemplateRef, withCtx } from "vue";
|
|
5
5
|
import { cloneDeep } from "lodash-es";
|
|
6
6
|
//#region packages/editor/src/fields/DataSourceMethods.vue?vue&type=script&setup=true&lang.ts
|
|
7
7
|
var _hoisted_1 = { class: "m-editor-data-source-methods" };
|
|
@@ -37,6 +37,19 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
37
37
|
const codeConfig = ref();
|
|
38
38
|
const codeBlockEditorRef = useTemplateRef("codeBlockEditor");
|
|
39
39
|
let editIndex = -1;
|
|
40
|
+
const editMethod = (method, index) => {
|
|
41
|
+
let codeContent = "({ params, dataSource, app }) => {\n // place your code here\n}";
|
|
42
|
+
if (method.content) if (typeof method.content !== "string") codeContent = method.content.toString();
|
|
43
|
+
else codeContent = method.content;
|
|
44
|
+
codeConfig.value = {
|
|
45
|
+
...cloneDeep(method),
|
|
46
|
+
content: codeContent
|
|
47
|
+
};
|
|
48
|
+
editIndex = index;
|
|
49
|
+
nextTick(() => {
|
|
50
|
+
codeBlockEditorRef.value?.show();
|
|
51
|
+
});
|
|
52
|
+
};
|
|
40
53
|
const methodColumns = [
|
|
41
54
|
{
|
|
42
55
|
label: "名称",
|
|
@@ -61,17 +74,7 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
61
74
|
actions: [{
|
|
62
75
|
text: "编辑",
|
|
63
76
|
handler: (method, index) => {
|
|
64
|
-
|
|
65
|
-
if (method.content) if (typeof method.content !== "string") codeContent = method.content.toString();
|
|
66
|
-
else codeContent = method.content;
|
|
67
|
-
codeConfig.value = {
|
|
68
|
-
...cloneDeep(method),
|
|
69
|
-
content: codeContent
|
|
70
|
-
};
|
|
71
|
-
editIndex = index;
|
|
72
|
-
nextTick(() => {
|
|
73
|
-
codeBlockEditorRef.value?.show();
|
|
74
|
-
});
|
|
77
|
+
editMethod(method, index);
|
|
75
78
|
}
|
|
76
79
|
}, {
|
|
77
80
|
text: "删除",
|
|
@@ -119,6 +122,16 @@ var DataSourceMethods_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
119
122
|
codeConfig.value = void 0;
|
|
120
123
|
codeBlockEditorRef.value?.hide();
|
|
121
124
|
};
|
|
125
|
+
/** 由 DataSourceConfigPanel 注入:打开数据源详情后需要直接打开的方法名 */
|
|
126
|
+
const editingMethodName = inject("editingDataSourceMethodName", computed(() => ""));
|
|
127
|
+
onMounted(() => {
|
|
128
|
+
const methodName = editingMethodName.value;
|
|
129
|
+
if (!methodName) return;
|
|
130
|
+
const methods = props.model[props.name] || [];
|
|
131
|
+
const index = methods.findIndex((method) => method.name === methodName);
|
|
132
|
+
if (index === -1) return;
|
|
133
|
+
editMethod(methods[index], index);
|
|
134
|
+
});
|
|
122
135
|
return (_ctx, _cache) => {
|
|
123
136
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
124
137
|
createVNode(unref(MagicTable), {
|
|
@@ -54,6 +54,13 @@ var Border_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
54
54
|
] }));
|
|
55
55
|
const selectDirection = (d) => direction.value = d || "";
|
|
56
56
|
const emit = __emit;
|
|
57
|
+
const props = __props;
|
|
58
|
+
const hasValue = (value) => value !== void 0 && value !== null && value !== "";
|
|
59
|
+
const isConfigured = (d) => [
|
|
60
|
+
"Width",
|
|
61
|
+
"Color",
|
|
62
|
+
"Style"
|
|
63
|
+
].some((key) => hasValue(props.model?.[`border${d}${key}`]));
|
|
57
64
|
const change = (value, eventData) => {
|
|
58
65
|
eventData.changeRecords?.forEach((record) => {
|
|
59
66
|
emit("change", record.value, { modifyKey: record.propPath });
|
|
@@ -63,25 +70,40 @@ var Border_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
63
70
|
return (_ctx, _cache) => {
|
|
64
71
|
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [
|
|
65
72
|
createElementVNode("div", _hoisted_3, [createElementVNode("div", {
|
|
66
|
-
class: normalizeClass(["border-icon border-icon-top", {
|
|
73
|
+
class: normalizeClass(["border-icon border-icon-top", {
|
|
74
|
+
active: direction.value === "Top",
|
|
75
|
+
configured: isConfigured("Top")
|
|
76
|
+
}]),
|
|
67
77
|
onClick: _cache[0] || (_cache[0] = ($event) => selectDirection("Top"))
|
|
68
78
|
}, null, 2)]),
|
|
69
79
|
createElementVNode("div", _hoisted_4, [
|
|
70
80
|
createElementVNode("div", {
|
|
71
|
-
class: normalizeClass(["border-icon border-icon-left", {
|
|
81
|
+
class: normalizeClass(["border-icon border-icon-left", {
|
|
82
|
+
active: direction.value === "Left",
|
|
83
|
+
configured: isConfigured("Left")
|
|
84
|
+
}]),
|
|
72
85
|
onClick: _cache[1] || (_cache[1] = ($event) => selectDirection("Left"))
|
|
73
86
|
}, null, 2),
|
|
74
87
|
createElementVNode("div", {
|
|
75
|
-
class: normalizeClass(["border-icon", {
|
|
88
|
+
class: normalizeClass(["border-icon", {
|
|
89
|
+
active: direction.value === "",
|
|
90
|
+
configured: isConfigured("")
|
|
91
|
+
}]),
|
|
76
92
|
onClick: _cache[2] || (_cache[2] = ($event) => selectDirection())
|
|
77
93
|
}, null, 2),
|
|
78
94
|
createElementVNode("div", {
|
|
79
|
-
class: normalizeClass(["border-icon border-icon-right", {
|
|
95
|
+
class: normalizeClass(["border-icon border-icon-right", {
|
|
96
|
+
active: direction.value === "Right",
|
|
97
|
+
configured: isConfigured("Right")
|
|
98
|
+
}]),
|
|
80
99
|
onClick: _cache[3] || (_cache[3] = ($event) => selectDirection("Right"))
|
|
81
100
|
}, null, 2)
|
|
82
101
|
]),
|
|
83
102
|
createElementVNode("div", _hoisted_5, [createElementVNode("div", {
|
|
84
|
-
class: normalizeClass(["border-icon border-icon-bottom", {
|
|
103
|
+
class: normalizeClass(["border-icon border-icon-bottom", {
|
|
104
|
+
active: direction.value === "Bottom",
|
|
105
|
+
configured: isConfigured("Bottom")
|
|
106
|
+
}]),
|
|
85
107
|
onClick: _cache[4] || (_cache[4] = ($event) => selectDirection("Bottom"))
|
|
86
108
|
}, null, 2)])
|
|
87
109
|
]), createElementVNode("div", _hoisted_6, [createVNode(unref(MContainer), {
|
package/dist/es/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { advancedTabConfig, arrayOptions, displayTabConfig, eqOptions, eventTabC
|
|
|
4
4
|
import props_default from "./services/props.js";
|
|
5
5
|
import { getEditorConfig, setEditorConfig } from "./utils/config.js";
|
|
6
6
|
import { UndoRedo } from "./utils/undo-redo.js";
|
|
7
|
-
import { createStackStep, describeRevertStep, deserializeStacks, detectPageTargetId, detectPageTargetName, detectStackOpType, getOrCreateStack, markStackSaved, mergePageSteps, mergeStackSteps, serializeStacks, undoFloor } from "./utils/history.js";
|
|
7
|
+
import { createStackStep, describeRevertStep, deserializeStacks, detectPageTargetId, detectPageTargetName, detectStackOpType, getLastPushedHistoryIds, getOrCreateStack, markStackSaved, mergePageSteps, mergeStackSteps, serializeStacks, undoFloor } from "./utils/history.js";
|
|
8
8
|
import { idbDelete, idbGet, idbSet, isIndexedDBSupported, openIndexedDB } from "./utils/indexed-db.js";
|
|
9
9
|
import history_default from "./services/history.js";
|
|
10
10
|
import storage_default from "./services/storage.js";
|
|
@@ -83,4 +83,4 @@ export * from "@tmagic/table";
|
|
|
83
83
|
export * from "@tmagic/stage";
|
|
84
84
|
export * from "@tmagic/design";
|
|
85
85
|
export * from "@tmagic/utils";
|
|
86
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, CodeBlockEditor_default as CodeBlockEditor, CodeBlockList_default as CodeBlockList, CodeBlockListPanel_default as CodeBlockListPanel, CodeDeleteErrorType, CodeSelect_default as CodeSelect, CodeSelectCol_default as CodeSelectCol, ColumnLayout, CompareForm_default as CompareForm, ComponentListPanel_default as ComponentListPanel, CondOpSelect_default as CondOpSelect, ContentMenu_default as ContentMenu, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, DataSourceAddButton_default as DataSourceAddButton, DataSourceConfigPanel_default as DataSourceConfigPanel, Index_default as DataSourceFieldSelect, DataSourceFields_default as DataSourceFields, DataSourceInput_default as DataSourceInput, DataSourceMethodSelect_default as DataSourceMethodSelect, DataSourceMethods_default as DataSourceMethods, DataSourceMocks_default as DataSourceMocks, DataSourceSelect_default as DataSourceSelect, DepTargetType, DisplayConds_default as DisplayConds, DragType, EventSelect_default as EventSelect, Fixed2Other, FloatingBox_default as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, HistoryDiffDialog_default as HistoryDiffDialog, Bucket_default as HistoryListBucket, BucketTab_default as HistoryListBucketTab, Icon_default as Icon, IdleTask, KeyBindingCommand, KeyValue_default as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerOffset, LayerPanel_default as LayerPanel, Layout, SplitView_default as LayoutContainer, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, PageFragmentSelect_default as PageFragmentSelect, FormPanel_default as PropsFormPanel, PropsPanel_default as PropsPanel, RIGHT_COLUMN_WIDTH_STORAGE_KEY, Resizer_default as Resizer, ScrollViewer, SideItemKey, SplitView_default as SplitView, StageCore, Index_default$1 as StyleSetter, CodeEditor_default as TMagicCodeEditor, Editor_default as TMagicEditor, ToolButton_default as ToolButton, Tree_default as Tree, TreeNode_default as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, arrayOptions, beforePaste, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, codeBlock_default as codeBlockService, collectRelatedNodes, createStackStep, dataSource_default as dataSourceService, debug, plugin_default as default, defaultIsExpandable, dep_default as depService, describeRevertStep, describeStepForRevert, deserializeStacks, designPlugin, detectPageTargetId, detectPageTargetName, detectStackOpType, displayTabConfig, editorNodeMergeCustomizer, editor_default as editorService, eqOptions, error, eventTabConfig, events_default as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getDefaultConfig, getDisplayField, getEditorConfig, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getOrCreateStack, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, history_default as historyService, idbDelete, idbGet, idbSet, info, isIncludeDataSource, isIndexedDBSupported, monaco_editor_default as loadMonaco, log, markStackSaved, mergePageSteps, mergeStackSteps, moveItemsInContainer, numberOptions, openIndexedDB, props_default as propsService, resolveSelectedNode, serializeConfig, serializeStacks, setChildrenLayout, setEditorConfig, setLayout, stageOverlay_default as stageOverlayService, storage_default as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, ui_default as uiService, undoFloor, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus, useServices, useStage, useWindowRect, warn };
|
|
86
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, CodeBlockEditor_default as CodeBlockEditor, CodeBlockList_default as CodeBlockList, CodeBlockListPanel_default as CodeBlockListPanel, CodeDeleteErrorType, CodeSelect_default as CodeSelect, CodeSelectCol_default as CodeSelectCol, ColumnLayout, CompareForm_default as CompareForm, ComponentListPanel_default as ComponentListPanel, CondOpSelect_default as CondOpSelect, ContentMenu_default as ContentMenu, DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, DataSourceAddButton_default as DataSourceAddButton, DataSourceConfigPanel_default as DataSourceConfigPanel, Index_default as DataSourceFieldSelect, DataSourceFields_default as DataSourceFields, DataSourceInput_default as DataSourceInput, DataSourceMethodSelect_default as DataSourceMethodSelect, DataSourceMethods_default as DataSourceMethods, DataSourceMocks_default as DataSourceMocks, DataSourceSelect_default as DataSourceSelect, DepTargetType, DisplayConds_default as DisplayConds, DragType, EventSelect_default as EventSelect, Fixed2Other, FloatingBox_default as FloatingBox, H_GUIDE_LINE_STORAGE_KEY, HistoryDiffDialog_default as HistoryDiffDialog, Bucket_default as HistoryListBucket, BucketTab_default as HistoryListBucketTab, Icon_default as Icon, IdleTask, KeyBindingCommand, KeyValue_default as KeyValue, Keys, LEFT_COLUMN_WIDTH_STORAGE_KEY, LayerOffset, LayerPanel_default as LayerPanel, Layout, SplitView_default as LayoutContainer, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, PageFragmentSelect_default as PageFragmentSelect, FormPanel_default as PropsFormPanel, PropsPanel_default as PropsPanel, RIGHT_COLUMN_WIDTH_STORAGE_KEY, Resizer_default as Resizer, ScrollViewer, SideItemKey, SplitView_default as SplitView, StageCore, Index_default$1 as StyleSetter, CodeEditor_default as TMagicCodeEditor, Editor_default as TMagicEditor, ToolButton_default as ToolButton, Tree_default as Tree, TreeNode_default as TreeNode, UI_SELECT_MODE_EVENT_NAME, UndoRedo, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, arrayOptions, beforePaste, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, canUsePluginMethods, change2Fixed, classifyDragSources, codeBlock_default as codeBlockService, collectRelatedNodes, createStackStep, dataSource_default as dataSourceService, debug, plugin_default as default, defaultIsExpandable, dep_default as depService, describeRevertStep, describeStepForRevert, deserializeStacks, designPlugin, detectPageTargetId, detectPageTargetName, detectStackOpType, displayTabConfig, editorNodeMergeCustomizer, editor_default as editorService, eqOptions, error, eventTabConfig, events_default as eventsService, fillConfig, fixNodeLeft, fixNodePosition, formPlugin, generatePageName, generatePageNameByApp, getAddParent, getCascaderOptionsFromFields, getCodeBlockFormConfig, getDefaultConfig, getDisplayField, getEditorConfig, getFieldType, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getLastPushedHistoryIds, getNodeIndex, getOrCreateStack, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, history_default as historyService, idbDelete, idbGet, idbSet, info, isIncludeDataSource, isIndexedDBSupported, monaco_editor_default as loadMonaco, log, markStackSaved, mergePageSteps, mergeStackSteps, moveItemsInContainer, numberOptions, openIndexedDB, props_default as propsService, resolveSelectedNode, serializeConfig, serializeStacks, setChildrenLayout, setEditorConfig, setLayout, stageOverlay_default as stageOverlayService, storage_default as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, ui_default as uiService, undoFloor, updateStatus, useCodeBlockEdit, useEditorContentHeight, useFilter, useFloatBox, useGetSo, useNextFloatBoxPosition, useNodeStatus, useServices, useStage, useWindowRect, warn };
|
package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -22,8 +22,8 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
22
22
|
/**
|
|
23
23
|
* 历史记录面板:在顶部 NavMenu 上点击图标打开 popover,分三个 tab:
|
|
24
24
|
* - 页面:当前活动页面的历史栈,连续修改同一节点的多步会被合并成一组
|
|
25
|
-
* - 数据源:以 dataSource.id
|
|
26
|
-
* - 代码块:同上,按 codeBlock.id
|
|
25
|
+
* - 数据源:以 dataSource.id 分桶,每条操作记录独立展示
|
|
26
|
+
* - 代码块:同上,按 codeBlock.id 分桶,每条操作记录独立展示
|
|
27
27
|
*
|
|
28
28
|
* 数据通过 historyService 暴露的聚合 API 读取,UI 仅用于只读展示,
|
|
29
29
|
* 同时支持点击任意一条记录跳转至该状态:
|
|
@@ -5,9 +5,14 @@ var _hoisted_1 = ["title"];
|
|
|
5
5
|
var _hoisted_2 = { class: "m-editor-history-list-item-desc" };
|
|
6
6
|
var _hoisted_3 = {
|
|
7
7
|
key: 0,
|
|
8
|
+
class: "m-editor-history-list-item-saved",
|
|
9
|
+
title: "该记录为最近一次保存的状态"
|
|
10
|
+
};
|
|
11
|
+
var _hoisted_4 = {
|
|
12
|
+
key: 1,
|
|
8
13
|
class: "m-editor-history-list-item-actions"
|
|
9
14
|
};
|
|
10
|
-
var
|
|
15
|
+
var _hoisted_5 = ["title"];
|
|
11
16
|
var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
12
17
|
name: "MEditorHistoryListInitialRow",
|
|
13
18
|
__name: "InitialRow",
|
|
@@ -32,6 +37,8 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
32
37
|
*/
|
|
33
38
|
const props = __props;
|
|
34
39
|
const desc = computed(() => props.marker?.historyDescription || "未修改的初始状态");
|
|
40
|
+
/** 基线(初始状态)是否为最近一次保存点:仅页面栈的 `initial` 基线 step 会被 markSaved 标记。 */
|
|
41
|
+
const saved = computed(() => Boolean(props.marker?.saved));
|
|
35
42
|
const time = computed(() => formatHistoryTime(props.marker?.timestamp));
|
|
36
43
|
const timeTitle = computed(() => formatHistoryFullTime(props.marker?.timestamp));
|
|
37
44
|
const rowTitle = computed(() => {
|
|
@@ -57,16 +64,17 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
57
64
|
}, "#0", -1)),
|
|
58
65
|
_cache[1] || (_cache[1] = createElementVNode("span", { class: "m-editor-history-list-item-op op-initial" }, "初始", -1)),
|
|
59
66
|
createElementVNode("span", _hoisted_2, toDisplayString(desc.value), 1),
|
|
60
|
-
|
|
67
|
+
saved.value ? (openBlock(), createElementBlock("span", _hoisted_3, "已保存")) : createCommentVNode("v-if", true),
|
|
68
|
+
__props.gotoEnabled && !__props.isCurrent ? (openBlock(), createElementBlock("span", _hoisted_4, [createElementVNode("span", {
|
|
61
69
|
class: "m-editor-history-list-item-goto",
|
|
62
70
|
title: "回到该记录",
|
|
63
71
|
onClick: withModifiers(onClick, ["stop"])
|
|
64
72
|
}, "回到")])) : createCommentVNode("v-if", true),
|
|
65
73
|
time.value ? (openBlock(), createElementBlock("span", {
|
|
66
|
-
key:
|
|
74
|
+
key: 2,
|
|
67
75
|
class: "m-editor-history-list-item-time",
|
|
68
76
|
title: timeTitle.value
|
|
69
|
-
}, toDisplayString(time.value), 9,
|
|
77
|
+
}, toDisplayString(time.value), 9, _hoisted_5)) : createCommentVNode("v-if", true)
|
|
70
78
|
], 10, _hoisted_1);
|
|
71
79
|
};
|
|
72
80
|
}
|
|
@@ -4,7 +4,7 @@ import { useNextFloatBoxPosition } from "../../../hooks/use-next-float-box-posit
|
|
|
4
4
|
import FloatingBox_default from "../../../components/FloatingBox.js";
|
|
5
5
|
import { MFormBox } from "@tmagic/form";
|
|
6
6
|
import { tMagicMessage } from "@tmagic/design";
|
|
7
|
-
import { createBlock, createVNode, defineComponent, inject, isRef, mergeModels, nextTick, openBlock, ref, unref, useModel, watch, watchEffect, withCtx } from "vue";
|
|
7
|
+
import { computed, createBlock, createVNode, defineComponent, inject, isRef, mergeModels, nextTick, openBlock, provide, ref, unref, useModel, watch, watchEffect, withCtx } from "vue";
|
|
8
8
|
//#region packages/editor/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue?vue&type=script&setup=true&lang.ts
|
|
9
9
|
var DataSourceConfigPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
10
10
|
name: "MEditorDataSourceConfigPanel",
|
|
@@ -12,7 +12,9 @@ var DataSourceConfigPanel_vue_vue_type_script_setup_true_lang_default = /* @__PU
|
|
|
12
12
|
props: /* @__PURE__ */ mergeModels({
|
|
13
13
|
title: {},
|
|
14
14
|
values: {},
|
|
15
|
-
disabled: { type: Boolean }
|
|
15
|
+
disabled: { type: Boolean },
|
|
16
|
+
editMethodName: {},
|
|
17
|
+
editFieldPath: {}
|
|
16
18
|
}, {
|
|
17
19
|
"visible": {
|
|
18
20
|
type: Boolean,
|
|
@@ -37,9 +39,20 @@ var DataSourceConfigPanel_vue_vue_type_script_setup_true_lang_default = /* @__PU
|
|
|
37
39
|
const dataSourceConfig = ref([]);
|
|
38
40
|
const { height: editorHeight } = useEditorContentHeight();
|
|
39
41
|
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(uiService, inject("parentFloating", ref(null)));
|
|
42
|
+
/** 供「方法定义」tab 内的字段消费,用于打开数据源详情后自动打开指定方法 */
|
|
43
|
+
provide("editingDataSourceMethodName", computed(() => props.editMethodName));
|
|
44
|
+
/** 供「数据定义」tab 内的字段消费,用于打开数据源详情后自动打开指定字段 */
|
|
45
|
+
provide("editingDataSourceFieldPath", computed(() => props.editFieldPath || []));
|
|
40
46
|
watchEffect(() => {
|
|
41
47
|
initValues.value = props.values;
|
|
42
|
-
|
|
48
|
+
const config = dataSourceService.getFormConfig(initValues.value.type);
|
|
49
|
+
let activeTab = "";
|
|
50
|
+
if (props.editMethodName) activeTab = "methods";
|
|
51
|
+
else if (props.editFieldPath?.length) activeTab = "fields";
|
|
52
|
+
dataSourceConfig.value = activeTab ? config.map((item) => item.type === "tab" ? {
|
|
53
|
+
...item,
|
|
54
|
+
active: activeTab
|
|
55
|
+
} : item) : config;
|
|
43
56
|
});
|
|
44
57
|
const submitHandler = (values, data) => {
|
|
45
58
|
emit("submit", values, data);
|
|
@@ -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()}`;
|