@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#41446](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41446) [`ff8add18e61`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ff8add18e61) - Add drag handle controls to table behind a feature flag
8
+
9
+ ## 5.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#41703](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41703) [`3631a9d9750`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3631a9d9750) - [ux] Added a command to show insert line decoration/ drop target when dragging a table column or a row.
14
+ - [#41640](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41640) [`c387b1bfcdd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c387b1bfcdd) - Added a Pragmatic Drag and Drop montior to the DnD table plugin. This is responsible for triggering the row/column move when a drop operation occurs.
15
+
3
16
  ## 5.3.0
4
17
 
5
18
  ### Minor Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.showResizeHandleLine = exports.hoverTable = exports.hoverRows = exports.hoverMergedCells = exports.hoverColumns = exports.hideResizeHandleLine = exports.clearHoverSelection = void 0;
6
+ exports.showResizeHandleLine = exports.hoverTable = exports.hoverRows = exports.hoverMergedCells = exports.hoverColumns = exports.hoverCell = exports.hideResizeHandleLine = exports.clearHoverSelection = void 0;
7
7
  var _tableMap = require("@atlaskit/editor-tables/table-map");
8
8
  var _utils = require("@atlaskit/editor-tables/utils");
9
9
  var _pluginFactory = require("../pm-plugins/plugin-factory");
@@ -11,14 +11,9 @@ var _types = require("../types");
11
11
  var _utils2 = require("../utils");
12
12
  // #region Imports
13
13
 
14
- // #endregion
15
- // #region Utils
16
14
  var makeArray = function makeArray(n) {
17
15
  return Array.from(Array(n).keys());
18
16
  };
19
- // #endregion
20
-
21
- // #region Commands
22
17
  var hoverMergedCells = exports.hoverMergedCells = function hoverMergedCells() {
23
18
  return (0, _pluginFactory.createCommand)(function (state) {
24
19
  var mergedCellsPositions = (0, _utils2.getMergedCellsPositions)(state.tr);
@@ -38,7 +33,7 @@ var hoverMergedCells = exports.hoverMergedCells = function hoverMergedCells() {
38
33
  });
39
34
  var decorations = (0, _utils2.createCellHoverDecoration)(mergedCells);
40
35
  return {
41
- type: 'HOVER_CELLS',
36
+ type: 'HOVER_MERGED_CELLS',
42
37
  data: {
43
38
  decorationSet: (0, _utils2.updatePluginStateDecorations)(state, decorations, _types.TableDecorations.CELL_CONTROLS_HOVER)
44
39
  }
@@ -143,4 +138,18 @@ var hideResizeHandleLine = exports.hideResizeHandleLine = function hideResizeHan
143
138
  };
144
139
  });
145
140
  };
146
- // #endregion
141
+ var hoverCell = exports.hoverCell = function hoverCell(rowIndex, colIndex) {
142
+ return (0, _pluginFactory.createCommand)(function () {
143
+ return {
144
+ type: 'HOVER_CELL',
145
+ data: {
146
+ hoveredCell: {
147
+ rowIndex: rowIndex,
148
+ colIndex: colIndex
149
+ }
150
+ }
151
+ };
152
+ }, function (tr) {
153
+ return tr.setMeta('addToHistory', false);
154
+ });
155
+ };
@@ -75,6 +75,12 @@ Object.defineProperty(exports, "hideResizeHandleLine", {
75
75
  return _hover.hideResizeHandleLine;
76
76
  }
77
77
  });
78
+ Object.defineProperty(exports, "hoverCell", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _hover.hoverCell;
82
+ }
83
+ });
78
84
  Object.defineProperty(exports, "hoverColumns", {
79
85
  enumerable: true,
80
86
  get: function get() {
@@ -21,11 +21,6 @@ var _nodes = require("../utils/nodes");
21
21
  var _updatePluginStateDecorations = require("../utils/update-plugin-state-decorations");
22
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // #region Imports
24
- // #endregion
25
-
26
- // #endregion
27
-
28
- // #region Commands
29
24
  var setEditorFocus = exports.setEditorFocus = function setEditorFocus(editorHasFocus) {
30
25
  return (0, _pluginFactory.createCommand)({
31
26
  type: 'SET_EDITOR_FOCUS',
@@ -444,5 +439,4 @@ var addBoldInEmptyHeaderCells = exports.addBoldInEmptyHeaderCells = function add
444
439
  }
445
440
  return false;
446
441
  };
447
- };
448
- // #endregion
442
+ };
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.handleMouseOver = exports.handleMouseOut = exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseDown = exports.handleFocus = exports.handleCut = exports.handleClick = exports.handleBlur = void 0;
8
8
  exports.handleTripleClick = handleTripleClick;
9
- exports.whenTableInFocus = void 0;
9
+ exports.withCellTracking = exports.whenTableInFocus = void 0;
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
@@ -173,11 +173,15 @@ var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view
173
173
  dispatch = view.dispatch;
174
174
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
175
175
  insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
176
- insertRowButtonIndex = _getPluginState2.insertRowButtonIndex;
176
+ insertRowButtonIndex = _getPluginState2.insertRowButtonIndex,
177
+ isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
177
178
  var target = event.target;
178
179
  if ((0, _utils3.isTableControlsButton)(target)) {
179
180
  return true;
180
181
  }
182
+ if (isDragAndDropEnabled) {
183
+ (0, _commands.hoverCell)(undefined, undefined)(state, dispatch);
184
+ }
181
185
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch)) {
182
186
  return true;
183
187
  }
@@ -318,4 +322,27 @@ var whenTableInFocus = exports.whenTableInFocus = function whenTableInFocus(even
318
322
  }
319
323
  return eventHandler(view, mouseEvent, elementContentRects);
320
324
  };
325
+ };
326
+ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
327
+ var target = mouseEvent.target;
328
+ var maybeTableCell = (0, _utils.isElementInTableCell)(target);
329
+ if (!maybeTableCell) {
330
+ return;
331
+ }
332
+ var colIndex = maybeTableCell.cellIndex;
333
+ var rowElement = (0, _utils.closestElement)(target, 'tr');
334
+ var rowIndex = rowElement && rowElement.rowIndex;
335
+ var _getPluginState8 = (0, _pluginFactory.getPluginState)(view.state),
336
+ hoveredCell = _getPluginState8.hoveredCell;
337
+ if (hoveredCell.colIndex !== colIndex || hoveredCell.rowIndex !== rowIndex) {
338
+ (0, _commands.hoverCell)(rowIndex, colIndex)(view.state, view.dispatch);
339
+ }
340
+ };
341
+ var withCellTracking = exports.withCellTracking = function withCellTracking(eventHandler, elementContentRects) {
342
+ return function (view, mouseEvent) {
343
+ if ((0, _pluginFactory.getPluginState)(view.state).isDragAndDropEnabled) {
344
+ trackCellLocation(view, mouseEvent);
345
+ }
346
+ return eventHandler(view, mouseEvent, elementContentRects);
347
+ };
321
348
  };
@@ -114,7 +114,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
114
114
  tableOptions = _ref3.tableOptions,
115
115
  getEditorFeatureFlags = _ref3.getEditorFeatureFlags,
116
116
  dragAndDropEnabled = _ref3.dragAndDropEnabled;
117
- return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
117
+ return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
118
118
  }
119
119
  }, {
120
120
  name: 'tablePMColResizing',
@@ -469,7 +469,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
469
469
  // doesn't work well with WithPluginState
470
470
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
471
471
  isInDanger = _getPluginState2.isInDanger,
472
- hoveredRows = _getPluginState2.hoveredRows;
472
+ hoveredRows = _getPluginState2.hoveredRows,
473
+ hoveredCell = _getPluginState2.hoveredCell;
473
474
  var tableRef = this.table || undefined;
474
475
  var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
475
476
  var hasHeaderRow = (0, _utils4.containsHeaderRow)(node);
@@ -480,10 +481,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
480
481
  tableRef: tableRef,
481
482
  tableActive: tableActive,
482
483
  hoveredRows: hoveredRows,
484
+ hoveredCell: hoveredCell,
483
485
  isInDanger: isInDanger,
484
486
  isResizing: isResizing,
485
487
  isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
486
488
  isHeaderRowEnabled: isHeaderRowEnabled,
489
+ isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
487
490
  ordering: ordering,
488
491
  isHeaderColumnEnabled: isHeaderColumnEnabled,
489
492
  hasHeaderRow: hasHeaderRow
@@ -491,8 +494,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
491
494
  ,
492
495
  selection: view.state.selection,
493
496
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
494
- stickyHeader: this.state.stickyHeader,
495
- getEditorFeatureFlags: this.props.getEditorFeatureFlags
497
+ stickyHeader: this.state.stickyHeader
496
498
  }));
497
499
  var colControls = /*#__PURE__*/_react.default.createElement("div", {
498
500
  className: _types.TableCssClassName.COLUMN_CONTROLS_WRAPPER
@@ -255,7 +255,8 @@ var createTableView = exports.createTableView = function createTableView(node, v
255
255
  isBreakoutEnabled = _getPluginState2.isBreakoutEnabled,
256
256
  isFullWidthModeEnabled = _getPluginState2.isFullWidthModeEnabled,
257
257
  wasFullWidthModeEnabled = _getPluginState2.wasFullWidthModeEnabled,
258
- isTableResizingEnabled = _getPluginState2.isTableResizingEnabled;
258
+ isTableResizingEnabled = _getPluginState2.isTableResizingEnabled,
259
+ isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
259
260
  var _getPluginConfig = (0, _createPluginConfig.pluginConfig)(pluginConfig),
260
261
  allowColumnResizing = _getPluginConfig.allowColumnResizing;
261
262
  var hasIntlContext = true;
@@ -270,7 +271,8 @@ var createTableView = exports.createTableView = function createTableView(node, v
270
271
  isBreakoutEnabled: isBreakoutEnabled,
271
272
  isFullWidthModeEnabled: isFullWidthModeEnabled,
272
273
  wasFullWidthModeEnabled: wasFullWidthModeEnabled,
273
- isTableResizingEnabled: isTableResizingEnabled
274
+ isTableResizingEnabled: isTableResizingEnabled,
275
+ isDragAndDropEnabled: isDragAndDropEnabled
274
276
  },
275
277
  getEditorContainerWidth: getEditorContainerWidth,
276
278
  getEditorFeatureFlags: getEditorFeatureFlags,
@@ -16,7 +16,7 @@ var getDecorations = exports.getDecorations = function getDecorations(state) {
16
16
  return pluginKey.getState(state);
17
17
  };
18
18
  var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
19
- var _tableWidthPluginKey$, _tableWidthPluginKey$2;
19
+ var _tableWidthPluginKey$, _tableWidthPluginKey$2, _tr$getMeta;
20
20
  var isResizing = (_tableWidthPluginKey$ = _tableWidth.pluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
21
21
  var wasResizing = (_tableWidthPluginKey$2 = _tableWidth.pluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
22
22
  var changedResizing = isResizing !== wasResizing;
@@ -24,7 +24,7 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
24
24
  // Remove column controls when resizing
25
25
  if (isResizing) {
26
26
  return _view.DecorationSet.empty;
27
- } else if (tr.docChanged || tr.selection instanceof _cellSelection.CellSelection || changedResizing) {
27
+ } else if (tr.docChanged || tr.selection instanceof _cellSelection.CellSelection || changedResizing || ((_tr$getMeta = tr.getMeta(_pluginKey.pluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type) === 'HOVER_CELL') {
28
28
  return (0, _utils.buildColumnControlsDecorations)({
29
29
  decorationSet: decorationSet,
30
30
  tr: tr
@@ -47,12 +47,16 @@ var createPlugin = exports.createPlugin = function createPlugin() {
47
47
  return _view.DecorationSet.empty;
48
48
  },
49
49
  apply: function apply(tr, decorationSet, oldState, newState) {
50
+ var _tablePluginKey$getSt, _tablePluginKey$getSt2;
50
51
  var pluginState = decorationSet;
51
52
  var meta = tr.getMeta(_pluginKey.pluginKey);
53
+ var previousHover = (_tablePluginKey$getSt = _pluginKey.pluginKey.getState(oldState)) === null || _tablePluginKey$getSt === void 0 ? void 0 : _tablePluginKey$getSt.hoveredCell;
54
+ var newHover = (_tablePluginKey$getSt2 = _pluginKey.pluginKey.getState(newState)) === null || _tablePluginKey$getSt2 === void 0 ? void 0 : _tablePluginKey$getSt2.hoveredCell;
55
+ var 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);
52
56
  if (meta && meta.data && meta.data.decorationSet) {
53
57
  pluginState = meta.data.decorationSet;
54
58
  }
55
- if (tr.docChanged || tr.selectionSet || tr.getMeta(_tableWidth.pluginKey)) {
59
+ if (tr.docChanged || tr.selectionSet || tr.getMeta(_tableWidth.pluginKey) || changedCellHover) {
56
60
  pluginState = pluginState.map(tr.mapping, tr.doc);
57
61
  return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
58
62
  }
@@ -8,6 +8,7 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
8
8
  var _utils = require("@atlaskit/editor-tables/utils");
9
9
  var _types = require("../../../types");
10
10
  var _decoration = require("../../../utils/decoration");
11
+ var _pluginKey = require("../../plugin-key");
11
12
  var _composeDecorations = require("./compose-decorations");
12
13
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
13
14
 
@@ -29,13 +30,17 @@ var maybeUpdateColumnSelectedDecoration = function maybeUpdateColumnSelectedDeco
29
30
  return (0, _decoration.updateDecorations)(tr.doc, decorationSet, (0, _decoration.createColumnSelectedDecoration)(tr), _types.TableDecorations.COLUMN_SELECTED);
30
31
  };
31
32
  var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDecoration(_ref3) {
33
+ var _meta$data;
32
34
  var decorationSet = _ref3.decorationSet,
33
35
  tr = _ref3.tr;
34
36
  var table = (0, _utils.findTable)(tr.selection);
35
- if (!table) {
37
+ var meta = tr.getMeta(_pluginKey.pluginKey);
38
+
39
+ // avoid re-drawing state if dnd decorations don't need to be updated
40
+ if (!table && (meta === null || meta === void 0 ? void 0 : meta.type) !== 'HOVER_CELL') {
36
41
  return decorationSet;
37
42
  }
38
- return (0, _decoration.updateDecorations)(tr.doc, decorationSet, (0, _decoration.createColumnControlsDecoration)(tr.selection), _types.TableDecorations.COLUMN_CONTROLS_DECORATIONS);
43
+ return (0, _decoration.updateDecorations)(tr.doc, decorationSet, (0, _decoration.createColumnControlsDecoration)(tr.selection, meta === null || meta === void 0 || (_meta$data = meta.data) === null || _meta$data === void 0 ? void 0 : _meta$data.hoveredCell), _types.TableDecorations.COLUMN_CONTROLS_DECORATIONS);
39
44
  };
40
45
 
41
46
  // @see: https://product-fabric.atlassian.net/browse/ED-7304
@@ -3,8 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.defaultTableSelection = void 0;
6
+ exports.defaultTableSelection = exports.defaultHoveredCell = void 0;
7
7
  var defaultTableSelection = exports.defaultTableSelection = {
8
8
  hoveredColumns: [],
9
9
  hoveredRows: []
10
+ };
11
+
12
+ /**
13
+ * Creating a separate object for hoveredCell so it doesn't get defaulted when `handleDocOrSelectionChanged` runs.
14
+ *
15
+ * It is safe to persist this value as it gets removed when the mouse cursor leaves the table, so no need to remove it
16
+ * when doc changes.
17
+ */
18
+ var defaultHoveredCell = exports.defaultHoveredCell = {
19
+ hoveredCell: {
20
+ rowIndex: undefined,
21
+ colIndex: undefined
22
+ }
10
23
  };
@@ -3,24 +3,53 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setDropTarget = exports.clearDropTarget = void 0;
6
+ exports.updatePluginStateDecorations = exports.setDropTarget = exports.getDecorations = exports.clearDropTarget = void 0;
7
+ var _view = require("@atlaskit/editor-prosemirror/view");
8
+ var _types = require("../../types");
9
+ var _utils = require("../../utils");
7
10
  var _actions = require("./actions");
8
11
  var _pluginFactory = require("./plugin-factory");
12
+ var _pluginKey = require("./plugin-key");
9
13
  // TODO: This command is a placeholder example. Please replace this if required.
14
+ var getDecorations = exports.getDecorations = function getDecorations(state) {
15
+ var _pluginKey$getState;
16
+ return ((_pluginKey$getState = _pluginKey.pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorationSet) || _view.DecorationSet.empty;
17
+ };
18
+ var updatePluginStateDecorations = exports.updatePluginStateDecorations = function updatePluginStateDecorations(state, decorations, key) {
19
+ return (0, _utils.updateDecorations)(state.doc, getDecorations(state), decorations, key);
20
+ };
10
21
  var setDropTarget = exports.setDropTarget = function setDropTarget(type, index, tr) {
11
- return (0, _pluginFactory.createCommand)({
12
- type: _actions.DragAndDropActionType.SET_DROP_TARGET,
13
- data: {
14
- type: type,
15
- index: index
22
+ return (0, _pluginFactory.createCommand)(function (state) {
23
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
24
+ dropTargetType = _getPluginState.dropTargetType,
25
+ dropTargetIndex = _getPluginState.dropTargetIndex;
26
+ if (dropTargetType === type && dropTargetIndex === index) {
27
+ return false;
16
28
  }
29
+ var decorationSet = _view.DecorationSet.empty;
30
+ if (type === 'column') {
31
+ decorationSet = updatePluginStateDecorations(state, (0, _utils.createColumnInsertLine)(index, state.selection), _types.TableDecorations.COLUMN_INSERT_LINE);
32
+ } else if (type === 'row') {
33
+ decorationSet = updatePluginStateDecorations(state, (0, _utils.createRowInsertLine)(index, state.selection), _types.TableDecorations.ROW_INSERT_LINE);
34
+ }
35
+ return {
36
+ type: _actions.DragAndDropActionType.SET_DROP_TARGET,
37
+ data: {
38
+ decorationSet: decorationSet,
39
+ type: type,
40
+ index: index
41
+ }
42
+ };
17
43
  }, function (originalTr) {
18
44
  return (tr || originalTr).setMeta('addToHistory', false);
19
45
  });
20
46
  };
21
47
  var clearDropTarget = exports.clearDropTarget = function clearDropTarget(tr) {
22
48
  return (0, _pluginFactory.createCommand)({
23
- type: _actions.DragAndDropActionType.CLEAR_DROP_TARGET
49
+ type: _actions.DragAndDropActionType.CLEAR_DROP_TARGET,
50
+ data: {
51
+ decorationSet: _view.DecorationSet.empty
52
+ }
24
53
  }, function (originalTr) {
25
54
  return (tr || originalTr).setMeta('addToHistory', false);
26
55
  });
@@ -1,17 +1,24 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.createPlugin = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
7
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
10
  var _view = require("@atlaskit/editor-prosemirror/view");
11
+ var _utils = require("@atlaskit/editor-tables/utils");
12
+ var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
13
+ var _mergedCells = require("../../utils/merged-cells");
14
+ var _pluginFactory = require("../plugin-factory");
9
15
  var _consts = require("./consts");
10
- var _pluginFactory = require("./plugin-factory");
16
+ var _pluginFactory2 = require("./plugin-factory");
11
17
  var _pluginKey = require("./plugin-key");
18
+ var _monitor = require("./utils/monitor");
12
19
  var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventDispatcher) {
13
20
  return new _safePlugin.SafePlugin({
14
- state: (0, _pluginFactory.createPluginState)(dispatch, function (state) {
21
+ state: (0, _pluginFactory2.createPluginState)(dispatch, function (state) {
15
22
  return {
16
23
  decorationSet: _view.DecorationSet.empty,
17
24
  // TODO: This is example placeholder state. We could use this to track which row/col is currently set as the drop target
@@ -22,16 +29,71 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
22
29
  }),
23
30
  key: _pluginKey.pluginKey,
24
31
  view: function view(editorView) {
25
- // TODO: Add Pragmatic DnD monitor when the view is constructed.
26
-
27
32
  return {
28
- // TODO: Cleanup monitor instance
29
- // destroy: cleanup,
33
+ destroy: (0, _element.monitorForElements)({
34
+ canMonitor: function canMonitor(_ref) {
35
+ var source = _ref.source;
36
+ var _ref2 = source.data,
37
+ type = _ref2.type,
38
+ localId = _ref2.localId,
39
+ indexes = _ref2.indexes;
40
+
41
+ // First; Perform any quick checks so we can abort early.
42
+ if (!indexes || !localId ||
43
+ // FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
44
+ // of more then 1 item.
45
+ indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
46
+ return false;
47
+ }
48
+ var _getTablePluginState = (0, _pluginFactory.getPluginState)(editorView.state),
49
+ tableNode = _getTablePluginState.tableNode;
50
+ // If the draggable localId is the same as the current selected table localId then we will allow the monitor
51
+ // watch for changes
52
+ return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
53
+ },
54
+ onDrag: function onDrag(event) {
55
+ var data = (0, _monitor.getDraggableDataFromEvent)(event);
56
+
57
+ // If no data can be found then it's most like we do not want to perform any drag actions
58
+ if (!data) {
59
+ return;
60
+ }
61
+
62
+ // TODO: as we drag an element around we are going to want to update the state to acurately reflect the current
63
+ // insert location as to where the draggable will most likely be go. For example;
64
+ // const { sourceType, targetAdjustedIndex } = data;
65
+ // const highlight = sourceType === 'table-row' ? highlightRow : highlightColumn;
66
+ // return editorView.dispatch(
67
+ // highlight(targetAdjustedIndex)(editorView.state.tr),
68
+ // );
69
+ },
70
+ onDrop: function onDrop(event) {
71
+ var data = (0, _monitor.getDraggableDataFromEvent)(event);
72
+
73
+ // If no data can be found then it's most like we do not want to perform any drop action
74
+ if (!data) {
75
+ return;
76
+ }
77
+ var sourceType = data.sourceType,
78
+ sourceIndexes = data.sourceIndexes,
79
+ targetAdjustedIndex = data.targetAdjustedIndex;
80
+
81
+ // If the drop target index contains merged cells then we should not allow the drop to occur.
82
+ var hasMergedCells = sourceType === 'table-row' ? _mergedCells.hasMergedCellsInRow : _mergedCells.hasMergedCellsInColumn;
83
+ if (hasMergedCells(targetAdjustedIndex)(editorView.state.selection)) {
84
+ return;
85
+ }
86
+ var move = sourceType === 'table-row' ? _utils.moveRow : _utils.moveColumn;
87
+ var _sourceIndexes = (0, _slicedToArray2.default)(sourceIndexes, 1),
88
+ sourceIndex = _sourceIndexes[0];
89
+ return editorView.dispatch(move(sourceIndex, targetAdjustedIndex)(editorView.state.tr));
90
+ }
91
+ })
30
92
  };
31
93
  },
32
94
  props: {
33
95
  decorations: function decorations(state) {
34
- var _getPluginState = (0, _pluginFactory.getPluginState)(state),
96
+ var _getPluginState = (0, _pluginFactory2.getPluginState)(state),
35
97
  decorationSet = _getPluginState.decorationSet;
36
98
  return decorationSet;
37
99
  }
@@ -14,11 +14,13 @@ var _default = exports.default = function _default(pluginState, action) {
14
14
  switch (action.type) {
15
15
  case _actions.DragAndDropActionType.SET_DROP_TARGET:
16
16
  return _objectSpread(_objectSpread({}, pluginState), {}, {
17
+ decorationSet: action.data.decorationSet,
17
18
  dropTargetType: action.data.type,
18
19
  dropTargetIndex: action.data.index
19
20
  });
20
21
  case _actions.DragAndDropActionType.CLEAR_DROP_TARGET:
21
22
  return _objectSpread(_objectSpread({}, pluginState), {}, {
23
+ decorationSet: action.data.decorationSet,
22
24
  dropTargetType: _consts.DropTargetType.NONE,
23
25
  dropTargetIndex: 0
24
26
  });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "getDraggableDataFromEvent", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _monitor.getDraggableDataFromEvent;
10
+ }
11
+ });
12
+ var _monitor = require("./monitor");
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDraggableDataFromEvent = void 0;
7
+ var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge");
8
+ var getDraggableDataFromEvent = exports.getDraggableDataFromEvent = function getDraggableDataFromEvent(_ref) {
9
+ var _extractClosestEdge;
10
+ var location = _ref.location,
11
+ source = _ref.source;
12
+ var destination = location.current.dropTargets.at(0);
13
+ // If no target exists at the current location, then the current draggable is not over a target or the target doesn't support
14
+ // the current draggable.
15
+ if (!destination) {
16
+ return undefined;
17
+ }
18
+
19
+ // This is the draggable elements data
20
+ var _ref2 = source.data,
21
+ sourceIndexes = _ref2.indexes,
22
+ sourceType = _ref2.type,
23
+ sourceLocalId = _ref2.localId;
24
+
25
+ // This is the drop target's data
26
+ var _ref3 = destination.data,
27
+ targetIndex = _ref3.targetIndex,
28
+ targetType = _ref3.type,
29
+ targetLocalId = _ref3.localId;
30
+
31
+ // Some basic check to abort early with...
32
+ if (!sourceIndexes || targetIndex < 0 ||
33
+ // abort if the type of the draggable is different to the target, for eg. rows cannot be dropped onto column targets.
34
+ sourceType !== targetType ||
35
+ // abort if the draggable is coming from a different table that the target is on.
36
+ sourceLocalId !== targetLocalId) {
37
+ return undefined;
38
+ }
39
+
40
+ // FIXME: currently we only support a single row/col index being moved, remove this clause when this is no longer the case.
41
+ if (sourceIndexes.length > 1) {
42
+ return undefined;
43
+ }
44
+ var targetClosestEdge = (_extractClosestEdge = (0, _closestEdge.extractClosestEdge)(destination.data)) !== null && _extractClosestEdge !== void 0 ? _extractClosestEdge : targetType === 'table-row' ? 'top' : 'left';
45
+ // NOTE: By default we always insert row/cols at the target index to the top/left (retrospectively of row/cols).
46
+ // This introduces an offset in the event the drop occured closer to the bottom/right of the target. We want
47
+ // the new target index to be 1 index higher.
48
+ var targetOffset = targetClosestEdge === 'right' || targetClosestEdge === 'bottom' ? 1 : 0;
49
+ return {
50
+ sourceType: sourceType,
51
+ sourceLocalId: sourceLocalId,
52
+ sourceIndexes: sourceIndexes,
53
+ targetType: targetType,
54
+ targetLocalId: targetLocalId,
55
+ targetIndex: targetIndex,
56
+ targetAdjustedIndex: targetIndex + targetOffset,
57
+ targetClosestEdge: targetClosestEdge
58
+ };
59
+ };
@@ -30,9 +30,9 @@ var _pluginFactory = require("./plugin-factory");
30
30
  var _pluginKey = require("./plugin-key");
31
31
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
32
32
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
33
- var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) {
33
+ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) {
34
34
  var _window;
35
- var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread({
35
+ var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread(_objectSpread({
36
36
  pluginConfig: pluginConfig,
37
37
  insertColumnButtonIndex: undefined,
38
38
  insertRowButtonIndex: undefined,
@@ -43,7 +43,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
43
43
  isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
44
44
  isHeaderColumnEnabled: false,
45
45
  isDragAndDropEnabled: dragAndDropEnabled
46
- }, _defaultTableSelection.defaultTableSelection), {}, {
46
+ }, _defaultTableSelection.defaultHoveredCell), _defaultTableSelection.defaultTableSelection), {}, {
47
47
  getIntl: getIntl
48
48
  }));
49
49
  var elementContentRects = {};
@@ -247,8 +247,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
247
247
  handleDOMEvents: {
248
248
  focus: _eventHandlers.handleFocus,
249
249
  blur: _eventHandlers.handleBlur,
250
- mousedown: _eventHandlers.handleMouseDown,
251
- mouseover: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseOver),
250
+ mousedown: (0, _eventHandlers.withCellTracking)(_eventHandlers.handleMouseDown),
251
+ mouseover: (0, _eventHandlers.whenTableInFocus)((0, _eventHandlers.withCellTracking)(_eventHandlers.handleMouseOver)),
252
252
  mouseleave: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseLeave),
253
253
  mouseout: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseOut),
254
254
  mousemove: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseMove, elementContentRects),
@@ -97,7 +97,8 @@ var _default = exports.default = function _default(pluginState, action) {
97
97
  case 'HOVER_ROWS':
98
98
  case 'HOVER_COLUMNS':
99
99
  case 'HOVER_TABLE':
100
- case 'HOVER_CELLS':
100
+ case 'HOVER_MERGED_CELLS':
101
+ case 'HOVER_CELL':
101
102
  case 'SHOW_RESIZE_HANDLE_LINE':
102
103
  case 'SET_EDITOR_FOCUS':
103
104
  return _objectSpread(_objectSpread({}, pluginState), action.data);