@atlaskit/editor-plugin-table 5.3.1 → 5.3.3

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 (161) hide show
  1. package/CHANGELOG.md +12 -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/main.js +5 -5
  13. package/dist/cjs/plugins/table/reducer.js +2 -1
  14. package/dist/cjs/plugins/table/types.js +6 -0
  15. package/dist/cjs/plugins/table/ui/DragHandle/index.js +50 -0
  16. package/dist/cjs/plugins/table/ui/DragPreview/index.js +39 -0
  17. package/dist/cjs/plugins/table/ui/Icons/DragInMotionIcon.js +55 -0
  18. package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +53 -14
  19. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +114 -0
  20. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +53 -0
  21. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +11 -106
  22. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +16 -6
  23. package/dist/cjs/plugins/table/ui/common-styles.js +9 -6
  24. package/dist/cjs/plugins/table/ui/consts.js +2 -1
  25. package/dist/cjs/plugins/table/ui/ui-styles.js +18 -9
  26. package/dist/cjs/plugins/table/utils/decoration.js +44 -18
  27. package/dist/cjs/plugins/table/utils/dom.js +7 -1
  28. package/dist/cjs/plugins/table/utils/index.js +12 -0
  29. package/dist/es2019/plugins/table/commands/hover.js +12 -8
  30. package/dist/es2019/plugins/table/commands/index.js +1 -1
  31. package/dist/es2019/plugins/table/commands/misc.js +1 -7
  32. package/dist/es2019/plugins/table/event-handlers.js +28 -2
  33. package/dist/es2019/plugins/table/index.js +1 -1
  34. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -3
  35. package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
  36. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +8 -6
  37. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  38. package/dist/es2019/plugins/table/pm-plugins/default-table-selection.js +13 -0
  39. package/dist/es2019/plugins/table/pm-plugins/main.js +6 -5
  40. package/dist/es2019/plugins/table/reducer.js +2 -1
  41. package/dist/es2019/plugins/table/types.js +6 -0
  42. package/dist/es2019/plugins/table/ui/DragHandle/index.js +41 -0
  43. package/dist/es2019/plugins/table/ui/DragPreview/index.js +33 -0
  44. package/dist/es2019/plugins/table/ui/Icons/DragInMotionIcon.js +47 -0
  45. package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -10
  46. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +86 -0
  47. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +43 -0
  48. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -88
  49. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -7
  50. package/dist/es2019/plugins/table/ui/common-styles.js +47 -12
  51. package/dist/es2019/plugins/table/ui/consts.js +1 -0
  52. package/dist/es2019/plugins/table/ui/ui-styles.js +57 -14
  53. package/dist/es2019/plugins/table/utils/decoration.js +44 -18
  54. package/dist/es2019/plugins/table/utils/dom.js +2 -0
  55. package/dist/es2019/plugins/table/utils/index.js +1 -1
  56. package/dist/esm/plugins/table/commands/hover.js +16 -8
  57. package/dist/esm/plugins/table/commands/index.js +1 -1
  58. package/dist/esm/plugins/table/commands/misc.js +1 -7
  59. package/dist/esm/plugins/table/event-handlers.js +29 -2
  60. package/dist/esm/plugins/table/index.js +1 -1
  61. package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -3
  62. package/dist/esm/plugins/table/nodeviews/table.js +4 -2
  63. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +8 -6
  64. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +7 -2
  65. package/dist/esm/plugins/table/pm-plugins/default-table-selection.js +13 -0
  66. package/dist/esm/plugins/table/pm-plugins/main.js +7 -7
  67. package/dist/esm/plugins/table/reducer.js +2 -1
  68. package/dist/esm/plugins/table/types.js +6 -0
  69. package/dist/esm/plugins/table/ui/DragHandle/index.js +41 -0
  70. package/dist/esm/plugins/table/ui/DragPreview/index.js +32 -0
  71. package/dist/esm/plugins/table/ui/Icons/DragInMotionIcon.js +48 -0
  72. package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +54 -15
  73. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.js +104 -0
  74. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -0
  75. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +2 -104
  76. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +17 -7
  77. package/dist/esm/plugins/table/ui/common-styles.js +10 -7
  78. package/dist/esm/plugins/table/ui/consts.js +1 -0
  79. package/dist/esm/plugins/table/ui/ui-styles.js +18 -9
  80. package/dist/esm/plugins/table/utils/decoration.js +44 -18
  81. package/dist/esm/plugins/table/utils/dom.js +6 -0
  82. package/dist/esm/plugins/table/utils/index.js +1 -1
  83. package/dist/types/plugins/table/commands/hover.d.ts +2 -1
  84. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  85. package/dist/types/plugins/table/event-handlers.d.ts +1 -0
  86. package/dist/types/plugins/table/nodeviews/types.d.ts +4 -3
  87. package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
  88. package/dist/types/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
  89. package/dist/types/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
  90. package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
  91. package/dist/types/plugins/table/types.d.ts +16 -1
  92. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +11 -0
  93. package/dist/types/plugins/table/ui/DragPreview/index.d.ts +6 -0
  94. package/dist/types/plugins/table/ui/Icons/DragInMotionIcon.d.ts +6 -0
  95. package/dist/types/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
  96. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
  97. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
  98. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
  99. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  100. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  101. package/dist/types/plugins/table/utils/decoration.d.ts +2 -2
  102. package/dist/types/plugins/table/utils/dom.d.ts +2 -0
  103. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  104. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
  105. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
  106. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -0
  107. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +4 -3
  108. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -1
  109. package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +1 -1
  110. package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +12 -0
  111. package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
  112. package/dist/types-ts4.5/plugins/table/types.d.ts +16 -1
  113. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +11 -0
  114. package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +6 -0
  115. package/dist/types-ts4.5/plugins/table/ui/Icons/DragInMotionIcon.d.ts +6 -0
  116. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +4 -1
  117. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.d.ts +17 -0
  118. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +16 -0
  119. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +2 -17
  120. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -2
  121. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  122. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +2 -2
  123. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +2 -0
  124. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  125. package/package.json +5 -3
  126. package/src/__tests__/unit/event-handlers.ts +74 -1
  127. package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +35 -15
  128. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +146 -42
  129. package/src/__tests__/unit/ui/NumberColumn.tsx +148 -0
  130. package/src/__tests__/unit/ui/RowControls.tsx +4 -4
  131. package/src/__tests__/unit/ui/RowDragControls.tsx +118 -0
  132. package/src/__tests__/unit/ui/TableFloatingControls.tsx +9 -5
  133. package/src/plugins/table/commands/hover.ts +16 -7
  134. package/src/plugins/table/commands/index.ts +1 -0
  135. package/src/plugins/table/commands/misc.ts +0 -5
  136. package/src/plugins/table/event-handlers.ts +49 -2
  137. package/src/plugins/table/index.tsx +1 -1
  138. package/src/plugins/table/nodeviews/TableComponent.tsx +3 -2
  139. package/src/plugins/table/nodeviews/table.tsx +2 -0
  140. package/src/plugins/table/nodeviews/types.ts +4 -3
  141. package/src/plugins/table/pm-plugins/decorations/plugin.ts +13 -4
  142. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +10 -5
  143. package/src/plugins/table/pm-plugins/default-table-selection.ts +10 -0
  144. package/src/plugins/table/pm-plugins/main.ts +9 -4
  145. package/src/plugins/table/reducer.ts +2 -1
  146. package/src/plugins/table/types.ts +14 -2
  147. package/src/plugins/table/ui/DragHandle/index.tsx +57 -0
  148. package/src/plugins/table/ui/DragPreview/index.tsx +45 -0
  149. package/src/plugins/table/ui/Icons/DragInMotionIcon.tsx +60 -0
  150. package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +68 -30
  151. package/src/plugins/table/ui/TableFloatingControls/RowControls/ClassicControls.tsx +129 -0
  152. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +75 -0
  153. package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +2 -135
  154. package/src/plugins/table/ui/TableFloatingControls/index.tsx +43 -24
  155. package/src/plugins/table/ui/common-styles.ts +52 -11
  156. package/src/plugins/table/ui/consts.ts +1 -0
  157. package/src/plugins/table/ui/ui-styles.ts +58 -14
  158. package/src/plugins/table/utils/decoration.ts +75 -27
  159. package/src/plugins/table/utils/dom.ts +8 -0
  160. package/src/plugins/table/utils/index.ts +2 -0
  161. package/tsconfig.app.json +6 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#41701](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41701) [`168e0da8a1c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/168e0da8a1c) - [ux] ED-20425: Added DragPreview and DragInMotionIcon
8
+
9
+ ## 5.3.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+
3
15
  ## 5.3.1
4
16
 
5
17
  ### Patch 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
  };
@@ -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);
@@ -54,6 +54,7 @@ var TableDecorations = exports.TableDecorations = /*#__PURE__*/function (TableDe
54
54
  return TableDecorations;
55
55
  }({});
56
56
  var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread({}, _styles.TableSharedCssClassName), {}, {
57
+ /** Classic controls */
57
58
  COLUMN_CONTROLS: "".concat(_adfSchema.tablePrefixSelector, "-column-controls"),
58
59
  COLUMN_CONTROLS_DECORATIONS: "".concat(_adfSchema.tablePrefixSelector, "-column-controls-decoration"),
59
60
  COLUMN_SELECTED: "".concat(_adfSchema.tablePrefixSelector, "-column__selected"),
@@ -84,8 +85,13 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
84
85
  CORNER_CONTROLS_INSERT_ROW_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-corner-controls__insert-row-marker"),
85
86
  CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-corner-controls__insert-column-marker"),
86
87
  CONTROLS_CORNER_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-corner-button"),
88
+ /** Controls with drag handle */
89
+ COLUMN_CONTROLS_DECORATIONS_WITH_DRAG: "".concat(_adfSchema.tablePrefixSelector, "-column-controls-decoration-with-drag"),
90
+ ROW_CONTROLS_WITH_DRAG: "".concat(_adfSchema.tablePrefixSelector, "-row-controls-with-drag"),
91
+ /** Other classes */
87
92
  NUMBERED_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column"),
88
93
  NUMBERED_COLUMN_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column__button"),
94
+ NUMBERED_COLUMN_BUTTON_DISABLED: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column__button-disabled"),
89
95
  HOVERED_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-hovered-column"),
90
96
  HOVERED_ROW: "".concat(_adfSchema.tablePrefixSelector, "-hovered-row"),
91
97
  HOVERED_TABLE: "".concat(_adfSchema.tablePrefixSelector, "-hovered-table"),
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DragHandle = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _dragHandleButton = require("@atlaskit/pragmatic-drag-and-drop-react-accessibility/drag-handle-button");
10
+ var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ // TODO: use for now, in future replace with custom @atlaskit/icon/glyph/drag-handler
14
+ // width is too large (24px), should be 16px
15
+ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
16
+ var tableLocalId = _ref.tableLocalId,
17
+ _ref$direction = _ref.direction,
18
+ direction = _ref$direction === void 0 ? 'row' : _ref$direction,
19
+ indexes = _ref.indexes,
20
+ onClick = _ref.onClick,
21
+ onMouseOver = _ref.onMouseOver,
22
+ onMouseOut = _ref.onMouseOut;
23
+ var dragHandleDivRef = (0, _react.useRef)(null);
24
+ (0, _react.useEffect)(function () {
25
+ var dragHandleDivRefCurrent = dragHandleDivRef.current;
26
+ if (dragHandleDivRefCurrent) {
27
+ return (0, _element.draggable)({
28
+ element: dragHandleDivRefCurrent,
29
+ getInitialData: function getInitialData() {
30
+ return {
31
+ localId: tableLocalId,
32
+ type: "table-".concat(direction),
33
+ indexes: indexes
34
+ };
35
+ }
36
+ });
37
+ }
38
+ }, [tableLocalId, direction, indexes]);
39
+ return /*#__PURE__*/_react.default.createElement("div", {
40
+ ref: dragHandleDivRef,
41
+ style: {
42
+ backgroundColor: "var(--ds-surface, white)",
43
+ borderRadius: '4px',
44
+ border: "2px solid ".concat("var(--ds-surface, white)"),
45
+ transform: direction === 'column' ? 'rotate(90deg)' : 'none'
46
+ }
47
+ }, /*#__PURE__*/_react.default.createElement(_dragHandleButton.DragHandleButton, {
48
+ label: "blah"
49
+ }));
50
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DragPreview = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _primitives = require("@atlaskit/primitives");
10
+ var _DragInMotionIcon = require("../Icons/DragInMotionIcon");
11
+ var boxStyles = (0, _primitives.xcss)({
12
+ borderColor: 'color.border.focused',
13
+ borderStyle: 'solid',
14
+ borderRadius: 'border.radius.100',
15
+ borderWidth: 'border.width.outline',
16
+ backgroundColor: 'color.blanket.selected'
17
+ });
18
+ var DragPreview = exports.DragPreview = function DragPreview(_ref) {
19
+ var direction = _ref.direction,
20
+ width = _ref.width,
21
+ height = _ref.height;
22
+ var marginLeft = direction === 'row' ? -14 : width / 2 - 14;
23
+ var marginTop = direction === 'row' ? height / 2 - 14 : -10;
24
+ var transform = direction === 'row' ? 'rotate(90deg)' : 'none';
25
+ return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
26
+ xcss: boxStyles,
27
+ style: {
28
+ width: "".concat(width, "px"),
29
+ height: "".concat(height, "px")
30
+ }
31
+ }, /*#__PURE__*/_react.default.createElement(_DragInMotionIcon.DragInMotionIcon, {
32
+ style: {
33
+ position: 'absolute',
34
+ marginLeft: "".concat(marginLeft, "px"),
35
+ marginTop: "".concat(marginTop, "px"),
36
+ transform: transform
37
+ }
38
+ }));
39
+ };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DragInMotionIcon = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var DragInMotionIcon = exports.DragInMotionIcon = function DragInMotionIcon(_ref) {
10
+ var style = _ref.style;
11
+ return /*#__PURE__*/_react.default.createElement("svg", {
12
+ width: "28",
13
+ height: "20",
14
+ viewBox: "0 0 28 20",
15
+ fill: "none",
16
+ xmlns: "http://www.w3.org/2000/svg",
17
+ style: style
18
+ }, /*#__PURE__*/_react.default.createElement("rect", {
19
+ x: "1",
20
+ y: "1",
21
+ width: "26",
22
+ height: "18",
23
+ rx: "5",
24
+ fill: "var(--ds-background-accent-blue-subtle, #579DFF)"
25
+ }), /*#__PURE__*/_react.default.createElement("rect", {
26
+ x: "9",
27
+ y: "6",
28
+ width: "2",
29
+ height: "8",
30
+ rx: "1",
31
+ fill: "var(--ds-border-inverse, #FFFFFF)"
32
+ }), /*#__PURE__*/_react.default.createElement("rect", {
33
+ x: "13",
34
+ y: "6",
35
+ width: "2",
36
+ height: "8",
37
+ rx: "1",
38
+ fill: "var(--ds-border-inverse, #FFFFFF)"
39
+ }), /*#__PURE__*/_react.default.createElement("rect", {
40
+ x: "17",
41
+ y: "6",
42
+ width: "2",
43
+ height: "8",
44
+ rx: "1",
45
+ fill: "var(--ds-border-inverse, #FFFFFF)"
46
+ }), /*#__PURE__*/_react.default.createElement("rect", {
47
+ x: "1",
48
+ y: "1",
49
+ width: "26",
50
+ height: "18",
51
+ rx: "5",
52
+ stroke: "var(--ds-border-inverse, #FFFFFF)",
53
+ strokeWidth: "2"
54
+ }));
55
+ };
@@ -14,11 +14,14 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
14
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
16
  var _react = _interopRequireWildcard(require("react"));
17
+ var _classnames2 = _interopRequireDefault(require("classnames"));
17
18
  var _state = require("@atlaskit/editor-prosemirror/state");
18
19
  var _utils = require("@atlaskit/editor-tables/utils");
19
20
  var _commands = require("../../../commands");
21
+ var _pluginFactory = require("../../../pm-plugins/plugin-factory");
20
22
  var _types = require("../../../types");
21
23
  var _utils2 = require("../../../utils");
24
+ var _consts = require("../../consts");
22
25
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
27
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -69,14 +72,42 @@ var NumberColumn = exports.default = /*#__PURE__*/function (_Component) {
69
72
  (0, _commands.clearHoverSelection)()(state, dispatch);
70
73
  }
71
74
  });
72
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getClassNames", function (index) {
75
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDragHandleLocation", function (rowIndex) {
73
76
  var _this$props3 = _this.props,
74
- hoveredRows = _this$props3.hoveredRows,
75
77
  editorView = _this$props3.editorView,
76
- isInDanger = _this$props3.isInDanger,
77
- isResizing = _this$props3.isResizing;
78
+ tableActive = _this$props3.tableActive;
79
+ var state = editorView.state,
80
+ dispatch = editorView.dispatch;
81
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
82
+ hoveredCell = _getPluginState.hoveredCell;
83
+ if (tableActive && hoveredCell.rowIndex !== rowIndex) {
84
+ (0, _commands.hoverCell)(rowIndex, hoveredCell.colIndex)(state, dispatch);
85
+ }
86
+ });
87
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getCellStyles", function (index, rowHeight) {
88
+ var _this$props4 = _this.props,
89
+ stickyTop = _this$props4.stickyTop,
90
+ hasHeaderRow = _this$props4.hasHeaderRow;
91
+ if (stickyTop && hasHeaderRow && index === 0) {
92
+ return {
93
+ height: rowHeight,
94
+ top: "".concat(stickyTop, "px")
95
+ };
96
+ }
97
+ return {
98
+ height: rowHeight
99
+ };
100
+ });
101
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getClassNames", function (index) {
102
+ var _classnames;
103
+ var isButtonDisabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
104
+ var _this$props5 = _this.props,
105
+ hoveredRows = _this$props5.hoveredRows,
106
+ editorView = _this$props5.editorView,
107
+ isInDanger = _this$props5.isInDanger,
108
+ isResizing = _this$props5.isResizing;
78
109
  var isActive = (0, _utils.isRowSelected)(index)(editorView.state.selection) || (hoveredRows || []).indexOf(index) !== -1 && !isResizing;
79
- return [_types.TableCssClassName.NUMBERED_COLUMN_BUTTON, isActive ? _types.TableCssClassName.HOVERED_CELL_ACTIVE : '', isActive && isInDanger ? _types.TableCssClassName.HOVERED_CELL_IN_DANGER : ''].join(' ');
110
+ return (0, _classnames2.default)(_types.TableCssClassName.NUMBERED_COLUMN_BUTTON, (_classnames = {}, (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.NUMBERED_COLUMN_BUTTON_DISABLED, isButtonDisabled), (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.HOVERED_CELL_IN_DANGER, isActive && isInDanger), (0, _defineProperty2.default)(_classnames, _types.TableCssClassName.HOVERED_CELL_ACTIVE, isActive), _classnames));
80
111
  });
81
112
  return _this;
82
113
  }
@@ -84,25 +115,33 @@ var NumberColumn = exports.default = /*#__PURE__*/function (_Component) {
84
115
  key: "render",
85
116
  value: function render() {
86
117
  var _this2 = this;
87
- var _this$props4 = this.props,
88
- tableRef = _this$props4.tableRef,
89
- hasHeaderRow = _this$props4.hasHeaderRow;
118
+ var _this$props6 = this.props,
119
+ tableRef = _this$props6.tableRef,
120
+ hasHeaderRow = _this$props6.hasHeaderRow,
121
+ isDragAndDropEnabled = _this$props6.isDragAndDropEnabled,
122
+ tableActive = _this$props6.tableActive;
90
123
  var rowHeights = (0, _utils2.getRowHeights)(tableRef);
91
124
  return /*#__PURE__*/_react.default.createElement("div", {
92
125
  className: _types.TableCssClassName.NUMBERED_COLUMN,
93
126
  style: {
94
- marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined
127
+ marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined,
128
+ borderLeft: isDragAndDropEnabled && tableActive ? "1px solid ".concat((0, _consts.tableBorderColor)()) : undefined
95
129
  },
96
130
  contentEditable: false
97
131
  }, rowHeights.map(function (rowHeight, index) {
98
- return /*#__PURE__*/_react.default.createElement("div", {
132
+ return isDragAndDropEnabled ? /*#__PURE__*/_react.default.createElement("div", {
133
+ key: "wrapper-".concat(index),
134
+ className: _this2.getClassNames(index, true),
135
+ "data-index": index,
136
+ style: _this2.getCellStyles(index, rowHeight),
137
+ onMouseOver: function onMouseOver() {
138
+ return _this2.updateDragHandleLocation(index);
139
+ }
140
+ }, hasHeaderRow ? index > 0 ? index : null : index + 1) : /*#__PURE__*/_react.default.createElement("div", {
99
141
  key: "wrapper-".concat(index),
100
142
  className: _this2.getClassNames(index),
101
143
  "data-index": index,
102
- style: {
103
- height: rowHeight,
104
- top: _this2.props.stickyTop !== undefined && hasHeaderRow && index === 0 ? "".concat(_this2.props.stickyTop, "px") : undefined
105
- },
144
+ style: _this2.getCellStyles(index, rowHeight),
106
145
  onClick: function onClick(event) {
107
146
  return _this2.selectRow(index, event);
108
147
  },