feat(datagrid): 为表格编辑增加单元格级撤销能力

- 在 V2 与旧版单元格菜单中增加撤销当前修改入口
- 复用现有改单保存链路回退单元格值与脏标记
- 修复刷新后本地改单状态未完全清理的问题
- 补充相关布局与菜单回归测试

Close #563
This commit is contained in:
Syngnat
2026-06-14 15:41:26 +08:00
parent 6bbe5ad30d
commit 6cb5998cd6
4 changed files with 99 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ import {
FolderAddOutlined,
HddOutlined,
PushpinOutlined,
UndoOutlined,
SortAscendingOutlined,
SortDescendingOutlined,
VerticalAlignBottomOutlined,
@@ -543,6 +544,7 @@ export type V2CellContextMenuActionKey =
| 'copy-row-for-paste'
| 'paste-row-as-new'
| 'copy-column-data'
| 'undo-cell-change'
| 'set-null'
| 'edit-row'
| 'fill-selected'
@@ -652,6 +654,7 @@ export const V2CellContextMenuView: React.FC<{
rowLabel?: string;
selectedRowCount?: number;
canModifyData?: boolean;
canUndoCellChange?: boolean;
copiedRowCount?: number;
canPasteCopiedColumns?: boolean;
supportsCopyInsert?: boolean;
@@ -663,6 +666,7 @@ export const V2CellContextMenuView: React.FC<{
rowLabel,
selectedRowCount = 0,
canModifyData = false,
canUndoCellChange = false,
copiedRowCount = 0,
canPasteCopiedColumns = false,
supportsCopyInsert = true,
@@ -694,6 +698,12 @@ export const V2CellContextMenuView: React.FC<{
<>
<div className="gn-v2-context-menu-section-title"></div>
{renderItems([
{
action: 'undo-cell-change',
icon: <UndoOutlined />,
title: '撤销此单元格修改',
disabled: !canUndoCellChange,
},
{ action: 'set-null', icon: <ClearOutlined />, title: '设置为 NULL' },
{ action: 'edit-row', icon: <EditOutlined />, title: '编辑本行', kbd: '↵' },
{ action: 'copy-row-for-paste', icon: <CopyOutlined />, title: '复制本行为新增行' },