@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
|
@@ -101,7 +101,7 @@ var CompareForm_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ de
|
|
|
101
101
|
switch (props.category) {
|
|
102
102
|
case "node":
|
|
103
103
|
if (!props.type) return [];
|
|
104
|
-
return removeStyleDisplayConfig(await propsService.getPropsConfig(props.type));
|
|
104
|
+
return removeStyleDisplayConfig(await propsService.getPropsConfig(props.type, { node: props.value }));
|
|
105
105
|
case "data-source": return dataSourceService.getFormConfig(props.type || "base");
|
|
106
106
|
case "code-block": return getCodeBlockFormConfig({
|
|
107
107
|
paramColConfig: codeBlockService.getParamsColConfig(),
|
|
@@ -73,11 +73,11 @@ var ToolButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
73
73
|
placement: "bottom-start",
|
|
74
74
|
content: __props.data.tooltip
|
|
75
75
|
}, {
|
|
76
|
-
default: withCtx(() => [createVNode(unref(TMagicButton), {
|
|
76
|
+
default: withCtx(() => [createVNode(unref(TMagicButton), mergeProps({
|
|
77
77
|
size: "small",
|
|
78
78
|
link: "",
|
|
79
79
|
disabled: disabled.value
|
|
80
|
-
}, createSlots({ _: 2 }, [__props.data.icon ? {
|
|
80
|
+
}, __props.data.buttonProps || {}), createSlots({ _: 2 }, [__props.data.icon ? {
|
|
81
81
|
name: "icon",
|
|
82
82
|
fn: withCtx(() => [createVNode(Icon_default, { icon: __props.data.icon }, null, 8, ["icon"])]),
|
|
83
83
|
key: "0"
|
|
@@ -85,15 +85,15 @@ var ToolButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
85
85
|
name: "default",
|
|
86
86
|
fn: withCtx(() => [createTextVNode(toDisplayString(__props.data.text), 1)]),
|
|
87
87
|
key: "1"
|
|
88
|
-
} : void 0]),
|
|
88
|
+
} : void 0]), 1040, ["disabled"])]),
|
|
89
89
|
_: 1
|
|
90
|
-
}, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), {
|
|
90
|
+
}, 8, ["content"])) : (openBlock(), createBlock(unref(TMagicButton), mergeProps({
|
|
91
91
|
key: 1,
|
|
92
92
|
size: "small",
|
|
93
93
|
link: "",
|
|
94
94
|
disabled: disabled.value,
|
|
95
95
|
title: __props.data.text
|
|
96
|
-
}, createSlots({ _: 2 }, [__props.data.icon ? {
|
|
96
|
+
}, __props.data.buttonProps || {}), createSlots({ _: 2 }, [__props.data.icon ? {
|
|
97
97
|
name: "icon",
|
|
98
98
|
fn: withCtx(() => [createVNode(Icon_default, { icon: __props.data.icon }, null, 8, ["icon"])]),
|
|
99
99
|
key: "0"
|
|
@@ -101,7 +101,7 @@ var ToolButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
101
101
|
name: "default",
|
|
102
102
|
fn: withCtx(() => [createTextVNode(toDisplayString(__props.data.text), 1)]),
|
|
103
103
|
key: "1"
|
|
104
|
-
} : void 0]),
|
|
104
|
+
} : void 0]), 1040, ["disabled", "title"]))], 64)) : __props.data.type === "dropdown" ? (openBlock(), createBlock(unref(TMagicDropdown), {
|
|
105
105
|
key: 3,
|
|
106
106
|
trigger: "click",
|
|
107
107
|
disabled: disabled.value,
|
package/dist/es/index.js
CHANGED
|
@@ -2,11 +2,13 @@ import { CODE_DRAFT_STORAGE_KEY, CodeDeleteErrorType, ColumnLayout, DragType, Ke
|
|
|
2
2
|
import { useCodeBlockEdit } from "./hooks/use-code-block-edit.js";
|
|
3
3
|
import { advancedTabConfig, arrayOptions, displayTabConfig, eqOptions, eventTabConfig, fillConfig, numberOptions, styleTabConfig } from "./utils/props.js";
|
|
4
4
|
import props_default from "./services/props.js";
|
|
5
|
+
import { getEditorConfig, setEditorConfig } from "./utils/config.js";
|
|
5
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";
|
|
8
|
+
import { idbDelete, idbGet, idbSet, isIndexedDBSupported, openIndexedDB } from "./utils/indexed-db.js";
|
|
6
9
|
import history_default from "./services/history.js";
|
|
7
|
-
import { getEditorConfig, setEditorConfig } from "./utils/config.js";
|
|
8
10
|
import storage_default from "./services/storage.js";
|
|
9
|
-
import { COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, Fixed2Other, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, change2Fixed, classifyDragSources, collectRelatedNodes, editorNodeMergeCustomizer, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getRelativeStyle, isIncludeDataSource, moveItemsInContainer, resolveSelectedNode, serializeConfig, setChildrenLayout, setLayout, toggleFixedPosition } from "./utils/editor.js";
|
|
11
|
+
import { COPY_CODE_STORAGE_KEY, COPY_DS_STORAGE_KEY, COPY_STORAGE_KEY, Fixed2Other, buildChangeRecords, calcAlignCenterStyle, calcLayerTargetIndex, calcMoveStyle, change2Fixed, classifyDragSources, collectRelatedNodes, describeStepForRevert, editorNodeMergeCustomizer, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getRelativeStyle, isIncludeDataSource, moveItemsInContainer, resolveSelectedNode, serializeConfig, setChildrenLayout, setLayout, toggleFixedPosition } from "./utils/editor.js";
|
|
10
12
|
import { beforePaste, getAddParent, getDefaultConfig, getPositionInContainer } from "./utils/operator.js";
|
|
11
13
|
import editor_default from "./services/editor.js";
|
|
12
14
|
import { DEFAULT_LEFT_COLUMN_WIDTH, DEFAULT_RIGHT_COLUMN_WIDTH, H_GUIDE_LINE_STORAGE_KEY, LEFT_COLUMN_WIDTH_STORAGE_KEY, MIN_CENTER_COLUMN_WIDTH, MIN_LEFT_COLUMN_WIDTH, MIN_RIGHT_COLUMN_WIDTH, PROPS_PANEL_WIDTH_STORAGE_KEY, RIGHT_COLUMN_WIDTH_STORAGE_KEY, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY } from "./utils/const.js";
|
|
@@ -33,6 +35,7 @@ import Icon_default from "./components/Icon.js";
|
|
|
33
35
|
import ToolButton_default from "./components/ToolButton.js";
|
|
34
36
|
import CodeEditor_default from "./layouts/CodeEditor.js";
|
|
35
37
|
import Bucket_default from "./layouts/history-list/Bucket.js";
|
|
38
|
+
import BucketTab_default from "./layouts/history-list/BucketTab.js";
|
|
36
39
|
import CompareForm_default from "./components/CompareForm.js";
|
|
37
40
|
import HistoryDiffDialog_default from "./layouts/history-list/HistoryDiffDialog.js";
|
|
38
41
|
import FormPanel_default from "./layouts/props-panel/FormPanel.js";
|
|
@@ -80,4 +83,4 @@ export * from "@tmagic/table";
|
|
|
80
83
|
export * from "@tmagic/stage";
|
|
81
84
|
export * from "@tmagic/design";
|
|
82
85
|
export * from "@tmagic/utils";
|
|
83
|
-
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, 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, dataSource_default as dataSourceService, debug, plugin_default as default, defaultIsExpandable, dep_default as depService, designPlugin, 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, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, history_default as historyService, info, isIncludeDataSource, monaco_editor_default as loadMonaco, log, moveItemsInContainer, numberOptions, props_default as propsService, resolveSelectedNode, serializeConfig, setChildrenLayout, setEditorConfig, setLayout, stageOverlay_default as stageOverlayService, storage_default as storageService, styleTabConfig, tablePlugin, toggleFixedPosition, ui_default as uiService, 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, 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/initService.js
CHANGED
|
@@ -6,7 +6,7 @@ import { cloneDeep as cloneDeep$1 } from "lodash-es";
|
|
|
6
6
|
//#region packages/editor/src/initService.ts
|
|
7
7
|
var initServiceState = (props, { editorService, historyService, componentListService, propsService, eventsService, uiService, codeBlockService, keybindingService, dataSourceService, depService }) => {
|
|
8
8
|
watch(() => props.modelValue, (modelValue) => {
|
|
9
|
-
editorService.set("root", modelValue || null);
|
|
9
|
+
editorService.set("root", modelValue || null, { historySource: "initial" });
|
|
10
10
|
}, { immediate: true });
|
|
11
11
|
watch(() => props.disabledMultiSelect, (disabledMultiSelect) => {
|
|
12
12
|
editorService.set("disabledMultiSelect", disabledMultiSelect || false);
|
|
@@ -66,7 +66,7 @@ var Framework_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
66
66
|
const saveCode = (value) => {
|
|
67
67
|
try {
|
|
68
68
|
const parseDSL = getEditorConfig("parseDSL");
|
|
69
|
-
editorService.set("root", parseDSL(value));
|
|
69
|
+
editorService.set("root", parseDSL(value), { historySource: "root-code" });
|
|
70
70
|
} catch (e) {
|
|
71
71
|
console.error(e);
|
|
72
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isHistoryGroupExpanded, toRowGroup } from "./composables.js";
|
|
2
2
|
import GroupRow_default from "./GroupRow.js";
|
|
3
3
|
import InitialRow_default from "./InitialRow.js";
|
|
4
4
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, openBlock, renderList, toDisplayString, unref } from "vue";
|
|
@@ -11,23 +11,10 @@ var Bucket_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
11
11
|
name: "MEditorHistoryListBucket",
|
|
12
12
|
__name: "Bucket",
|
|
13
13
|
props: {
|
|
14
|
-
|
|
14
|
+
config: {},
|
|
15
15
|
bucketId: {},
|
|
16
|
-
prefix: {},
|
|
17
|
-
showInitial: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
default: true
|
|
20
|
-
},
|
|
21
16
|
groups: {},
|
|
22
|
-
|
|
23
|
-
describeStep: {},
|
|
24
|
-
isStepDiffable: {},
|
|
25
|
-
isStepRevertable: {},
|
|
26
|
-
expanded: {},
|
|
27
|
-
gotoEnabled: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
default: true
|
|
30
|
-
}
|
|
17
|
+
expanded: {}
|
|
31
18
|
},
|
|
32
19
|
emits: [
|
|
33
20
|
"toggle",
|
|
@@ -38,65 +25,42 @@ var Bucket_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
38
25
|
],
|
|
39
26
|
setup(__props) {
|
|
40
27
|
const props = __props;
|
|
28
|
+
/**
|
|
29
|
+
* 子项 / 折叠状态 key:`${prefix}-${bucketId}-${组内首步 index}`。
|
|
30
|
+
* 以稳定的 step 索引(而非展示位置)标识分组,历史数据更新后已展开的分组状态仍能正确保持。
|
|
31
|
+
*/
|
|
32
|
+
const rowKey = (group) => `${props.config.prefix}-${props.bucketId}-${group.steps[0]?.index}`;
|
|
33
|
+
/** 把原始分组派生为 GroupRow 直接消费的视图模型。 */
|
|
34
|
+
const toRow = (group) => toRowGroup(group, rowKey(group), props.config);
|
|
41
35
|
/** 该 bucket 是否处于初始状态(栈 cursor=0),等价于全部 group 都未 applied。 */
|
|
42
36
|
const isInitial = computed(() => props.groups.length > 0 && props.groups.every((g) => !g.applied));
|
|
43
37
|
return (_ctx, _cache) => {
|
|
44
38
|
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [
|
|
45
|
-
createElementVNode("span", null, toDisplayString(__props.title), 1),
|
|
39
|
+
createElementVNode("span", null, toDisplayString(__props.config.title), 1),
|
|
46
40
|
createElementVNode("code", null, toDisplayString(String(__props.bucketId)), 1),
|
|
47
41
|
createElementVNode("span", _hoisted_3, toDisplayString(__props.groups.length) + " 组", 1)
|
|
48
42
|
]), createElementVNode("ul", _hoisted_4, [
|
|
49
43
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.groups, (group) => {
|
|
50
44
|
return openBlock(), createBlock(GroupRow_default, {
|
|
51
|
-
key:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"op-type": group.opType,
|
|
56
|
-
desc: __props.describeGroup(group),
|
|
57
|
-
source: unref(groupSource)(group),
|
|
58
|
-
time: unref(formatHistoryTime)(unref(groupTimestamp)(group)),
|
|
59
|
-
"time-title": unref(formatHistoryFullTime)(unref(groupTimestamp)(group)),
|
|
60
|
-
"step-count": group.steps.length,
|
|
61
|
-
"sub-steps": group.steps.map((s) => ({
|
|
62
|
-
index: s.index,
|
|
63
|
-
applied: s.applied,
|
|
64
|
-
isCurrent: s.isCurrent,
|
|
65
|
-
desc: __props.describeStep(s.step),
|
|
66
|
-
diffable: __props.isStepDiffable ? __props.isStepDiffable(s.step) : false,
|
|
67
|
-
revertable: s.applied && (__props.isStepRevertable ? __props.isStepRevertable(s.step) : true),
|
|
68
|
-
source: s.step.source,
|
|
69
|
-
time: unref(formatHistoryTime)(s.step.timestamp),
|
|
70
|
-
timeTitle: unref(formatHistoryFullTime)(s.step.timestamp)
|
|
71
|
-
})),
|
|
72
|
-
"is-current": group.isCurrent,
|
|
73
|
-
expanded: !!__props.expanded[`${__props.prefix}-${__props.bucketId}-${group.steps[0]?.index}`],
|
|
74
|
-
"goto-enabled": __props.gotoEnabled,
|
|
45
|
+
key: rowKey(group),
|
|
46
|
+
group: toRow(group),
|
|
47
|
+
expanded: unref(isHistoryGroupExpanded)(__props.expanded, rowKey(group)),
|
|
48
|
+
"goto-enabled": __props.config.gotoEnabled,
|
|
75
49
|
onToggle: _cache[0] || (_cache[0] = (key) => _ctx.$emit("toggle", key)),
|
|
76
50
|
onGoto: _cache[1] || (_cache[1] = (index) => _ctx.$emit("goto", __props.bucketId, index)),
|
|
77
51
|
onDiffStep: _cache[2] || (_cache[2] = (index) => _ctx.$emit("diff-step", __props.bucketId, index)),
|
|
78
52
|
onRevertStep: _cache[3] || (_cache[3] = (index) => _ctx.$emit("revert-step", __props.bucketId, index))
|
|
79
53
|
}, null, 8, [
|
|
80
|
-
"group
|
|
81
|
-
"applied",
|
|
82
|
-
"merged",
|
|
83
|
-
"op-type",
|
|
84
|
-
"desc",
|
|
85
|
-
"source",
|
|
86
|
-
"time",
|
|
87
|
-
"time-title",
|
|
88
|
-
"step-count",
|
|
89
|
-
"sub-steps",
|
|
90
|
-
"is-current",
|
|
54
|
+
"group",
|
|
91
55
|
"expanded",
|
|
92
56
|
"goto-enabled"
|
|
93
57
|
]);
|
|
94
58
|
}), 128)),
|
|
95
|
-
createCommentVNode("\n 初始状态项:永远位于该 bucket 列表底部(同样按倒序展示,最底部 = 最早状态)。\n 当 bucket 内所有 group 都未 applied 时即为当前位置。\n showInitial=false 时不展示(用于没有\"撤销到初始状态\"语义的自定义历史,如业务模块历史)。\n "),
|
|
96
|
-
__props.showInitial !== false ? (openBlock(), createBlock(InitialRow_default, {
|
|
59
|
+
createCommentVNode("\n 初始状态项:永远位于该 bucket 列表底部(同样按倒序展示,最底部 = 最早状态)。\n 当 bucket 内所有 group 都未 applied 时即为当前位置。\n config.showInitial=false 时不展示(用于没有\"撤销到初始状态\"语义的自定义历史,如业务模块历史)。\n "),
|
|
60
|
+
__props.config.showInitial !== false ? (openBlock(), createBlock(InitialRow_default, {
|
|
97
61
|
key: 0,
|
|
98
62
|
"is-current": isInitial.value,
|
|
99
|
-
"goto-enabled": __props.gotoEnabled,
|
|
63
|
+
"goto-enabled": __props.config.gotoEnabled,
|
|
100
64
|
onGotoInitial: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("goto-initial", __props.bucketId))
|
|
101
65
|
}, null, 8, ["is-current", "goto-enabled"])) : createCommentVNode("v-if", true)
|
|
102
66
|
])]);
|
|
@@ -1,74 +1,57 @@
|
|
|
1
1
|
import Bucket_default from "./Bucket.js";
|
|
2
2
|
import { TMagicScrollbar } from "@tmagic/design";
|
|
3
|
-
import { Fragment, createBlock, createElementBlock, defineComponent, openBlock, renderList, unref, withCtx } from "vue";
|
|
3
|
+
import { Fragment, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, renderList, unref, withCtx } from "vue";
|
|
4
4
|
//#region packages/editor/src/layouts/history-list/BucketTab.vue?vue&type=script&setup=true&lang.ts
|
|
5
5
|
var _hoisted_1 = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "m-editor-history-list-empty"
|
|
8
8
|
};
|
|
9
|
+
var _hoisted_2 = { class: "m-editor-history-list-toolbar" };
|
|
10
|
+
var _hoisted_3 = ["title"];
|
|
9
11
|
var BucketTab_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
10
12
|
name: "MEditorHistoryListBucketTab",
|
|
11
13
|
__name: "BucketTab",
|
|
12
14
|
props: {
|
|
13
|
-
|
|
14
|
-
prefix: {},
|
|
15
|
+
config: {},
|
|
15
16
|
buckets: {},
|
|
16
|
-
|
|
17
|
-
describeStep: {},
|
|
18
|
-
isStepDiffable: {},
|
|
19
|
-
isStepRevertable: {},
|
|
20
|
-
expanded: {},
|
|
21
|
-
gotoEnabled: {
|
|
22
|
-
type: Boolean,
|
|
23
|
-
default: true
|
|
24
|
-
}
|
|
17
|
+
expanded: {}
|
|
25
18
|
},
|
|
26
19
|
emits: [
|
|
27
20
|
"toggle",
|
|
28
21
|
"goto",
|
|
29
22
|
"goto-initial",
|
|
30
23
|
"diff-step",
|
|
31
|
-
"revert-step"
|
|
24
|
+
"revert-step",
|
|
25
|
+
"clear"
|
|
32
26
|
],
|
|
33
27
|
setup(__props) {
|
|
34
28
|
return (_ctx, _cache) => {
|
|
35
|
-
return !__props.buckets.length ? (openBlock(), createElementBlock("div", _hoisted_1, "暂无操作记录")) : (openBlock(),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
return !__props.buckets.length ? (openBlock(), createElementBlock("div", _hoisted_1, "暂无操作记录")) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("div", _hoisted_2, [createElementVNode("span", {
|
|
30
|
+
class: "m-editor-history-list-clear",
|
|
31
|
+
title: `清空${__props.config.title}的历史记录`,
|
|
32
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("clear"))
|
|
33
|
+
}, "清空", 8, _hoisted_3)]), createVNode(unref(TMagicScrollbar), { "max-height": "360px" }, {
|
|
39
34
|
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.buckets, (bucket) => {
|
|
40
35
|
return openBlock(), createBlock(Bucket_default, {
|
|
41
|
-
key: `${__props.prefix}-${bucket.id}`,
|
|
42
|
-
|
|
36
|
+
key: `${__props.config.prefix}-${bucket.id}`,
|
|
37
|
+
config: __props.config,
|
|
43
38
|
"bucket-id": bucket.id,
|
|
44
|
-
prefix: __props.prefix,
|
|
45
39
|
groups: bucket.groups,
|
|
46
|
-
"describe-group": __props.describeGroup,
|
|
47
|
-
"describe-step": __props.describeStep,
|
|
48
|
-
"is-step-diffable": __props.isStepDiffable,
|
|
49
|
-
"is-step-revertable": __props.isStepRevertable,
|
|
50
40
|
expanded: __props.expanded,
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
onRevertStep: _cache[4] || (_cache[4] = (id, index) => _ctx.$emit("revert-step", id, index))
|
|
41
|
+
onToggle: _cache[1] || (_cache[1] = (key) => _ctx.$emit("toggle", key)),
|
|
42
|
+
onGoto: _cache[2] || (_cache[2] = (id, index) => _ctx.$emit("goto", id, index)),
|
|
43
|
+
onGotoInitial: _cache[3] || (_cache[3] = (id) => _ctx.$emit("goto-initial", id)),
|
|
44
|
+
onDiffStep: _cache[4] || (_cache[4] = (id, index) => _ctx.$emit("diff-step", id, index)),
|
|
45
|
+
onRevertStep: _cache[5] || (_cache[5] = (id, index) => _ctx.$emit("revert-step", id, index))
|
|
57
46
|
}, null, 8, [
|
|
58
|
-
"
|
|
47
|
+
"config",
|
|
59
48
|
"bucket-id",
|
|
60
|
-
"prefix",
|
|
61
49
|
"groups",
|
|
62
|
-
"
|
|
63
|
-
"describe-step",
|
|
64
|
-
"is-step-diffable",
|
|
65
|
-
"is-step-revertable",
|
|
66
|
-
"expanded",
|
|
67
|
-
"goto-enabled"
|
|
50
|
+
"expanded"
|
|
68
51
|
]);
|
|
69
52
|
}), 128))]),
|
|
70
53
|
_: 1
|
|
71
|
-
}));
|
|
54
|
+
})], 64));
|
|
72
55
|
};
|
|
73
56
|
}
|
|
74
57
|
});
|