@atlaskit/editor-plugin-table 5.5.2 → 5.5.4
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/CHANGELOG.md +14 -0
- package/dist/cjs/plugins/table/commands/index.js +12 -0
- package/dist/cjs/plugins/table/commands/misc.js +61 -1
- package/dist/cjs/plugins/table/index.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +8 -19
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +70 -36
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +11 -0
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +46 -1
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +25 -29
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +5 -18
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +16 -1
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +61 -1
- package/dist/esm/plugins/table/index.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/esm/plugins/table/ui/DragHandle/index.js +6 -17
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +2 -0
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/package.json +1 -4
- package/src/__tests__/unit/ui/RowDragControls.tsx +2 -0
- package/src/plugins/table/commands/index.ts +2 -0
- package/src/plugins/table/commands/misc.ts +78 -0
- package/src/plugins/table/index.tsx +5 -7
- package/src/plugins/table/nodeviews/TableComponent.tsx +31 -38
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +2 -0
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -7
- package/src/plugins/table/types.ts +2 -0
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +5 -30
- package/src/plugins/table/ui/DragHandle/index.tsx +6 -23
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +134 -49
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +3 -3
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +137 -44
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -1
|
@@ -16,6 +16,7 @@ type DragControlsProps = {
|
|
|
16
16
|
canDrag?: boolean;
|
|
17
17
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
18
18
|
selectRow: (row: number, expand: boolean) => void;
|
|
19
|
+
selectRows: (rowIndexes: number[]) => void;
|
|
19
20
|
updateCellHoverLocation: (rowIndex: number) => void;
|
|
20
21
|
};
|
|
21
22
|
export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps<"intl">>> & {
|
|
@@ -2,7 +2,7 @@ export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clear
|
|
|
2
2
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
3
3
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout, } from './toggle';
|
|
4
4
|
export { clearMultipleCells } from './clear';
|
|
5
|
-
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectRow, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, } from './misc';
|
|
5
|
+
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, } from './misc';
|
|
6
6
|
export { sortByColumn } from './sort';
|
|
7
7
|
export { goToNextCell } from './go-to-next-cell';
|
|
8
8
|
export { removeDescendantNodes } from './referentiality';
|
|
@@ -20,7 +20,9 @@ export declare const convertFirstRowToHeader: (schema: Schema) => (tr: Transacti
|
|
|
20
20
|
export declare const moveCursorBackward: Command;
|
|
21
21
|
export declare const setMultipleCellAttrs: (attrs: Object, targetCellPosition?: number) => Command;
|
|
22
22
|
export declare const selectColumn: (column: number, expand?: boolean) => Command;
|
|
23
|
+
export declare const selectColumns: (columnIndexes: number[]) => Command;
|
|
23
24
|
export declare const selectRow: (row: number, expand?: boolean) => Command;
|
|
25
|
+
export declare const selectRows: (rowIndexes: number[]) => Command;
|
|
24
26
|
export declare const showInsertColumnButton: (columnIndex: number) => Command;
|
|
25
27
|
export declare const showInsertRowButton: (rowIndex: number) => Command;
|
|
26
28
|
export declare const hideInsertColumnOrRowButton: () => Command;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
type HandleIconProps = {
|
|
3
|
-
|
|
4
|
-
hasMergedCells: boolean;
|
|
5
|
-
direction: 'row' | 'column';
|
|
6
|
-
isDragMenuOpen: boolean | undefined;
|
|
3
|
+
forceDefaultHandle: boolean;
|
|
7
4
|
isRowHandleHovered: boolean;
|
|
8
5
|
isColumnHandleHovered: boolean;
|
|
9
|
-
|
|
10
|
-
isCurrentColumnSelected: boolean;
|
|
11
|
-
dragMenuDirection: 'row' | 'column' | undefined;
|
|
6
|
+
hasMergedCells: boolean;
|
|
12
7
|
};
|
|
13
8
|
export declare const HandleIconComponent: (props: HandleIconProps) => JSX.Element;
|
|
14
9
|
export {};
|
|
@@ -5,6 +5,7 @@ type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
|
|
|
5
5
|
type DragHandleProps = {
|
|
6
6
|
tableLocalId: string;
|
|
7
7
|
indexes: number[];
|
|
8
|
+
forceDefaultHandle?: boolean;
|
|
8
9
|
previewWidth?: number;
|
|
9
10
|
previewHeight?: number;
|
|
10
11
|
direction?: TableDirection;
|
|
@@ -16,5 +17,5 @@ type DragHandleProps = {
|
|
|
16
17
|
editorView: EditorView;
|
|
17
18
|
canDrag?: boolean;
|
|
18
19
|
};
|
|
19
|
-
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
|
|
20
|
+
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
|
|
20
21
|
export {};
|
package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ type DragControlsProps = {
|
|
|
16
16
|
canDrag?: boolean;
|
|
17
17
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
18
18
|
selectRow: (row: number, expand: boolean) => void;
|
|
19
|
+
selectRows: (rowIndexes: number[]) => void;
|
|
19
20
|
updateCellHoverLocation: (rowIndex: number) => void;
|
|
20
21
|
};
|
|
21
22
|
export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps<"intl">>> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.4",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -121,9 +121,6 @@
|
|
|
121
121
|
"platform.editor.table-remove-update-resize-handles_djvab": {
|
|
122
122
|
"type": "boolean"
|
|
123
123
|
},
|
|
124
|
-
"platform.editor.table.overflow-state-analytics": {
|
|
125
|
-
"type": "boolean"
|
|
126
|
-
},
|
|
127
124
|
"platform.editor.table.increase-shadow-visibility_lh89r": {
|
|
128
125
|
"type": "boolean"
|
|
129
126
|
},
|
|
@@ -74,6 +74,7 @@ describe('NumberColumn', () => {
|
|
|
74
74
|
isTableHovered={true}
|
|
75
75
|
hoverRows={jest.fn()}
|
|
76
76
|
selectRow={jest.fn()}
|
|
77
|
+
selectRows={jest.fn()}
|
|
77
78
|
updateCellHoverLocation={jest.fn()}
|
|
78
79
|
tableWidth={760}
|
|
79
80
|
/>
|
|
@@ -111,6 +112,7 @@ describe('NumberColumn', () => {
|
|
|
111
112
|
}}
|
|
112
113
|
hoverRows={jest.fn()}
|
|
113
114
|
selectRow={jest.fn()}
|
|
115
|
+
selectRows={jest.fn()}
|
|
114
116
|
updateCellHoverLocation={jest.fn()}
|
|
115
117
|
tableWidth={760}
|
|
116
118
|
/>
|
|
@@ -30,8 +30,10 @@ import {
|
|
|
30
30
|
isSelectionType,
|
|
31
31
|
isTableSelected,
|
|
32
32
|
removeTable,
|
|
33
|
+
selectColumns as selectColumnsTransform,
|
|
33
34
|
selectColumn as selectColumnTransform,
|
|
34
35
|
selectionCell,
|
|
36
|
+
selectRows as selectRowsTransform,
|
|
35
37
|
selectRow as selectRowTransform,
|
|
36
38
|
setCellAttrs,
|
|
37
39
|
} from '@atlaskit/editor-tables/utils';
|
|
@@ -487,6 +489,53 @@ export const selectColumn = (column: number, expand?: boolean) =>
|
|
|
487
489
|
selectColumnTransform(column, expand)(tr).setMeta('addToHistory', false),
|
|
488
490
|
);
|
|
489
491
|
|
|
492
|
+
export const selectColumns = (columnIndexes: number[]) =>
|
|
493
|
+
createCommand(
|
|
494
|
+
(state) => {
|
|
495
|
+
if (!columnIndexes) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
const cells = columnIndexes
|
|
499
|
+
.map((column) => getCellsInColumn(column)(state.tr.selection))
|
|
500
|
+
.flat();
|
|
501
|
+
if (
|
|
502
|
+
!cells ||
|
|
503
|
+
!cells.length ||
|
|
504
|
+
cells.some((cell) => cell && typeof cell.pos !== 'number')
|
|
505
|
+
) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
const decorations = createColumnSelectedDecoration(
|
|
509
|
+
selectColumnsTransform(columnIndexes)(state.tr),
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
const decorationSet = updatePluginStateDecorations(
|
|
513
|
+
state,
|
|
514
|
+
decorations,
|
|
515
|
+
TableDecorations.COLUMN_SELECTED,
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
const cellsInFirstColumn = getCellsInColumn(Math.min(...columnIndexes))(
|
|
519
|
+
state.tr.selection,
|
|
520
|
+
);
|
|
521
|
+
if (!cellsInFirstColumn || cellsInFirstColumn.length === 0) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
const targetCellPosition = cellsInFirstColumn[0].pos;
|
|
525
|
+
|
|
526
|
+
return {
|
|
527
|
+
type: 'SELECT_COLUMN',
|
|
528
|
+
data: { targetCellPosition, decorationSet },
|
|
529
|
+
};
|
|
530
|
+
},
|
|
531
|
+
(tr: Transaction) => {
|
|
532
|
+
return selectColumnsTransform(columnIndexes)(tr).setMeta(
|
|
533
|
+
'addToHistory',
|
|
534
|
+
false,
|
|
535
|
+
);
|
|
536
|
+
},
|
|
537
|
+
);
|
|
538
|
+
|
|
490
539
|
export const selectRow = (row: number, expand?: boolean) =>
|
|
491
540
|
createCommand(
|
|
492
541
|
(state) => {
|
|
@@ -501,6 +550,35 @@ export const selectRow = (row: number, expand?: boolean) =>
|
|
|
501
550
|
(tr) => selectRowTransform(row, expand)(tr).setMeta('addToHistory', false),
|
|
502
551
|
);
|
|
503
552
|
|
|
553
|
+
export const selectRows = (rowIndexes: number[]) =>
|
|
554
|
+
createCommand(
|
|
555
|
+
(state) => {
|
|
556
|
+
if (rowIndexes.length === 0) {
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
const cells = rowIndexes
|
|
560
|
+
.map((row) => getCellsInRow(row)(state.tr.selection))
|
|
561
|
+
.flat();
|
|
562
|
+
if (
|
|
563
|
+
!cells ||
|
|
564
|
+
!cells.length ||
|
|
565
|
+
cells.some((cell) => cell && typeof cell.pos !== 'number')
|
|
566
|
+
) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
const cellsInFirstRow = getCellsInRow(Math.min(...rowIndexes))(
|
|
570
|
+
state.tr.selection,
|
|
571
|
+
);
|
|
572
|
+
if (!cellsInFirstRow || cellsInFirstRow.length === 0) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
const targetCellPosition = cellsInFirstRow[0].pos;
|
|
576
|
+
|
|
577
|
+
return { type: 'SET_TARGET_CELL_POSITION', data: { targetCellPosition } };
|
|
578
|
+
},
|
|
579
|
+
(tr) => selectRowsTransform(rowIndexes)(tr).setMeta('addToHistory', false),
|
|
580
|
+
);
|
|
581
|
+
|
|
504
582
|
export const showInsertColumnButton = (columnIndex: number) =>
|
|
505
583
|
createCommand(
|
|
506
584
|
(_) =>
|
|
@@ -303,13 +303,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
303
303
|
{
|
|
304
304
|
name: 'tableOverflowAnalyticsPlugin',
|
|
305
305
|
plugin: ({ dispatch, dispatchAnalyticsEvent }) =>
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
)
|
|
312
|
-
: undefined,
|
|
306
|
+
createTableOverflowAnalyticsPlugin(
|
|
307
|
+
dispatch,
|
|
308
|
+
dispatchAnalyticsEvent,
|
|
309
|
+
options?.tableResizingEnabled ?? false,
|
|
310
|
+
),
|
|
313
311
|
},
|
|
314
312
|
{
|
|
315
313
|
name: 'tableAnalyticsPlugin',
|
|
@@ -263,13 +263,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
263
263
|
|
|
264
264
|
eventDispatcher.on((stickyHeadersPluginKey as any).key, this.onStickyState);
|
|
265
265
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
266
|
+
const initialIsOveflowing =
|
|
267
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
268
|
+
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
270
269
|
|
|
271
|
-
|
|
272
|
-
}
|
|
270
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
273
271
|
}
|
|
274
272
|
|
|
275
273
|
componentWillUnmount() {
|
|
@@ -389,42 +387,37 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
389
387
|
this.handleTableResizingDebounced();
|
|
390
388
|
}
|
|
391
389
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
390
|
+
const newIsOverflowing =
|
|
391
|
+
this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
392
|
+
this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
396
393
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
394
|
+
const prevIsOverflowing =
|
|
395
|
+
prevState[ShadowEvent.SHOW_BEFORE_SHADOW] ||
|
|
396
|
+
prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
400
397
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
398
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
399
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
400
|
+
}
|
|
404
401
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
402
|
+
if (!this.isInitialOverflowSent) {
|
|
403
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
404
|
+
}
|
|
408
405
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
parentWidth: this.state?.parentWidth || 0,
|
|
425
|
-
}),
|
|
426
|
-
);
|
|
427
|
-
}
|
|
406
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
407
|
+
const {
|
|
408
|
+
dispatch,
|
|
409
|
+
state: { tr },
|
|
410
|
+
} = this.props.view;
|
|
411
|
+
|
|
412
|
+
dispatch(
|
|
413
|
+
tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
414
|
+
isOverflowing: newIsOverflowing,
|
|
415
|
+
wasOverflowing: prevIsOverflowing,
|
|
416
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
417
|
+
width: this.node.attrs.width || 0,
|
|
418
|
+
parentWidth: this.state?.parentWidth || 0,
|
|
419
|
+
}),
|
|
420
|
+
);
|
|
428
421
|
}
|
|
429
422
|
}
|
|
430
423
|
|
|
@@ -55,13 +55,11 @@ export const handleMouseDown = (
|
|
|
55
55
|
}
|
|
56
56
|
event.preventDefault();
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
dispatch(tr);
|
|
64
|
-
}
|
|
58
|
+
const tr = view.state.tr;
|
|
59
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
60
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN,
|
|
61
|
+
});
|
|
62
|
+
dispatch(tr);
|
|
65
63
|
|
|
66
64
|
const mouseDownTime = event.timeStamp;
|
|
67
65
|
const cell = state.doc.nodeAt(localResizeHandlePos);
|
|
@@ -7,48 +7,23 @@ import {
|
|
|
7
7
|
} from '../icons';
|
|
8
8
|
|
|
9
9
|
type HandleIconProps = {
|
|
10
|
-
|
|
11
|
-
hasMergedCells: boolean;
|
|
12
|
-
direction: 'row' | 'column';
|
|
13
|
-
isDragMenuOpen: boolean | undefined;
|
|
10
|
+
forceDefaultHandle: boolean;
|
|
14
11
|
isRowHandleHovered: boolean;
|
|
15
12
|
isColumnHandleHovered: boolean;
|
|
16
|
-
|
|
17
|
-
isCurrentColumnSelected: boolean;
|
|
18
|
-
dragMenuDirection: 'row' | 'column' | undefined;
|
|
13
|
+
hasMergedCells: boolean;
|
|
19
14
|
};
|
|
20
15
|
|
|
21
16
|
export const HandleIconComponent = (props: HandleIconProps) => {
|
|
22
17
|
const {
|
|
23
|
-
|
|
24
|
-
direction,
|
|
25
|
-
isDragMenuOpen,
|
|
18
|
+
forceDefaultHandle,
|
|
26
19
|
isRowHandleHovered,
|
|
27
20
|
isColumnHandleHovered,
|
|
28
21
|
hasMergedCells,
|
|
29
|
-
isCurrentRowSelected,
|
|
30
|
-
isCurrentColumnSelected,
|
|
31
|
-
dragMenuDirection,
|
|
32
22
|
} = props;
|
|
33
23
|
const isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
34
|
-
const isCurrentRowOrColumnSelected =
|
|
35
|
-
isCurrentRowSelected || isCurrentColumnSelected;
|
|
36
|
-
const isDragMenuOpenOnCurrentRowOrColumn =
|
|
37
|
-
isDragMenuOpen &&
|
|
38
|
-
dragMenuDirection === direction &&
|
|
39
|
-
isCurrentRowOrColumnSelected;
|
|
40
|
-
|
|
41
|
-
const isDragPossible = canDrag && !hasMergedCells;
|
|
42
|
-
|
|
43
|
-
const showNormalHandle = !isDragPossible ? (
|
|
44
|
-
<DragHandleDisabledIcon />
|
|
45
|
-
) : (
|
|
46
|
-
<DragHandleIcon />
|
|
47
|
-
);
|
|
48
24
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return showNormalHandle;
|
|
25
|
+
if (isHandleHovered || forceDefaultHandle) {
|
|
26
|
+
return hasMergedCells ? <DragHandleDisabledIcon /> : <DragHandleIcon />;
|
|
52
27
|
}
|
|
53
28
|
|
|
54
29
|
return <MinimisedHandleIcon />;
|
|
@@ -9,7 +9,6 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
9
9
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
10
10
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
11
11
|
|
|
12
|
-
import { getPluginState as getDragDropPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
13
12
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
14
13
|
import type { TableDirection } from '../../types';
|
|
15
14
|
import { TableCssClassName as ClassName } from '../../types';
|
|
@@ -23,6 +22,7 @@ type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
|
|
|
23
22
|
type DragHandleProps = {
|
|
24
23
|
tableLocalId: string;
|
|
25
24
|
indexes: number[];
|
|
25
|
+
forceDefaultHandle?: boolean;
|
|
26
26
|
previewWidth?: number;
|
|
27
27
|
previewHeight?: number;
|
|
28
28
|
direction?: TableDirection;
|
|
@@ -40,6 +40,7 @@ export const DragHandle = ({
|
|
|
40
40
|
direction = 'row',
|
|
41
41
|
appearance = 'default',
|
|
42
42
|
indexes,
|
|
43
|
+
forceDefaultHandle = false,
|
|
43
44
|
previewWidth,
|
|
44
45
|
previewHeight,
|
|
45
46
|
onMouseOver,
|
|
@@ -53,24 +54,11 @@ export const DragHandle = ({
|
|
|
53
54
|
const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(
|
|
54
55
|
null,
|
|
55
56
|
);
|
|
56
|
-
const { hoveredColumns, hoveredRows, hoveredCell } = getPluginState(
|
|
57
|
-
editorView.state,
|
|
58
|
-
);
|
|
59
57
|
|
|
60
|
-
const {
|
|
61
|
-
getDragDropPluginState(editorView.state);
|
|
58
|
+
const { hoveredColumns, hoveredRows } = getPluginState(editorView.state);
|
|
62
59
|
|
|
63
60
|
const { selection } = editorView.state;
|
|
64
61
|
|
|
65
|
-
const isCurrentRowSelected =
|
|
66
|
-
isDragMenuOpen &&
|
|
67
|
-
direction === 'row' &&
|
|
68
|
-
hoveredCell.rowIndex === dragMenuIndex;
|
|
69
|
-
const isCurrentColumnSelected =
|
|
70
|
-
isDragMenuOpen &&
|
|
71
|
-
direction === 'column' &&
|
|
72
|
-
hoveredCell.colIndex === dragMenuIndex;
|
|
73
|
-
|
|
74
62
|
const isRowHandleHovered = direction === 'row' && hoveredRows.length > 0;
|
|
75
63
|
const isColumnHandleHovered =
|
|
76
64
|
direction === 'column' && hoveredColumns.length > 0;
|
|
@@ -84,15 +72,10 @@ export const DragHandle = ({
|
|
|
84
72
|
);
|
|
85
73
|
|
|
86
74
|
const handleIconProps = {
|
|
87
|
-
|
|
88
|
-
hasMergedCells,
|
|
89
|
-
direction,
|
|
90
|
-
isDragMenuOpen,
|
|
91
|
-
isRowHandleHovered,
|
|
75
|
+
forceDefaultHandle,
|
|
92
76
|
isColumnHandleHovered,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
dragMenuDirection,
|
|
77
|
+
isRowHandleHovered,
|
|
78
|
+
hasMergedCells,
|
|
96
79
|
};
|
|
97
80
|
|
|
98
81
|
useEffect(() => {
|