dbeaver/pro#9133 use common GridSelectAction (#4342)

Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
alex
2026-05-18 11:22:26 +02:00
committed by GitHub
co-authored by Daria Marutkina
parent 4b30dc3ba5
commit 5f5a6743eb
2 changed files with 5 additions and 10 deletions
@@ -27,7 +27,6 @@ import {
DATA_CONTEXT_DV_PRESENTATION,
type DatabaseDataSelectActionsData,
DatabaseEditChangeType,
DatabaseSelectAction,
DataViewerPresentationType,
type IDatabaseDataModel,
type IDataPresentationProps,
@@ -186,7 +185,7 @@ export const DataGridTable = observer<IDataPresentationProps>(function DataGridT
},
}));
const gridSelectedCellCopy = useGridSelectedCellsCopy(tableData, selectionAction as unknown as DatabaseSelectAction, gridSelectionContext);
const gridSelectedCellCopy = useGridSelectedCellsCopy(tableData, selectionAction, gridSelectionContext);
const gridSelectedCellPaste = useGridSelectedCellsPaste(tableData, selectionAction as unknown as ResultSetSelectAction);
const { onMouseDownHandler, onMouseMoveHandler } = useGridDragging({
onDragStart: startPosition => {
@@ -12,13 +12,12 @@ import { useService } from '@cloudbeaver/core-di';
import { EventContext, EventStopPropagationFlag } from '@cloudbeaver/core-events';
import { copyToClipboard } from '@cloudbeaver/core-utils';
import {
DatabaseSelectAction,
DataViewerService,
type IGridColumnKey,
type IGridDataKey,
GridDataKeysUtils,
ResultSetSelectAction,
useDataViewerCopyHandler,
GridSelectAction,
} from '@cloudbeaver/plugin-data-viewer';
import type { IDataGridSelectionContext } from './DataGridSelection/DataGridSelectionContext.js';
@@ -68,7 +67,7 @@ function getSelectedCellsValue(tableData: ITableData, selectedCells: Map<string,
export function useGridSelectedCellsCopy(
tableData: ITableData,
selectAction: DatabaseSelectAction | undefined,
selectAction: GridSelectAction | undefined,
selectionContext: IDataGridSelectionContext,
) {
const dataViewerService = useService(DataViewerService);
@@ -80,7 +79,7 @@ export function useGridSelectedCellsCopy(
const activeElement = document.activeElement as HTMLElement | null;
const isEditing = activeElement?.matches('input, textarea, [contenteditable="true"]');
if(isEditing) {
if (isEditing) {
return;
}
@@ -93,11 +92,8 @@ export function useGridSelectedCellsCopy(
EventContext.set(event, EventStopPropagationFlag);
if (dataViewerService.canCopyData) {
if (!(props.selectAction instanceof ResultSetSelectAction)) {
throw new Error('Copying data is not supported');
}
const focusedElement = props.selectAction?.getFocusedElement();
let value: string | null = null;
if (Array.from(props.selectionContext.selectedCells.keys()).length > 0) {