@tmagic/editor 1.8.0-beta.2 → 1.8.0-beta.3
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/Editor.vue_vue_type_script_setup_true_lang.js +9 -0
- package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +32 -28
- package/dist/es/editorProps.js +2 -0
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +2 -5
- package/dist/es/hooks/use-stage.js +2 -1
- package/dist/es/index.js +3 -1
- package/dist/es/layouts/CodeEditor.vue_vue_type_script_setup_true_lang.js +2 -5
- package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +33 -14
- package/dist/es/layouts/history-list/BucketTab.js +5 -0
- package/dist/es/layouts/history-list/{CodeBlockTab.vue_vue_type_script_setup_true_lang.js → BucketTab.vue_vue_type_script_setup_true_lang.js} +27 -16
- package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +71 -53
- package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +78 -28
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +136 -66
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +15 -9
- package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +12 -6
- package/dist/es/layouts/history-list/composables.js +20 -2
- package/dist/es/services/history.js +5 -2
- package/dist/es/style.css +44 -12
- package/dist/style.css +44 -12
- package/dist/tmagic-editor.umd.cjs +479 -326
- package/package.json +7 -7
- package/src/Editor.vue +8 -0
- package/src/components/CompareForm.vue +32 -19
- package/src/editorProps.ts +7 -0
- package/src/fields/CodeLink.vue +2 -5
- package/src/hooks/use-stage.ts +1 -0
- package/src/index.ts +2 -0
- package/src/layouts/CodeEditor.vue +2 -5
- package/src/layouts/history-list/Bucket.vue +53 -28
- package/src/layouts/history-list/BucketTab.vue +77 -0
- package/src/layouts/history-list/GroupRow.vue +95 -60
- package/src/layouts/history-list/HistoryDiffDialog.vue +51 -32
- package/src/layouts/history-list/HistoryListPanel.vue +161 -52
- package/src/layouts/history-list/InitialRow.vue +17 -6
- package/src/layouts/history-list/PageTab.vue +20 -6
- package/src/layouts/history-list/composables.ts +32 -1
- package/src/services/history.ts +3 -0
- package/src/theme/history-list-panel.scss +52 -13
- package/src/type.ts +90 -0
- package/types/index.d.ts +295 -135
- package/dist/es/layouts/history-list/CodeBlockTab.js +0 -5
- package/dist/es/layouts/history-list/DataSourceTab.js +0 -5
- package/dist/es/layouts/history-list/DataSourceTab.vue_vue_type_script_setup_true_lang.js +0 -62
- package/src/layouts/history-list/CodeBlockTab.vue +0 -61
- package/src/layouts/history-list/DataSourceTab.vue +0 -61
package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1,27 +1,44 @@
|
|
|
1
1
|
import CodeEditor_default from "../CodeEditor.js";
|
|
2
2
|
import CompareForm_default from "../../components/CompareForm.js";
|
|
3
3
|
import { TMagicButton, TMagicDialog, TMagicRadioButton, TMagicRadioGroup, TMagicTag } from "@tmagic/design";
|
|
4
|
-
import { Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, toDisplayString, unref, watch, withCtx } from "vue";
|
|
4
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, toDisplayString, unref, watch, withCtx } from "vue";
|
|
5
5
|
import { isEqual } from "lodash-es";
|
|
6
6
|
//#region packages/editor/src/layouts/history-list/HistoryDiffDialog.vue?vue&type=script&setup=true&lang.ts
|
|
7
7
|
var _hoisted_1 = {
|
|
8
8
|
key: 0,
|
|
9
9
|
class: "m-editor-history-diff-dialog-body"
|
|
10
10
|
};
|
|
11
|
-
var _hoisted_2 = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
11
|
+
var _hoisted_2 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "m-editor-history-diff-dialog-notice"
|
|
14
|
+
};
|
|
15
|
+
var _hoisted_3 = { class: "m-editor-history-diff-dialog-header" };
|
|
16
|
+
var _hoisted_4 = { class: "m-editor-history-diff-dialog-target" };
|
|
17
|
+
var _hoisted_5 = { class: "m-editor-history-diff-dialog-controls" };
|
|
18
|
+
var _hoisted_6 = { class: "m-editor-history-diff-dialog-legend" };
|
|
19
|
+
var _hoisted_7 = {
|
|
16
20
|
key: 0,
|
|
17
21
|
class: "m-editor-history-diff-dialog-tip"
|
|
18
22
|
};
|
|
19
23
|
var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
20
24
|
name: "MEditorHistoryDiffDialog",
|
|
21
25
|
__name: "HistoryDiffDialog",
|
|
22
|
-
props: {
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
props: {
|
|
27
|
+
extendState: {},
|
|
28
|
+
loadConfig: {},
|
|
29
|
+
width: { default: "900px" },
|
|
30
|
+
onConfirm: {},
|
|
31
|
+
selfDiffFieldTypes: {}
|
|
32
|
+
},
|
|
33
|
+
emits: ["close"],
|
|
34
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
35
|
+
const props = __props;
|
|
36
|
+
const emit = __emit;
|
|
37
|
+
/**
|
|
38
|
+
* 差异对比模式:
|
|
39
|
+
* - before:该步骤修改前 vs 该步骤修改后(默认行为,体现这一步带来的变化)
|
|
40
|
+
* - current:该步骤修改后 vs 当前最新值(用于查看「该步骤之后是否还被改过」)
|
|
41
|
+
*/
|
|
25
42
|
const visible = ref(false);
|
|
26
43
|
const payload = ref(null);
|
|
27
44
|
const mode = ref("before");
|
|
@@ -43,6 +60,7 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
43
60
|
scrollBeyondLastLine: false,
|
|
44
61
|
hideUnchangedRegions: { enabled: true }
|
|
45
62
|
};
|
|
63
|
+
const dialogTitle = computed(() => props.onConfirm ? "确认回滚" : "查看修改差异");
|
|
46
64
|
const hasCurrent = computed(() => payload.value?.currentValue !== void 0 && payload.value?.currentValue !== null);
|
|
47
65
|
/** 左侧(旧/参照)值 */
|
|
48
66
|
const leftValue = computed(() => {
|
|
@@ -63,6 +81,11 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
63
81
|
if (mode.value !== "current" || !payload.value) return false;
|
|
64
82
|
return isEqual(payload.value.value, payload.value.currentValue);
|
|
65
83
|
});
|
|
84
|
+
const onConfirmClick = () => {
|
|
85
|
+
const cb = props.onConfirm;
|
|
86
|
+
cb?.();
|
|
87
|
+
visible.value = false;
|
|
88
|
+
};
|
|
66
89
|
const targetText = computed(() => {
|
|
67
90
|
if (!payload.value) return "";
|
|
68
91
|
const prefix = {
|
|
@@ -86,6 +109,9 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
86
109
|
watch(visible, (v) => {
|
|
87
110
|
if (!v) payload.value = null;
|
|
88
111
|
});
|
|
112
|
+
const onClose = () => {
|
|
113
|
+
emit("close");
|
|
114
|
+
};
|
|
89
115
|
__expose({
|
|
90
116
|
open,
|
|
91
117
|
close
|
|
@@ -93,33 +119,49 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
93
119
|
return (_ctx, _cache) => {
|
|
94
120
|
return openBlock(), createBlock(Teleport, { to: "body" }, [createVNode(unref(TMagicDialog), {
|
|
95
121
|
modelValue: visible.value,
|
|
96
|
-
"onUpdate:modelValue": _cache[
|
|
122
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => visible.value = $event),
|
|
97
123
|
class: "m-editor-history-diff-dialog",
|
|
98
|
-
title:
|
|
99
|
-
width: "900px",
|
|
124
|
+
title: dialogTitle.value,
|
|
100
125
|
top: "5vh",
|
|
101
126
|
"destroy-on-close": "",
|
|
102
|
-
"append-to-body": ""
|
|
127
|
+
"append-to-body": "",
|
|
128
|
+
width: __props.width,
|
|
129
|
+
onClose
|
|
103
130
|
}, {
|
|
104
|
-
footer: withCtx(() => [createVNode(unref(TMagicButton), {
|
|
131
|
+
footer: withCtx(() => [__props.onConfirm ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode(unref(TMagicButton), {
|
|
105
132
|
size: "small",
|
|
106
133
|
onClick: _cache[2] || (_cache[2] = ($event) => visible.value = false)
|
|
107
134
|
}, {
|
|
108
|
-
default: withCtx(() => [..._cache[
|
|
135
|
+
default: withCtx(() => [..._cache[10] || (_cache[10] = [createTextVNode("取消", -1)])]),
|
|
109
136
|
_: 1
|
|
110
|
-
})
|
|
137
|
+
}), createVNode(unref(TMagicButton), {
|
|
138
|
+
size: "small",
|
|
139
|
+
type: "primary",
|
|
140
|
+
onClick: onConfirmClick
|
|
141
|
+
}, {
|
|
142
|
+
default: withCtx(() => [..._cache[11] || (_cache[11] = [createTextVNode("确定回滚", -1)])]),
|
|
143
|
+
_: 1
|
|
144
|
+
})], 64)) : (openBlock(), createBlock(unref(TMagicButton), {
|
|
145
|
+
key: 1,
|
|
146
|
+
size: "small",
|
|
147
|
+
onClick: _cache[3] || (_cache[3] = ($event) => visible.value = false)
|
|
148
|
+
}, {
|
|
149
|
+
default: withCtx(() => [..._cache[12] || (_cache[12] = [createTextVNode("关闭", -1)])]),
|
|
150
|
+
_: 1
|
|
151
|
+
}))]),
|
|
111
152
|
default: withCtx(() => [payload.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
112
|
-
|
|
153
|
+
__props.onConfirm ? (openBlock(), createElementBlock("div", _hoisted_2, "仅回滚有差异的字段")) : createCommentVNode("v-if", true),
|
|
154
|
+
createElementVNode("div", _hoisted_3, [createElementVNode("span", _hoisted_4, toDisplayString(targetText.value), 1), createElementVNode("div", _hoisted_5, [createVNode(unref(TMagicRadioGroup), {
|
|
113
155
|
modelValue: viewMode.value,
|
|
114
156
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => viewMode.value = $event),
|
|
115
157
|
size: "small",
|
|
116
158
|
class: "m-editor-history-diff-dialog-view"
|
|
117
159
|
}, {
|
|
118
160
|
default: withCtx(() => [createVNode(unref(TMagicRadioButton), { value: "form" }, {
|
|
119
|
-
default: withCtx(() => [..._cache[
|
|
161
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode("表单对比", -1)])]),
|
|
120
162
|
_: 1
|
|
121
163
|
}), createVNode(unref(TMagicRadioButton), { value: "code" }, {
|
|
122
|
-
default: withCtx(() => [..._cache[
|
|
164
|
+
default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("源码对比", -1)])]),
|
|
123
165
|
_: 1
|
|
124
166
|
})]),
|
|
125
167
|
_: 1
|
|
@@ -130,18 +172,18 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
130
172
|
class: "m-editor-history-diff-dialog-mode"
|
|
131
173
|
}, {
|
|
132
174
|
default: withCtx(() => [createVNode(unref(TMagicRadioButton), { value: "before" }, {
|
|
133
|
-
default: withCtx(() => [..._cache[
|
|
175
|
+
default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("与修改前对比", -1)])]),
|
|
134
176
|
_: 1
|
|
135
177
|
}), createVNode(unref(TMagicRadioButton), {
|
|
136
178
|
value: "current",
|
|
137
179
|
disabled: !hasCurrent.value
|
|
138
180
|
}, {
|
|
139
|
-
default: withCtx(() => [..._cache[
|
|
181
|
+
default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode("与当前对比", -1)])]),
|
|
140
182
|
_: 1
|
|
141
183
|
}, 8, ["disabled"])]),
|
|
142
184
|
_: 1
|
|
143
185
|
}, 8, ["modelValue"])])]),
|
|
144
|
-
createElementVNode("div",
|
|
186
|
+
createElementVNode("div", _hoisted_6, [
|
|
145
187
|
createVNode(unref(TMagicTag), {
|
|
146
188
|
size: "small",
|
|
147
189
|
type: "danger"
|
|
@@ -149,7 +191,7 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
149
191
|
default: withCtx(() => [createTextVNode(toDisplayString(leftLabel.value), 1)]),
|
|
150
192
|
_: 1
|
|
151
193
|
}),
|
|
152
|
-
_cache[
|
|
194
|
+
_cache[9] || (_cache[9] = createElementVNode("span", { class: "m-editor-history-diff-dialog-arrow" }, "→", -1)),
|
|
153
195
|
createVNode(unref(TMagicTag), {
|
|
154
196
|
size: "small",
|
|
155
197
|
type: "success"
|
|
@@ -157,16 +199,18 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
157
199
|
default: withCtx(() => [createTextVNode(toDisplayString(rightLabel.value), 1)]),
|
|
158
200
|
_: 1
|
|
159
201
|
}),
|
|
160
|
-
mode.value === "current" && isSameAsCurrent.value ? (openBlock(), createElementBlock("span",
|
|
202
|
+
mode.value === "current" && isSameAsCurrent.value ? (openBlock(), createElementBlock("span", _hoisted_7, " 当前值与该步修改后一致,无差异 ")) : createCommentVNode("v-if", true)
|
|
161
203
|
]),
|
|
162
204
|
viewMode.value === "form" ? (openBlock(), createBlock(CompareForm_default, {
|
|
163
|
-
key:
|
|
205
|
+
key: 1,
|
|
164
206
|
category: payload.value.category,
|
|
165
207
|
type: payload.value.type,
|
|
166
208
|
"data-source-type": payload.value.dataSourceType,
|
|
167
209
|
value: rightValue.value,
|
|
168
210
|
"last-value": leftValue.value,
|
|
169
211
|
"extend-state": __props.extendState,
|
|
212
|
+
"load-config": __props.loadConfig,
|
|
213
|
+
"self-diff-field-types": __props.selfDiffFieldTypes,
|
|
170
214
|
height: "70vh"
|
|
171
215
|
}, null, 8, [
|
|
172
216
|
"category",
|
|
@@ -174,9 +218,11 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
174
218
|
"data-source-type",
|
|
175
219
|
"value",
|
|
176
220
|
"last-value",
|
|
177
|
-
"extend-state"
|
|
221
|
+
"extend-state",
|
|
222
|
+
"load-config",
|
|
223
|
+
"self-diff-field-types"
|
|
178
224
|
])) : (openBlock(), createBlock(CodeEditor_default, {
|
|
179
|
-
key:
|
|
225
|
+
key: 2,
|
|
180
226
|
type: "diff",
|
|
181
227
|
language: "json",
|
|
182
228
|
"init-values": leftValue.value,
|
|
@@ -187,7 +233,11 @@ var HistoryDiffDialog_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
187
233
|
}, null, 8, ["init-values", "modified-values"]))
|
|
188
234
|
])) : createCommentVNode("v-if", true)]),
|
|
189
235
|
_: 1
|
|
190
|
-
}, 8, [
|
|
236
|
+
}, 8, [
|
|
237
|
+
"modelValue",
|
|
238
|
+
"title",
|
|
239
|
+
"width"
|
|
240
|
+
])]);
|
|
191
241
|
};
|
|
192
242
|
}
|
|
193
243
|
});
|
package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { useServices } from "../../hooks/use-services.js";
|
|
2
2
|
import Icon_default from "../../components/Icon.js";
|
|
3
|
-
import { useHistoryList } from "./composables.js";
|
|
4
|
-
import
|
|
5
|
-
import DataSourceTab_default from "./DataSourceTab.js";
|
|
3
|
+
import { describeCodeBlockGroup, describeCodeBlockStep, describeDataSourceGroup, describeDataSourceStep, useHistoryList } from "./composables.js";
|
|
4
|
+
import BucketTab_default from "./BucketTab.js";
|
|
6
5
|
import HistoryDiffDialog_default from "./HistoryDiffDialog.js";
|
|
7
6
|
import PageTab_default from "./PageTab.js";
|
|
8
7
|
import { TMagicButton, TMagicPopover, TMagicTabs, TMagicTooltip, getDesignConfig } from "@tmagic/design";
|
|
9
|
-
import { Fragment, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, guardReactiveProps, inject, markRaw, normalizeProps, openBlock, ref, resolveDynamicComponent, unref, useTemplateRef, withCtx } from "vue";
|
|
8
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, guardReactiveProps, inject, markRaw, mergeProps, normalizeProps, openBlock, ref, renderList, resolveDynamicComponent, shallowRef, toHandlers, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
10
9
|
import { Clock, Close } from "@element-plus/icons-vue";
|
|
11
10
|
//#region packages/editor/src/layouts/history-list/HistoryListPanel.vue?vue&type=script&setup=true&lang.ts
|
|
12
11
|
var _hoisted_1 = { class: "m-editor-history-list" };
|
|
@@ -31,7 +30,8 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
31
30
|
* 此外每条 step 上提供"查看差异"入口(仅在前后值都存在的 update 步骤显示),
|
|
32
31
|
* 点击后弹出 HistoryDiffDialog,使用 CompareForm 组件以表单形式展示新旧值差异。
|
|
33
32
|
*
|
|
34
|
-
* 各 tab 的内容拆分为独立的 SFC
|
|
33
|
+
* 各 tab 的内容拆分为独立的 SFC:页面用 PageTab,数据源 / 代码块复用通用的 BucketTab
|
|
34
|
+
* (通过 title / prefix / describe* / isStepDiffable 注入差异)。
|
|
35
35
|
* 共享的描述生成与折叠状态在 composables.ts 中维护。
|
|
36
36
|
*/
|
|
37
37
|
const ClockIcon = markRaw(Clock);
|
|
@@ -40,7 +40,23 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
40
40
|
/** 面板显隐受控:reference 图标点击切换,右上角关闭按钮置为 false。 */
|
|
41
41
|
const visible = ref(false);
|
|
42
42
|
const tabPaneComponent = getDesignConfig("components")?.tabPane;
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* 业务方自定义的扩展 tab,由 Editor 顶层通过 `historyListExtraTabs` 注入。
|
|
45
|
+
* 追加在内置「页面 / 数据源 / 代码块」三个 tab 之后,未提供时为空数组。
|
|
46
|
+
*/
|
|
47
|
+
const extraTabs = inject("historyListExtraTabs", []);
|
|
48
|
+
/** label 支持字符串或函数,函数形式便于展示动态数量等内容。 */
|
|
49
|
+
const resolveTabLabel = (tab) => typeof tab.label === "function" ? tab.label() : tab.label;
|
|
50
|
+
const { editorService, dataSourceService, codeBlockService, historyService, propsService } = useServices();
|
|
51
|
+
/**
|
|
52
|
+
* 数据源 / 代码块功能可被业务方通过 `disabledDataSource` / `disabledCodeBlock` 禁用,
|
|
53
|
+
* 禁用后对应的历史记录 tab 不再展示。若当前激活的 tab 恰好被禁用,则回退到「页面」tab。
|
|
54
|
+
*/
|
|
55
|
+
const disabledDataSource = computed(() => propsService.getDisabledDataSource());
|
|
56
|
+
const disabledCodeBlock = computed(() => propsService.getDisabledCodeBlock());
|
|
57
|
+
watch([disabledDataSource, disabledCodeBlock], ([dsDisabled, cbDisabled]) => {
|
|
58
|
+
if (activeTab.value === "data-source" && dsDisabled || activeTab.value === "code-block" && cbDisabled) activeTab.value = "page";
|
|
59
|
+
});
|
|
44
60
|
/**
|
|
45
61
|
* 通过 inject 拿到 Editor 顶层注入的 `extendFormState`,转交给 HistoryDiffDialog
|
|
46
62
|
* 内部的 CompareForm,使差异对比表单的 filterFunction 能拿到完整的业务上下文。
|
|
@@ -48,6 +64,10 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
48
64
|
*/
|
|
49
65
|
const extendFormState = inject("extendFormState", void 0);
|
|
50
66
|
const { expanded, toggleGroup, pageGroups, dataSourceGroups, codeBlockGroups, pageGroupsDisplay, dataSourceGroupsByTarget, codeBlockGroupsByTarget } = useHistoryList();
|
|
67
|
+
/** 数据源 step 仅 update(前后 schema 都存在)时可查看差异。 */
|
|
68
|
+
const isDataSourceStepDiffable = (step) => Boolean(step.oldSchema && step.newSchema);
|
|
69
|
+
/** 代码块 step 仅 update(前后 content 都存在)时可查看差异。 */
|
|
70
|
+
const isCodeBlockStepDiffable = (step) => Boolean(step.oldContent && step.newContent);
|
|
51
71
|
/** 把"目标 step 索引"翻译成"目标 cursor"(已应用步骤数量)。 */
|
|
52
72
|
const indexToCursor = (index) => index + 1;
|
|
53
73
|
const onPageGoto = (index) => {
|
|
@@ -72,36 +92,24 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
72
92
|
const onCodeBlockGotoInitial = (id) => {
|
|
73
93
|
codeBlockService.goto(id, 0);
|
|
74
94
|
};
|
|
75
|
-
/**
|
|
76
|
-
* 「回滚」入口:把目标历史步骤的修改作为一次新操作反向应用(类 git revert),
|
|
77
|
-
* 不破坏原有栈结构。各 service 内部完成反向 + 入栈,并自带描述用于面板展示。
|
|
78
|
-
*/
|
|
79
|
-
const onPageRevert = (index) => {
|
|
80
|
-
editorService.revertPageStep(index);
|
|
81
|
-
};
|
|
82
|
-
const onDataSourceRevert = (id, index) => {
|
|
83
|
-
dataSourceService.revert(id, index);
|
|
84
|
-
};
|
|
85
|
-
const onCodeBlockRevert = (id, index) => {
|
|
86
|
-
codeBlockService.revert(id, index);
|
|
87
|
-
};
|
|
88
95
|
const diffDialogRef = useTemplateRef("diffDialog");
|
|
89
96
|
/**
|
|
90
|
-
*
|
|
97
|
+
* 构造页面 step 的差异弹窗入参:仅 update 单节点修改可对比,传入旧/新节点。
|
|
91
98
|
* 节点类型 `type` 优先取 newNode.type,再回退 oldNode.type。
|
|
92
99
|
* `currentValue` 取自 editorService 中该节点当前实际值,用于支持「与当前对比」。
|
|
100
|
+
* 无可对比内容(如多节点 / add / remove)时返回 null。
|
|
93
101
|
*/
|
|
94
|
-
const
|
|
102
|
+
const buildPageDiffPayload = (index) => {
|
|
95
103
|
const groups = historyService.getPageHistoryGroups();
|
|
96
104
|
for (const group of groups) {
|
|
97
105
|
const entry = group.steps.find((s) => s.index === index);
|
|
98
106
|
if (!entry) continue;
|
|
99
107
|
const item = entry.step.updatedItems?.[0];
|
|
100
|
-
if (!item?.oldNode || !item?.newNode) return;
|
|
108
|
+
if (!item?.oldNode || !item?.newNode) return null;
|
|
101
109
|
const type = item.newNode.type || item.oldNode.type || "";
|
|
102
110
|
const nodeId = item.newNode.id ?? item.oldNode.id;
|
|
103
111
|
const currentNode = nodeId !== void 0 ? editorService.getNodeById(nodeId) : null;
|
|
104
|
-
|
|
112
|
+
return {
|
|
105
113
|
category: "node",
|
|
106
114
|
type,
|
|
107
115
|
lastValue: item.oldNode,
|
|
@@ -109,50 +117,87 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
109
117
|
currentValue: currentNode || null,
|
|
110
118
|
targetLabel: item.newNode.name || item.oldNode.name || type,
|
|
111
119
|
id: nodeId
|
|
112
|
-
}
|
|
113
|
-
return;
|
|
120
|
+
};
|
|
114
121
|
}
|
|
122
|
+
return null;
|
|
115
123
|
};
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
/**
|
|
125
|
+
* 在指定分组列表中按 id / index 查找命中的 step,命中后交由 build 构造差异弹窗入参。
|
|
126
|
+
* 用于统一数据源、代码块两类历史的查找逻辑。
|
|
127
|
+
*/
|
|
128
|
+
const findGroupStep = (groups, id, index, build) => {
|
|
118
129
|
for (const group of groups) {
|
|
119
130
|
if (group.id !== id) continue;
|
|
120
131
|
const entry = group.steps.find((s) => s.index === index);
|
|
121
132
|
if (!entry) continue;
|
|
122
|
-
|
|
123
|
-
if (!oldSchema || !newSchema) return;
|
|
124
|
-
const currentSchema = dataSourceService.getDataSourceById(`${id}`);
|
|
125
|
-
diffDialogRef.value?.open({
|
|
126
|
-
category: "data-source",
|
|
127
|
-
type: newSchema.type || oldSchema.type || "base",
|
|
128
|
-
lastValue: oldSchema,
|
|
129
|
-
value: newSchema,
|
|
130
|
-
currentValue: currentSchema || null,
|
|
131
|
-
targetLabel: newSchema.title || oldSchema.title || `${id}`,
|
|
132
|
-
id
|
|
133
|
-
});
|
|
134
|
-
return;
|
|
133
|
+
return build(entry.step);
|
|
135
134
|
}
|
|
135
|
+
return null;
|
|
136
|
+
};
|
|
137
|
+
const buildDataSourceDiffPayload = (id, index) => findGroupStep(historyService.getDataSourceHistoryGroups(), id, index, ({ oldSchema, newSchema }) => {
|
|
138
|
+
if (!oldSchema || !newSchema) return null;
|
|
139
|
+
const currentSchema = dataSourceService.getDataSourceById(`${id}`);
|
|
140
|
+
return {
|
|
141
|
+
category: "data-source",
|
|
142
|
+
type: newSchema.type || oldSchema.type || "base",
|
|
143
|
+
lastValue: oldSchema,
|
|
144
|
+
value: newSchema,
|
|
145
|
+
currentValue: currentSchema || null,
|
|
146
|
+
targetLabel: newSchema.title || oldSchema.title || `${id}`,
|
|
147
|
+
id
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
const buildCodeBlockDiffPayload = (id, index) => findGroupStep(historyService.getCodeBlockHistoryGroups(), id, index, ({ oldContent, newContent }) => {
|
|
151
|
+
if (!oldContent || !newContent) return null;
|
|
152
|
+
return {
|
|
153
|
+
category: "code-block",
|
|
154
|
+
lastValue: oldContent,
|
|
155
|
+
value: newContent,
|
|
156
|
+
currentValue: codeBlockService.getCodeContentById(id) || null,
|
|
157
|
+
targetLabel: newContent.name || oldContent.name || `${id}`,
|
|
158
|
+
id
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
const onPageDiff = (index) => {
|
|
162
|
+
const payload = buildPageDiffPayload(index);
|
|
163
|
+
if (payload) diffDialogRef.value?.open(payload);
|
|
164
|
+
};
|
|
165
|
+
const onDataSourceDiff = (id, index) => {
|
|
166
|
+
const payload = buildDataSourceDiffPayload(id, index);
|
|
167
|
+
if (payload) diffDialogRef.value?.open(payload);
|
|
136
168
|
};
|
|
137
169
|
const onCodeBlockDiff = (id, index) => {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
170
|
+
const payload = buildCodeBlockDiffPayload(id, index);
|
|
171
|
+
if (payload) diffDialogRef.value?.open(payload);
|
|
172
|
+
};
|
|
173
|
+
const onConfirmRevert = shallowRef();
|
|
174
|
+
/**
|
|
175
|
+
* 「回滚」入口:把目标历史步骤的修改作为一次新操作反向应用(类 git revert),
|
|
176
|
+
* 不破坏原有栈结构。各 service 内部完成反向 + 入栈,并自带描述用于面板展示。
|
|
177
|
+
*
|
|
178
|
+
* 交互:先弹出该步骤的差异弹窗供用户确认,点击「确定回滚」后再真正执行回滚;
|
|
179
|
+
* 对没有可对比内容的步骤(如 add / remove / 多节点更新)则直接回滚。
|
|
180
|
+
*/
|
|
181
|
+
const onPageRevert = (index) => {
|
|
182
|
+
const payload = buildPageDiffPayload(index);
|
|
183
|
+
onConfirmRevert.value = () => editorService.revertPageStep(index);
|
|
184
|
+
if (payload) diffDialogRef.value?.open({ ...payload });
|
|
185
|
+
else onConfirmRevert.value();
|
|
186
|
+
};
|
|
187
|
+
const onDataSourceRevert = (id, index) => {
|
|
188
|
+
const payload = buildDataSourceDiffPayload(id, index);
|
|
189
|
+
onConfirmRevert.value = () => dataSourceService.revert(id, index);
|
|
190
|
+
if (payload) diffDialogRef.value?.open({ ...payload });
|
|
191
|
+
else onConfirmRevert.value();
|
|
192
|
+
};
|
|
193
|
+
const onCodeBlockRevert = (id, index) => {
|
|
194
|
+
const payload = buildCodeBlockDiffPayload(id, index);
|
|
195
|
+
onConfirmRevert.value = () => codeBlockService.revert(id, index);
|
|
196
|
+
if (payload) diffDialogRef.value?.open({ ...payload });
|
|
197
|
+
else onConfirmRevert.value();
|
|
198
|
+
};
|
|
199
|
+
const onDiffDialogClose = () => {
|
|
200
|
+
onConfirmRevert.value = void 0;
|
|
156
201
|
};
|
|
157
202
|
return (_ctx, _cache) => {
|
|
158
203
|
return openBlock(), createElementBlock(Fragment, null, [createVNode(unref(TMagicPopover), {
|
|
@@ -217,13 +262,18 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
217
262
|
])]),
|
|
218
263
|
_: 1
|
|
219
264
|
}, 16)),
|
|
220
|
-
(openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"), normalizeProps(
|
|
265
|
+
!disabledDataSource.value ? (openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"), normalizeProps(mergeProps({ key: 0 }, unref(tabPaneComponent)?.props({
|
|
221
266
|
name: "data-source",
|
|
222
267
|
label: `数据源 (${unref(dataSourceGroups).length})`
|
|
223
268
|
}) || {})), {
|
|
224
|
-
default: withCtx(() => [createVNode(
|
|
269
|
+
default: withCtx(() => [createVNode(BucketTab_default, {
|
|
270
|
+
title: "数据源",
|
|
271
|
+
prefix: "ds",
|
|
225
272
|
buckets: unref(dataSourceGroupsByTarget),
|
|
226
273
|
expanded: unref(expanded),
|
|
274
|
+
"describe-group": unref(describeDataSourceGroup),
|
|
275
|
+
"describe-step": unref(describeDataSourceStep),
|
|
276
|
+
"is-step-diffable": isDataSourceStepDiffable,
|
|
227
277
|
onToggle: unref(toggleGroup),
|
|
228
278
|
onGoto: onDataSourceGoto,
|
|
229
279
|
onGotoInitial: onDataSourceGotoInitial,
|
|
@@ -232,17 +282,24 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
232
282
|
}, null, 8, [
|
|
233
283
|
"buckets",
|
|
234
284
|
"expanded",
|
|
285
|
+
"describe-group",
|
|
286
|
+
"describe-step",
|
|
235
287
|
"onToggle"
|
|
236
288
|
])]),
|
|
237
289
|
_: 1
|
|
238
|
-
}, 16)),
|
|
239
|
-
(openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"), normalizeProps(
|
|
290
|
+
}, 16)) : createCommentVNode("v-if", true),
|
|
291
|
+
!disabledCodeBlock.value ? (openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"), normalizeProps(mergeProps({ key: 1 }, unref(tabPaneComponent)?.props({
|
|
240
292
|
name: "code-block",
|
|
241
293
|
label: `代码块 (${unref(codeBlockGroups).length})`
|
|
242
294
|
}) || {})), {
|
|
243
|
-
default: withCtx(() => [createVNode(
|
|
295
|
+
default: withCtx(() => [createVNode(BucketTab_default, {
|
|
296
|
+
title: "代码块",
|
|
297
|
+
prefix: "cb",
|
|
244
298
|
buckets: unref(codeBlockGroupsByTarget),
|
|
245
299
|
expanded: unref(expanded),
|
|
300
|
+
"describe-group": unref(describeCodeBlockGroup),
|
|
301
|
+
"describe-step": unref(describeCodeBlockStep),
|
|
302
|
+
"is-step-diffable": isCodeBlockStepDiffable,
|
|
246
303
|
onToggle: unref(toggleGroup),
|
|
247
304
|
onGoto: onCodeBlockGoto,
|
|
248
305
|
onGotoInitial: onCodeBlockGotoInitial,
|
|
@@ -251,18 +308,31 @@ var HistoryListPanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
251
308
|
}, null, 8, [
|
|
252
309
|
"buckets",
|
|
253
310
|
"expanded",
|
|
311
|
+
"describe-group",
|
|
312
|
+
"describe-step",
|
|
254
313
|
"onToggle"
|
|
255
314
|
])]),
|
|
256
315
|
_: 1
|
|
257
|
-
}, 16))
|
|
316
|
+
}, 16)) : createCommentVNode("v-if", true),
|
|
317
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(extraTabs), (tab) => {
|
|
318
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(tabPaneComponent)?.component || "el-tab-pane"), mergeProps({ key: tab.name }, { ref_for: true }, unref(tabPaneComponent)?.props({
|
|
319
|
+
name: tab.name,
|
|
320
|
+
label: resolveTabLabel(tab)
|
|
321
|
+
}) || {}), {
|
|
322
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(tab.component), mergeProps({ ref_for: true }, tab.props || {}, toHandlers(tab.listeners || {})), null, 16))]),
|
|
323
|
+
_: 2
|
|
324
|
+
}, 1040);
|
|
325
|
+
}), 128))
|
|
258
326
|
]),
|
|
259
327
|
_: 1
|
|
260
328
|
}, 8, ["modelValue"])])]),
|
|
261
329
|
_: 1
|
|
262
330
|
}, 8, ["visible"]), createVNode(HistoryDiffDialog_default, {
|
|
263
331
|
ref: "diffDialog",
|
|
264
|
-
"extend-state": unref(extendFormState)
|
|
265
|
-
|
|
332
|
+
"extend-state": unref(extendFormState),
|
|
333
|
+
"on-confirm": onConfirmRevert.value,
|
|
334
|
+
onClose: onDiffDialogClose
|
|
335
|
+
}, null, 8, ["extend-state", "on-confirm"])], 64);
|
|
266
336
|
};
|
|
267
337
|
}
|
|
268
338
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock } from "vue";
|
|
1
|
+
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, withModifiers } from "vue";
|
|
2
2
|
//#region packages/editor/src/layouts/history-list/InitialRow.vue?vue&type=script&setup=true&lang.ts
|
|
3
3
|
var _hoisted_1 = ["title"];
|
|
4
|
-
var _hoisted_2 = {
|
|
5
|
-
key: 0,
|
|
6
|
-
class: "m-editor-history-list-item-current"
|
|
7
|
-
};
|
|
8
4
|
var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
9
5
|
name: "MEditorHistoryListInitialRow",
|
|
10
6
|
__name: "InitialRow",
|
|
11
|
-
props: {
|
|
7
|
+
props: {
|
|
8
|
+
isCurrent: { type: Boolean },
|
|
9
|
+
gotoEnabled: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: true
|
|
12
|
+
}
|
|
13
|
+
},
|
|
12
14
|
emits: ["goto-initial"],
|
|
13
15
|
setup(__props, { emit: __emit }) {
|
|
14
16
|
/**
|
|
@@ -30,8 +32,7 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
30
32
|
"is-current": __props.isCurrent,
|
|
31
33
|
"is-clickable": !__props.isCurrent
|
|
32
34
|
}]),
|
|
33
|
-
title: __props.isCurrent ? "当前已回到未修改的初始状态" : "点击回到未修改的初始状态"
|
|
34
|
-
onClick
|
|
35
|
+
title: __props.isCurrent ? "当前已回到未修改的初始状态" : "点击回到未修改的初始状态"
|
|
35
36
|
}, [
|
|
36
37
|
_cache[0] || (_cache[0] = createElementVNode("span", {
|
|
37
38
|
class: "m-editor-history-list-item-index",
|
|
@@ -39,7 +40,12 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
39
40
|
}, "#0", -1)),
|
|
40
41
|
_cache[1] || (_cache[1] = createElementVNode("span", { class: "m-editor-history-list-item-op op-initial" }, "初始", -1)),
|
|
41
42
|
_cache[2] || (_cache[2] = createElementVNode("span", { class: "m-editor-history-list-item-desc" }, "未修改的初始状态", -1)),
|
|
42
|
-
__props.isCurrent ? (openBlock(), createElementBlock("span",
|
|
43
|
+
__props.gotoEnabled && !__props.isCurrent ? (openBlock(), createElementBlock("span", {
|
|
44
|
+
key: 0,
|
|
45
|
+
class: "m-editor-history-list-item-goto",
|
|
46
|
+
title: "回到该记录",
|
|
47
|
+
onClick: withModifiers(onClick, ["stop"])
|
|
48
|
+
}, "回到")) : createCommentVNode("v-if", true)
|
|
43
49
|
], 10, _hoisted_1);
|
|
44
50
|
};
|
|
45
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describePageGroup, describePageStep } from "./composables.js";
|
|
1
|
+
import { describePageGroup, describePageStep, formatHistoryFullTime, formatHistoryTime, groupTimestamp } from "./composables.js";
|
|
2
2
|
import GroupRow_default from "./GroupRow.js";
|
|
3
3
|
import InitialRow_default from "./InitialRow.js";
|
|
4
4
|
import { TMagicScrollbar } from "@tmagic/design";
|
|
@@ -49,14 +49,16 @@ var PageTab_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
49
49
|
"max-height": "360px"
|
|
50
50
|
}, {
|
|
51
51
|
default: withCtx(() => [createElementVNode("ul", _hoisted_2, [
|
|
52
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (group
|
|
52
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (group) => {
|
|
53
53
|
return openBlock(), createBlock(GroupRow_default, {
|
|
54
|
-
key: `pg-${
|
|
55
|
-
"group-key": `pg-${
|
|
54
|
+
key: `pg-${group.steps[0]?.index}`,
|
|
55
|
+
"group-key": `pg-${group.steps[0]?.index}`,
|
|
56
56
|
applied: group.applied,
|
|
57
57
|
merged: group.steps.length > 1,
|
|
58
58
|
"op-type": group.opType,
|
|
59
59
|
desc: unref(describePageGroup)(group),
|
|
60
|
+
time: unref(formatHistoryTime)(unref(groupTimestamp)(group)),
|
|
61
|
+
"time-title": unref(formatHistoryFullTime)(unref(groupTimestamp)(group)),
|
|
60
62
|
"step-count": group.steps.length,
|
|
61
63
|
"sub-steps": group.steps.map((s) => ({
|
|
62
64
|
index: s.index,
|
|
@@ -64,10 +66,12 @@ var PageTab_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
64
66
|
isCurrent: s.isCurrent,
|
|
65
67
|
desc: unref(describePageStep)(s.step),
|
|
66
68
|
diffable: isPageStepDiffable(s.step),
|
|
67
|
-
revertable: s.applied
|
|
69
|
+
revertable: s.applied,
|
|
70
|
+
time: unref(formatHistoryTime)(s.step.timestamp),
|
|
71
|
+
timeTitle: unref(formatHistoryFullTime)(s.step.timestamp)
|
|
68
72
|
})),
|
|
69
73
|
"is-current": group.isCurrent,
|
|
70
|
-
expanded: !!__props.expanded[`pg-${
|
|
74
|
+
expanded: !!__props.expanded[`pg-${group.steps[0]?.index}`],
|
|
71
75
|
onToggle: _cache[0] || (_cache[0] = (key) => _ctx.$emit("toggle", key)),
|
|
72
76
|
onGoto: _cache[1] || (_cache[1] = (index) => _ctx.$emit("goto", index)),
|
|
73
77
|
onDiffStep: _cache[2] || (_cache[2] = (index) => _ctx.$emit("diff-step", index)),
|
|
@@ -78,6 +82,8 @@ var PageTab_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
78
82
|
"merged",
|
|
79
83
|
"op-type",
|
|
80
84
|
"desc",
|
|
85
|
+
"time",
|
|
86
|
+
"time-title",
|
|
81
87
|
"step-count",
|
|
82
88
|
"sub-steps",
|
|
83
89
|
"is-current",
|