mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-16 14:50:15 +08:00
dbeaver/pro#9133 use common GridSelectAction (#4342)
Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
@@ -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 => {
|
||||
|
||||
+4
-8
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user