@atlaskit/editor-plugin-table 5.3.12 → 5.3.14

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 (155) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/plugins/table/event-handlers.js +6 -3
  3. package/dist/cjs/plugins/table/index.js +16 -2
  4. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
  5. package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +3 -7
  6. package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
  7. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
  8. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +22 -1
  9. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -7
  10. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
  11. package/dist/cjs/plugins/table/types.js +9 -2
  12. package/dist/cjs/plugins/table/ui/DragHandle/index.js +2 -0
  13. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +80 -0
  14. package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +62 -0
  15. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +52 -4
  16. package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
  17. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +12 -3
  18. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +44 -5
  19. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +6 -4
  20. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +44 -20
  21. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -0
  22. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  23. package/dist/cjs/plugins/table/ui/consts.js +3 -2
  24. package/dist/cjs/plugins/table/ui/ui-styles.js +27 -24
  25. package/dist/cjs/plugins/table/utils/dom.js +12 -4
  26. package/dist/cjs/plugins/table/utils/drag-menu.js +59 -0
  27. package/dist/cjs/plugins/table/utils/index.js +12 -0
  28. package/dist/es2019/plugins/table/event-handlers.js +5 -4
  29. package/dist/es2019/plugins/table/index.js +16 -2
  30. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
  31. package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +3 -7
  32. package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
  33. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
  34. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +20 -0
  35. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -3
  36. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +7 -0
  37. package/dist/es2019/plugins/table/types.js +9 -2
  38. package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
  39. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +77 -0
  40. package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +56 -0
  41. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +53 -2
  42. package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
  43. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +9 -3
  44. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +46 -6
  45. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
  46. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +45 -22
  47. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -0
  48. package/dist/es2019/plugins/table/ui/common-styles.js +51 -3
  49. package/dist/es2019/plugins/table/ui/consts.js +2 -1
  50. package/dist/es2019/plugins/table/ui/ui-styles.js +23 -1
  51. package/dist/es2019/plugins/table/utils/dom.js +5 -1
  52. package/dist/es2019/plugins/table/utils/drag-menu.js +44 -0
  53. package/dist/es2019/plugins/table/utils/index.js +1 -1
  54. package/dist/esm/plugins/table/event-handlers.js +7 -4
  55. package/dist/esm/plugins/table/index.js +16 -2
  56. package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
  57. package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +3 -7
  58. package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
  59. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
  60. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +21 -0
  61. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -7
  62. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
  63. package/dist/esm/plugins/table/types.js +9 -2
  64. package/dist/esm/plugins/table/ui/DragHandle/index.js +2 -0
  65. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +73 -0
  66. package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +55 -0
  67. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +51 -3
  68. package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
  69. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +9 -3
  70. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -6
  71. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
  72. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -22
  73. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -0
  74. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  75. package/dist/esm/plugins/table/ui/consts.js +2 -1
  76. package/dist/esm/plugins/table/ui/ui-styles.js +26 -23
  77. package/dist/esm/plugins/table/utils/dom.js +11 -3
  78. package/dist/esm/plugins/table/utils/drag-menu.js +52 -0
  79. package/dist/esm/plugins/table/utils/index.js +1 -1
  80. package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
  81. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
  82. package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
  83. package/dist/types/plugins/table/types.d.ts +10 -2
  84. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +4 -2
  85. package/dist/types/plugins/table/ui/DragPreview/index.d.ts +2 -1
  86. package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
  87. package/dist/types/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
  88. package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
  89. package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
  90. package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +6 -1
  91. package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
  92. package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +5 -5
  93. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  94. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +4 -0
  95. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
  96. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  97. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
  98. package/dist/types/plugins/table/utils/dom.d.ts +4 -1
  99. package/dist/types/plugins/table/utils/drag-menu.d.ts +7 -0
  100. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  101. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
  102. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
  103. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
  104. package/dist/types-ts4.5/plugins/table/types.d.ts +10 -2
  105. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +4 -2
  106. package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +2 -1
  107. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
  108. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
  109. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
  110. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
  111. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +6 -1
  112. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
  113. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +5 -5
  114. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  115. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +4 -0
  116. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
  117. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  118. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
  119. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -1
  120. package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +7 -0
  121. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  122. package/package.json +3 -2
  123. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +40 -194
  124. package/src/__tests__/unit/ui/RowDragControls.tsx +9 -11
  125. package/src/plugins/table/event-handlers.ts +15 -3
  126. package/src/plugins/table/index.tsx +18 -1
  127. package/src/plugins/table/nodeviews/TableComponent.tsx +2 -1
  128. package/src/plugins/table/pm-plugins/decorations/plugin.ts +2 -9
  129. package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -3
  130. package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +14 -1
  131. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +32 -1
  132. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +50 -2
  133. package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +7 -0
  134. package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +5 -0
  135. package/src/plugins/table/types.ts +14 -2
  136. package/src/plugins/table/ui/DragHandle/index.tsx +5 -1
  137. package/src/plugins/table/ui/DragPreview/index.tsx +2 -1
  138. package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +2 -1
  139. package/src/plugins/table/ui/FloatingDeleteButton/types.ts +3 -1
  140. package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +99 -0
  141. package/src/plugins/table/ui/FloatingDragMenu/index.tsx +91 -0
  142. package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +79 -4
  143. package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +31 -7
  144. package/src/plugins/table/ui/FloatingInsertButton/index.tsx +28 -13
  145. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +47 -3
  146. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +11 -4
  147. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +65 -25
  148. package/src/plugins/table/ui/TableFloatingControls/index.tsx +7 -0
  149. package/src/plugins/table/ui/common-styles.ts +57 -2
  150. package/src/plugins/table/ui/consts.ts +2 -0
  151. package/src/plugins/table/ui/ui-styles.ts +27 -1
  152. package/src/plugins/table/utils/dom.ts +11 -4
  153. package/src/plugins/table/utils/drag-menu.ts +65 -0
  154. package/src/plugins/table/utils/index.ts +2 -0
  155. package/tsconfig.app.json +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.3.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42038](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42038) [`071533736a8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/071533736a8) - Fixed an bug in the tables where the onBlur was causing the editor has focus flag to be reset to false. This would result in the drag handle disappearing due to the table not being active anymore.
8
+ - [#42188](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42188) [`5b8b565940b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5b8b565940b) - Killed the outline for the drag handle button which appears only in firfox when the button has focus
9
+ - [#42186](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42186) [`20b5f464a2b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/20b5f464a2b) - [ux] Integrate drag menu with column control
10
+ - [#42148](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42148) [`fb0c3a2c035`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fb0c3a2c035) - Add row and column select functionality for table drag controls
11
+ - [#42182](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42182) [`1053f5745d3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1053f5745d3) - Added autoscroller functionality to the table DnD plugin. When dragging rows/cols the table will auto scroll into view when the drag approaches the borders of the table
12
+
13
+ ## 5.3.13
14
+
15
+ ### Patch Changes
16
+
17
+ - [#41846](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41846) [`7fe6ab0832b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7fe6ab0832b) - [ux] Add utility function to create drag menu content and integrate with row control behind platform.editor.table.drag-and-drop FF
18
+ - [#42137](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42137) [`88058fc0fcb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/88058fc0fcb) - ED-20197 moved editor preset and other prod code out of labs
19
+ - Updated dependencies
20
+
3
21
  ## 5.3.12
4
22
 
5
23
  ### Patch Changes
@@ -30,12 +30,15 @@ var isFocusingModal = function isFocusingModal(event) {
30
30
  var isFocusingFloatingToolbar = function isFocusingFloatingToolbar(event) {
31
31
  return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
32
32
  };
33
+ var isFocusingDragHandles = function isFocusingDragHandles(event) {
34
+ return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.getAttribute('draggable') === 'true';
35
+ };
33
36
  var handleBlur = exports.handleBlur = function handleBlur(view, event) {
34
37
  var state = view.state,
35
38
  dispatch = view.dispatch;
36
39
  // IE version check for ED-4665
37
40
  // Calendar focus check for ED-10466
38
- if (_utils.browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
41
+ if (_utils.browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event)) {
39
42
  (0, _commands.setEditorFocus)(false)(state, dispatch);
40
43
  }
41
44
  event.preventDefault();
@@ -192,7 +195,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
192
195
  return false;
193
196
  }
194
197
  var element = event.target;
195
- if ((0, _utils3.isColumnControlsDecorations)(element)) {
198
+ if ((0, _utils3.isColumnControlsDecorations)(element) || (0, _utils3.isDragColumnFloatingInsertDot)(element)) {
196
199
  var state = view.state,
197
200
  dispatch = view.dispatch;
198
201
  var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
@@ -206,7 +209,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
206
209
  return (0, _commands.showInsertColumnButton)(positionColumn)(state, dispatch);
207
210
  }
208
211
  }
209
- if ((0, _utils3.isRowControlsButton)(element)) {
212
+ if ((0, _utils3.isRowControlsButton)(element) || (0, _utils3.isDragRowFloatingInsertDot)(element)) {
210
213
  var _state3 = view.state,
211
214
  _dispatch4 = view.dispatch;
212
215
  var _getPluginState4 = (0, _pluginFactory.getPluginState)(_state3),
@@ -35,6 +35,7 @@ var _toolbar = require("./toolbar");
35
35
  var _FloatingContextualButton = _interopRequireDefault(require("./ui/FloatingContextualButton"));
36
36
  var _FloatingContextualMenu = _interopRequireDefault(require("./ui/FloatingContextualMenu"));
37
37
  var _FloatingDeleteButton = _interopRequireDefault(require("./ui/FloatingDeleteButton"));
38
+ var _FloatingDragMenu = _interopRequireDefault(require("./ui/FloatingDragMenu"));
38
39
  var _FloatingInsertButton = _interopRequireDefault(require("./ui/FloatingInsertButton"));
39
40
  var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
40
41
  var _utils3 = require("./utils");
@@ -256,7 +257,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
256
257
  var resizingPluginState = _ref13.tableResizingPluginState,
257
258
  stickyHeadersState = _ref13.stickyHeadersState,
258
259
  tablePluginState = _ref13.tablePluginState,
259
- tableWidthPluginState = _ref13.tableWidthPluginState;
260
+ tableWidthPluginState = _ref13.tableWidthPluginState,
261
+ dragAndDropState = _ref13.dragAndDropState;
260
262
  var state = editorView.state;
261
263
  var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
262
264
  var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
@@ -273,6 +275,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
273
275
  insertRowButtonIndex = _ref14.insertRowButtonIndex,
274
276
  isHeaderColumnEnabled = _ref14.isHeaderColumnEnabled,
275
277
  isHeaderRowEnabled = _ref14.isHeaderRowEnabled,
278
+ isDragAndDropEnabled = _ref14.isDragAndDropEnabled,
276
279
  tableWrapperTarget = _ref14.tableWrapperTarget;
277
280
  var allowControls = pluginConfig.allowControls;
278
281
  var stickyHeader = stickyHeadersState ? (0, _stickyHeaders.findStickyHeaderForTable)(stickyHeadersState, tablePos) : undefined;
@@ -306,6 +309,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
306
309
  insertRowButtonIndex: insertRowButtonIndex,
307
310
  isHeaderColumnEnabled: isHeaderColumnEnabled,
308
311
  isHeaderRowEnabled: isHeaderRowEnabled,
312
+ isDragAndDropEnabled: isDragAndDropEnabled,
309
313
  editorView: editorView,
310
314
  mountPoint: popupsMountPoint,
311
315
  boundariesElement: popupsBoundariesElement,
@@ -324,7 +328,17 @@ var tablesPlugin = function tablesPlugin(_ref) {
324
328
  editorAnalyticsAPI: editorAnalyticsAPI,
325
329
  getEditorContainerWidth: defaultGetEditorContainerWidth,
326
330
  getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
327
- }), allowControls && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
331
+ }), isDragAndDropEnabled && /*#__PURE__*/_react.default.createElement(_FloatingDragMenu.default, {
332
+ editorView: editorView,
333
+ mountPoint: popupsMountPoint,
334
+ boundariesElement: popupsBoundariesElement,
335
+ tableRef: tableRef,
336
+ tableNode: tableNode,
337
+ targetCellPosition: targetCellPosition,
338
+ direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
339
+ index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
340
+ isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
341
+ }), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
328
342
  editorView: editorView,
329
343
  selection: editorView.state.selection,
330
344
  tableRef: tableRef,
@@ -479,6 +479,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
479
479
  }, /*#__PURE__*/_react.default.createElement(_TableFloatingControls.default, {
480
480
  editorView: view,
481
481
  tableRef: tableRef,
482
+ tableNode: node,
482
483
  tableActive: tableActive,
483
484
  hoveredRows: hoveredRows,
484
485
  hoveredCell: hoveredCell,
@@ -486,7 +487,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
486
487
  isResizing: isResizing,
487
488
  isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
488
489
  isHeaderRowEnabled: isHeaderRowEnabled,
489
- isDragAndDropEnabled: options === null || options === void 0 ? void 0 : options.isDragAndDropEnabled,
490
+ isDragAndDropEnabled: isDragAndDropEnabled,
490
491
  ordering: ordering,
491
492
  isHeaderColumnEnabled: isHeaderColumnEnabled,
492
493
  hasHeaderRow: hasHeaderRow
@@ -17,7 +17,7 @@ var getDecorations = exports.getDecorations = function getDecorations(state) {
17
17
  return pluginKey.getState(state);
18
18
  };
19
19
  var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
20
- var _tableWidthPluginKey$, _tableWidthPluginKey$2, _tr$getMeta;
20
+ var _tableWidthPluginKey$, _tableWidthPluginKey$2;
21
21
  var isResizing = (_tableWidthPluginKey$ = _tableWidth.pluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
22
22
  var wasResizing = (_tableWidthPluginKey$2 = _tableWidth.pluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
23
23
  var changedResizing = isResizing !== wasResizing;
@@ -25,7 +25,7 @@ var handleDocOrSelectionChanged = exports.handleDocOrSelectionChanged = function
25
25
  // Remove column controls when resizing and don't add column decoration controls when DnD enabled
26
26
  if (isResizing || (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-and-drop')) {
27
27
  return _view.DecorationSet.empty;
28
- } 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
+ } else if (tr.docChanged || tr.selection instanceof _cellSelection.CellSelection || changedResizing) {
29
29
  return (0, _utils.buildColumnControlsDecorations)({
30
30
  decorationSet: decorationSet,
31
31
  tr: tr
@@ -48,16 +48,12 @@ var createPlugin = exports.createPlugin = function createPlugin() {
48
48
  return _view.DecorationSet.empty;
49
49
  },
50
50
  apply: function apply(tr, decorationSet, oldState, newState) {
51
- var _tablePluginKey$getSt, _tablePluginKey$getSt2;
52
51
  var pluginState = decorationSet;
53
52
  var meta = tr.getMeta(_pluginKey.pluginKey);
54
- var previousHover = (_tablePluginKey$getSt = _pluginKey.pluginKey.getState(oldState)) === null || _tablePluginKey$getSt === void 0 ? void 0 : _tablePluginKey$getSt.hoveredCell;
55
- var newHover = (_tablePluginKey$getSt2 = _pluginKey.pluginKey.getState(newState)) === null || _tablePluginKey$getSt2 === void 0 ? void 0 : _tablePluginKey$getSt2.hoveredCell;
56
- 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);
57
53
  if (meta && meta.data && meta.data.decorationSet) {
58
54
  pluginState = meta.data.decorationSet;
59
55
  }
60
- if (tr.docChanged || tr.selectionSet || tr.getMeta(_tableWidth.pluginKey) || changedCellHover) {
56
+ if (tr.docChanged || tr.selectionSet || tr.getMeta(_tableWidth.pluginKey)) {
61
57
  pluginState = pluginState.map(tr.mapping, tr.doc);
62
58
  return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
63
59
  }
@@ -8,7 +8,6 @@ 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");
12
11
  var _composeDecorations = require("./compose-decorations");
13
12
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
14
13
 
@@ -33,10 +32,9 @@ var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDeco
33
32
  var decorationSet = _ref3.decorationSet,
34
33
  tr = _ref3.tr;
35
34
  var table = (0, _utils.findTable)(tr.selection);
36
- var meta = tr.getMeta(_pluginKey.pluginKey);
37
35
 
38
36
  // avoid re-drawing state if dnd decorations don't need to be updated
39
- if (!table && (meta === null || meta === void 0 ? void 0 : meta.type) !== 'HOVER_CELL') {
37
+ if (!table) {
40
38
  return decorationSet;
41
39
  }
42
40
  return (0, _decoration.updateDecorations)(tr.doc, decorationSet, (0, _decoration.createColumnControlsDecoration)(tr.selection), _types.TableDecorations.COLUMN_CONTROLS_DECORATIONS);
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.DragAndDropActionType = void 0;
7
7
  var DragAndDropActionType = exports.DragAndDropActionType = {
8
8
  SET_DROP_TARGET: 'SET_DROP_TARGET',
9
- CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET'
9
+ CLEAR_DROP_TARGET: 'CLEAR_DROP_TARGET',
10
+ TOGGLE_DRAG_MENU: 'TOGGLE_DRAG_MENU'
10
11
  };
11
12
 
12
13
  // NOTE: This should be a Union of all possible actions
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.updatePluginStateDecorations = exports.setDropTarget = exports.moveSource = exports.getDecorations = exports.clearDropTarget = void 0;
6
+ exports.updatePluginStateDecorations = exports.toggleDragMenu = exports.setDropTarget = exports.moveSource = exports.getDecorations = exports.clearDropTarget = void 0;
7
7
  var _view = require("@atlaskit/editor-prosemirror/view");
8
8
  var _utils = require("@atlaskit/editor-tables/utils");
9
9
  var _types = require("../../types");
@@ -82,4 +82,25 @@ var moveSource = exports.moveSource = function moveSource(sourceType, sourceInde
82
82
  var select = isTableRow ? _utils.selectRow : _utils.selectColumn;
83
83
  return select(targetIndex)(newTr);
84
84
  });
85
+ };
86
+ var toggleDragMenu = exports.toggleDragMenu = function toggleDragMenu(isDragMenuOpen, direction, index) {
87
+ return (0, _pluginFactory.createCommand)(function (state) {
88
+ var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
89
+ previousOpenState = _getPluginState3.isDragMenuOpen,
90
+ dragMenuDirection = _getPluginState3.dragMenuDirection,
91
+ dragMenuIndex = _getPluginState3.dragMenuIndex;
92
+ if (previousOpenState === isDragMenuOpen) {
93
+ return false;
94
+ }
95
+ return {
96
+ type: _actions.DragAndDropActionType.TOGGLE_DRAG_MENU,
97
+ data: {
98
+ isDragMenuOpen: isDragMenuOpen === undefined ? !previousOpenState : isDragMenuOpen,
99
+ direction: direction !== null && direction !== void 0 ? direction : dragMenuDirection,
100
+ index: index !== null && index !== void 0 ? index : dragMenuIndex
101
+ }
102
+ };
103
+ }, function (tr) {
104
+ return tr.setMeta('addToHistory', false);
105
+ });
85
106
  };
@@ -8,9 +8,12 @@ exports.createPlugin = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
10
  var _view = require("@atlaskit/editor-prosemirror/view");
11
+ var _utils = require("@atlaskit/editor-tables/utils");
12
+ var _pragmaticDragAndDropReactBeautifulDndAutoscroll = require("@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll");
11
13
  var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
12
14
  var _mergedCells = require("../../utils/merged-cells");
13
15
  var _pluginFactory = require("../plugin-factory");
16
+ var _actions = require("./actions");
14
17
  var _commands = require("./commands");
15
18
  var _consts = require("./consts");
16
19
  var _pluginFactory2 = require("./plugin-factory");
@@ -21,13 +24,47 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
21
24
  state: (0, _pluginFactory2.createPluginState)(dispatch, function (state) {
22
25
  return {
23
26
  decorationSet: _view.DecorationSet.empty,
24
- // TODO: This is example placeholder state. We could use this to track which row/col is currently set as the drop target
25
- // This would result in a blue highlight being displayed on the corrisponding row/column to single the drop target location.
26
27
  dropTargetType: _consts.DropTargetType.NONE,
27
- dropTargetIndex: 0
28
+ dropTargetIndex: 0,
29
+ isDragMenuOpen: false,
30
+ dragMenuIndex: 0
28
31
  };
29
32
  }),
30
33
  key: _pluginKey.pluginKey,
34
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
35
+ var _getTablePluginState = (0, _pluginFactory.getPluginState)(oldState),
36
+ oldTargetCellPosition = _getTablePluginState.targetCellPosition;
37
+ var _getTablePluginState2 = (0, _pluginFactory.getPluginState)(newState),
38
+ newTargetCellPosition = _getTablePluginState2.targetCellPosition;
39
+ var _getPluginState = (0, _pluginFactory2.getPluginState)(newState),
40
+ isDragMenuOpen = _getPluginState.isDragMenuOpen,
41
+ dragMenuIndex = _getPluginState.dragMenuIndex;
42
+
43
+ // What's happening here? you asked... In a nutshell;
44
+ // If the target cell position changes while the drag menu is open then we want to close the drag menu if it has been opened.
45
+ // This will stop the drag menu from moving around the screen to different row/cols. Too achieve this we need
46
+ // to check if the new target cell position is pointed at a different cell than what the drag menu was opened on.
47
+ if (oldTargetCellPosition !== newTargetCellPosition) {
48
+ if (isDragMenuOpen) {
49
+ var tr = newState.tr;
50
+ var action = {
51
+ type: _actions.DragAndDropActionType.TOGGLE_DRAG_MENU,
52
+ data: {
53
+ isDragMenuOpen: false,
54
+ direction: undefined
55
+ }
56
+ };
57
+ if (newTargetCellPosition !== undefined) {
58
+ var cells = (0, _utils.getCellsInRow)(dragMenuIndex)(tr.selection);
59
+ if (cells && cells.length && cells[0].node !== tr.doc.nodeAt(newTargetCellPosition)) {
60
+ return tr.setMeta(_pluginKey.pluginKey, action);
61
+ } // else NOP
62
+ } else {
63
+ return tr.setMeta(_pluginKey.pluginKey, action);
64
+ }
65
+ }
66
+ }
67
+ },
31
68
  view: function view(editorView) {
32
69
  return {
33
70
  destroy: (0, _element.monitorForElements)({
@@ -45,13 +82,22 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
45
82
  indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
46
83
  return false;
47
84
  }
48
- var _getTablePluginState = (0, _pluginFactory.getPluginState)(editorView.state),
49
- tableNode = _getTablePluginState.tableNode;
85
+ var _getTablePluginState3 = (0, _pluginFactory.getPluginState)(editorView.state),
86
+ tableNode = _getTablePluginState3.tableNode;
50
87
  // If the draggable localId is the same as the current selected table localId then we will allow the monitor
51
88
  // watch for changes
52
89
  return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
53
90
  },
91
+ onDragStart: function onDragStart(_ref3) {
92
+ var location = _ref3.location;
93
+ _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.start({
94
+ input: location.current.input
95
+ });
96
+ },
54
97
  onDrag: function onDrag(event) {
98
+ _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.updateInput({
99
+ input: event.location.current.input
100
+ });
55
101
  var data = (0, _monitor.getDraggableDataFromEvent)(event);
56
102
  // If no data can be found then it's most like we do not want to perform any drag actions
57
103
  if (!data) {
@@ -67,6 +113,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
67
113
  (0, _commands.setDropTarget)(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
68
114
  },
69
115
  onDrop: function onDrop(event) {
116
+ _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.stop();
70
117
  var data = (0, _monitor.getDraggableDataFromEvent)(event);
71
118
 
72
119
  // If no data can be found then it's most like we do not want to perform any drop action
@@ -94,8 +141,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
94
141
  },
95
142
  props: {
96
143
  decorations: function decorations(state) {
97
- var _getPluginState = (0, _pluginFactory2.getPluginState)(state),
98
- decorationSet = _getPluginState.decorationSet;
144
+ var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
145
+ decorationSet = _getPluginState2.decorationSet;
99
146
  return decorationSet;
100
147
  }
101
148
  }
@@ -24,6 +24,12 @@ var _default = exports.default = function _default(pluginState, action) {
24
24
  dropTargetType: _consts.DropTargetType.NONE,
25
25
  dropTargetIndex: 0
26
26
  });
27
+ case _actions.DragAndDropActionType.TOGGLE_DRAG_MENU:
28
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
29
+ isDragMenuOpen: action.data.isDragMenuOpen,
30
+ dragMenuDirection: action.data.direction,
31
+ dragMenuIndex: action.data.index
32
+ });
27
33
  default:
28
34
  return pluginState;
29
35
  }
@@ -74,6 +74,9 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
74
74
  CONTROLS_INSERT_LINE: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-line"),
75
75
  CONTROLS_BUTTON_OVERLAY: "".concat(_adfSchema.tablePrefixSelector, "-controls__button-overlay"),
76
76
  LAYOUT_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-layout-button"),
77
+ DRAG_CONTROLS_INSERT_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-controls__drag-insert-button"),
78
+ DRAG_CONTROLS_INSERT_BUTTON_INNER: "".concat(_adfSchema.tablePrefixSelector, "-controls__drag-insert-button-inner"),
79
+ DRAG_CONTROLS_INSERT_BUTTON_WRAP: "".concat(_adfSchema.tablePrefixSelector, "-controls__drag-insert-button-wrap"),
77
80
  CONTROLS_INSERT_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-marker"),
78
81
  CONTROLS_INSERT_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-column"),
79
82
  CONTROLS_INSERT_ROW: "".concat(_adfSchema.tablePrefixSelector, "-controls__insert-row"),
@@ -86,8 +89,12 @@ var TableCssClassName = exports.TableCssClassName = _objectSpread(_objectSpread(
86
89
  CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(_adfSchema.tablePrefixSelector, "-corner-controls__insert-column-marker"),
87
90
  CONTROLS_CORNER_BUTTON: "".concat(_adfSchema.tablePrefixSelector, "-corner-button"),
88
91
  /** Controls with drag handle */
89
- COLUMN_CONTROLS_WITH_DRAG: "".concat(_adfSchema.tablePrefixSelector, "-column-controls-with-drag"),
90
- ROW_CONTROLS_WITH_DRAG: "".concat(_adfSchema.tablePrefixSelector, "-row-controls-with-drag"),
92
+ DRAG_ROW_CONTROLS: "".concat(_adfSchema.tablePrefixSelector, "-drag-row-controls"),
93
+ DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER: "".concat(_adfSchema.tablePrefixSelector, "-drag-row-floating-insert-dot-wrapper"),
94
+ DRAG_ROW_FLOATING_INSERT_DOT: "".concat(_adfSchema.tablePrefixSelector, "-drag-row-floating-insert-dot"),
95
+ DRAG_COLUMN_CONTROLS: "".concat(_adfSchema.tablePrefixSelector, "-drag-column-controls"),
96
+ DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER: "".concat(_adfSchema.tablePrefixSelector, "-drag-columns-floating-insert-dot-wrapper"),
97
+ DRAG_COLUMN_FLOATING_INSERT_DOT: "".concat(_adfSchema.tablePrefixSelector, "-drag-columns-floating-insert-dot"),
91
98
  DRAG_HANDLE_BUTTON_CONTAINER: "".concat(_adfSchema.tablePrefixSelector, "-drag-handle-button-container"),
92
99
  /** Other classes */
93
100
  NUMBERED_COLUMN: "".concat(_adfSchema.tablePrefixSelector, "-numbered-column"),
@@ -28,6 +28,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
28
28
  previewHeight = _ref.previewHeight,
29
29
  onMouseOver = _ref.onMouseOver,
30
30
  onMouseOut = _ref.onMouseOut,
31
+ onMouseUp = _ref.onMouseUp,
31
32
  onClick = _ref.onClick;
32
33
  var dragHandleDivRef = (0, _react.useRef)(null);
33
34
  var _useState = (0, _react.useState)(null),
@@ -87,6 +88,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
87
88
  "data-testid": "table-floating-column-controls-drag-handle",
88
89
  onMouseOver: onMouseOver,
89
90
  onMouseOut: onMouseOut,
91
+ onMouseUp: onMouseUp,
90
92
  onClick: onClick
91
93
  }, /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_DragPreview.DragPreview, {
92
94
  direction: direction,
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DragMenu = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
10
+ var _tableMap = require("@atlaskit/editor-tables/table-map");
11
+ var _commands = require("../../pm-plugins/drag-and-drop/commands");
12
+ var _dragMenu = require("../../utils/drag-menu");
13
+ var _consts = require("../consts");
14
+ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
15
+ var menuItems = [];
16
+ var menuCallback = {};
17
+ dragMenuConfig.forEach(function (item) {
18
+ menuItems.push({
19
+ key: item.id,
20
+ content: item.title,
21
+ value: {
22
+ name: item.id
23
+ },
24
+ isDisabled: item.disabled
25
+ });
26
+ item.onClick && (menuCallback[item.id] = item.onClick);
27
+ });
28
+ return {
29
+ menuItems: menuItems,
30
+ menuCallback: menuCallback
31
+ };
32
+ };
33
+ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
34
+ var _ref$direction = _ref.direction,
35
+ direction = _ref$direction === void 0 ? 'row' : _ref$direction,
36
+ index = _ref.index,
37
+ isOpen = _ref.isOpen,
38
+ editorView = _ref.editorView,
39
+ tableNode = _ref.tableNode,
40
+ mountPoint = _ref.mountPoint,
41
+ boundariesElement = _ref.boundariesElement,
42
+ scrollableElement = _ref.scrollableElement;
43
+ var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
44
+ var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, tableMap, index);
45
+ var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
46
+ menuItems = _convertToDropdownIte.menuItems,
47
+ menuCallback = _convertToDropdownIte.menuCallback;
48
+ var closeMenu = function closeMenu() {
49
+ var state = editorView.state,
50
+ dispatch = editorView.dispatch;
51
+ (0, _commands.toggleDragMenu)(false)(state, dispatch);
52
+ };
53
+ var onMenuItemActivated = function onMenuItemActivated(_ref2) {
54
+ var _menuCallback$item$va;
55
+ var item = _ref2.item;
56
+ (_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, editorView.state, editorView.dispatch);
57
+ closeMenu();
58
+ };
59
+ if (!menuItems) {
60
+ return null;
61
+ }
62
+ return /*#__PURE__*/_react.default.createElement(_uiMenu.DropdownMenu, {
63
+ mountTo: mountPoint
64
+ //This needs be removed when the a11y is completely handled
65
+ //Disabling key navigation now as it works only partially
66
+ ,
67
+ arrowKeyNavigationProviderOptions: {
68
+ type: _uiMenu.ArrowKeyNavigationType.MENU,
69
+ disableArrowKeyNavigation: true
70
+ },
71
+ items: [{
72
+ items: menuItems
73
+ }],
74
+ isOpen: isOpen,
75
+ onOpenChange: closeMenu,
76
+ onItemActivated: onMenuItemActivated,
77
+ fitWidth: _consts.dragMenuDropdownWidth,
78
+ boundariesElement: boundariesElement
79
+ });
80
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _ui = require("@atlaskit/editor-common/ui");
10
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
11
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
+ var _tableMap = require("@atlaskit/editor-tables/table-map");
13
+ var _consts = require("../consts");
14
+ var _DragMenu = require("./DragMenu");
15
+ var FloatingDragMenu = function FloatingDragMenu(_ref) {
16
+ var mountPoint = _ref.mountPoint,
17
+ boundariesElement = _ref.boundariesElement,
18
+ scrollableElement = _ref.scrollableElement,
19
+ editorView = _ref.editorView,
20
+ isOpen = _ref.isOpen,
21
+ tableRef = _ref.tableRef,
22
+ tableNode = _ref.tableNode,
23
+ direction = _ref.direction,
24
+ index = _ref.index,
25
+ targetCellPosition = _ref.targetCellPosition;
26
+ if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
27
+ return null;
28
+ }
29
+ var domAtPos = editorView.domAtPos.bind(editorView);
30
+ var targetCellRef = (0, _utils.findDomRefAtPos)(targetCellPosition, domAtPos);
31
+ if (!targetCellRef) {
32
+ return null;
33
+ }
34
+ var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
35
+ var offset = direction === 'row' ? [7, 0] : index === ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) || 1) - 1 ? [14, 0] : [-14, 0];
36
+ // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
37
+ return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
38
+ alignX: direction === 'row' ? 'left' : 'center',
39
+ alignY: "top",
40
+ target: targetCellRef,
41
+ mountTo: mountPoint,
42
+ boundariesElement: boundariesElement,
43
+ scrollableElement: scrollableElement,
44
+ fitWidth: _consts.dragMenuDropdownWidth
45
+ // z-index value below is to ensure that this menu is above other floating menu
46
+ // in table, but below floating dialogs like typeaheads, pickers, etc.
47
+ ,
48
+ zIndex: _editorSharedStyles.akEditorFloatingOverlapPanelZIndex,
49
+ forcePlacement: true,
50
+ offset: offset,
51
+ stick: true
52
+ }, /*#__PURE__*/_react.default.createElement(_DragMenu.DragMenu, {
53
+ editorView: editorView,
54
+ isOpen: isOpen,
55
+ boundariesElement: boundariesElement,
56
+ tableNode: tableNode,
57
+ direction: direction,
58
+ index: index
59
+ }));
60
+ };
61
+ FloatingDragMenu.displayName = 'FloatingDragMenu';
62
+ var _default = exports.default = FloatingDragMenu;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.default = exports.InsertButtonForDragAndDrop = exports.DragAndDropInsertButton = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _keymaps = require("@atlaskit/editor-common/keymaps");
@@ -15,6 +15,8 @@ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
15
15
  var _types = require("../../types");
16
16
  var _consts = require("../consts");
17
17
  var _messages = _interopRequireDefault(require("../messages"));
18
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
19
+
18
20
  var getInsertLineHeight = function getInsertLineHeight(tableRef, hasStickyHeaders) {
19
21
  // The line gets height 100% from the table,
20
22
  // but since we have an overflow on the left,
@@ -30,7 +32,7 @@ var getToolbarSize = function getToolbarSize(tableRef) {
30
32
  }
31
33
  return _consts.tableToolbarSize;
32
34
  };
33
- var getInsertLineWidth = function getInsertLineWidth(tableRef) {
35
+ var getInsertLineWidth = function getInsertLineWidth(tableRef, isDragAndDropEnabled) {
34
36
  // The line gets width 100% from the table,
35
37
  // but since we have an overflow on the left,
36
38
  // we should add an offset to make up for it.
@@ -41,13 +43,13 @@ var getInsertLineWidth = function getInsertLineWidth(tableRef) {
41
43
  var _ref = parentElement,
42
44
  scrollLeft = _ref.scrollLeft;
43
45
  var diff = offsetWidth - parentOffsetWidth;
44
- var toolbarSize = getToolbarSize(tableRef);
46
+ var toolbarSize = isDragAndDropEnabled ? 0 : getToolbarSize(tableRef);
45
47
  return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
46
48
  };
47
49
  var tooltipMessageByType = function tooltipMessageByType(type) {
48
50
  return type === 'row' ? _messages.default.insertRow : _messages.default.insertColumn;
49
51
  };
50
- var InsertButton = function InsertButton(_ref2) {
52
+ var InsertButtonForDragAndDrop = exports.InsertButtonForDragAndDrop = function InsertButtonForDragAndDrop(_ref2) {
51
53
  var onMouseDown = _ref2.onMouseDown,
52
54
  tableRef = _ref2.tableRef,
53
55
  type = _ref2.type,
@@ -59,6 +61,52 @@ var InsertButton = function InsertButton(_ref2) {
59
61
  keymap: type === 'row' ? _keymaps.addRowAfter : _keymaps.addColumnAfter
60
62
  }),
61
63
  position: "top"
64
+ }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
65
+ className: _types.TableCssClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER
66
+ }, /*#__PURE__*/_react.default.createElement("button", {
67
+ type: "button",
68
+ className: _types.TableCssClassName.DRAG_CONTROLS_INSERT_BUTTON,
69
+ onMouseDown: onMouseDown
70
+ }, /*#__PURE__*/_react.default.createElement("svg", {
71
+ width: "10",
72
+ height: "10",
73
+ viewBox: "0 0 10 10",
74
+ fill: "none",
75
+ xmlns: "http://www.w3.org/2000/svg"
76
+ }, /*#__PURE__*/_react.default.createElement("path", {
77
+ fillRule: "evenodd",
78
+ clipRule: "evenodd",
79
+ d: "M5.41667 4.58333V2.91667C5.41667 2.80616 5.37277 2.70018 5.29463 2.62204C5.21649 2.5439 5.11051 2.5 5 2.5C4.88949 2.5 4.78351 2.5439 4.70537 2.62204C4.62723 2.70018 4.58333 2.80616 4.58333 2.91667V4.58333H2.91667C2.80616 4.58333 2.70018 4.62723 2.62204 4.70537C2.5439 4.78351 2.5 4.88949 2.5 5C2.5 5.11051 2.5439 5.21649 2.62204 5.29463C2.70018 5.37277 2.80616 5.41667 2.91667 5.41667H4.58333V7.08333C4.58333 7.19384 4.62723 7.29982 4.70537 7.37796C4.78351 7.4561 4.88949 7.5 5 7.5C5.11051 7.5 5.21649 7.4561 5.29463 7.37796C5.37277 7.29982 5.41667 7.19384 5.41667 7.08333V5.41667H7.08333C7.19384 5.41667 7.29982 5.37277 7.37796 5.29463C7.4561 5.21649 7.5 5.11051 7.5 5C7.5 4.88949 7.4561 4.78351 7.37796 4.70537C7.29982 4.62723 7.19384 4.58333 7.08333 4.58333H5.41667Z",
80
+ fill: "currentColor"
81
+ })))), /*#__PURE__*/_react.default.createElement("div", {
82
+ className: _types.TableCssClassName.CONTROLS_INSERT_LINE,
83
+ style: type === 'row' ? {
84
+ width: getInsertLineWidth(tableRef, true),
85
+ left: '14px'
86
+ } : {
87
+ height: getInsertLineHeight(tableRef, hasStickyHeaders) - 11
88
+ }
89
+ })));
90
+ var floatingButtonClassName = type === 'column' ? _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_COLUMN : _types.TableCssClassName.CONTROLS_FLOATING_BUTTON_ROW;
91
+ return /*#__PURE__*/_react.default.createElement("div", {
92
+ className: floatingButtonClassName
93
+ }, /*#__PURE__*/_react.default.createElement("div", {
94
+ className: "".concat(_types.TableCssClassName.CONTROLS_INSERT_BUTTON_WRAP, " ").concat(_types.TableCssClassName.CONTROLS_INSERT_ROW)
95
+ }, content));
96
+ };
97
+ var DragAndDropInsertButton = exports.DragAndDropInsertButton = (0, _reactIntlNext.injectIntl)(InsertButtonForDragAndDrop);
98
+ var InsertButton = function InsertButton(_ref3) {
99
+ var onMouseDown = _ref3.onMouseDown,
100
+ tableRef = _ref3.tableRef,
101
+ type = _ref3.type,
102
+ formatMessage = _ref3.intl.formatMessage,
103
+ hasStickyHeaders = _ref3.hasStickyHeaders;
104
+ var content = /*#__PURE__*/_react.default.createElement(_tooltip.default, {
105
+ content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
106
+ description: formatMessage(tooltipMessageByType(type)),
107
+ keymap: type === 'row' ? _keymaps.addRowAfter : _keymaps.addColumnAfter
108
+ }),
109
+ position: "top"
62
110
  }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
63
111
  className: _types.TableCssClassName.CONTROLS_INSERT_BUTTON_INNER
64
112
  }, /*#__PURE__*/_react.default.createElement("button", {