@tmagic/editor 1.8.0-beta.4 → 1.8.0-beta.5
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/components/CompareForm.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/ToolButton.vue_vue_type_script_setup_true_lang.js +6 -6
- package/dist/es/index.js +6 -3
- package/dist/es/initService.js +1 -1
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +19 -55
- package/dist/es/layouts/history-list/BucketTab.vue_vue_type_script_setup_true_lang.js +22 -39
- package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +149 -103
- package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +32 -8
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +333 -211
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +28 -7
- package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +47 -60
- package/dist/es/layouts/history-list/composables.js +73 -32
- package/dist/es/layouts/page-bar/PageBar.vue_vue_type_script_setup_true_lang.js +4 -2
- package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +5 -1
- package/dist/es/services/codeBlock.js +85 -37
- package/dist/es/services/dataSource.js +62 -26
- package/dist/es/services/editor.js +243 -100
- package/dist/es/services/history.js +270 -206
- package/dist/es/services/ui.js +3 -0
- package/dist/es/style.css +49 -6
- package/dist/es/utils/editor.js +35 -1
- package/dist/es/utils/history.js +223 -0
- package/dist/es/utils/indexed-db.js +86 -0
- package/dist/es/utils/undo-redo.js +60 -1
- package/dist/style.css +49 -6
- package/dist/tmagic-editor.umd.cjs +1799 -905
- package/package.json +7 -7
- package/src/components/CompareForm.vue +3 -1
- package/src/components/ToolButton.vue +2 -2
- package/src/index.ts +1 -0
- package/src/initService.ts +1 -1
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/history-list/Bucket.vue +34 -71
- package/src/layouts/history-list/BucketTab.vue +46 -54
- package/src/layouts/history-list/GroupRow.vue +146 -111
- package/src/layouts/history-list/HistoryDiffDialog.vue +94 -68
- package/src/layouts/history-list/HistoryListPanel.vue +296 -113
- package/src/layouts/history-list/InitialRow.vue +25 -9
- package/src/layouts/history-list/PageTab.vue +57 -51
- package/src/layouts/history-list/composables.ts +157 -36
- package/src/layouts/page-bar/PageBar.vue +4 -2
- package/src/layouts/sidebar/Sidebar.vue +6 -1
- package/src/services/codeBlock.ts +107 -37
- package/src/services/dataSource.ts +89 -40
- package/src/services/editor.ts +370 -134
- package/src/services/history.ts +305 -203
- package/src/services/ui.ts +7 -0
- package/src/theme/history-list-panel.scss +72 -5
- package/src/theme/page-bar.scss +0 -4
- package/src/type.ts +167 -63
- package/src/utils/editor.ts +41 -1
- package/src/utils/history.ts +298 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/indexed-db.ts +122 -0
- package/src/utils/undo-redo.ts +88 -0
- package/types/index.d.ts +783 -291
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatHistoryFullTime, formatHistoryTime } from "./composables.js";
|
|
2
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, toDisplayString, withModifiers } from "vue";
|
|
2
3
|
//#region packages/editor/src/layouts/history-list/InitialRow.vue?vue&type=script&setup=true&lang.ts
|
|
3
4
|
var _hoisted_1 = ["title"];
|
|
5
|
+
var _hoisted_2 = { class: "m-editor-history-list-item-desc" };
|
|
6
|
+
var _hoisted_3 = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "m-editor-history-list-item-actions"
|
|
9
|
+
};
|
|
10
|
+
var _hoisted_4 = ["title"];
|
|
4
11
|
var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
5
12
|
name: "MEditorHistoryListInitialRow",
|
|
6
13
|
__name: "InitialRow",
|
|
@@ -9,7 +16,8 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
9
16
|
gotoEnabled: {
|
|
10
17
|
type: Boolean,
|
|
11
18
|
default: true
|
|
12
|
-
}
|
|
19
|
+
},
|
|
20
|
+
marker: { default: void 0 }
|
|
13
21
|
},
|
|
14
22
|
emits: ["goto-initial"],
|
|
15
23
|
setup(__props, { emit: __emit }) {
|
|
@@ -17,10 +25,19 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
17
25
|
* 「初始状态」记录行:渲染于历史列表底部,作为整个栈的"零点"。
|
|
18
26
|
* - 点击该行会把对应栈撤销到 cursor === 0(即没有任何已应用步骤),等同于回到所有修改之前。
|
|
19
27
|
* - 当对应栈本身已处于 cursor === 0 时(isCurrent=true),用户已在初始状态,点击不再触发动作。
|
|
28
|
+
* - 当上层传入 `marker`(设置 root 时为该页生成的「未修改的初始状态」标记)时,
|
|
29
|
+
* 用标记的文案与时间渲染本行;标记不进入撤销/重做栈,仅作为该页基线展示。
|
|
20
30
|
*
|
|
21
31
|
* 该行不是真实 step,仅作为 UI 入口;上层负责把"点击"翻译为 `service.goto*(0)`。
|
|
22
32
|
*/
|
|
23
33
|
const props = __props;
|
|
34
|
+
const desc = computed(() => props.marker?.historyDescription || "未修改的初始状态");
|
|
35
|
+
const time = computed(() => formatHistoryTime(props.marker?.timestamp));
|
|
36
|
+
const timeTitle = computed(() => formatHistoryFullTime(props.marker?.timestamp));
|
|
37
|
+
const rowTitle = computed(() => {
|
|
38
|
+
const base = props.marker?.historyDescription || "未修改的初始状态";
|
|
39
|
+
return props.isCurrent ? `当前已回到${base}` : `点击回到${base}`;
|
|
40
|
+
});
|
|
24
41
|
const emit = __emit;
|
|
25
42
|
const onClick = () => {
|
|
26
43
|
if (props.isCurrent) return;
|
|
@@ -32,20 +49,24 @@ var InitialRow_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
32
49
|
"is-current": __props.isCurrent,
|
|
33
50
|
"is-clickable": !__props.isCurrent
|
|
34
51
|
}]),
|
|
35
|
-
title:
|
|
52
|
+
title: rowTitle.value
|
|
36
53
|
}, [
|
|
37
54
|
_cache[0] || (_cache[0] = createElementVNode("span", {
|
|
38
55
|
class: "m-editor-history-list-item-index",
|
|
39
56
|
title: "历史步骤编号 #0(未修改的初始状态)"
|
|
40
57
|
}, "#0", -1)),
|
|
41
58
|
_cache[1] || (_cache[1] = createElementVNode("span", { class: "m-editor-history-list-item-op op-initial" }, "初始", -1)),
|
|
42
|
-
|
|
43
|
-
__props.gotoEnabled && !__props.isCurrent ? (openBlock(), createElementBlock("span", {
|
|
44
|
-
key: 0,
|
|
59
|
+
createElementVNode("span", _hoisted_2, toDisplayString(desc.value), 1),
|
|
60
|
+
__props.gotoEnabled && !__props.isCurrent ? (openBlock(), createElementBlock("span", _hoisted_3, [createElementVNode("span", {
|
|
45
61
|
class: "m-editor-history-list-item-goto",
|
|
46
62
|
title: "回到该记录",
|
|
47
63
|
onClick: withModifiers(onClick, ["stop"])
|
|
48
|
-
}, "回到")) : createCommentVNode("v-if", true)
|
|
64
|
+
}, "回到")])) : createCommentVNode("v-if", true),
|
|
65
|
+
time.value ? (openBlock(), createElementBlock("span", {
|
|
66
|
+
key: 1,
|
|
67
|
+
class: "m-editor-history-list-item-time",
|
|
68
|
+
title: timeTitle.value
|
|
69
|
+
}, toDisplayString(time.value), 9, _hoisted_4)) : createCommentVNode("v-if", true)
|
|
49
70
|
], 10, _hoisted_1);
|
|
50
71
|
};
|
|
51
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describePageGroup, describePageStep,
|
|
1
|
+
import { describePageGroup, describePageStep, isHistoryGroupExpanded, isPageStepRevertable, toRowGroup } 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";
|
|
@@ -8,99 +8,86 @@ var _hoisted_1 = {
|
|
|
8
8
|
key: 0,
|
|
9
9
|
class: "m-editor-history-list-empty"
|
|
10
10
|
};
|
|
11
|
-
var _hoisted_2 = {
|
|
11
|
+
var _hoisted_2 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "m-editor-history-list-toolbar"
|
|
14
|
+
};
|
|
15
|
+
var _hoisted_3 = { class: "m-editor-history-list-ul" };
|
|
12
16
|
var PageTab_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
13
17
|
name: "MEditorHistoryListPageTab",
|
|
14
18
|
__name: "PageTab",
|
|
15
19
|
props: {
|
|
16
20
|
list: {},
|
|
17
|
-
expanded: {}
|
|
21
|
+
expanded: {},
|
|
22
|
+
marker: {}
|
|
18
23
|
},
|
|
19
24
|
emits: [
|
|
20
25
|
"toggle",
|
|
21
26
|
"goto",
|
|
22
27
|
"goto-initial",
|
|
23
28
|
"diff-step",
|
|
24
|
-
"revert-step"
|
|
29
|
+
"revert-step",
|
|
30
|
+
"select",
|
|
31
|
+
"clear"
|
|
25
32
|
],
|
|
26
33
|
setup(__props) {
|
|
27
34
|
const props = __props;
|
|
28
35
|
/**
|
|
29
36
|
* 当前 step 是否可查看差异:
|
|
30
37
|
* - 仅 update 操作;
|
|
31
|
-
* - 单节点更新(
|
|
38
|
+
* - 单节点更新(diff.length === 1),且 oldSchema / newSchema 都存在。
|
|
32
39
|
* 多节点更新难以选定单一对比目标,统一不展示差异入口。
|
|
33
40
|
*/
|
|
34
41
|
const isPageStepDiffable = (step) => {
|
|
35
42
|
if (step.opType !== "update") return false;
|
|
36
|
-
const items = step.
|
|
43
|
+
const items = step.diff ?? [];
|
|
37
44
|
if (items.length !== 1) return false;
|
|
38
|
-
return Boolean(items[0]?.
|
|
45
|
+
return Boolean(items[0]?.oldSchema && items[0]?.newSchema);
|
|
46
|
+
};
|
|
47
|
+
/** 页面历史的描述 / 可操作性判定集合,注入给统一的 `toRowGroup`。 */
|
|
48
|
+
const descriptor = {
|
|
49
|
+
describeGroup: describePageGroup,
|
|
50
|
+
describeStep: describePageStep,
|
|
51
|
+
isStepDiffable: isPageStepDiffable,
|
|
52
|
+
isStepRevertable: isPageStepRevertable
|
|
39
53
|
};
|
|
54
|
+
const rowKey = (group) => `pg-${group.steps[0]?.index}`;
|
|
55
|
+
const toRow = (group) => toRowGroup(group, rowKey(group), descriptor);
|
|
40
56
|
/**
|
|
41
57
|
* 是否处于"初始状态"——即对应页面历史栈 cursor===0:
|
|
42
|
-
* 当 list 中所有 group 的 applied 都为 false
|
|
43
|
-
*
|
|
58
|
+
* 当 list 中所有 group 的 applied 都为 false 时即为该状态(空列表 `every` 返回 true,
|
|
59
|
+
* 即仅有 marker、无任何操作记录时也视为处于初始状态)。
|
|
44
60
|
*/
|
|
45
|
-
const isInitial = computed(() => props.list.
|
|
61
|
+
const isInitial = computed(() => props.list.every((g) => !g.applied));
|
|
46
62
|
return (_ctx, _cache) => {
|
|
47
|
-
return !__props.list.length ? (openBlock(), createElementBlock("div", _hoisted_1, "暂无操作记录")) : (openBlock(),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
return !__props.list.length && !__props.marker ? (openBlock(), createElementBlock("div", _hoisted_1, "暂无操作记录")) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [__props.list.length ? (openBlock(), createElementBlock("div", _hoisted_2, [createElementVNode("span", {
|
|
64
|
+
class: "m-editor-history-list-clear",
|
|
65
|
+
title: "清空当前页面的历史记录",
|
|
66
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("clear"))
|
|
67
|
+
}, "清空")])) : createCommentVNode("v-if", true), createVNode(unref(TMagicScrollbar), { "max-height": "360px" }, {
|
|
68
|
+
default: withCtx(() => [createElementVNode("ul", _hoisted_3, [
|
|
52
69
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (group) => {
|
|
53
70
|
return openBlock(), createBlock(GroupRow_default, {
|
|
54
|
-
key:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"sub-steps": group.steps.map((s) => ({
|
|
65
|
-
index: s.index,
|
|
66
|
-
applied: s.applied,
|
|
67
|
-
isCurrent: s.isCurrent,
|
|
68
|
-
desc: unref(describePageStep)(s.step),
|
|
69
|
-
diffable: isPageStepDiffable(s.step),
|
|
70
|
-
revertable: s.applied && unref(isPageStepRevertable)(s.step),
|
|
71
|
-
source: s.step.source,
|
|
72
|
-
time: unref(formatHistoryTime)(s.step.timestamp),
|
|
73
|
-
timeTitle: unref(formatHistoryFullTime)(s.step.timestamp)
|
|
74
|
-
})),
|
|
75
|
-
"is-current": group.isCurrent,
|
|
76
|
-
expanded: !!__props.expanded[`pg-${group.steps[0]?.index}`],
|
|
77
|
-
onToggle: _cache[0] || (_cache[0] = (key) => _ctx.$emit("toggle", key)),
|
|
78
|
-
onGoto: _cache[1] || (_cache[1] = (index) => _ctx.$emit("goto", index)),
|
|
79
|
-
onDiffStep: _cache[2] || (_cache[2] = (index) => _ctx.$emit("diff-step", index)),
|
|
80
|
-
onRevertStep: _cache[3] || (_cache[3] = (index) => _ctx.$emit("revert-step", index))
|
|
81
|
-
}, null, 8, [
|
|
82
|
-
"group-key",
|
|
83
|
-
"applied",
|
|
84
|
-
"merged",
|
|
85
|
-
"op-type",
|
|
86
|
-
"desc",
|
|
87
|
-
"source",
|
|
88
|
-
"time",
|
|
89
|
-
"time-title",
|
|
90
|
-
"step-count",
|
|
91
|
-
"sub-steps",
|
|
92
|
-
"is-current",
|
|
93
|
-
"expanded"
|
|
94
|
-
]);
|
|
71
|
+
key: rowKey(group),
|
|
72
|
+
group: toRow(group),
|
|
73
|
+
expanded: unref(isHistoryGroupExpanded)(__props.expanded, rowKey(group)),
|
|
74
|
+
"select-enabled": true,
|
|
75
|
+
onToggle: _cache[1] || (_cache[1] = (key) => _ctx.$emit("toggle", key)),
|
|
76
|
+
onGoto: _cache[2] || (_cache[2] = (index) => _ctx.$emit("goto", index)),
|
|
77
|
+
onDiffStep: _cache[3] || (_cache[3] = (index) => _ctx.$emit("diff-step", index)),
|
|
78
|
+
onRevertStep: _cache[4] || (_cache[4] = (index) => _ctx.$emit("revert-step", index)),
|
|
79
|
+
onSelect: _cache[5] || (_cache[5] = (index) => _ctx.$emit("select", index))
|
|
80
|
+
}, null, 8, ["group", "expanded"]);
|
|
95
81
|
}), 128)),
|
|
96
|
-
createCommentVNode("\n 初始状态项:永远位于列表底部(页面 tab 倒序展示,最底部=最早),\n 作为\"未修改\"零点。当所有 group 都未 applied 时它即为当前位置。\n "),
|
|
82
|
+
createCommentVNode("\n 初始状态项:永远位于列表底部(页面 tab 倒序展示,最底部=最早),\n 作为\"未修改\"零点。当所有 group 都未 applied 时它即为当前位置。\n 设置 root 时生成的「未修改的初始状态」标记(marker)会作为该行的文案与时间来源。\n "),
|
|
97
83
|
createVNode(InitialRow_default, {
|
|
98
84
|
"is-current": isInitial.value,
|
|
99
|
-
|
|
100
|
-
|
|
85
|
+
marker: __props.marker,
|
|
86
|
+
onGotoInitial: _cache[6] || (_cache[6] = ($event) => _ctx.$emit("goto-initial"))
|
|
87
|
+
}, null, 8, ["is-current", "marker"])
|
|
101
88
|
])]),
|
|
102
89
|
_: 1
|
|
103
|
-
}));
|
|
90
|
+
})], 64));
|
|
104
91
|
};
|
|
105
92
|
}
|
|
106
93
|
});
|
|
@@ -2,6 +2,8 @@ import { useServices } from "../../hooks/use-services.js";
|
|
|
2
2
|
import { datetimeFormatter } from "@tmagic/form";
|
|
3
3
|
import { computed, reactive } from "vue";
|
|
4
4
|
//#region packages/editor/src/layouts/history-list/composables.ts
|
|
5
|
+
/** 合并组默认展开;仅当 expanded[key] === false 时为收起。 */
|
|
6
|
+
var isHistoryGroupExpanded = (expanded, key) => expanded[key] !== false;
|
|
5
7
|
/**
|
|
6
8
|
* 历史记录面板共享逻辑:
|
|
7
9
|
* - 暴露三类历史的聚合数据(页面 / 数据源 / 代码块);
|
|
@@ -15,10 +17,11 @@ var useHistoryList = () => {
|
|
|
15
17
|
/**
|
|
16
18
|
* 折叠状态:key 形如 `pg-${组内首步 index}` / `ds-${id}-${组内首步 index}` / `cb-${id}-${组内首步 index}`。
|
|
17
19
|
* 用组内首步的稳定 index(而非展示位置)作为 key,确保历史数据更新后已展开的分组状态保持不变。
|
|
20
|
+
* 合并组默认展开;仅当值为 `false` 时表示收起。
|
|
18
21
|
*/
|
|
19
22
|
const expanded = reactive({});
|
|
20
23
|
const toggleGroup = (key) => {
|
|
21
|
-
expanded[key] =
|
|
24
|
+
expanded[key] = expanded[key] === false;
|
|
22
25
|
};
|
|
23
26
|
const pageGroups = computed(() => historyService.getPageHistoryGroups());
|
|
24
27
|
const dataSourceGroups = computed(() => historyService.getDataSourceHistoryGroups());
|
|
@@ -80,6 +83,7 @@ var HISTORY_SOURCE_LABELS = {
|
|
|
80
83
|
"component-panel": "组件面板",
|
|
81
84
|
props: "配置面板",
|
|
82
85
|
code: "源码",
|
|
86
|
+
"root-code": "DSL源码",
|
|
83
87
|
"stage-contextmenu": "画布菜单",
|
|
84
88
|
"tree-contextmenu": "树菜单",
|
|
85
89
|
toolbar: "工具栏",
|
|
@@ -87,6 +91,8 @@ var HISTORY_SOURCE_LABELS = {
|
|
|
87
91
|
rollback: "回滚",
|
|
88
92
|
api: "接口",
|
|
89
93
|
ai: "AI",
|
|
94
|
+
initial: "初始值",
|
|
95
|
+
sync: "同步",
|
|
90
96
|
unknown: "未知"
|
|
91
97
|
};
|
|
92
98
|
/** 操作途径文案:用于历史面板展示「画布 / 树面板 / 配置面板…」标签。 */
|
|
@@ -95,6 +101,37 @@ var sourceLabel = (source = "unknown") => {
|
|
|
95
101
|
};
|
|
96
102
|
/** 取一组历史步骤里最后一步(最近一次)的操作途径,用于组头部展示。 */
|
|
97
103
|
var groupSource = (group) => group.steps[group.steps.length - 1]?.step.source;
|
|
104
|
+
/**
|
|
105
|
+
* 把一个历史分组(页面 / bucket)派生为 GroupRow 直接消费的视图模型 {@link HistoryRowGroup}。
|
|
106
|
+
* 统一了原先 PageTab / Bucket 各自内联的 sub-steps 映射逻辑:描述、可差异、可回滚、时间、途径
|
|
107
|
+
* 全部在此一次性算好,组件层只负责渲染。
|
|
108
|
+
*/
|
|
109
|
+
var toRowGroup = (group, key, descriptor) => {
|
|
110
|
+
const { describeGroup, describeStep, isStepDiffable, isStepRevertable } = descriptor;
|
|
111
|
+
const timestamp = groupTimestamp(group);
|
|
112
|
+
return {
|
|
113
|
+
key,
|
|
114
|
+
applied: group.applied,
|
|
115
|
+
isCurrent: Boolean(group.isCurrent),
|
|
116
|
+
opType: group.opType,
|
|
117
|
+
desc: describeGroup(group),
|
|
118
|
+
source: groupSource(group),
|
|
119
|
+
time: formatHistoryTime(timestamp),
|
|
120
|
+
timeTitle: formatHistoryFullTime(timestamp),
|
|
121
|
+
subSteps: group.steps.map((s) => ({
|
|
122
|
+
index: s.index,
|
|
123
|
+
applied: s.applied,
|
|
124
|
+
isCurrent: s.isCurrent,
|
|
125
|
+
saved: s.step.saved,
|
|
126
|
+
desc: describeStep(s.step),
|
|
127
|
+
diffable: isStepDiffable ? isStepDiffable(s.step) : false,
|
|
128
|
+
revertable: s.applied && (isStepRevertable ? isStepRevertable(s.step) : true),
|
|
129
|
+
source: s.step.source,
|
|
130
|
+
time: formatHistoryTime(s.step.timestamp),
|
|
131
|
+
timeTitle: formatHistoryFullTime(s.step.timestamp)
|
|
132
|
+
}))
|
|
133
|
+
};
|
|
134
|
+
};
|
|
98
135
|
var nameOf = (node) => node?.name || node?.type || `${node?.id ?? ""}`;
|
|
99
136
|
/**
|
|
100
137
|
* 默认描述里展示「名称 (id: xxx)」,便于区分同名实体。
|
|
@@ -113,24 +150,24 @@ var pickLastDescription = (descs) => {
|
|
|
113
150
|
var describePageStep = (step) => {
|
|
114
151
|
if (step.historyDescription) return step.historyDescription;
|
|
115
152
|
const { opType } = step;
|
|
153
|
+
const items = step.diff ?? [];
|
|
116
154
|
if (opType === "add") {
|
|
117
|
-
const count =
|
|
118
|
-
const node =
|
|
155
|
+
const count = items.length;
|
|
156
|
+
const node = items[0]?.newSchema;
|
|
119
157
|
return `新增 ${count} 个节点${count === 1 && node ? `(${labelWithId(nameOf(node), node.id)})` : ""}`;
|
|
120
158
|
}
|
|
121
159
|
if (opType === "remove") {
|
|
122
|
-
const count =
|
|
123
|
-
const node =
|
|
160
|
+
const count = items.length;
|
|
161
|
+
const node = items[0]?.oldSchema;
|
|
124
162
|
return `删除 ${count} 个节点${count === 1 && node ? `(${labelWithId(nameOf(node), node.id)})` : ""}`;
|
|
125
163
|
}
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
const { newNode, changeRecords } = updated[0];
|
|
164
|
+
if (!items.length) return "修改节点";
|
|
165
|
+
if (items.length === 1) {
|
|
166
|
+
const { newSchema, changeRecords } = items[0];
|
|
130
167
|
const propPath = changeRecords?.[0]?.propPath;
|
|
131
|
-
return `修改 ${labelWithId(nameOf(
|
|
168
|
+
return `修改 ${labelWithId(nameOf(newSchema), newSchema?.id)}${propPath ? ` · ${propPath}` : ""}`;
|
|
132
169
|
}
|
|
133
|
-
return `修改 ${
|
|
170
|
+
return `修改 ${items.length} 个节点`;
|
|
134
171
|
};
|
|
135
172
|
/**
|
|
136
173
|
* 合并组的展示文案:
|
|
@@ -144,7 +181,7 @@ var describePageGroup = (group) => {
|
|
|
144
181
|
if (group.steps.length === 1) return describePageStep(group.steps[0].step);
|
|
145
182
|
const paths = /* @__PURE__ */ new Set();
|
|
146
183
|
group.steps.forEach((s) => {
|
|
147
|
-
s.step.
|
|
184
|
+
s.step.diff?.[0]?.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
148
185
|
});
|
|
149
186
|
const pathList = Array.from(paths).slice(0, 3).join(", ");
|
|
150
187
|
const target = labelWithId(group.targetName ?? (group.targetId !== void 0 ? `${group.targetId}` : "节点"), group.targetId);
|
|
@@ -152,10 +189,11 @@ var describePageGroup = (group) => {
|
|
|
152
189
|
};
|
|
153
190
|
var describeDataSourceStep = (step) => {
|
|
154
191
|
if (step.historyDescription) return step.historyDescription;
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
const
|
|
192
|
+
const { oldSchema, newSchema, changeRecords } = step.diff?.[0] ?? {};
|
|
193
|
+
if (!oldSchema && newSchema) return `创建 ${labelWithId(newSchema.title, newSchema.id ?? step.id)}`;
|
|
194
|
+
if (!newSchema && oldSchema) return `删除 ${labelWithId(oldSchema.title, oldSchema.id ?? step.id)}`;
|
|
195
|
+
const propPath = changeRecords?.[0]?.propPath;
|
|
196
|
+
const title = labelWithId(newSchema?.title || oldSchema?.title, step.id);
|
|
159
197
|
return propPath ? `修改 ${title} · ${propPath}` : `修改 ${title}`;
|
|
160
198
|
};
|
|
161
199
|
var describeDataSourceGroup = (group) => {
|
|
@@ -164,18 +202,19 @@ var describeDataSourceGroup = (group) => {
|
|
|
164
202
|
if (group.steps.length === 1) return describeDataSourceStep(group.steps[0].step);
|
|
165
203
|
const paths = /* @__PURE__ */ new Set();
|
|
166
204
|
group.steps.forEach((s) => {
|
|
167
|
-
s.step.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
205
|
+
s.step.diff?.[0]?.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
168
206
|
});
|
|
169
207
|
const pathList = Array.from(paths).slice(0, 3).join(", ");
|
|
170
|
-
const target = labelWithId(group.steps[group.steps.length - 1].step.newSchema?.title || group.steps[0].step.oldSchema?.title, group.id);
|
|
208
|
+
const target = labelWithId(group.steps[group.steps.length - 1].step.diff?.[0]?.newSchema?.title || group.steps[0].step.diff?.[0]?.oldSchema?.title, group.id);
|
|
171
209
|
return pathList ? `修改 ${target} · ${pathList}${paths.size > 3 ? "…" : ""}` : `修改 ${target}`;
|
|
172
210
|
};
|
|
173
211
|
var describeCodeBlockStep = (step) => {
|
|
174
212
|
if (step.historyDescription) return step.historyDescription;
|
|
175
|
-
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
const
|
|
213
|
+
const { oldSchema: oldContent, newSchema: newContent, changeRecords } = step.diff?.[0] ?? {};
|
|
214
|
+
if (!oldContent && newContent) return `创建 ${labelWithId(newContent.name, newContent.id ?? step.id)}`;
|
|
215
|
+
if (!newContent && oldContent) return `删除 ${labelWithId(oldContent.name, oldContent.id ?? step.id)}`;
|
|
216
|
+
const propPath = changeRecords?.[0]?.propPath;
|
|
217
|
+
const title = labelWithId(newContent?.name || oldContent?.name, step.id);
|
|
179
218
|
return propPath ? `修改 ${title} · ${propPath}` : `修改 ${title}`;
|
|
180
219
|
};
|
|
181
220
|
var describeCodeBlockGroup = (group) => {
|
|
@@ -184,10 +223,10 @@ var describeCodeBlockGroup = (group) => {
|
|
|
184
223
|
if (group.steps.length === 1) return describeCodeBlockStep(group.steps[0].step);
|
|
185
224
|
const paths = /* @__PURE__ */ new Set();
|
|
186
225
|
group.steps.forEach((s) => {
|
|
187
|
-
s.step.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
226
|
+
s.step.diff?.[0]?.changeRecords?.forEach((r) => r.propPath && paths.add(r.propPath));
|
|
188
227
|
});
|
|
189
228
|
const pathList = Array.from(paths).slice(0, 3).join(", ");
|
|
190
|
-
const target = labelWithId(group.steps[group.steps.length - 1].step.
|
|
229
|
+
const target = labelWithId(group.steps[group.steps.length - 1].step.diff?.[0]?.newSchema?.name || group.steps[0].step.diff?.[0]?.oldSchema?.name, group.id);
|
|
191
230
|
return pathList ? `修改 ${target} · ${pathList}${paths.size > 3 ? "…" : ""}` : `修改 ${target}`;
|
|
192
231
|
};
|
|
193
232
|
/**
|
|
@@ -198,27 +237,29 @@ var describeCodeBlockGroup = (group) => {
|
|
|
198
237
|
*/
|
|
199
238
|
var isPageStepRevertable = (step) => {
|
|
200
239
|
if (step.opType !== "update") return true;
|
|
201
|
-
const items = step.
|
|
240
|
+
const items = step.diff ?? [];
|
|
202
241
|
if (!items.length) return false;
|
|
203
242
|
return items.every((item) => Boolean(item.changeRecords?.length));
|
|
204
243
|
};
|
|
205
244
|
/**
|
|
206
245
|
* 数据源 step 是否支持「回滚」:
|
|
207
|
-
* -
|
|
246
|
+
* - 新增(无 oldSchema)/ 删除(无 newSchema):不依赖 changeRecords,始终可回滚;
|
|
208
247
|
* - 更新(前后 schema 都存在):必须有 changeRecords 才支持局部反向 patch,否则不支持回滚。
|
|
209
248
|
*/
|
|
210
249
|
var isDataSourceStepRevertable = (step) => {
|
|
211
|
-
|
|
212
|
-
|
|
250
|
+
const item = step.diff?.[0];
|
|
251
|
+
if (!item?.oldSchema || !item?.newSchema) return true;
|
|
252
|
+
return Boolean(item.changeRecords?.length);
|
|
213
253
|
};
|
|
214
254
|
/**
|
|
215
255
|
* 代码块 step 是否支持「回滚」:
|
|
216
|
-
* -
|
|
256
|
+
* - 新增(无 oldSchema)/ 删除(无 newSchema):不依赖 changeRecords,始终可回滚;
|
|
217
257
|
* - 更新(前后 content 都存在):必须有 changeRecords 才支持局部反向 patch,否则不支持回滚。
|
|
218
258
|
*/
|
|
219
259
|
var isCodeBlockStepRevertable = (step) => {
|
|
220
|
-
|
|
221
|
-
|
|
260
|
+
const item = step.diff?.[0];
|
|
261
|
+
if (!item?.oldSchema || !item?.newSchema) return true;
|
|
262
|
+
return Boolean(item.changeRecords?.length);
|
|
222
263
|
};
|
|
223
264
|
//#endregion
|
|
224
|
-
export { describeCodeBlockGroup, describeCodeBlockStep, describeDataSourceGroup, describeDataSourceStep, describePageGroup, describePageStep, formatHistoryFullTime, formatHistoryTime,
|
|
265
|
+
export { describeCodeBlockGroup, describeCodeBlockStep, describeDataSourceGroup, describeDataSourceStep, describePageGroup, describePageStep, formatHistoryFullTime, formatHistoryTime, isCodeBlockStepRevertable, isDataSourceStepRevertable, isHistoryGroupExpanded, isPageStepRevertable, opLabel, sourceLabel, toRowGroup, useHistoryList };
|
|
@@ -4,7 +4,7 @@ import AddButton_default from "./AddButton.js";
|
|
|
4
4
|
import PageBarScrollContainer_default from "./PageBarScrollContainer.js";
|
|
5
5
|
import PageList_default from "./PageList.js";
|
|
6
6
|
import Search_default from "./Search.js";
|
|
7
|
-
import { TMagicIcon, TMagicPopover } from "@tmagic/design";
|
|
7
|
+
import { TMagicIcon, TMagicPopover, tMagicMessageBox } from "@tmagic/design";
|
|
8
8
|
import { NodeType } from "@tmagic/core";
|
|
9
9
|
import { Fragment, computed, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
10
10
|
import { CaretBottom, Delete, DocumentCopy } from "@element-plus/icons-vue";
|
|
@@ -54,7 +54,8 @@ var PageBar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
54
54
|
top: 0
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
|
-
const remove = (node) => {
|
|
57
|
+
const remove = async (node) => {
|
|
58
|
+
await tMagicMessageBox.confirm("确定删除该页面吗?");
|
|
58
59
|
editorService.remove(node);
|
|
59
60
|
};
|
|
60
61
|
const pageBarScrollContainerRef = useTemplateRef("pageBarScrollContainer");
|
|
@@ -121,6 +122,7 @@ var PageBar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
121
122
|
type: "button",
|
|
122
123
|
text: "删除",
|
|
123
124
|
icon: unref(Delete),
|
|
125
|
+
buttonProps: { type: "danger" },
|
|
124
126
|
handler: () => remove(item)
|
|
125
127
|
} }, null, 8, ["data"])])])]),
|
|
126
128
|
_: 2
|
|
@@ -71,7 +71,11 @@ var Sidebar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
}, { immediate: true });
|
|
74
|
-
const activeTabName =
|
|
74
|
+
const activeTabName = computed({
|
|
75
|
+
get: () => uiService.get("sideBarActiveTabName"),
|
|
76
|
+
set: (value) => uiService.set("sideBarActiveTabName", value)
|
|
77
|
+
});
|
|
78
|
+
uiService.set("sideBarActiveTabName", props.data?.status || "");
|
|
75
79
|
const getItemConfig = (data) => {
|
|
76
80
|
const map = {
|
|
77
81
|
[SideItemKey.COMPONENT_LIST]: {
|