@atlaskit/editor-plugin-table 5.3.9 → 5.3.11

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 (68) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/commands/hover.js +4 -2
  3. package/dist/cjs/plugins/table/event-handlers.js +7 -4
  4. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +3 -2
  5. package/dist/cjs/plugins/table/ui/DragHandle/index.js +11 -25
  6. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +59 -22
  7. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  8. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +15 -27
  9. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +68 -18
  10. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +47 -29
  11. package/dist/cjs/plugins/table/ui/common-styles.js +2 -2
  12. package/dist/cjs/plugins/table/ui/icons/DragHandleIcon.js +11 -52
  13. package/dist/es2019/plugins/table/commands/hover.js +4 -2
  14. package/dist/es2019/plugins/table/event-handlers.js +7 -4
  15. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +3 -2
  16. package/dist/es2019/plugins/table/ui/DragHandle/index.js +10 -24
  17. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +61 -18
  18. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  19. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +4 -20
  20. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +69 -17
  21. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +24 -2
  22. package/dist/es2019/plugins/table/ui/common-styles.js +64 -4
  23. package/dist/es2019/plugins/table/ui/icons/DragHandleIcon.js +11 -52
  24. package/dist/esm/plugins/table/commands/hover.js +4 -2
  25. package/dist/esm/plugins/table/event-handlers.js +7 -4
  26. package/dist/esm/plugins/table/nodeviews/TableComponent.js +3 -2
  27. package/dist/esm/plugins/table/ui/DragHandle/index.js +11 -25
  28. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +56 -21
  29. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  30. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +16 -28
  31. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -19
  32. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +48 -30
  33. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  34. package/dist/esm/plugins/table/ui/icons/DragHandleIcon.js +11 -51
  35. package/dist/types/plugins/table/commands/hover.d.ts +1 -1
  36. package/dist/types/plugins/table/types.d.ts +8 -4
  37. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +3 -3
  38. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +6 -5
  39. package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +3 -2
  40. package/dist/types/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +1 -1
  41. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +6 -4
  42. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  43. package/dist/types/plugins/table/ui/icons/DragHandleIcon.d.ts +1 -6
  44. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +1 -1
  45. package/dist/types-ts4.5/plugins/table/types.d.ts +8 -4
  46. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +3 -3
  47. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +6 -5
  48. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +3 -2
  49. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +1 -1
  50. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +6 -4
  51. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  52. package/dist/types-ts4.5/plugins/table/ui/icons/DragHandleIcon.d.ts +1 -6
  53. package/package.json +1 -1
  54. package/src/__tests__/unit/event-handlers.ts +4 -1
  55. package/src/__tests__/unit/ui/NumberColumn.tsx +5 -8
  56. package/src/__tests__/unit/ui/RowDragControls.tsx +6 -0
  57. package/src/plugins/table/commands/hover.ts +7 -2
  58. package/src/plugins/table/event-handlers.ts +18 -4
  59. package/src/plugins/table/nodeviews/TableComponent.tsx +3 -2
  60. package/src/plugins/table/types.ts +13 -4
  61. package/src/plugins/table/ui/DragHandle/index.tsx +10 -26
  62. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +90 -39
  63. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +5 -2
  64. package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +10 -15
  65. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +97 -28
  66. package/src/plugins/table/ui/TableFloatingControls/index.tsx +19 -3
  67. package/src/plugins/table/ui/common-styles.ts +67 -4
  68. package/src/plugins/table/ui/icons/DragHandleIcon.tsx +5 -69
@@ -7,6 +7,7 @@ export interface Props {
7
7
  hoverRows: (rows: number[], danger?: boolean) => void;
8
8
  hoveredRows?: number[];
9
9
  selectRow: (row: number, expand: boolean) => void;
10
+ updateCellHoverLocation: (rowIndex: number) => void;
10
11
  hasHeaderRow?: boolean;
11
12
  isInDanger?: boolean;
12
13
  isResizing?: boolean;
@@ -18,7 +19,6 @@ export default class NumberColumn extends Component<Props, any> {
18
19
  private hoverRows;
19
20
  private selectRow;
20
21
  private clearHoverSelection;
21
- private updateDragHandleLocation;
22
22
  private getCellStyles;
23
23
  private getClassNames;
24
24
  }
@@ -1,14 +1,16 @@
1
1
  import React from 'react';
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { CellHoverCoordinates } from '../../../types';
4
+ import type { CellHoverMeta } from '../../../types';
5
5
  type DragControlsProps = {
6
6
  editorView: EditorView;
7
7
  tableRef: HTMLTableElement;
8
8
  tableActive?: boolean;
9
- hoveredCell?: CellHoverCoordinates;
10
- hoverRows?: (rows: number[], danger?: boolean) => void;
11
- selectRow?: (row: number, expand: boolean) => void;
9
+ hoveredCell?: CellHoverMeta;
10
+ isInDanger?: boolean;
11
+ hoverRows: (rows: number[], danger?: boolean) => void;
12
+ selectRow: (row: number, expand: boolean) => void;
13
+ updateCellHoverLocation: (rowIndex: number) => void;
12
14
  };
13
15
  export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps<"intl">>> & {
14
16
  WrappedComponent: React.ComponentType<DragControlsProps & WrappedComponentProps<"intl">>;
@@ -3,7 +3,7 @@ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
3
3
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
- import type { CellHoverCoordinates } from '../../types';
6
+ import type { CellHoverMeta } from '../../types';
7
7
  export interface Props {
8
8
  editorView: EditorView;
9
9
  selection?: Selection;
@@ -18,7 +18,7 @@ export interface Props {
18
18
  hasHeaderRow?: boolean;
19
19
  headerRowHeight?: number;
20
20
  hoveredRows?: number[];
21
- hoveredCell?: CellHoverCoordinates;
21
+ hoveredCell?: CellHoverMeta;
22
22
  ordering?: TableColumnOrdering;
23
23
  stickyHeader?: RowStickyState;
24
24
  }
@@ -36,5 +36,6 @@ export default class TableFloatingControls extends Component<Props, State> {
36
36
  render(): JSX.Element | null;
37
37
  private selectRow;
38
38
  private hoverRows;
39
+ private updateCellHoverLocation;
39
40
  }
40
41
  export {};
@@ -1,7 +1,2 @@
1
1
  /// <reference types="react" />
2
- interface DragHandleIconProps {
3
- backgroundColor?: string;
4
- foregroundColor?: string;
5
- }
6
- export declare const DragHandleIcon: ({ backgroundColor, foregroundColor, }: DragHandleIconProps) => JSX.Element;
7
- export {};
2
+ export declare const DragHandleIcon: () => JSX.Element;
@@ -6,4 +6,4 @@ export declare const hoverTable: (isInDanger?: boolean, isSelected?: boolean) =>
6
6
  export declare const clearHoverSelection: () => import("@atlaskit/editor-common/types").Command;
7
7
  export declare const showResizeHandleLine: (cellColumnPositioning: CellColumnPositioning) => import("@atlaskit/editor-common/types").Command;
8
8
  export declare const hideResizeHandleLine: () => import("@atlaskit/editor-common/types").Command;
9
- export declare const hoverCell: (rowIndex?: number, colIndex?: number) => import("@atlaskit/editor-common/types").Command;
9
+ export declare const hoverCell: (rowIndex?: number, colIndex?: number, colWidth?: number, colHeight?: number) => import("@atlaskit/editor-common/types").Command;
@@ -44,15 +44,17 @@ export interface PluginConfig {
44
44
  }
45
45
  export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
46
46
  export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
47
- export type CellHoverCoordinates = {
47
+ export interface CellHoverMeta {
48
48
  colIndex?: number;
49
49
  rowIndex?: number;
50
- };
50
+ colWidth?: number;
51
+ colHeight?: number;
52
+ }
51
53
  export interface TablePluginState {
52
54
  editorHasFocus?: boolean;
53
55
  hoveredColumns: number[];
54
56
  hoveredRows: number[];
55
- hoveredCell: CellHoverCoordinates;
57
+ hoveredCell: CellHoverMeta;
56
58
  pluginConfig: PluginConfig;
57
59
  isHeaderColumnEnabled: boolean;
58
60
  isHeaderRowEnabled: boolean;
@@ -170,7 +172,9 @@ export type TablePluginAction = {
170
172
  };
171
173
  } | {
172
174
  type: 'HOVER_CELL';
173
- data: CellHoverCoordinates;
175
+ data: {
176
+ hoveredCell: CellHoverMeta;
177
+ };
174
178
  } | {
175
179
  type: 'SET_TARGET_CELL_POSITION';
176
180
  data: {
@@ -1,15 +1,15 @@
1
1
  import type { MouseEventHandler } from 'react';
2
- type DragHandleState = 'default' | 'selected' | 'disabled' | 'danger';
2
+ type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
3
3
  type DragHandleProps = {
4
4
  tableLocalId: string;
5
5
  indexes: number[];
6
6
  previewWidth?: number;
7
7
  previewHeight?: number;
8
8
  direction?: 'column' | 'row';
9
- state?: DragHandleState;
9
+ appearance?: DragHandleAppearance;
10
10
  onClick?: MouseEventHandler;
11
11
  onMouseOver?: MouseEventHandler;
12
12
  onMouseOut?: MouseEventHandler;
13
13
  };
14
- export declare const DragHandle: ({ tableLocalId, direction, state, indexes, previewWidth, previewHeight, onClick, onMouseOver, onMouseOut, }: DragHandleProps) => JSX.Element;
14
+ export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onClick, }: DragHandleProps) => JSX.Element;
15
15
  export {};
@@ -1,16 +1,17 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- import type { CellHoverCoordinates } from '../../../types';
4
- export interface Props {
3
+ import type { CellHoverMeta } from '../../../types';
4
+ export interface ColumnControlsProps {
5
5
  editorView: EditorView;
6
6
  tableActive?: boolean;
7
+ isInDanger?: boolean;
7
8
  tableRef: HTMLTableElement;
8
- hoveredCell?: CellHoverCoordinates;
9
+ hoveredCell?: CellHoverMeta;
9
10
  isResizing?: boolean;
10
11
  stickyTop?: number;
11
12
  localId?: string;
12
13
  rowHeights?: number[];
13
14
  colWidths?: (number | undefined)[];
14
15
  }
15
- export declare const ColumnControls: React.FC<Props>;
16
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, }: ColumnControlsProps) => JSX.Element;
16
17
  export default ColumnControls;
@@ -5,7 +5,7 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
7
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
8
- import type { CellHoverCoordinates } from '../../types';
8
+ import type { CellHoverMeta } from '../../types';
9
9
  export interface Props {
10
10
  editorView: EditorView;
11
11
  getEditorFeatureFlags: GetEditorFeatureFlags;
@@ -13,10 +13,11 @@ export interface Props {
13
13
  tableRef?: HTMLTableElement;
14
14
  getNode: () => PmNode;
15
15
  tableActive?: boolean;
16
+ isInDanger?: boolean;
16
17
  hasHeaderRow?: boolean;
17
18
  headerRowHeight?: number;
18
19
  hoveredRows?: number[];
19
- hoveredCell?: CellHoverCoordinates;
20
+ hoveredCell?: CellHoverMeta;
20
21
  isResizing?: boolean;
21
22
  ordering?: TableColumnOrdering;
22
23
  stickyHeader?: RowStickyState;
@@ -7,6 +7,7 @@ export interface Props {
7
7
  hoverRows: (rows: number[], danger?: boolean) => void;
8
8
  hoveredRows?: number[];
9
9
  selectRow: (row: number, expand: boolean) => void;
10
+ updateCellHoverLocation: (rowIndex: number) => void;
10
11
  hasHeaderRow?: boolean;
11
12
  isInDanger?: boolean;
12
13
  isResizing?: boolean;
@@ -18,7 +19,6 @@ export default class NumberColumn extends Component<Props, any> {
18
19
  private hoverRows;
19
20
  private selectRow;
20
21
  private clearHoverSelection;
21
- private updateDragHandleLocation;
22
22
  private getCellStyles;
23
23
  private getClassNames;
24
24
  }
@@ -1,14 +1,16 @@
1
1
  import React from 'react';
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { CellHoverCoordinates } from '../../../types';
4
+ import type { CellHoverMeta } from '../../../types';
5
5
  type DragControlsProps = {
6
6
  editorView: EditorView;
7
7
  tableRef: HTMLTableElement;
8
8
  tableActive?: boolean;
9
- hoveredCell?: CellHoverCoordinates;
10
- hoverRows?: (rows: number[], danger?: boolean) => void;
11
- selectRow?: (row: number, expand: boolean) => void;
9
+ hoveredCell?: CellHoverMeta;
10
+ isInDanger?: boolean;
11
+ hoverRows: (rows: number[], danger?: boolean) => void;
12
+ selectRow: (row: number, expand: boolean) => void;
13
+ updateCellHoverLocation: (rowIndex: number) => void;
12
14
  };
13
15
  export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps<"intl">>> & {
14
16
  WrappedComponent: React.ComponentType<DragControlsProps & WrappedComponentProps<"intl">>;
@@ -3,7 +3,7 @@ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
3
3
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
- import type { CellHoverCoordinates } from '../../types';
6
+ import type { CellHoverMeta } from '../../types';
7
7
  export interface Props {
8
8
  editorView: EditorView;
9
9
  selection?: Selection;
@@ -18,7 +18,7 @@ export interface Props {
18
18
  hasHeaderRow?: boolean;
19
19
  headerRowHeight?: number;
20
20
  hoveredRows?: number[];
21
- hoveredCell?: CellHoverCoordinates;
21
+ hoveredCell?: CellHoverMeta;
22
22
  ordering?: TableColumnOrdering;
23
23
  stickyHeader?: RowStickyState;
24
24
  }
@@ -36,5 +36,6 @@ export default class TableFloatingControls extends Component<Props, State> {
36
36
  render(): JSX.Element | null;
37
37
  private selectRow;
38
38
  private hoverRows;
39
+ private updateCellHoverLocation;
39
40
  }
40
41
  export {};
@@ -1,7 +1,2 @@
1
1
  /// <reference types="react" />
2
- interface DragHandleIconProps {
3
- backgroundColor?: string;
4
- foregroundColor?: string;
5
- }
6
- export declare const DragHandleIcon: ({ backgroundColor, foregroundColor, }: DragHandleIconProps) => JSX.Element;
7
- export {};
2
+ export declare const DragHandleIcon: () => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.3.9",
3
+ "version": "5.3.11",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -301,7 +301,10 @@ describe('withCellTracking', () => {
301
301
  withCellTracking(jest.fn())(editorView, event as any);
302
302
 
303
303
  const pluginState = getPluginState(editorView.state);
304
- expect(pluginState.hoveredCell).toEqual({ colIndex: 0, rowIndex: 0 });
304
+ expect(pluginState.hoveredCell).toEqual({
305
+ colIndex: undefined,
306
+ rowIndex: undefined,
307
+ });
305
308
  });
306
309
  });
307
310
  });
@@ -27,9 +27,7 @@ import {
27
27
  } from '@atlaskit/editor-test-helpers/doc-builder';
28
28
 
29
29
  import tablePlugin from '../../../plugins/table-plugin';
30
- import { getPluginState } from '../../../plugins/table/pm-plugins/plugin-factory';
31
30
  import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
32
- // import type { TablePluginState } from '../../../plugins/table/types';
33
31
  import { TableCssClassName as ClassName } from '../../../plugins/table/types';
34
32
  import NumberColumn from '../../../plugins/table/ui/TableFloatingControls/NumberColumn';
35
33
 
@@ -55,6 +53,7 @@ describe('NumberColumn', () => {
55
53
  doc(p('text'), table()(tr(tdEmpty, tdEmpty, tdEmpty))),
56
54
  { dragAndDropEnabled: true },
57
55
  );
56
+ const hoverCellLocationMock = jest.fn();
58
57
  const ref = editorView.dom.querySelector('table');
59
58
 
60
59
  const { container } = render(
@@ -65,6 +64,7 @@ describe('NumberColumn', () => {
65
64
  editorView={editorView}
66
65
  hoverRows={jest.fn()}
67
66
  selectRow={jest.fn()}
67
+ updateCellHoverLocation={hoverCellLocationMock}
68
68
  isDragAndDropEnabled
69
69
  />
70
70
  </IntlProvider>,
@@ -76,12 +76,7 @@ describe('NumberColumn', () => {
76
76
 
77
77
  fireEvent.mouseOver(firstNumberedCell!);
78
78
 
79
- const pluginState = getPluginState(editorView.state);
80
- // colIndex is not defined yet, keep undefined
81
- expect(pluginState.hoveredCell).toEqual({
82
- colIndex: undefined,
83
- rowIndex: 0,
84
- });
79
+ expect(hoverCellLocationMock).toHaveBeenCalledWith(0);
85
80
  });
86
81
 
87
82
  it('should render button disabled numbered column cells - when drag and drop is enabled', () => {
@@ -99,6 +94,7 @@ describe('NumberColumn', () => {
99
94
  editorView={editorView}
100
95
  hoverRows={jest.fn()}
101
96
  selectRow={jest.fn()}
97
+ updateCellHoverLocation={jest.fn()}
102
98
  isDragAndDropEnabled
103
99
  />
104
100
  </IntlProvider>,
@@ -130,6 +126,7 @@ describe('NumberColumn', () => {
130
126
  editorView={editorView}
131
127
  hoverRows={jest.fn()}
132
128
  selectRow={jest.fn()}
129
+ updateCellHoverLocation={jest.fn()}
133
130
  isDragAndDropEnabled={false}
134
131
  />
135
132
  </IntlProvider>,
@@ -70,6 +70,9 @@ describe('NumberColumn', () => {
70
70
  tableActive
71
71
  editorView={editorView}
72
72
  hoveredCell={{ rowIndex: 1, colIndex: 1 }}
73
+ hoverRows={jest.fn()}
74
+ selectRow={jest.fn()}
75
+ updateCellHoverLocation={jest.fn()}
73
76
  />
74
77
  </IntlProvider>,
75
78
  );
@@ -105,6 +108,9 @@ describe('NumberColumn', () => {
105
108
  colIndex: undefined,
106
109
  rowIndex: undefined,
107
110
  }}
111
+ hoverRows={jest.fn()}
112
+ selectRow={jest.fn()}
113
+ updateCellHoverLocation={jest.fn()}
108
114
  />
109
115
  </IntlProvider>,
110
116
  );
@@ -191,13 +191,18 @@ export const hideResizeHandleLine = () =>
191
191
  },
192
192
  }));
193
193
 
194
- export const hoverCell = (rowIndex?: number, colIndex?: number) =>
194
+ export const hoverCell = (
195
+ rowIndex?: number,
196
+ colIndex?: number,
197
+ colWidth?: number,
198
+ colHeight?: number,
199
+ ) =>
195
200
  createCommand(
196
201
  () => {
197
202
  return {
198
203
  type: 'HOVER_CELL',
199
204
  data: {
200
- hoveredCell: { rowIndex, colIndex },
205
+ hoveredCell: { rowIndex, colIndex, colWidth, colHeight },
201
206
  },
202
207
  };
203
208
  },
@@ -288,7 +288,7 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
288
288
  }
289
289
 
290
290
  if (isDragAndDropEnabled) {
291
- hoverCell(undefined, undefined)(state, dispatch);
291
+ hoverCell()(state, dispatch);
292
292
  }
293
293
 
294
294
  if (
@@ -512,8 +512,9 @@ const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
512
512
  const maybeTableCell = isElementInTableCell(
513
513
  target as HTMLElement,
514
514
  ) as HTMLTableCellElement | null;
515
+ const tableRef = getPluginState(view.state).tableRef;
515
516
 
516
- if (!maybeTableCell) {
517
+ if (!maybeTableCell || !tableRef) {
517
518
  return;
518
519
  }
519
520
 
@@ -525,8 +526,21 @@ const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
525
526
  const rowIndex = rowElement && rowElement.rowIndex;
526
527
  const { hoveredCell } = getPluginState(view.state);
527
528
 
528
- if (hoveredCell.colIndex !== colIndex || hoveredCell.rowIndex !== rowIndex) {
529
- hoverCell(rowIndex, colIndex)(view.state, view.dispatch);
529
+ const colHeight = tableRef.offsetHeight;
530
+ const colWidth = maybeTableCell.offsetWidth;
531
+
532
+ if (
533
+ hoveredCell.colIndex !== colIndex ||
534
+ hoveredCell.rowIndex !== rowIndex ||
535
+ hoveredCell.colWidth !== colWidth ||
536
+ hoveredCell.colHeight !== colHeight
537
+ ) {
538
+ hoverCell(
539
+ rowIndex,
540
+ colIndex,
541
+ colWidth,
542
+ colHeight,
543
+ )(view.state, view.dispatch);
530
544
  }
531
545
  };
532
546
 
@@ -435,12 +435,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
435
435
  </div>
436
436
  );
437
437
 
438
- const colControls = (
438
+ const colControls = isDragAndDropEnabled ? (
439
439
  <TableFloatingColumnControls
440
440
  editorView={view}
441
441
  tableRef={tableRef}
442
442
  getNode={getNode}
443
443
  tableActive={tableActive}
444
+ isInDanger={isInDanger}
444
445
  hoveredRows={hoveredRows}
445
446
  hoveredCell={hoveredCell}
446
447
  isResizing={isResizing}
@@ -452,7 +453,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
452
453
  stickyHeader={this.state.stickyHeader}
453
454
  getEditorFeatureFlags={this.props.getEditorFeatureFlags}
454
455
  />
455
- );
456
+ ) : null;
456
457
 
457
458
  const shadowPadding =
458
459
  allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
@@ -85,14 +85,18 @@ export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
85
85
  *
86
86
  */
87
87
  export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
88
-
89
- export type CellHoverCoordinates = { colIndex?: number; rowIndex?: number };
88
+ export interface CellHoverMeta {
89
+ colIndex?: number;
90
+ rowIndex?: number;
91
+ colWidth?: number;
92
+ colHeight?: number;
93
+ }
90
94
 
91
95
  export interface TablePluginState {
92
96
  editorHasFocus?: boolean;
93
97
  hoveredColumns: number[];
94
98
  hoveredRows: number[];
95
- hoveredCell: CellHoverCoordinates;
99
+ hoveredCell: CellHoverMeta;
96
100
  pluginConfig: PluginConfig;
97
101
  isHeaderColumnEnabled: boolean;
98
102
  isHeaderRowEnabled: boolean;
@@ -200,7 +204,12 @@ export type TablePluginAction =
200
204
  | { type: 'CLEAR_HOVER_SELECTION'; data: { decorationSet: DecorationSet } }
201
205
  | { type: 'SHOW_RESIZE_HANDLE_LINE'; data: { decorationSet: DecorationSet } }
202
206
  | { type: 'HIDE_RESIZE_HANDLE_LINE'; data: { decorationSet: DecorationSet } }
203
- | { type: 'HOVER_CELL'; data: CellHoverCoordinates }
207
+ | {
208
+ type: 'HOVER_CELL';
209
+ data: {
210
+ hoveredCell: CellHoverMeta;
211
+ };
212
+ }
204
213
  | { type: 'SET_TARGET_CELL_POSITION'; data: { targetCellPosition?: number } }
205
214
  | {
206
215
  type: 'SELECT_COLUMN';
@@ -1,18 +1,17 @@
1
1
  import type { MouseEventHandler } from 'react';
2
2
  import React, { useEffect, useRef, useState } from 'react';
3
3
 
4
+ import classnames from 'classnames';
4
5
  import ReactDOM from 'react-dom';
5
6
 
6
7
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
7
8
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
8
- import { N200, N700 } from '@atlaskit/theme/colors';
9
- import { token } from '@atlaskit/tokens';
10
9
 
11
10
  import { TableCssClassName as ClassName } from '../../types';
12
11
  import { DragPreview } from '../DragPreview';
13
12
  import { DragHandleIcon } from '../icons';
14
13
 
15
- type DragHandleState = 'default' | 'selected' | 'disabled' | 'danger';
14
+ type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
16
15
 
17
16
  type DragHandleProps = {
18
17
  tableLocalId: string;
@@ -20,39 +19,24 @@ type DragHandleProps = {
20
19
  previewWidth?: number;
21
20
  previewHeight?: number;
22
21
  direction?: 'column' | 'row';
23
- state?: DragHandleState;
22
+ appearance?: DragHandleAppearance;
24
23
  onClick?: MouseEventHandler;
25
24
  onMouseOver?: MouseEventHandler;
26
25
  onMouseOut?: MouseEventHandler;
27
26
  };
28
27
 
29
- const mapStateToProps = (state: DragHandleState) => {
30
- switch (state) {
31
- case 'danger':
32
- case 'disabled':
33
- case 'selected':
34
- case 'default':
35
- default:
36
- return {
37
- backgroundColor: token('color.background.accent.gray.subtlest', N200),
38
- foregroundColor: token('color.icon.subtle', N700),
39
- };
40
- }
41
- };
42
-
43
28
  export const DragHandle = ({
44
29
  tableLocalId,
45
30
  direction = 'row',
46
- state = 'default',
31
+ appearance = 'default',
47
32
  indexes,
48
33
  previewWidth,
49
34
  previewHeight,
50
- onClick,
51
35
  onMouseOver,
52
36
  onMouseOut,
37
+ onClick,
53
38
  }: DragHandleProps) => {
54
39
  const dragHandleDivRef = useRef<HTMLButtonElement>(null);
55
- const iconProps = mapStateToProps(state);
56
40
  const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(
57
41
  null,
58
42
  );
@@ -92,18 +76,18 @@ export const DragHandle = ({
92
76
 
93
77
  return (
94
78
  <button
95
- className={ClassName.DRAG_HANDLE_BUTTON_CONTAINER}
79
+ className={classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance)}
96
80
  ref={dragHandleDivRef}
97
81
  style={{
98
- backgroundColor: `${token('elevation.surface', 'white')}`,
99
- borderRadius: '4px',
100
- border: `2px solid ${token('elevation.surface', 'white')}`,
101
82
  transform: direction === 'column' ? 'none' : 'rotate(90deg)',
102
83
  pointerEvents: 'auto',
103
84
  }}
104
85
  data-testid="table-floating-column-controls-drag-handle"
86
+ onMouseOver={onMouseOver}
87
+ onMouseOut={onMouseOut}
88
+ onClick={onClick}
105
89
  >
106
- <DragHandleIcon {...iconProps} />
90
+ <DragHandleIcon />
107
91
  {previewContainer &&
108
92
  previewWidth !== undefined &&
109
93
  previewHeight !== undefined &&