@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/plugins/table/commands/index.js +12 -0
  3. package/dist/cjs/plugins/table/commands/misc.js +61 -1
  4. package/dist/cjs/plugins/table/index.js +1 -1
  5. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +22 -26
  6. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
  7. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
  8. package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
  9. package/dist/cjs/plugins/table/ui/DragHandle/index.js +8 -19
  10. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +70 -36
  11. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
  12. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +11 -0
  13. package/dist/es2019/plugins/table/commands/index.js +1 -1
  14. package/dist/es2019/plugins/table/commands/misc.js +46 -1
  15. package/dist/es2019/plugins/table/index.js +1 -1
  16. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +25 -29
  17. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
  18. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
  19. package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
  20. package/dist/es2019/plugins/table/ui/DragHandle/index.js +5 -18
  21. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
  22. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +3 -1
  23. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
  24. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +16 -1
  25. package/dist/esm/plugins/table/commands/index.js +1 -1
  26. package/dist/esm/plugins/table/commands/misc.js +61 -1
  27. package/dist/esm/plugins/table/index.js +1 -1
  28. package/dist/esm/plugins/table/nodeviews/TableComponent.js +22 -26
  29. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
  30. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
  31. package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
  32. package/dist/esm/plugins/table/ui/DragHandle/index.js +6 -17
  33. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
  34. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
  35. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -1
  36. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  37. package/dist/types/plugins/table/commands/misc.d.ts +2 -0
  38. package/dist/types/plugins/table/types.d.ts +1 -0
  39. package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
  40. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
  41. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  42. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  43. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
  44. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +2 -0
  45. package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
  46. package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
  47. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
  48. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  49. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  50. package/package.json +1 -4
  51. package/src/__tests__/unit/ui/RowDragControls.tsx +2 -0
  52. package/src/plugins/table/commands/index.ts +2 -0
  53. package/src/plugins/table/commands/misc.ts +78 -0
  54. package/src/plugins/table/index.tsx +5 -7
  55. package/src/plugins/table/nodeviews/TableComponent.tsx +31 -38
  56. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +2 -0
  57. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -7
  58. package/src/plugins/table/types.ts +2 -0
  59. package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +5 -30
  60. package/src/plugins/table/ui/DragHandle/index.tsx +6 -23
  61. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +134 -49
  62. package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +3 -3
  63. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +137 -44
  64. 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">>> & {
@@ -42,6 +42,7 @@ export default class TableFloatingControls extends Component<Props, State> {
42
42
  componentWillUnmount(): void;
43
43
  render(): JSX.Element | null;
44
44
  private selectRow;
45
+ private selectRows;
45
46
  private hoverRows;
46
47
  private updateCellHoverLocation;
47
48
  }
@@ -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;
@@ -421,3 +421,4 @@ export interface DraggableData {
421
421
  targetClosestEdge: Edge;
422
422
  direction: 1 | -1;
423
423
  }
424
+ export type HandleTypes = 'hover' | 'selected';
@@ -1,14 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  type HandleIconProps = {
3
- canDrag: boolean;
4
- hasMergedCells: boolean;
5
- direction: 'row' | 'column';
6
- isDragMenuOpen: boolean | undefined;
3
+ forceDefaultHandle: boolean;
7
4
  isRowHandleHovered: boolean;
8
5
  isColumnHandleHovered: boolean;
9
- isCurrentRowSelected: boolean;
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 {};
@@ -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">>> & {
@@ -42,6 +42,7 @@ export default class TableFloatingControls extends Component<Props, State> {
42
42
  componentWillUnmount(): void;
43
43
  render(): JSX.Element | null;
44
44
  private selectRow;
45
+ private selectRows;
45
46
  private hoverRows;
46
47
  private updateCellHoverLocation;
47
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.5.2",
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
  />
@@ -26,7 +26,9 @@ export {
26
26
  hideInsertColumnOrRowButton,
27
27
  moveCursorBackward,
28
28
  selectColumn,
29
+ selectColumns,
29
30
  selectRow,
31
+ selectRows,
30
32
  setCellAttr,
31
33
  setEditorFocus,
32
34
  setMultipleCellAttrs,
@@ -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
- getBooleanFF('platform.editor.table.overflow-state-analytics')
307
- ? createTableOverflowAnalyticsPlugin(
308
- dispatch,
309
- dispatchAnalyticsEvent,
310
- options?.tableResizingEnabled ?? false,
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
- if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
267
- const initialIsOveflowing =
268
- this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
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
- this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
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
- if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
393
- const newIsOverflowing =
394
- this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
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
- const prevIsOverflowing =
398
- prevState[ShadowEvent.SHOW_BEFORE_SHADOW] ||
399
- prevState[ShadowEvent.SHOW_AFTER_SHADOW];
394
+ const prevIsOverflowing =
395
+ prevState[ShadowEvent.SHOW_BEFORE_SHADOW] ||
396
+ prevState[ShadowEvent.SHOW_AFTER_SHADOW];
400
397
 
401
- if (this.initialOverflowCaptureTimerId) {
402
- clearTimeout(this.initialOverflowCaptureTimerId);
403
- }
398
+ if (this.initialOverflowCaptureTimerId) {
399
+ clearTimeout(this.initialOverflowCaptureTimerId);
400
+ }
404
401
 
405
- if (!this.isInitialOverflowSent) {
406
- this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
407
- }
402
+ if (!this.isInitialOverflowSent) {
403
+ this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
404
+ }
408
405
 
409
- if (
410
- this.isInitialOverflowSent &&
411
- prevIsOverflowing !== newIsOverflowing
412
- ) {
413
- const {
414
- dispatch,
415
- state: { tr },
416
- } = this.props.view;
417
-
418
- dispatch(
419
- tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
420
- isOverflowing: newIsOverflowing,
421
- wasOverflowing: prevIsOverflowing,
422
- editorWidth: this.props.containerWidth.width || 0,
423
- width: this.node.attrs.width || 0,
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
 
@@ -235,6 +235,8 @@ export const createPlugin = (
235
235
  targetAdjustedIndex + (direction === -1 ? 0 : -1),
236
236
  tr,
237
237
  )(editorView.state, editorView.dispatch);
238
+
239
+ editorView.focus();
238
240
  });
239
241
  },
240
242
  }),
@@ -55,13 +55,11 @@ export const handleMouseDown = (
55
55
  }
56
56
  event.preventDefault();
57
57
 
58
- if (getBooleanFF('platform.editor.table.overflow-state-analytics')) {
59
- const tr = view.state.tr;
60
- tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
61
- name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN,
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);
@@ -463,3 +463,5 @@ export interface DraggableData {
463
463
  targetClosestEdge: Edge;
464
464
  direction: 1 | -1;
465
465
  }
466
+
467
+ export type HandleTypes = 'hover' | 'selected';
@@ -7,48 +7,23 @@ import {
7
7
  } from '../icons';
8
8
 
9
9
  type HandleIconProps = {
10
- canDrag: boolean;
11
- hasMergedCells: boolean;
12
- direction: 'row' | 'column';
13
- isDragMenuOpen: boolean | undefined;
10
+ forceDefaultHandle: boolean;
14
11
  isRowHandleHovered: boolean;
15
12
  isColumnHandleHovered: boolean;
16
- isCurrentRowSelected: boolean;
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
- canDrag,
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
- // hoverred handle or open drag menu
50
- if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
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 { dragMenuDirection, isDragMenuOpen, dragMenuIndex } =
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
- canDrag,
88
- hasMergedCells,
89
- direction,
90
- isDragMenuOpen,
91
- isRowHandleHovered,
75
+ forceDefaultHandle,
92
76
  isColumnHandleHovered,
93
- isCurrentRowSelected,
94
- isCurrentColumnSelected,
95
- dragMenuDirection,
77
+ isRowHandleHovered,
78
+ hasMergedCells,
96
79
  };
97
80
 
98
81
  useEffect(() => {