@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
@@ -1,9 +1,12 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
+ import { getCellsInRow } from '@atlaskit/editor-tables/utils';
5
+ import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
4
6
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
5
7
  import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
6
8
  import { getPluginState as getTablePluginState } from '../plugin-factory';
9
+ import { DragAndDropActionType } from './actions';
7
10
  import { clearDropTarget, moveSource, setDropTarget } from './commands';
8
11
  import { DropTargetType } from './consts';
9
12
  import { createPluginState, getPluginState } from './plugin-factory';
@@ -14,13 +17,47 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
14
17
  state: createPluginState(dispatch, function (state) {
15
18
  return {
16
19
  decorationSet: DecorationSet.empty,
17
- // TODO: This is example placeholder state. We could use this to track which row/col is currently set as the drop target
18
- // This would result in a blue highlight being displayed on the corrisponding row/column to single the drop target location.
19
20
  dropTargetType: DropTargetType.NONE,
20
- dropTargetIndex: 0
21
+ dropTargetIndex: 0,
22
+ isDragMenuOpen: false,
23
+ dragMenuIndex: 0
21
24
  };
22
25
  }),
23
26
  key: pluginKey,
27
+ appendTransaction: function appendTransaction(transactions, oldState, newState) {
28
+ var _getTablePluginState = getTablePluginState(oldState),
29
+ oldTargetCellPosition = _getTablePluginState.targetCellPosition;
30
+ var _getTablePluginState2 = getTablePluginState(newState),
31
+ newTargetCellPosition = _getTablePluginState2.targetCellPosition;
32
+ var _getPluginState = getPluginState(newState),
33
+ isDragMenuOpen = _getPluginState.isDragMenuOpen,
34
+ dragMenuIndex = _getPluginState.dragMenuIndex;
35
+
36
+ // What's happening here? you asked... In a nutshell;
37
+ // 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.
38
+ // This will stop the drag menu from moving around the screen to different row/cols. Too achieve this we need
39
+ // to check if the new target cell position is pointed at a different cell than what the drag menu was opened on.
40
+ if (oldTargetCellPosition !== newTargetCellPosition) {
41
+ if (isDragMenuOpen) {
42
+ var tr = newState.tr;
43
+ var action = {
44
+ type: DragAndDropActionType.TOGGLE_DRAG_MENU,
45
+ data: {
46
+ isDragMenuOpen: false,
47
+ direction: undefined
48
+ }
49
+ };
50
+ if (newTargetCellPosition !== undefined) {
51
+ var cells = getCellsInRow(dragMenuIndex)(tr.selection);
52
+ if (cells && cells.length && cells[0].node !== tr.doc.nodeAt(newTargetCellPosition)) {
53
+ return tr.setMeta(pluginKey, action);
54
+ } // else NOP
55
+ } else {
56
+ return tr.setMeta(pluginKey, action);
57
+ }
58
+ }
59
+ }
60
+ },
24
61
  view: function view(editorView) {
25
62
  return {
26
63
  destroy: monitorForElements({
@@ -38,13 +75,22 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
38
75
  indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
39
76
  return false;
40
77
  }
41
- var _getTablePluginState = getTablePluginState(editorView.state),
42
- tableNode = _getTablePluginState.tableNode;
78
+ var _getTablePluginState3 = getTablePluginState(editorView.state),
79
+ tableNode = _getTablePluginState3.tableNode;
43
80
  // If the draggable localId is the same as the current selected table localId then we will allow the monitor
44
81
  // watch for changes
45
82
  return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
46
83
  },
84
+ onDragStart: function onDragStart(_ref3) {
85
+ var location = _ref3.location;
86
+ autoScroller.start({
87
+ input: location.current.input
88
+ });
89
+ },
47
90
  onDrag: function onDrag(event) {
91
+ autoScroller.updateInput({
92
+ input: event.location.current.input
93
+ });
48
94
  var data = getDraggableDataFromEvent(event);
49
95
  // If no data can be found then it's most like we do not want to perform any drag actions
50
96
  if (!data) {
@@ -60,6 +106,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
60
106
  setDropTarget(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
61
107
  },
62
108
  onDrop: function onDrop(event) {
109
+ autoScroller.stop();
63
110
  var data = getDraggableDataFromEvent(event);
64
111
 
65
112
  // If no data can be found then it's most like we do not want to perform any drop action
@@ -87,8 +134,8 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
87
134
  },
88
135
  props: {
89
136
  decorations: function decorations(state) {
90
- var _getPluginState = getPluginState(state),
91
- decorationSet = _getPluginState.decorationSet;
137
+ var _getPluginState2 = getPluginState(state),
138
+ decorationSet = _getPluginState2.decorationSet;
92
139
  return decorationSet;
93
140
  }
94
141
  }
@@ -17,6 +17,12 @@ export default (function (pluginState, action) {
17
17
  dropTargetType: DropTargetType.NONE,
18
18
  dropTargetIndex: 0
19
19
  });
20
+ case DragAndDropActionType.TOGGLE_DRAG_MENU:
21
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
22
+ isDragMenuOpen: action.data.isDragMenuOpen,
23
+ dragMenuDirection: action.data.direction,
24
+ dragMenuIndex: action.data.index
25
+ });
20
26
  default:
21
27
  return pluginState;
22
28
  }
@@ -68,6 +68,9 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
68
68
  CONTROLS_INSERT_LINE: "".concat(tablePrefixSelector, "-controls__insert-line"),
69
69
  CONTROLS_BUTTON_OVERLAY: "".concat(tablePrefixSelector, "-controls__button-overlay"),
70
70
  LAYOUT_BUTTON: "".concat(tablePrefixSelector, "-layout-button"),
71
+ DRAG_CONTROLS_INSERT_BUTTON: "".concat(tablePrefixSelector, "-controls__drag-insert-button"),
72
+ DRAG_CONTROLS_INSERT_BUTTON_INNER: "".concat(tablePrefixSelector, "-controls__drag-insert-button-inner"),
73
+ DRAG_CONTROLS_INSERT_BUTTON_WRAP: "".concat(tablePrefixSelector, "-controls__drag-insert-button-wrap"),
71
74
  CONTROLS_INSERT_MARKER: "".concat(tablePrefixSelector, "-controls__insert-marker"),
72
75
  CONTROLS_INSERT_COLUMN: "".concat(tablePrefixSelector, "-controls__insert-column"),
73
76
  CONTROLS_INSERT_ROW: "".concat(tablePrefixSelector, "-controls__insert-row"),
@@ -80,8 +83,12 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
80
83
  CORNER_CONTROLS_INSERT_COLUMN_MARKER: "".concat(tablePrefixSelector, "-corner-controls__insert-column-marker"),
81
84
  CONTROLS_CORNER_BUTTON: "".concat(tablePrefixSelector, "-corner-button"),
82
85
  /** Controls with drag handle */
83
- COLUMN_CONTROLS_WITH_DRAG: "".concat(tablePrefixSelector, "-column-controls-with-drag"),
84
- ROW_CONTROLS_WITH_DRAG: "".concat(tablePrefixSelector, "-row-controls-with-drag"),
86
+ DRAG_ROW_CONTROLS: "".concat(tablePrefixSelector, "-drag-row-controls"),
87
+ DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER: "".concat(tablePrefixSelector, "-drag-row-floating-insert-dot-wrapper"),
88
+ DRAG_ROW_FLOATING_INSERT_DOT: "".concat(tablePrefixSelector, "-drag-row-floating-insert-dot"),
89
+ DRAG_COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-drag-column-controls"),
90
+ DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot-wrapper"),
91
+ DRAG_COLUMN_FLOATING_INSERT_DOT: "".concat(tablePrefixSelector, "-drag-columns-floating-insert-dot"),
85
92
  DRAG_HANDLE_BUTTON_CONTAINER: "".concat(tablePrefixSelector, "-drag-handle-button-container"),
86
93
  /** Other classes */
87
94
  NUMBERED_COLUMN: "".concat(tablePrefixSelector, "-numbered-column"),
@@ -18,6 +18,7 @@ export var DragHandle = function DragHandle(_ref) {
18
18
  previewHeight = _ref.previewHeight,
19
19
  onMouseOver = _ref.onMouseOver,
20
20
  onMouseOut = _ref.onMouseOut,
21
+ onMouseUp = _ref.onMouseUp,
21
22
  onClick = _ref.onClick;
22
23
  var dragHandleDivRef = useRef(null);
23
24
  var _useState = useState(null),
@@ -77,6 +78,7 @@ export var DragHandle = function DragHandle(_ref) {
77
78
  "data-testid": "table-floating-column-controls-drag-handle",
78
79
  onMouseOver: onMouseOver,
79
80
  onMouseOut: onMouseOut,
81
+ onMouseUp: onMouseUp,
80
82
  onClick: onClick
81
83
  }, /*#__PURE__*/React.createElement(DragHandleIcon, null), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
82
84
  direction: direction,
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
3
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
4
+ import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
5
+ import { getDragMenuConfig } from '../../utils/drag-menu';
6
+ import { dragMenuDropdownWidth } from '../consts';
7
+ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
8
+ var menuItems = [];
9
+ var menuCallback = {};
10
+ dragMenuConfig.forEach(function (item) {
11
+ menuItems.push({
12
+ key: item.id,
13
+ content: item.title,
14
+ value: {
15
+ name: item.id
16
+ },
17
+ isDisabled: item.disabled
18
+ });
19
+ item.onClick && (menuCallback[item.id] = item.onClick);
20
+ });
21
+ return {
22
+ menuItems: menuItems,
23
+ menuCallback: menuCallback
24
+ };
25
+ };
26
+ export var DragMenu = function DragMenu(_ref) {
27
+ var _ref$direction = _ref.direction,
28
+ direction = _ref$direction === void 0 ? 'row' : _ref$direction,
29
+ index = _ref.index,
30
+ isOpen = _ref.isOpen,
31
+ editorView = _ref.editorView,
32
+ tableNode = _ref.tableNode,
33
+ mountPoint = _ref.mountPoint,
34
+ boundariesElement = _ref.boundariesElement,
35
+ scrollableElement = _ref.scrollableElement;
36
+ var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
37
+ var dragMenuConfig = getDragMenuConfig(direction, tableMap, index);
38
+ var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
39
+ menuItems = _convertToDropdownIte.menuItems,
40
+ menuCallback = _convertToDropdownIte.menuCallback;
41
+ var closeMenu = function closeMenu() {
42
+ var state = editorView.state,
43
+ dispatch = editorView.dispatch;
44
+ toggleDragMenu(false)(state, dispatch);
45
+ };
46
+ var onMenuItemActivated = function onMenuItemActivated(_ref2) {
47
+ var _menuCallback$item$va;
48
+ var item = _ref2.item;
49
+ (_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, editorView.state, editorView.dispatch);
50
+ closeMenu();
51
+ };
52
+ if (!menuItems) {
53
+ return null;
54
+ }
55
+ return /*#__PURE__*/React.createElement(DropdownMenu, {
56
+ mountTo: mountPoint
57
+ //This needs be removed when the a11y is completely handled
58
+ //Disabling key navigation now as it works only partially
59
+ ,
60
+ arrowKeyNavigationProviderOptions: {
61
+ type: ArrowKeyNavigationType.MENU,
62
+ disableArrowKeyNavigation: true
63
+ },
64
+ items: [{
65
+ items: menuItems
66
+ }],
67
+ isOpen: isOpen,
68
+ onOpenChange: closeMenu,
69
+ onItemActivated: onMenuItemActivated,
70
+ fitWidth: dragMenuDropdownWidth,
71
+ boundariesElement: boundariesElement
72
+ });
73
+ };
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { Popup } from '@atlaskit/editor-common/ui';
3
+ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
+ import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
5
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
6
+ import { dragMenuDropdownWidth } from '../consts';
7
+ import { DragMenu } from './DragMenu';
8
+ var FloatingDragMenu = function FloatingDragMenu(_ref) {
9
+ var mountPoint = _ref.mountPoint,
10
+ boundariesElement = _ref.boundariesElement,
11
+ scrollableElement = _ref.scrollableElement,
12
+ editorView = _ref.editorView,
13
+ isOpen = _ref.isOpen,
14
+ tableRef = _ref.tableRef,
15
+ tableNode = _ref.tableNode,
16
+ direction = _ref.direction,
17
+ index = _ref.index,
18
+ targetCellPosition = _ref.targetCellPosition;
19
+ if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
20
+ return null;
21
+ }
22
+ var domAtPos = editorView.domAtPos.bind(editorView);
23
+ var targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
24
+ if (!targetCellRef) {
25
+ return null;
26
+ }
27
+ var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
28
+ var offset = direction === 'row' ? [7, 0] : index === ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) || 1) - 1 ? [14, 0] : [-14, 0];
29
+ // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
30
+ return /*#__PURE__*/React.createElement(Popup, {
31
+ alignX: direction === 'row' ? 'left' : 'center',
32
+ alignY: "top",
33
+ target: targetCellRef,
34
+ mountTo: mountPoint,
35
+ boundariesElement: boundariesElement,
36
+ scrollableElement: scrollableElement,
37
+ fitWidth: dragMenuDropdownWidth
38
+ // z-index value below is to ensure that this menu is above other floating menu
39
+ // in table, but below floating dialogs like typeaheads, pickers, etc.
40
+ ,
41
+ zIndex: akEditorFloatingOverlapPanelZIndex,
42
+ forcePlacement: true,
43
+ offset: offset,
44
+ stick: true
45
+ }, /*#__PURE__*/React.createElement(DragMenu, {
46
+ editorView: editorView,
47
+ isOpen: isOpen,
48
+ boundariesElement: boundariesElement,
49
+ tableNode: tableNode,
50
+ direction: direction,
51
+ index: index
52
+ }));
53
+ };
54
+ FloatingDragMenu.displayName = 'FloatingDragMenu';
55
+ export default FloatingDragMenu;
@@ -1,3 +1,5 @@
1
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
+
1
3
  import React from 'react';
2
4
  import { injectIntl } from 'react-intl-next';
3
5
  import { addColumnAfter, addRowAfter, ToolTipContent } from '@atlaskit/editor-common/keymaps';
@@ -23,7 +25,7 @@ var getToolbarSize = function getToolbarSize(tableRef) {
23
25
  }
24
26
  return tableToolbarSize;
25
27
  };
26
- var getInsertLineWidth = function getInsertLineWidth(tableRef) {
28
+ var getInsertLineWidth = function getInsertLineWidth(tableRef, isDragAndDropEnabled) {
27
29
  // The line gets width 100% from the table,
28
30
  // but since we have an overflow on the left,
29
31
  // we should add an offset to make up for it.
@@ -34,13 +36,13 @@ var getInsertLineWidth = function getInsertLineWidth(tableRef) {
34
36
  var _ref = parentElement,
35
37
  scrollLeft = _ref.scrollLeft;
36
38
  var diff = offsetWidth - parentOffsetWidth;
37
- var toolbarSize = getToolbarSize(tableRef);
39
+ var toolbarSize = isDragAndDropEnabled ? 0 : getToolbarSize(tableRef);
38
40
  return Math.min(offsetWidth + toolbarSize, parentOffsetWidth + toolbarSize - Math.max(scrollLeft - diff, 0)) + LINE_OFFSET;
39
41
  };
40
42
  var tooltipMessageByType = function tooltipMessageByType(type) {
41
43
  return type === 'row' ? tableMessages.insertRow : tableMessages.insertColumn;
42
44
  };
43
- var InsertButton = function InsertButton(_ref2) {
45
+ export var InsertButtonForDragAndDrop = function InsertButtonForDragAndDrop(_ref2) {
44
46
  var onMouseDown = _ref2.onMouseDown,
45
47
  tableRef = _ref2.tableRef,
46
48
  type = _ref2.type,
@@ -52,6 +54,52 @@ var InsertButton = function InsertButton(_ref2) {
52
54
  keymap: type === 'row' ? addRowAfter : addColumnAfter
53
55
  }),
54
56
  position: "top"
57
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
58
+ className: ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER
59
+ }, /*#__PURE__*/React.createElement("button", {
60
+ type: "button",
61
+ className: ClassName.DRAG_CONTROLS_INSERT_BUTTON,
62
+ onMouseDown: onMouseDown
63
+ }, /*#__PURE__*/React.createElement("svg", {
64
+ width: "10",
65
+ height: "10",
66
+ viewBox: "0 0 10 10",
67
+ fill: "none",
68
+ xmlns: "http://www.w3.org/2000/svg"
69
+ }, /*#__PURE__*/React.createElement("path", {
70
+ fillRule: "evenodd",
71
+ clipRule: "evenodd",
72
+ 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",
73
+ fill: "currentColor"
74
+ })))), /*#__PURE__*/React.createElement("div", {
75
+ className: ClassName.CONTROLS_INSERT_LINE,
76
+ style: type === 'row' ? {
77
+ width: getInsertLineWidth(tableRef, true),
78
+ left: '14px'
79
+ } : {
80
+ height: getInsertLineHeight(tableRef, hasStickyHeaders) - 11
81
+ }
82
+ })));
83
+ var floatingButtonClassName = type === 'column' ? ClassName.CONTROLS_FLOATING_BUTTON_COLUMN : ClassName.CONTROLS_FLOATING_BUTTON_ROW;
84
+ return /*#__PURE__*/React.createElement("div", {
85
+ className: floatingButtonClassName
86
+ }, /*#__PURE__*/React.createElement("div", {
87
+ className: "".concat(ClassName.CONTROLS_INSERT_BUTTON_WRAP, " ").concat(ClassName.CONTROLS_INSERT_ROW)
88
+ }, content));
89
+ };
90
+ export var DragAndDropInsertButton = injectIntl(InsertButtonForDragAndDrop);
91
+ var InsertButton = function InsertButton(_ref3) {
92
+ var onMouseDown = _ref3.onMouseDown,
93
+ tableRef = _ref3.tableRef,
94
+ type = _ref3.type,
95
+ formatMessage = _ref3.intl.formatMessage,
96
+ hasStickyHeaders = _ref3.hasStickyHeaders;
97
+ var content = /*#__PURE__*/React.createElement(Tooltip, {
98
+ content: /*#__PURE__*/React.createElement(ToolTipContent, {
99
+ description: formatMessage(tooltipMessageByType(type)),
100
+ keymap: type === 'row' ? addRowAfter : addColumnAfter
101
+ }),
102
+ position: "top"
55
103
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
56
104
  className: ClassName.CONTROLS_INSERT_BUTTON_INNER
57
105
  }, /*#__PURE__*/React.createElement("button", {
@@ -6,9 +6,11 @@ import { tableInsertColumnButtonOffset, tableInsertColumnButtonSize, tableToolba
6
6
  var HORIZONTAL_ALIGN_COLUMN_BUTTON = -(tableInsertColumnButtonSize / 2);
7
7
  var HORIZONTAL_ALIGN_NUMBERED_COLUMN_BUTTON = HORIZONTAL_ALIGN_COLUMN_BUTTON + akEditorTableNumberColumnWidth;
8
8
  var VERTICAL_ALIGN_COLUMN_BUTTON = tableToolbarSize + tableInsertColumnButtonOffset;
9
+ var VERTICAL_ALIGN_COLUMN_BUTTON_DRAG = tableInsertColumnButtonOffset;
9
10
  var HORIZONTAL_ALIGN_ROW_BUTTON = -(tableToolbarSize + tableInsertColumnButtonOffset + tableInsertColumnButtonSize);
11
+ var HORIZONTAL_ALIGN_ROW_BUTTON_DRAG = -18;
10
12
  var VERTICAL_ALIGN_ROW_BUTTON = tableInsertColumnButtonSize / 2;
11
- function getRowOptions(index) {
13
+ function getRowOptions(index, isDragAndDropEnabled) {
12
14
  var defaultOptions = {
13
15
  alignX: 'left',
14
16
  alignY: 'bottom',
@@ -25,16 +27,16 @@ function getRowOptions(index) {
25
27
  onPositionCalculated: function onPositionCalculated(position) {
26
28
  return _objectSpread(_objectSpread({}, position), {}, {
27
29
  // Left position should be always the offset (To place in the correct position even if the table has overflow).
28
- left: HORIZONTAL_ALIGN_ROW_BUTTON
30
+ left: isDragAndDropEnabled ? HORIZONTAL_ALIGN_ROW_BUTTON_DRAG : HORIZONTAL_ALIGN_ROW_BUTTON
29
31
  });
30
32
  }
31
33
  });
32
34
  }
33
- function getColumnOptions(index, tableContainer, hasNumberedColumns) {
35
+ function getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled) {
34
36
  var options = {
35
37
  alignX: 'end',
36
38
  alignY: 'top',
37
- offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, VERTICAL_ALIGN_COLUMN_BUTTON],
39
+ offset: [HORIZONTAL_ALIGN_COLUMN_BUTTON, isDragAndDropEnabled ? VERTICAL_ALIGN_COLUMN_BUTTON_DRAG : VERTICAL_ALIGN_COLUMN_BUTTON],
38
40
  // :: (position: PopupPosition) -> PopupPosition
39
41
  // Limit the InsertButton position to the table container
40
42
  // if the left position starts before it
@@ -70,12 +72,12 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
70
72
  }
71
73
  return options;
72
74
  }
73
- function getPopupOptions(type, index, hasNumberedColumns, tableContainer) {
74
- switch (type) {
75
+ function getPopupOptions(direction, index, hasNumberedColumns, isDragAndDropEnabled, tableContainer) {
76
+ switch (direction) {
75
77
  case 'column':
76
- return getColumnOptions(index, tableContainer, hasNumberedColumns);
78
+ return getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled);
77
79
  case 'row':
78
- return getRowOptions(index);
80
+ return getRowOptions(index, isDragAndDropEnabled);
79
81
  default:
80
82
  return {};
81
83
  }
@@ -22,7 +22,7 @@ import { insertColumnWithAnalytics, insertRowWithAnalytics } from '../../command
22
22
  import { TableCssClassName as ClassName } from '../../types';
23
23
  import { checkIfNumberColumnEnabled } from '../../utils';
24
24
  import getPopupOptions from './getPopupOptions';
25
- import InsertButton from './InsertButton';
25
+ import InsertButton, { DragAndDropInsertButton } from './InsertButton';
26
26
  export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
27
27
  _inherits(FloatingInsertButton, _React$Component);
28
28
  var _super = _createSuper(FloatingInsertButton);
@@ -47,6 +47,7 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
47
47
  boundariesElement = _this$props.boundariesElement,
48
48
  isHeaderColumnEnabled = _this$props.isHeaderColumnEnabled,
49
49
  isHeaderRowEnabled = _this$props.isHeaderRowEnabled,
50
+ isDragAndDropEnabled = _this$props.isDragAndDropEnabled,
50
51
  dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent;
51
52
  var type = typeof insertColumnButtonIndex !== 'undefined' ? 'column' : typeof insertRowButtonIndex !== 'undefined' ? 'row' : null;
52
53
  if (!tableNode || !tableRef || !type) {
@@ -121,9 +122,14 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
121
122
  scrollableElement: tableWrapper,
122
123
  forcePlacement: true,
123
124
  allowOutOfBounds: true
124
- }, getPopupOptions(type, index, hasNumberedColumns, tableContainerWrapper), {
125
+ }, getPopupOptions(type, index, hasNumberedColumns, !!isDragAndDropEnabled, tableContainerWrapper), {
125
126
  zIndex: zIndex
126
- }), /*#__PURE__*/React.createElement(InsertButton, {
127
+ }), isDragAndDropEnabled ? /*#__PURE__*/React.createElement(DragAndDropInsertButton, {
128
+ type: type,
129
+ tableRef: tableRef,
130
+ onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
131
+ hasStickyHeaders: this.props.hasStickyHeaders || false
132
+ }) : /*#__PURE__*/React.createElement(InsertButton, {
127
133
  type: type,
128
134
  tableRef: tableRef,
129
135
  onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
@@ -2,8 +2,9 @@ import React, { useCallback, useMemo } from 'react';
2
2
  import { CellSelection } from '@atlaskit/editor-tables';
3
3
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
4
4
  import { clearHoverSelection, hoverColumns, selectColumn } from '../../../commands';
5
+ import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
5
6
  import { TableCssClassName as ClassName } from '../../../types';
6
- import { getSelectedColumnIndexes } from '../../../utils';
7
+ import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
7
8
  import { DragHandle } from '../../DragHandle';
8
9
  var getSelectedColumns = function getSelectedColumns(selection) {
9
10
  if (selection instanceof CellSelection && selection.isColSelection()) {
@@ -26,10 +27,13 @@ export var ColumnControls = function ColumnControls(_ref) {
26
27
  localId = _ref.localId,
27
28
  isInDanger = _ref.isInDanger,
28
29
  rowHeights = _ref.rowHeights,
29
- colWidths = _ref.colWidths;
30
+ colWidths = _ref.colWidths,
31
+ hasHeaderColumn = _ref.hasHeaderColumn;
30
32
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
31
33
  return width ? "".concat(width - 1, "px") : '0px';
32
34
  }).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
35
+ // TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
36
+ var columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
33
37
  var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
34
38
  var selectedColIndexes = getSelectedColumns(editorView.state.selection);
35
39
  var gridColumnPosition = useMemo(function () {
@@ -59,8 +63,13 @@ export var ColumnControls = function ColumnControls(_ref) {
59
63
  clearHoverSelection()(state, dispatch);
60
64
  }
61
65
  }, [editorView, tableActive]);
66
+ var handleMouseUp = useCallback(function () {
67
+ var state = editorView.state,
68
+ dispatch = editorView.dispatch;
69
+ toggleDragMenu(undefined, 'column', colIndex)(state, dispatch);
70
+ }, [editorView, colIndex]);
62
71
  return /*#__PURE__*/React.createElement("div", {
63
- className: ClassName.COLUMN_CONTROLS_WITH_DRAG
72
+ className: ClassName.DRAG_COLUMN_CONTROLS
64
73
  }, /*#__PURE__*/React.createElement("div", {
65
74
  className: ClassName.COLUMN_CONTROLS_INNER,
66
75
  "data-testid": "table-floating-column-controls",
@@ -68,10 +77,39 @@ export var ColumnControls = function ColumnControls(_ref) {
68
77
  gridTemplateColumns: widths,
69
78
  marginTop: marginTop
70
79
  }
71
- }, tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
80
+ }, !isResizing && columnParams.map(function (_ref2, index) {
81
+ var startIndex = _ref2.startIndex,
82
+ endIndex = _ref2.endIndex;
83
+ return /*#__PURE__*/React.createElement("div", {
84
+ style: {
85
+ gridColumn: "".concat(index + 1, " / span 1")
86
+ },
87
+ "data-start-index": startIndex,
88
+ "data-end-index": endIndex,
89
+ className: ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER,
90
+ contentEditable: false,
91
+ key: index
92
+ }, !hasHeaderColumn && index === 0 && /*#__PURE__*/React.createElement("div", {
93
+ style: {
94
+ left: '0px',
95
+ right: 'unset'
96
+ },
97
+ className: ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT
98
+ }), /*#__PURE__*/React.createElement("div", {
99
+ className: ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT,
100
+ style: columnParams.length - 1 === index ? {
101
+ right: '0'
102
+ } : {}
103
+ }));
104
+ }), tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
72
105
  style: {
73
106
  gridColumn: gridColumnPosition,
74
- marginTop: "-15px"
107
+ zIndex: 99,
108
+ display: 'flex',
109
+ width: '100%',
110
+ justifyContent: 'center',
111
+ alignItems: 'center',
112
+ marginTop: "var(--ds-space-negative-025, -2px)"
75
113
  },
76
114
  "data-column-control-index": hoveredCell.colIndex,
77
115
  "data-testid": "table-floating-column-control"
@@ -84,7 +122,8 @@ export var ColumnControls = function ColumnControls(_ref) {
84
122
  appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
85
123
  onClick: handleClick,
86
124
  onMouseOver: handleMouseOver,
87
- onMouseOut: handleMouseOut
125
+ onMouseOut: handleMouseOut,
126
+ onMouseUp: handleMouseUp
88
127
  }))));
89
128
  };
90
129
  export default ColumnControls;
@@ -6,7 +6,7 @@ import React, { useEffect, useMemo, useState } from 'react';
6
6
  import ReactDOM from 'react-dom';
7
7
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
8
8
  import { TableCssClassName as ClassName } from '../../types';
9
- import { getColumnsWidths, getRowHeights } from '../../utils';
9
+ import { containsHeaderColumn, getColumnsWidths, getRowHeights } from '../../utils';
10
10
  import { ColumnControls } from './ColumnControls';
11
11
  import { ColumnDropTargets } from './ColumnDropTargets';
12
12
  export var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
@@ -33,6 +33,7 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
33
33
  setHasDropTargets = _useState4[1];
34
34
  var node = getNode();
35
35
  var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
36
+ var hasHeaderColumn = containsHeaderColumn(node);
36
37
  useEffect(function () {
37
38
  var _window;
38
39
  if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
@@ -95,11 +96,11 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
95
96
  var colWidths = getColumnsWidths(editorView);
96
97
  var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
97
98
  var mountTo = tableRef && (tableRef === null || tableRef === void 0 ? void 0 : tableRef.parentElement) || document.body;
99
+ if (!tableActive) {
100
+ return null;
101
+ }
98
102
  return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement("div", {
99
103
  className: ClassName.COLUMN_CONTROLS_WRAPPER,
100
- style: {
101
- pointerEvents: 'none'
102
- },
103
104
  "data-testid": "table-floating-column-controls-wrapper"
104
105
  }, /*#__PURE__*/React.createElement(ColumnControls, {
105
106
  editorView: editorView,
@@ -111,7 +112,8 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
111
112
  localId: currentNodeLocalId,
112
113
  isInDanger: isInDanger,
113
114
  rowHeights: rowHeights,
114
- colWidths: colWidths
115
+ colWidths: colWidths,
116
+ hasHeaderColumn: hasHeaderColumn
115
117
  }), hasDropTargets && /*#__PURE__*/React.createElement(ColumnDropTargets, {
116
118
  tableRef: tableRef,
117
119
  stickyTop: tableActive ? stickyTop : undefined,