feat(grid): show details for read-only cells

This commit is contained in:
二丫讲梵 2026-07-21 16:57:12 +08:00 committed by GitHub
parent 497d041157
commit 00f58ebe16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 3 deletions

View File

@ -2855,6 +2855,17 @@ function startDomCellEdit(rowId: number, columnIndex: number, displayText: strin
startCellEdit(rowId, columnIndex, cellEditContentNeedsExpandedEditor({ displayText, editText, target: event.currentTarget }));
}
function showReadonlyCellDetailsOnDblClick(item: RowItem, rowIndex: number, visibleColIdx: number, actualColIdx: number): boolean {
if (canEditCellItem(item, actualColIdx)) return false;
showCellDetailsForVisibleCell(rowIndex, visibleColIdx, actualColIdx);
return true;
}
function onDomCellDblClick(item: RowItem, rowIndex: number, visibleColIdx: number, actualColIdx: number, event: MouseEvent) {
if (showReadonlyCellDetailsOnDblClick(item, rowIndex, visibleColIdx, actualColIdx)) return;
startDomCellEdit(item.id, actualColIdx, formatCellCached(item.data[actualColIdx], actualColIdx), event);
}
function cellEditContentNeedsExpandedEditor(options: { displayText: string; editText: string; target: EventTarget | null }): boolean {
const text = options.editText || options.displayText;
if (text.includes("\n") || text.includes("\r")) return true;
@ -4687,7 +4698,8 @@ function onCanvasDblClick(event: MouseEvent) {
}
const item = displayItemAt(hit.rowIndex);
const actualColIdx = visibleColumnIndexes.value[hit.visibleColIdx];
if (!item || actualColIdx === undefined || !canEditCellItem(item, actualColIdx)) return;
if (!item || actualColIdx === undefined) return;
if (showReadonlyCellDetailsOnDblClick(item, item.displayIndex, hit.visibleColIdx, actualColIdx)) return;
startCellEdit(item.id, actualColIdx, canvasCellContentOverflows(item, actualColIdx, hit.visibleColIdx));
}
@ -5258,6 +5270,16 @@ function showTransposeCellDetails(rowIndex: number, actualColIdx: number) {
gridRef.value?.focus({ preventScroll: true });
}
function onTransposeCellDblClick(rowIndex: number, actualColIdx: number, displayText: string, event: MouseEvent) {
const item = displayItemAt(rowIndex);
if (!item) return;
if (!canEditCellItem(item, actualColIdx)) {
showTransposeCellDetails(rowIndex, actualColIdx);
return;
}
startDomCellEdit(item.id, actualColIdx, displayText, event);
}
function onTransposeCellContext(rowIndex: number, actualColIdx: number, event: MouseEvent) {
selectTransposeCell(rowIndex, actualColIdx, event);
const item = displayItemAt(rowIndex);
@ -7716,7 +7738,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
@mouseenter="onTransposeCellMouseenter(cell.recordIndex, cell.valueIndex)"
@mouseleave="onCellMouseleave(cell.recordIndex, cell.valueIndex)"
@contextmenu="onTransposeCellContext(cell.recordIndex, cell.valueIndex, $event)"
@dblclick.stop="canEditCellItem(displayItems[cell.recordIndex], cell.valueIndex) && startDomCellEdit(displayItems[cell.recordIndex].id, cell.valueIndex, cell.display, $event)"
@dblclick.stop="onTransposeCellDblClick(cell.recordIndex, cell.valueIndex, cell.display, $event)"
>
<template v-if="editingCell?.rowId === displayItems[cell.recordIndex]?.id && editingCell?.col === cell.valueIndex">
<TemporalCellEditor
@ -8369,7 +8391,7 @@ const gridContextMenuItems = computed<ContextMenuItem[]>(() => {
"
@mouseenter="onCellMouseenter(item.displayIndex, col.visibleColIdx, col.actualColIdx)"
@mouseleave="onCellMouseleave(item.displayIndex, col.actualColIdx)"
@dblclick="canEditCellItem(item, col.actualColIdx) && startDomCellEdit(item.id, col.actualColIdx, formatCellCached(item.data[col.actualColIdx], col.actualColIdx), $event)"
@dblclick="onDomCellDblClick(item, item.displayIndex, col.visibleColIdx, col.actualColIdx, $event)"
:data-visible-col-index="col.visibleColIdx"
@contextmenu="onCellContext(item.id, item.displayIndex, col.actualColIdx, col.visibleColIdx, $event)"
>