@atlaskit/editor-plugin-table 5.3.0 → 5.3.2

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 (186) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/table/commands/hover.js +17 -8
  3. package/dist/cjs/plugins/table/commands/index.js +6 -0
  4. package/dist/cjs/plugins/table/commands/misc.js +1 -7
  5. package/dist/cjs/plugins/table/event-handlers.js +29 -2
  6. package/dist/cjs/plugins/table/index.js +1 -1
  7. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -3
  8. package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
  9. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +7 -3
  10. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  11. package/dist/cjs/plugins/table/pm-plugins/default-table-selection.js +14 -1
  12. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +36 -7
  13. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +69 -7
  14. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
  15. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/utils/index.js +12 -0
  16. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +59 -0
  17. package/dist/cjs/plugins/table/pm-plugins/main.js +5 -5
  18. package/dist/cjs/plugins/table/reducer.js +2 -1
  19. package/dist/cjs/plugins/table/types.js +14 -1
  20. package/dist/cjs/plugins/table/ui/DragHandle/index.js +50 -0
  21. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +53 -14
  22. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +114 -0
  23. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +53 -0
  24. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +11 -106
  25. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +16 -6
  26. package/dist/cjs/plugins/table/ui/common-styles.js +9 -6
  27. package/dist/cjs/plugins/table/ui/consts.js +3 -1
  28. package/dist/cjs/plugins/table/ui/ui-styles.js +21 -9
  29. package/dist/cjs/plugins/table/utils/decoration.js +111 -19
  30. package/dist/cjs/plugins/table/utils/dom.js +7 -1
  31. package/dist/cjs/plugins/table/utils/index.js +38 -1
  32. package/dist/cjs/plugins/table/utils/merged-cells.js +66 -0
  33. package/dist/es2019/plugins/table/commands/hover.js +12 -8
  34. package/dist/es2019/plugins/table/commands/index.js +1 -1
  35. package/dist/es2019/plugins/table/commands/misc.js +1 -7
  36. package/dist/es2019/plugins/table/event-handlers.js +28 -2
  37. package/dist/es2019/plugins/table/index.js +1 -1
  38. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -3
  39. package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
  40. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +8 -6
  41. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  42. package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +13 -0
  43. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +35 -7
  44. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +69 -4
  45. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
  46. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/utils/index.js +1 -0
  47. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +56 -0
  48. package/dist/es2019/plugins/table/pm-plugins/main.js +6 -5
  49. package/dist/es2019/plugins/table/reducer.js +2 -1
  50. package/dist/es2019/plugins/table/types.js +14 -1
  51. package/dist/es2019/plugins/table/ui/DragHandle/index.js +41 -0
  52. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -10
  53. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +86 -0
  54. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +43 -0
  55. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -88
  56. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -7
  57. package/dist/es2019/plugins/table/ui/common-styles.js +49 -13
  58. package/dist/es2019/plugins/table/ui/consts.js +2 -0
  59. package/dist/es2019/plugins/table/ui/ui-styles.js +171 -15
  60. package/dist/es2019/plugins/table/utils/decoration.js +106 -18
  61. package/dist/es2019/plugins/table/utils/dom.js +2 -0
  62. package/dist/es2019/plugins/table/utils/index.js +4 -3
  63. package/dist/es2019/plugins/table/utils/merged-cells.js +48 -0
  64. package/dist/esm/plugins/table/commands/hover.js +16 -8
  65. package/dist/esm/plugins/table/commands/index.js +1 -1
  66. package/dist/esm/plugins/table/commands/misc.js +1 -7
  67. package/dist/esm/plugins/table/event-handlers.js +29 -2
  68. package/dist/esm/plugins/table/index.js +1 -1
  69. package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -3
  70. package/dist/esm/plugins/table/nodeviews/table.js +4 -2
  71. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +8 -6
  72. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  73. package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +13 -0
  74. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +36 -7
  75. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +65 -4
  76. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +2 -0
  77. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/utils/index.js +1 -0
  78. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +53 -0
  79. package/dist/esm/plugins/table/pm-plugins/main.js +7 -7
  80. package/dist/esm/plugins/table/reducer.js +2 -1
  81. package/dist/esm/plugins/table/types.js +14 -1
  82. package/dist/esm/plugins/table/ui/DragHandle/index.js +41 -0
  83. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -15
  84. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +104 -0
  85. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -0
  86. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -104
  87. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +17 -7
  88. package/dist/esm/plugins/table/ui/common-styles.js +11 -8
  89. package/dist/esm/plugins/table/ui/consts.js +2 -0
  90. package/dist/esm/plugins/table/ui/ui-styles.js +21 -9
  91. package/dist/esm/plugins/table/utils/decoration.js +110 -18
  92. package/dist/esm/plugins/table/utils/dom.js +6 -0
  93. package/dist/esm/plugins/table/utils/index.js +4 -3
  94. package/dist/esm/plugins/table/utils/merged-cells.js +60 -0
  95. package/dist/types/plugins/table/commands/hover.d.ts +2 -1
  96. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  97. package/dist/types/plugins/table/event-handlers.d.ts +1 -0
  98. package/dist/types/plugins/table/nodeviews/types.d.ts +4 -3
  99. package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
  100. package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
  101. package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
  102. package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +5 -1
  103. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +6 -1
  104. package/dist/types/plugins/table/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
  105. package/dist/types/plugins/table/pm-plugins/drag-and-drop/utils/monitor.d.ts +3 -0
  106. package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
  107. package/dist/types/plugins/table/types.d.ts +35 -2
  108. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +11 -0
  109. package/dist/types/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
  110. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
  111. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
  112. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
  113. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  114. package/dist/types/plugins/table/ui/consts.d.ts +2 -0
  115. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
  116. package/dist/types/plugins/table/utils/decoration.d.ts +4 -2
  117. package/dist/types/plugins/table/utils/dom.d.ts +2 -0
  118. package/dist/types/plugins/table/utils/index.d.ts +3 -2
  119. package/dist/types/plugins/table/utils/merged-cells.d.ts +3 -0
  120. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
  121. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
  122. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -0
  123. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +4 -3
  124. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
  125. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
  126. package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
  127. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +5 -1
  128. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +6 -1
  129. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
  130. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/utils/monitor.d.ts +3 -0
  131. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
  132. package/dist/types-ts4.5/plugins/table/types.d.ts +35 -2
  133. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +11 -0
  134. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
  135. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
  136. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
  137. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
  138. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  139. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
  140. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
  141. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +4 -2
  142. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +2 -0
  143. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +3 -2
  144. package/dist/types-ts4.5/plugins/table/utils/merged-cells.d.ts +3 -0
  145. package/package.json +6 -2
  146. package/src/__tests__/unit/event-handlers.ts +74 -1
  147. package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +35 -15
  148. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +146 -42
  149. package/src/__tests__/unit/ui/NumberColumn.tsx +148 -0
  150. package/src/__tests__/unit/ui/RowControls.tsx +4 -4
  151. package/src/__tests__/unit/ui/RowDragControls.tsx +118 -0
  152. package/src/__tests__/unit/ui/TableFloatingControls.tsx +9 -5
  153. package/src/plugins/table/commands/hover.ts +16 -7
  154. package/src/plugins/table/commands/index.ts +1 -0
  155. package/src/plugins/table/commands/misc.ts +0 -5
  156. package/src/plugins/table/event-handlers.ts +49 -2
  157. package/src/plugins/table/index.tsx +1 -1
  158. package/src/plugins/table/nodeviews/TableComponent.tsx +3 -2
  159. package/src/plugins/table/nodeviews/table.tsx +2 -0
  160. package/src/plugins/table/nodeviews/types.ts +4 -3
  161. package/src/plugins/table/pm-plugins/decorations/plugin.ts +13 -4
  162. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +10 -5
  163. package/src/plugins/table/pm-plugins/default-table-selection.ts +10 -0
  164. package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +6 -1
  165. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +58 -8
  166. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +77 -4
  167. package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +2 -0
  168. package/src/plugins/table/pm-plugins/drag-and-drop/utils/index.ts +1 -0
  169. package/src/plugins/table/pm-plugins/drag-and-drop/utils/monitor.ts +72 -0
  170. package/src/plugins/table/pm-plugins/main.ts +9 -4
  171. package/src/plugins/table/reducer.ts +2 -1
  172. package/src/plugins/table/types.ts +37 -3
  173. package/src/plugins/table/ui/DragHandle/index.tsx +57 -0
  174. package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +68 -30
  175. package/src/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.tsx +129 -0
  176. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +75 -0
  177. package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +2 -135
  178. package/src/plugins/table/ui/TableFloatingControls/index.tsx +43 -24
  179. package/src/plugins/table/ui/common-styles.ts +54 -11
  180. package/src/plugins/table/ui/consts.ts +2 -0
  181. package/src/plugins/table/ui/ui-styles.ts +173 -14
  182. package/src/plugins/table/utils/decoration.ts +176 -27
  183. package/src/plugins/table/utils/dom.ts +8 -0
  184. package/src/plugins/table/utils/index.ts +5 -0
  185. package/src/plugins/table/utils/merged-cells.ts +67 -0
  186. package/tsconfig.app.json +3 -0
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasMergedCellsInRow = exports.hasMergedCellsInColumn = void 0;
7
+ var _editorTables = require("@atlaskit/editor-tables");
8
+ var hasMergedCells = function hasMergedCells(indexes, normalizeRect) {
9
+ return function (selection) {
10
+ var table = (0, _editorTables.findTable)(selection);
11
+ if (!table) {
12
+ return false;
13
+ }
14
+ var map = _editorTables.TableMap.get(table.node);
15
+ var cellPositions = new Set();
16
+ var mergedCells = new Set();
17
+ map.map.forEach(function (value) {
18
+ if (cellPositions.has(value)) {
19
+ mergedCells.add(value);
20
+ } else {
21
+ cellPositions.add(value);
22
+ }
23
+ });
24
+ if (!mergedCells.size) {
25
+ return false;
26
+ }
27
+ return (Array.isArray(indexes) ? indexes : [indexes]).map(function (index) {
28
+ return normalizeRect(index, map);
29
+ }).filter(function (rect) {
30
+ return rect.left < rect.right && rect.top < rect.bottom;
31
+ }).some(function (rect) {
32
+ var n = (rect.right - rect.left) * (rect.bottom - rect.top);
33
+ var cells = map.cellsInRect(rect);
34
+ if (cells.length !== n) {
35
+ // We can quickly assume that if the amount of cells from the map is different to what the rect says
36
+ // then there is most likely merged cells across this area which is removing cells
37
+ return true;
38
+ }
39
+ return cells.some(function (nodePos) {
40
+ return mergedCells.has(nodePos);
41
+ });
42
+ });
43
+ };
44
+ };
45
+ var hasMergedCellsInColumn = exports.hasMergedCellsInColumn = function hasMergedCellsInColumn(columnIndexes) {
46
+ return hasMergedCells(columnIndexes, function (index, map) {
47
+ var x = Math.max(Math.min(index, map.width - 1), 0); // clamped index
48
+ return {
49
+ left: x,
50
+ right: x === index ? x + 1 : x,
51
+ top: 0,
52
+ bottom: map.height
53
+ };
54
+ });
55
+ };
56
+ var hasMergedCellsInRow = exports.hasMergedCellsInRow = function hasMergedCellsInRow(rowIndexes) {
57
+ return hasMergedCells(rowIndexes, function (index, map) {
58
+ var y = Math.max(Math.min(index, map.height - 1), 0); // clamped index
59
+ return {
60
+ left: 0,
61
+ right: map.width,
62
+ top: y,
63
+ bottom: y === index ? y + 1 : y
64
+ };
65
+ });
66
+ };
@@ -4,13 +4,7 @@ import { findTable, getCellsInColumn, getCellsInRow } from '@atlaskit/editor-tab
4
4
  import { createCommand } from '../pm-plugins/plugin-factory';
5
5
  import { TableDecorations } from '../types';
6
6
  import { createCellHoverDecoration, createColumnLineResize, createControlsHoverDecoration, getMergedCellsPositions, updatePluginStateDecorations } from '../utils';
7
- // #endregion
8
-
9
- // #region Utils
10
7
  const makeArray = n => Array.from(Array(n).keys());
11
- // #endregion
12
-
13
- // #region Commands
14
8
  export const hoverMergedCells = () => createCommand(state => {
15
9
  const mergedCellsPositions = getMergedCellsPositions(state.tr);
16
10
  if (!mergedCellsPositions.length) {
@@ -27,7 +21,7 @@ export const hoverMergedCells = () => createCommand(state => {
27
21
  }));
28
22
  const decorations = createCellHoverDecoration(mergedCells);
29
23
  return {
30
- type: 'HOVER_CELLS',
24
+ type: 'HOVER_MERGED_CELLS',
31
25
  data: {
32
26
  decorationSet: updatePluginStateDecorations(state, decorations, TableDecorations.CELL_CONTROLS_HOVER)
33
27
  }
@@ -105,4 +99,14 @@ export const hideResizeHandleLine = () => createCommand(state => ({
105
99
  decorationSet: updatePluginStateDecorations(state, [], TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
106
100
  }
107
101
  }));
108
- // #endregion
102
+ export const hoverCell = (rowIndex, colIndex) => createCommand(() => {
103
+ return {
104
+ type: 'HOVER_CELL',
105
+ data: {
106
+ hoveredCell: {
107
+ rowIndex,
108
+ colIndex
109
+ }
110
+ }
111
+ };
112
+ }, tr => tr.setMeta('addToHistory', false));
@@ -1,4 +1,4 @@
1
- export { hoverColumns, hoverRows, hoverTable, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine } from './hover';
1
+ export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine } from './hover';
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';
@@ -13,11 +13,6 @@ import { TableCssClassName as ClassName, TableDecorations } from '../types';
13
13
  import { createColumnControlsDecoration, createColumnSelectedDecoration } from '../utils/decoration';
14
14
  import { checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isIsolating } from '../utils/nodes';
15
15
  import { updatePluginStateDecorations } from '../utils/update-plugin-state-decorations';
16
- // #endregion
17
-
18
- // #endregion
19
-
20
- // #region Commands
21
16
  export const setEditorFocus = editorHasFocus => createCommand({
22
17
  type: 'SET_EDITOR_FOCUS',
23
18
  data: {
@@ -419,5 +414,4 @@ export const addBoldInEmptyHeaderCells = tableCellHeader => (state, dispatch) =>
419
414
  return true;
420
415
  }
421
416
  return false;
422
- };
423
- // #endregion
417
+ };
@@ -4,7 +4,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
6
  import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
7
- import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
7
+ import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
8
8
  import { getPluginState } from './pm-plugins/plugin-factory';
9
9
  import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
10
10
  import { deleteColumns, deleteRows } from './transforms';
@@ -171,12 +171,16 @@ export const handleMouseLeave = (view, event) => {
171
171
  } = view;
172
172
  const {
173
173
  insertColumnButtonIndex,
174
- insertRowButtonIndex
174
+ insertRowButtonIndex,
175
+ isDragAndDropEnabled
175
176
  } = getPluginState(state);
176
177
  const target = event.target;
177
178
  if (isTableControlsButton(target)) {
178
179
  return true;
179
180
  }
181
+ if (isDragAndDropEnabled) {
182
+ hoverCell(undefined, undefined)(state, dispatch);
183
+ }
180
184
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
181
185
  return true;
182
186
  }
@@ -326,4 +330,26 @@ export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mo
326
330
  return false;
327
331
  }
328
332
  return eventHandler(view, mouseEvent, elementContentRects);
333
+ };
334
+ const trackCellLocation = (view, mouseEvent) => {
335
+ const target = mouseEvent.target;
336
+ const maybeTableCell = isElementInTableCell(target);
337
+ if (!maybeTableCell) {
338
+ return;
339
+ }
340
+ const colIndex = maybeTableCell.cellIndex;
341
+ const rowElement = closestElement(target, 'tr');
342
+ const rowIndex = rowElement && rowElement.rowIndex;
343
+ const {
344
+ hoveredCell
345
+ } = getPluginState(view.state);
346
+ if (hoveredCell.colIndex !== colIndex || hoveredCell.rowIndex !== rowIndex) {
347
+ hoverCell(rowIndex, colIndex)(view.state, view.dispatch);
348
+ }
349
+ };
350
+ export const withCellTracking = (eventHandler, elementContentRects) => (view, mouseEvent) => {
351
+ if (getPluginState(view.state).isDragAndDropEnabled) {
352
+ trackCellLocation(view, mouseEvent);
353
+ }
354
+ return eventHandler(view, mouseEvent, elementContentRects);
329
355
  };
@@ -106,7 +106,7 @@ const tablesPlugin = ({
106
106
  getEditorFeatureFlags,
107
107
  dragAndDropEnabled
108
108
  } = options || {};
109
- return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
109
+ return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
110
110
  }
111
111
  }, {
112
112
  name: 'tablePMColResizing',
@@ -466,7 +466,8 @@ class TableComponent extends React.Component {
466
466
  // doesn't work well with WithPluginState
467
467
  const {
468
468
  isInDanger,
469
- hoveredRows
469
+ hoveredRows,
470
+ hoveredCell
470
471
  } = getPluginState(view.state);
471
472
  const tableRef = this.table || undefined;
472
473
  const headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
@@ -478,10 +479,12 @@ class TableComponent extends React.Component {
478
479
  tableRef: tableRef,
479
480
  tableActive: tableActive,
480
481
  hoveredRows: hoveredRows,
482
+ hoveredCell: hoveredCell,
481
483
  isInDanger: isInDanger,
482
484
  isResizing: isResizing,
483
485
  isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
484
486
  isHeaderRowEnabled: isHeaderRowEnabled,
487
+ isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
485
488
  ordering: ordering,
486
489
  isHeaderColumnEnabled: isHeaderColumnEnabled,
487
490
  hasHeaderRow: hasHeaderRow
@@ -489,8 +492,7 @@ class TableComponent extends React.Component {
489
492
  ,
490
493
  selection: view.state.selection,
491
494
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
492
- stickyHeader: this.state.stickyHeader,
493
- getEditorFeatureFlags: this.props.getEditorFeatureFlags
495
+ stickyHeader: this.state.stickyHeader
494
496
  }));
495
497
  const colControls = /*#__PURE__*/React.createElement("div", {
496
498
  className: ClassName.COLUMN_CONTROLS_WRAPPER
@@ -223,7 +223,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
223
223
  isBreakoutEnabled,
224
224
  isFullWidthModeEnabled,
225
225
  wasFullWidthModeEnabled,
226
- isTableResizingEnabled
226
+ isTableResizingEnabled,
227
+ isDragAndDropEnabled
227
228
  } = getPluginState(view.state);
228
229
  const {
229
230
  allowColumnResizing
@@ -240,7 +241,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
240
241
  isBreakoutEnabled,
241
242
  isFullWidthModeEnabled,
242
243
  wasFullWidthModeEnabled,
243
- isTableResizingEnabled
244
+ isTableResizingEnabled,
245
+ isDragAndDropEnabled
244
246
  },
245
247
  getEditorContainerWidth,
246
248
  getEditorFeatureFlags,
@@ -1,7 +1,5 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey
3
- // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
4
- } from '@atlaskit/editor-prosemirror/state';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
5
  import { pluginKey as tablePluginKey } from '../plugin-key';
@@ -10,7 +8,7 @@ import { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecora
10
8
  export const pluginKey = new PluginKey('tableDecorationsPlugin');
11
9
  export const getDecorations = state => pluginKey.getState(state);
12
10
  export const handleDocOrSelectionChanged = (tr, decorationSet, oldState, newState) => {
13
- var _tableWidthPluginKey$, _tableWidthPluginKey$2;
11
+ var _tableWidthPluginKey$, _tableWidthPluginKey$2, _tr$getMeta;
14
12
  const isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
15
13
  const wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
16
14
  const changedResizing = isResizing !== wasResizing;
@@ -18,7 +16,7 @@ export const handleDocOrSelectionChanged = (tr, decorationSet, oldState, newStat
18
16
  // Remove column controls when resizing
19
17
  if (isResizing) {
20
18
  return DecorationSet.empty;
21
- } else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
19
+ } else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing || ((_tr$getMeta = tr.getMeta(tablePluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type) === 'HOVER_CELL') {
22
20
  return buildColumnControlsDecorations({
23
21
  decorationSet,
24
22
  tr
@@ -39,12 +37,16 @@ export const createPlugin = () => {
39
37
  state: {
40
38
  init: () => DecorationSet.empty,
41
39
  apply: (tr, decorationSet, oldState, newState) => {
40
+ var _tablePluginKey$getSt, _tablePluginKey$getSt2;
42
41
  let pluginState = decorationSet;
43
42
  const meta = tr.getMeta(tablePluginKey);
43
+ const previousHover = (_tablePluginKey$getSt = tablePluginKey.getState(oldState)) === null || _tablePluginKey$getSt === void 0 ? void 0 : _tablePluginKey$getSt.hoveredCell;
44
+ const newHover = (_tablePluginKey$getSt2 = tablePluginKey.getState(newState)) === null || _tablePluginKey$getSt2 === void 0 ? void 0 : _tablePluginKey$getSt2.hoveredCell;
45
+ const changedCellHover = (previousHover === null || previousHover === void 0 ? void 0 : previousHover.colIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.colIndex) || (previousHover === null || previousHover === void 0 ? void 0 : previousHover.rowIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.rowIndex);
44
46
  if (meta && meta.data && meta.data.decorationSet) {
45
47
  pluginState = meta.data.decorationSet;
46
48
  }
47
- if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)) {
49
+ if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey) || changedCellHover) {
48
50
  pluginState = pluginState.map(tr.mapping, tr.doc);
49
51
  return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
50
52
  }
@@ -4,6 +4,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
4
  import { findTable } from '@atlaskit/editor-tables/utils';
5
5
  import { TableDecorations } from '../../../types';
6
6
  import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../../utils/decoration';
7
+ import { pluginKey as tablePluginKey } from '../../plugin-key';
7
8
  import { composeDecorations } from './compose-decorations';
8
9
  const isColumnSelected = tr => tr.selection instanceof CellSelection && tr.selection.isColSelection();
9
10
 
@@ -24,11 +25,15 @@ const maybeUpdateColumnControlsDecoration = ({
24
25
  decorationSet,
25
26
  tr
26
27
  }) => {
28
+ var _meta$data;
27
29
  const table = findTable(tr.selection);
28
- if (!table) {
30
+ const meta = tr.getMeta(tablePluginKey);
31
+
32
+ // avoid re-drawing state if dnd decorations don't need to be updated
33
+ if (!table && (meta === null || meta === void 0 ? void 0 : meta.type) !== 'HOVER_CELL') {
29
34
  return decorationSet;
30
35
  }
31
- return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
36
+ return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection, meta === null || meta === void 0 ? void 0 : (_meta$data = meta.data) === null || _meta$data === void 0 ? void 0 : _meta$data.hoveredCell), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
32
37
  };
33
38
 
34
39
  // @see: https://product-fabric.atlassian.net/browse/ED-7304
@@ -1,4 +1,17 @@
1
1
  export const defaultTableSelection = {
2
2
  hoveredColumns: [],
3
3
  hoveredRows: []
4
+ };
5
+
6
+ /**
7
+ * Creating a separate object for hoveredCell so it doesn't get defaulted when `handleDocOrSelectionChanged` runs.
8
+ *
9
+ * It is safe to persist this value as it gets removed when the mouse cursor leaves the table, so no need to remove it
10
+ * when doc changes.
11
+ */
12
+ export const defaultHoveredCell = {
13
+ hoveredCell: {
14
+ rowIndex: undefined,
15
+ colIndex: undefined
16
+ }
4
17
  };
@@ -1,14 +1,42 @@
1
+ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
+ import { TableDecorations } from '../../types';
3
+ import { createColumnInsertLine, createRowInsertLine, updateDecorations } from '../../utils';
1
4
  import { DragAndDropActionType } from './actions';
2
- import { createCommand } from './plugin-factory';
5
+ import { createCommand, getPluginState } from './plugin-factory';
6
+ import { pluginKey } from './plugin-key';
3
7
 
4
8
  // TODO: This command is a placeholder example. Please replace this if required.
5
- export const setDropTarget = (type, index, tr) => createCommand({
6
- type: DragAndDropActionType.SET_DROP_TARGET,
7
- data: {
8
- type,
9
- index
9
+ export const getDecorations = state => {
10
+ var _pluginKey$getState;
11
+ return ((_pluginKey$getState = pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorationSet) || DecorationSet.empty;
12
+ };
13
+ export const updatePluginStateDecorations = (state, decorations, key) => updateDecorations(state.doc, getDecorations(state), decorations, key);
14
+ export const setDropTarget = (type, index, tr) => createCommand(state => {
15
+ const {
16
+ dropTargetType,
17
+ dropTargetIndex
18
+ } = getPluginState(state);
19
+ if (dropTargetType === type && dropTargetIndex === index) {
20
+ return false;
21
+ }
22
+ let decorationSet = DecorationSet.empty;
23
+ if (type === 'column') {
24
+ decorationSet = updatePluginStateDecorations(state, createColumnInsertLine(index, state.selection), TableDecorations.COLUMN_INSERT_LINE);
25
+ } else if (type === 'row') {
26
+ decorationSet = updatePluginStateDecorations(state, createRowInsertLine(index, state.selection), TableDecorations.ROW_INSERT_LINE);
10
27
  }
28
+ return {
29
+ type: DragAndDropActionType.SET_DROP_TARGET,
30
+ data: {
31
+ decorationSet,
32
+ type,
33
+ index
34
+ }
35
+ };
11
36
  }, originalTr => (tr || originalTr).setMeta('addToHistory', false));
12
37
  export const clearDropTarget = tr => createCommand({
13
- type: DragAndDropActionType.CLEAR_DROP_TARGET
38
+ type: DragAndDropActionType.CLEAR_DROP_TARGET,
39
+ data: {
40
+ decorationSet: DecorationSet.empty
41
+ }
14
42
  }, originalTr => (tr || originalTr).setMeta('addToHistory', false));
@@ -1,8 +1,13 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
+ import { moveColumn, moveRow } from '@atlaskit/editor-tables/utils';
4
+ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
5
+ import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
6
+ import { getPluginState as getTablePluginState } from '../plugin-factory';
3
7
  import { DropTargetType } from './consts';
4
8
  import { createPluginState, getPluginState } from './plugin-factory';
5
9
  import { pluginKey } from './plugin-key';
10
+ import { getDraggableDataFromEvent } from './utils/monitor';
6
11
  export const createPlugin = (dispatch, eventDispatcher) => {
7
12
  return new SafePlugin({
8
13
  state: createPluginState(dispatch, state => ({
@@ -14,11 +19,71 @@ export const createPlugin = (dispatch, eventDispatcher) => {
14
19
  })),
15
20
  key: pluginKey,
16
21
  view: editorView => {
17
- // TODO: Add Pragmatic DnD monitor when the view is constructed.
18
-
19
22
  return {
20
- // TODO: Cleanup monitor instance
21
- // destroy: cleanup,
23
+ destroy: monitorForElements({
24
+ canMonitor({
25
+ source
26
+ }) {
27
+ const {
28
+ type,
29
+ localId,
30
+ indexes
31
+ } = source.data;
32
+
33
+ // First; Perform any quick checks so we can abort early.
34
+ if (!indexes || !localId ||
35
+ // FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
36
+ // of more then 1 item.
37
+ indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
38
+ return false;
39
+ }
40
+ const {
41
+ tableNode
42
+ } = getTablePluginState(editorView.state);
43
+ // If the draggable localId is the same as the current selected table localId then we will allow the monitor
44
+ // watch for changes
45
+ return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
46
+ },
47
+ onDrag(event) {
48
+ const data = getDraggableDataFromEvent(event);
49
+
50
+ // If no data can be found then it's most like we do not want to perform any drag actions
51
+ if (!data) {
52
+ return;
53
+ }
54
+
55
+ // TODO: as we drag an element around we are going to want to update the state to acurately reflect the current
56
+ // insert location as to where the draggable will most likely be go. For example;
57
+ // const { sourceType, targetAdjustedIndex } = data;
58
+ // const highlight = sourceType === 'table-row' ? highlightRow : highlightColumn;
59
+ // return editorView.dispatch(
60
+ // highlight(targetAdjustedIndex)(editorView.state.tr),
61
+ // );
62
+ },
63
+
64
+ onDrop(event) {
65
+ const data = getDraggableDataFromEvent(event);
66
+
67
+ // If no data can be found then it's most like we do not want to perform any drop action
68
+ if (!data) {
69
+ return;
70
+ }
71
+ const {
72
+ sourceType,
73
+ sourceIndexes,
74
+ targetAdjustedIndex
75
+ } = data;
76
+
77
+ // If the drop target index contains merged cells then we should not allow the drop to occur.
78
+ const hasMergedCells = sourceType === 'table-row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
79
+ if (hasMergedCells(targetAdjustedIndex)(editorView.state.selection)) {
80
+ return;
81
+ }
82
+ const move = sourceType === 'table-row' ? moveRow : moveColumn;
83
+ const [sourceIndex] = sourceIndexes;
84
+ return editorView.dispatch(move(sourceIndex, targetAdjustedIndex)(editorView.state.tr));
85
+ }
86
+ })
22
87
  };
23
88
  },
24
89
  props: {
@@ -5,12 +5,14 @@ export default ((pluginState, action) => {
5
5
  case DragAndDropActionType.SET_DROP_TARGET:
6
6
  return {
7
7
  ...pluginState,
8
+ decorationSet: action.data.decorationSet,
8
9
  dropTargetType: action.data.type,
9
10
  dropTargetIndex: action.data.index
10
11
  };
11
12
  case DragAndDropActionType.CLEAR_DROP_TARGET:
12
13
  return {
13
14
  ...pluginState,
15
+ decorationSet: action.data.decorationSet,
14
16
  dropTargetType: DropTargetType.NONE,
15
17
  dropTargetIndex: 0
16
18
  };
@@ -0,0 +1 @@
1
+ export { getDraggableDataFromEvent } from './monitor';
@@ -0,0 +1,56 @@
1
+ import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
2
+ export const getDraggableDataFromEvent = ({
3
+ location,
4
+ source
5
+ }) => {
6
+ var _extractClosestEdge;
7
+ const destination = location.current.dropTargets.at(0);
8
+ // If no target exists at the current location, then the current draggable is not over a target or the target doesn't support
9
+ // the current draggable.
10
+ if (!destination) {
11
+ return undefined;
12
+ }
13
+
14
+ // This is the draggable elements data
15
+ const {
16
+ indexes: sourceIndexes,
17
+ type: sourceType,
18
+ localId: sourceLocalId
19
+ } = source.data;
20
+
21
+ // This is the drop target's data
22
+ const {
23
+ targetIndex,
24
+ type: targetType,
25
+ localId: targetLocalId
26
+ } = destination.data;
27
+
28
+ // Some basic check to abort early with...
29
+ if (!sourceIndexes || targetIndex < 0 ||
30
+ // abort if the type of the draggable is different to the target, for eg. rows cannot be dropped onto column targets.
31
+ sourceType !== targetType ||
32
+ // abort if the draggable is coming from a different table that the target is on.
33
+ sourceLocalId !== targetLocalId) {
34
+ return undefined;
35
+ }
36
+
37
+ // FIXME: currently we only support a single row/col index being moved, remove this clause when this is no longer the case.
38
+ if (sourceIndexes.length > 1) {
39
+ return undefined;
40
+ }
41
+ const targetClosestEdge = (_extractClosestEdge = extractClosestEdge(destination.data)) !== null && _extractClosestEdge !== void 0 ? _extractClosestEdge : targetType === 'table-row' ? 'top' : 'left';
42
+ // NOTE: By default we always insert row/cols at the target index to the top/left (retrospectively of row/cols).
43
+ // This introduces an offset in the event the drop occured closer to the bottom/right of the target. We want
44
+ // the new target index to be 1 index higher.
45
+ const targetOffset = targetClosestEdge === 'right' || targetClosestEdge === 'bottom' ? 1 : 0;
46
+ return {
47
+ sourceType,
48
+ sourceLocalId,
49
+ sourceIndexes,
50
+ targetType,
51
+ targetLocalId,
52
+ targetIndex,
53
+ targetAdjustedIndex: targetIndex + targetOffset,
54
+ targetClosestEdge
55
+ };
56
+ };
@@ -8,7 +8,7 @@ import { findTable } from '@atlaskit/editor-tables/utils';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
9
  import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
10
10
  import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
11
- import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
11
+ import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
12
12
  import { createTableView } from '../nodeviews/table';
13
13
  import TableCell from '../nodeviews/TableCell';
14
14
  import TableRow from '../nodeviews/TableRow';
@@ -17,10 +17,10 @@ import { fixTables, replaceSelectedTable } from '../transforms';
17
17
  import { TableCssClassName as ClassName } from '../types';
18
18
  import { findControlsHoverDecoration, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, transformSliceToRemoveOpenTable, updateResizeHandles } from '../utils';
19
19
  import { isHeaderRowRequired } from '../utils/paste';
20
- import { defaultTableSelection } from './default-table-selection';
20
+ import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
21
21
  import { createPluginState, getPluginState } from './plugin-factory';
22
22
  import { pluginKey } from './plugin-key';
23
- export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
23
+ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
24
24
  var _window;
25
25
  const state = createPluginState(dispatch, {
26
26
  pluginConfig,
@@ -33,6 +33,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
33
33
  isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
34
34
  isHeaderColumnEnabled: false,
35
35
  isDragAndDropEnabled: dragAndDropEnabled,
36
+ ...defaultHoveredCell,
36
37
  ...defaultTableSelection,
37
38
  getIntl
38
39
  });
@@ -234,8 +235,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
234
235
  handleDOMEvents: {
235
236
  focus: handleFocus,
236
237
  blur: handleBlur,
237
- mousedown: handleMouseDown,
238
- mouseover: whenTableInFocus(handleMouseOver),
238
+ mousedown: withCellTracking(handleMouseDown),
239
+ mouseover: whenTableInFocus(withCellTracking(handleMouseOver)),
239
240
  mouseleave: whenTableInFocus(handleMouseLeave),
240
241
  mouseout: whenTableInFocus(handleMouseOut),
241
242
  mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
@@ -114,7 +114,8 @@ export default ((pluginState, action) => {
114
114
  case 'HOVER_ROWS':
115
115
  case 'HOVER_COLUMNS':
116
116
  case 'HOVER_TABLE':
117
- case 'HOVER_CELLS':
117
+ case 'HOVER_MERGED_CELLS':
118
+ case 'HOVER_CELL':
118
119
  case 'SHOW_RESIZE_HANDLE_LINE':
119
120
  case 'SET_EDITOR_FOCUS':
120
121
  return {
@@ -39,11 +39,14 @@ export let TableDecorations = /*#__PURE__*/function (TableDecorations) {
39
39
  TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
40
40
  TableDecorations["COLUMN_RESIZING_HANDLE_WIDGET"] = "COLUMN_RESIZING_HANDLE_WIDGET";
41
41
  TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
42
+ TableDecorations["COLUMN_INSERT_LINE"] = "COLUMN_INSERT_LINE";
43
+ TableDecorations["ROW_INSERT_LINE"] = "ROW_INSERT_LINE";
42
44
  TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
43
45
  return TableDecorations;
44
46
  }({});
45
47
  export const TableCssClassName = {
46
48
  ...TableSharedCssClassName,
49
+ /** Classic controls */
47
50
  COLUMN_CONTROLS: `${tablePrefixSelector}-column-controls`,
48
51
  COLUMN_CONTROLS_DECORATIONS: `${tablePrefixSelector}-column-controls-decoration`,
49
52
  COLUMN_SELECTED: `${tablePrefixSelector}-column__selected`,
@@ -74,8 +77,13 @@ export const TableCssClassName = {
74
77
  CORNER_CONTROLS_INSERT_ROW_MARKER: `${tablePrefixSelector}-corner-controls__insert-row-marker`,
75
78
  CORNER_CONTROLS_INSERT_COLUMN_MARKER: `${tablePrefixSelector}-corner-controls__insert-column-marker`,
76
79
  CONTROLS_CORNER_BUTTON: `${tablePrefixSelector}-corner-button`,
80
+ /** Controls with drag handle */
81
+ COLUMN_CONTROLS_DECORATIONS_WITH_DRAG: `${tablePrefixSelector}-column-controls-decoration-with-drag`,
82
+ ROW_CONTROLS_WITH_DRAG: `${tablePrefixSelector}-row-controls-with-drag`,
83
+ /** Other classes */
77
84
  NUMBERED_COLUMN: `${tablePrefixSelector}-numbered-column`,
78
85
  NUMBERED_COLUMN_BUTTON: `${tablePrefixSelector}-numbered-column__button`,
86
+ NUMBERED_COLUMN_BUTTON_DISABLED: `${tablePrefixSelector}-numbered-column__button-disabled`,
79
87
  HOVERED_COLUMN: `${tablePrefixSelector}-hovered-column`,
80
88
  HOVERED_ROW: `${tablePrefixSelector}-hovered-row`,
81
89
  HOVERED_TABLE: `${tablePrefixSelector}-hovered-table`,
@@ -106,8 +114,13 @@ export const TableCssClassName = {
106
114
  TABLE_STICKY: `${tablePrefixSelector}-sticky`,
107
115
  TOP_LEFT_CELL: 'table > tbody > tr:nth-child(2) > td:nth-child(1)',
108
116
  LAST_ITEM_IN_CELL: `${tablePrefixSelector}-last-item-in-cell`,
117
+ WITH_COLUMN_INSERT_LINE: `${tablePrefixSelector}-column-insert-line`,
118
+ WITH_FIRST_COLUMN_INSERT_LINE: `${tablePrefixSelector}-first-column-insert-line`,
119
+ WITH_LAST_COLUMN_INSERT_LINE: `${tablePrefixSelector}-last-column-insert-line`,
109
120
  WITH_RESIZE_LINE: `${tablePrefixSelector}-column-resize-line`,
110
- WITH_RESIZE_LINE_LAST_COLUMN: `${tablePrefixSelector}-column-resize-line-last-column`
121
+ WITH_RESIZE_LINE_LAST_COLUMN: `${tablePrefixSelector}-column-resize-line-last-column`,
122
+ WITH_ROW_INSERT_LINE: `${tablePrefixSelector}-row-insert-line`,
123
+ WITH_LAST_ROW_INSERT_LINE: `${tablePrefixSelector}-last-row-insert-line`
111
124
  };
112
125
  export let ShadowEvent = /*#__PURE__*/function (ShadowEvent) {
113
126
  ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow";