@atlaskit/editor-plugin-table 5.4.14 → 5.4.15

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 (111) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/afm-cc/tsconfig.json +70 -0
  3. package/dist/cjs/plugins/table/commands/hover.js +26 -6
  4. package/dist/cjs/plugins/table/commands/index.js +6 -0
  5. package/dist/cjs/plugins/table/commands/misc.js +8 -3
  6. package/dist/cjs/plugins/table/event-handlers.js +56 -34
  7. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -1
  8. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  9. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +39 -7
  10. package/dist/cjs/plugins/table/pm-plugins/main.js +5 -3
  11. package/dist/cjs/plugins/table/reducer.js +1 -0
  12. package/dist/cjs/plugins/table/toolbar.js +6 -3
  13. package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +6 -3
  14. package/dist/cjs/plugins/table/ui/DragPreview/index.js +0 -2
  15. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -7
  16. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -10
  17. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  18. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +7 -4
  19. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -8
  20. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  21. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  22. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +12 -8
  23. package/dist/cjs/plugins/table/utils/dom.js +16 -1
  24. package/dist/cjs/plugins/table/utils/index.js +6 -0
  25. package/dist/es2019/plugins/table/commands/hover.js +22 -5
  26. package/dist/es2019/plugins/table/commands/index.js +1 -1
  27. package/dist/es2019/plugins/table/commands/misc.js +8 -3
  28. package/dist/es2019/plugins/table/event-handlers.js +45 -20
  29. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -1
  30. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  31. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +36 -3
  32. package/dist/es2019/plugins/table/pm-plugins/main.js +6 -4
  33. package/dist/es2019/plugins/table/reducer.js +1 -0
  34. package/dist/es2019/plugins/table/toolbar.js +5 -3
  35. package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
  36. package/dist/es2019/plugins/table/ui/DragPreview/index.js +0 -2
  37. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +9 -7
  38. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
  39. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
  40. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
  41. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -8
  42. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  43. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  44. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +12 -9
  45. package/dist/es2019/plugins/table/utils/dom.js +13 -0
  46. package/dist/es2019/plugins/table/utils/index.js +1 -1
  47. package/dist/esm/plugins/table/commands/hover.js +25 -5
  48. package/dist/esm/plugins/table/commands/index.js +1 -1
  49. package/dist/esm/plugins/table/commands/misc.js +8 -3
  50. package/dist/esm/plugins/table/event-handlers.js +55 -33
  51. package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -1
  52. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  53. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +35 -3
  54. package/dist/esm/plugins/table/pm-plugins/main.js +6 -4
  55. package/dist/esm/plugins/table/reducer.js +1 -0
  56. package/dist/esm/plugins/table/toolbar.js +5 -3
  57. package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
  58. package/dist/esm/plugins/table/ui/DragPreview/index.js +0 -2
  59. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +9 -7
  60. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
  61. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
  62. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
  63. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -8
  64. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  65. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  66. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -8
  67. package/dist/esm/plugins/table/utils/dom.js +15 -0
  68. package/dist/esm/plugins/table/utils/index.js +1 -1
  69. package/dist/types/plugins/table/commands/hover.d.ts +2 -1
  70. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  71. package/dist/types/plugins/table/commands/misc.d.ts +1 -1
  72. package/dist/types/plugins/table/event-handlers.d.ts +2 -0
  73. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  74. package/dist/types/plugins/table/types.d.ts +6 -2
  75. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  76. package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
  77. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  78. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  79. package/dist/types/plugins/table/utils/dom.d.ts +4 -0
  80. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  81. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
  82. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
  83. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +1 -1
  84. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +2 -0
  85. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  86. package/dist/types-ts4.5/plugins/table/types.d.ts +6 -2
  87. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  88. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
  89. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  90. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  91. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -0
  92. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  93. package/package.json +2 -2
  94. package/src/__tests__/unit/event-handlers.ts +2 -2
  95. package/src/__tests__/unit/ui/RowDragControls.tsx +1 -0
  96. package/src/plugins/table/commands/hover.ts +37 -7
  97. package/src/plugins/table/commands/index.ts +1 -0
  98. package/src/plugins/table/commands/misc.ts +9 -3
  99. package/src/plugins/table/event-handlers.ts +47 -29
  100. package/src/plugins/table/nodeviews/TableComponent.tsx +4 -1
  101. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +7 -5
  102. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +37 -2
  103. package/src/plugins/table/pm-plugins/main.ts +6 -3
  104. package/src/plugins/table/reducer.ts +1 -0
  105. package/src/plugins/table/types.ts +7 -2
  106. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +14 -5
  107. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +3 -0
  108. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +3 -1
  109. package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -5
  110. package/src/plugins/table/utils/dom.ts +22 -0
  111. package/src/plugins/table/utils/index.ts +1 -0
@@ -528,7 +528,8 @@ class TableComponent extends React.Component {
528
528
  const {
529
529
  isInDanger,
530
530
  hoveredRows,
531
- hoveredCell
531
+ hoveredCell,
532
+ isTableHovered
532
533
  } = getPluginState(view.state);
533
534
  const tableRef = this.table || undefined;
534
535
  const headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
@@ -540,6 +541,7 @@ class TableComponent extends React.Component {
540
541
  tableActive: tableActive,
541
542
  hoveredRows: hoveredRows,
542
543
  hoveredCell: hoveredCell,
544
+ isTableHovered: isTableHovered,
543
545
  isInDanger: isInDanger,
544
546
  isResizing: isResizing,
545
547
  isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
@@ -562,6 +564,7 @@ class TableComponent extends React.Component {
562
564
  isInDanger: isInDanger,
563
565
  hoveredRows: hoveredRows,
564
566
  hoveredCell: hoveredCell,
567
+ isTableHovered: isTableHovered,
565
568
  isResizing: isResizing,
566
569
  ordering: ordering,
567
570
  hasHeaderRow: hasHeaderRow
@@ -53,24 +53,25 @@ export const clearDropTarget = tr => createCommand(state => {
53
53
  }
54
54
  };
55
55
  }, originalTr => (tr || originalTr).setMeta('addToHistory', false));
56
- export const moveSource = (sourceType, sourceIndex, targetIndex) => createCommand(state => {
56
+ export const moveSource = (sourceType, sourceIndex, targetIndex, tr) => createCommand(state => {
57
57
  return {
58
58
  type: DragAndDropActionType.CLEAR_DROP_TARGET,
59
59
  data: {
60
60
  decorationSet: DecorationSet.empty
61
61
  }
62
62
  };
63
- }, tr => {
63
+ }, originalTr => {
64
+ const nextTr = tr || originalTr;
64
65
  if (sourceIndex === targetIndex) {
65
- return tr.setMeta('addToHistory', false);
66
+ return nextTr.setMeta('addToHistory', false);
66
67
  }
67
- const anchor = tr.selection.anchor;
68
+ const anchor = nextTr.selection.anchor;
68
69
  const selectStartOfTable = newTr => newTr.setSelection(TextSelection.create(newTr.doc, anchor));
69
70
  const isTableRow = sourceType === 'table-row';
70
71
  if (isTableRow) {
71
- return combineTransforms([moveRow(sourceIndex, targetIndex), selectStartOfTable, selectRow(targetIndex)], tr);
72
+ return combineTransforms([moveRow(sourceIndex, targetIndex), selectStartOfTable, selectRow(targetIndex)], nextTr);
72
73
  }
73
- return combineTransforms([moveColumn(sourceIndex, targetIndex), selectStartOfTable, selectColumn(targetIndex)], tr);
74
+ return combineTransforms([moveColumn(sourceIndex, targetIndex), selectStartOfTable, selectColumn(targetIndex)], nextTr);
74
75
  });
75
76
  export const toggleDragMenu = (isDragMenuOpen, direction, index) => createCommand(state => {
76
77
  let {
@@ -3,8 +3,10 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
3
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
4
  import { getCellsInRow } from '@atlaskit/editor-tables/utils';
5
5
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
6
+ import { findNearestCellIndexToPoint } from '../../utils';
6
7
  import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
7
8
  import { getPluginState as getTablePluginState } from '../plugin-factory';
9
+ import { pluginKey as tablePluginKey } from '../plugin-key';
8
10
  import { DragAndDropActionType } from './actions';
9
11
  import { clearDropTarget, moveSource, setDropTarget, toggleDragMenu } from './commands';
10
12
  import { DropTargetType } from './consts';
@@ -112,29 +114,60 @@ export const createPlugin = (dispatch, eventDispatcher) => {
112
114
  setDropTarget(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
113
115
  },
114
116
  onDrop(event) {
117
+ var _cell$row, _cell$col;
115
118
  const data = getDraggableDataFromEvent(event);
116
119
 
120
+ // On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
121
+ // over. This is so the drag handles update their positions to correctly align with the users mouse. Unfortunately
122
+ // at this point in time and during the drag opertation, the drop targets are eating all the mouse events so
123
+ // it's not possible to know what row/col the mouse is over (via mouse events). This attempts to locate the nearest cell and
124
+ // then tries to update the main table hoveredCell value by piggy-backing the transaction onto the command
125
+ // triggered by this on drop event.
126
+ const {
127
+ hoveredCell
128
+ } = getTablePluginState(editorView.state);
129
+ const cell = findNearestCellIndexToPoint(event.location.current.input.clientX, event.location.current.input.clientY);
130
+ const tr = editorView.state.tr;
131
+ const action = {
132
+ type: 'HOVER_CELL',
133
+ data: {
134
+ hoveredCell: {
135
+ rowIndex: (_cell$row = cell === null || cell === void 0 ? void 0 : cell.row) !== null && _cell$row !== void 0 ? _cell$row : hoveredCell.rowIndex,
136
+ colIndex: (_cell$col = cell === null || cell === void 0 ? void 0 : cell.col) !== null && _cell$col !== void 0 ? _cell$col : hoveredCell.colIndex
137
+ }
138
+ }
139
+ };
140
+ tr.setMeta(tablePluginKey, action);
141
+
117
142
  // If no data can be found then it's most like we do not want to perform any drop action
118
143
  if (!data) {
119
- clearDropTarget()(editorView.state, editorView.dispatch);
144
+ clearDropTarget(tr)(editorView.state, editorView.dispatch);
120
145
  return;
121
146
  }
122
147
  const {
123
148
  sourceType,
124
149
  sourceIndexes,
150
+ targetIndex,
125
151
  targetAdjustedIndex,
126
152
  direction
127
153
  } = data;
128
154
 
155
+ // When we drop on a target we will know the targets row/col index for certain,
156
+ if (sourceType === 'table-row') {
157
+ action.data.hoveredCell.rowIndex = targetIndex;
158
+ } else {
159
+ action.data.hoveredCell.colIndex = targetIndex;
160
+ }
161
+
129
162
  // If the drop target index contains merged cells then we should not allow the drop to occur.
130
163
  const hasMergedCells = sourceType === 'table-row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
131
164
  if (hasMergedCells(targetAdjustedIndex)(editorView.state.selection)) {
132
- clearDropTarget()(editorView.state, editorView.dispatch);
165
+ clearDropTarget(tr)(editorView.state, editorView.dispatch);
133
166
  return;
134
167
  }
135
168
  const [sourceIndex] = sourceIndexes;
136
169
  requestAnimationFrame(() => {
137
- moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1))(editorView.state, editorView.dispatch);
170
+ moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
138
171
  });
139
172
  }
140
173
  })
@@ -8,7 +8,7 @@ import { findTable } from '@atlaskit/editor-tables/utils';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
9
  import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
10
10
  import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
11
- import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
11
+ import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
12
12
  import { createTableView } from '../nodeviews/table';
13
13
  import TableCell from '../nodeviews/TableCell';
14
14
  import TableRow from '../nodeviews/TableRow';
@@ -24,6 +24,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
24
24
  var _window;
25
25
  const state = createPluginState(dispatch, {
26
26
  pluginConfig,
27
+ isTableHovered: false,
27
28
  insertColumnButtonIndex: undefined,
28
29
  insertRowButtonIndex: undefined,
29
30
  isFullWidthModeEnabled: fullWidthModeEnabled,
@@ -236,11 +237,12 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
236
237
  focus: handleFocus,
237
238
  blur: handleBlur,
238
239
  mousedown: withCellTracking(handleMouseDown),
239
- mouseover: whenTableInFocus(withCellTracking(handleMouseOver)),
240
- mouseleave: whenTableInFocus(handleMouseLeave),
240
+ mouseover: withCellTracking(whenTableInFocus(handleMouseOver)),
241
+ mouseleave: handleMouseLeave,
241
242
  mouseout: whenTableInFocus(handleMouseOut),
242
243
  mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
243
- click: whenTableInFocus(handleClick)
244
+ mouseenter: handleMouseEnter,
245
+ click: withCellTracking(whenTableInFocus(handleClick))
244
246
  },
245
247
  handleTripleClick
246
248
  }
@@ -114,6 +114,7 @@ export default ((pluginState, action) => {
114
114
  case 'HOVER_ROWS':
115
115
  case 'HOVER_COLUMNS':
116
116
  case 'HOVER_TABLE':
117
+ case 'TABLE_HOVERED':
117
118
  case 'HOVER_MERGED_CELLS':
118
119
  case 'HOVER_CELL':
119
120
  case 'SHOW_RESIZE_HANDLE_LINE':
@@ -1,3 +1,5 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
1
3
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
2
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
5
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
@@ -87,7 +89,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
87
89
  },
88
90
  selected: false,
89
91
  disabled: false,
90
- elemAfter: /*#__PURE__*/React.createElement("div", {
92
+ elemAfter: jsx("div", {
91
93
  css: shortcutStyle
92
94
  }, tooltip(addColumnAfter))
93
95
  }, {
@@ -106,7 +108,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
106
108
  },
107
109
  selected: false,
108
110
  disabled: false,
109
- elemAfter: /*#__PURE__*/React.createElement("div", {
111
+ elemAfter: jsx("div", {
110
112
  css: shortcutStyle
111
113
  }, tooltip(addRowAfter))
112
114
  }, {
@@ -239,7 +241,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
239
241
  },
240
242
  selected: false,
241
243
  disabled: false,
242
- elemAfter: /*#__PURE__*/React.createElement("div", {
244
+ elemAfter: jsx("div", {
243
245
  css: shortcutStyle
244
246
  }, tooltip(backspace))
245
247
  });
@@ -1,5 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ /** @jsx jsx */
2
3
  import React from 'react';
4
+ import { jsx } from '@emotion/react';
3
5
  import { useIntl } from 'react-intl-next';
4
6
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
5
7
  import Tooltip from '@atlaskit/tooltip';
@@ -13,19 +15,19 @@ export const ColumnResizeWidget = ({
13
15
  formatMessage
14
16
  } = useIntl();
15
17
  if (!includeTooltip) {
16
- return /*#__PURE__*/React.createElement("div", {
18
+ return jsx("div", {
17
19
  className: TableCssClassName.RESIZE_HANDLE_DECORATION,
18
20
  "data-start-index": startIndex,
19
21
  "data-end-index": endIndex
20
22
  });
21
23
  }
22
- return /*#__PURE__*/React.createElement(Tooltip, {
24
+ return jsx(Tooltip, {
23
25
  content: formatMessage(messages.adjustColumns),
24
26
  hideTooltipOnClick: true,
25
27
  hideTooltipOnMouseDown: true,
26
28
  position: "mouse",
27
29
  mousePosition: "auto-start"
28
- }, tooltipProps => /*#__PURE__*/React.createElement("div", _extends({
30
+ }, tooltipProps => jsx("div", _extends({
29
31
  className: TableCssClassName.RESIZE_HANDLE_DECORATION,
30
32
  "data-start-index": startIndex,
31
33
  "data-end-index": endIndex
@@ -1,5 +1,3 @@
1
- /* index.tsx generated by @compiled/babel-plugin v0.26.1 */
2
- import { ax, ix } from "@compiled/react/runtime";
3
1
  import React from 'react';
4
2
  import { Box, xcss } from '@atlaskit/primitives';
5
3
  import { DragInMotionIcon } from '../icons/DragInMotionIcon';
@@ -1,4 +1,6 @@
1
+ /** @jsx jsx */
1
2
  import React from 'react';
3
+ import { jsx } from '@emotion/react';
2
4
  import { injectIntl } from 'react-intl-next';
3
5
  import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
4
6
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
@@ -48,25 +50,25 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
48
50
  return null;
49
51
  }
50
52
  const labelCellOptions = formatMessage(messages.cellOptions);
51
- const button = /*#__PURE__*/React.createElement("div", {
53
+ const button = jsx("div", {
52
54
  css: theme => [tableFloatingCellButtonStyles({
53
55
  theme
54
56
  }), isContextualMenuOpen && tableFloatingCellButtonSelectedStyles({
55
57
  theme
56
58
  })]
57
- }, /*#__PURE__*/React.createElement(ToolbarButton, {
59
+ }, jsx(ToolbarButton, {
58
60
  className: ClassName.CONTEXTUAL_MENU_BUTTON,
59
61
  selected: isContextualMenuOpen,
60
62
  title: labelCellOptions,
61
63
  onClick: handleClick,
62
- iconBefore: /*#__PURE__*/React.createElement(ExpandIcon, {
64
+ iconBefore: jsx(ExpandIcon, {
63
65
  label: ""
64
66
  }),
65
67
  "aria-label": labelCellOptions
66
68
  }));
67
69
  const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
68
70
  if (stickyHeader && parentSticky && tableWrapper) {
69
- return /*#__PURE__*/React.createElement(FixedButton, {
71
+ return jsx(FixedButton, {
70
72
  offset: BUTTON_OFFSET,
71
73
  stickyHeader: stickyHeader,
72
74
  tableWrapper: tableWrapper,
@@ -76,7 +78,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
76
78
  isContextualMenuOpen: isContextualMenuOpen
77
79
  }, button);
78
80
  }
79
- return /*#__PURE__*/React.createElement(Popup, {
81
+ return jsx(Popup, {
80
82
  alignX: "right",
81
83
  alignY: "start",
82
84
  target: targetCellRef,
@@ -91,9 +93,9 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
91
93
  });
92
94
  const FloatingContextualButton = injectIntl(FloatingContextualButtonInner);
93
95
  export default function (props) {
94
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
96
+ return jsx(ErrorBoundary, {
95
97
  component: ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON,
96
98
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
97
99
  fallbackComponent: null
98
- }, /*#__PURE__*/React.createElement(FloatingContextualButton, props));
100
+ }, jsx(FloatingContextualButton, props));
99
101
  }
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ /** @jsx jsx */
2
3
  import { Component } from 'react';
4
+ import { jsx } from '@emotion/react';
3
5
  import { injectIntl } from 'react-intl-next';
4
6
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
5
7
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
@@ -73,15 +75,15 @@ export class ContextualMenu extends Component {
73
75
  value: {
74
76
  name: 'background'
75
77
  },
76
- elemAfter: /*#__PURE__*/React.createElement("div", {
78
+ elemAfter: jsx("div", {
77
79
  className: DropdownMenuSharedCssClassName.SUBMENU
78
- }, /*#__PURE__*/React.createElement("div", {
80
+ }, jsx("div", {
79
81
  css: cellColourPreviewStyles(background),
80
82
  className: ClassName.CONTEXTUAL_MENU_ICON
81
- }), isSubmenuOpen && /*#__PURE__*/React.createElement("div", {
83
+ }), isSubmenuOpen && jsx("div", {
82
84
  className: ClassName.CONTEXTUAL_SUBMENU,
83
85
  ref: this.handleSubMenuRef
84
- }, /*#__PURE__*/React.createElement(ColorPalette, {
86
+ }, jsx(ColorPalette, {
85
87
  cols: 7,
86
88
  onClick: this.setColor,
87
89
  selectedColor: background,
@@ -98,7 +100,7 @@ export class ContextualMenu extends Component {
98
100
  value: {
99
101
  name: 'insert_column'
100
102
  },
101
- elemAfter: /*#__PURE__*/React.createElement("div", {
103
+ elemAfter: jsx("div", {
102
104
  css: shortcutStyle
103
105
  }, tooltip(addColumnAfter))
104
106
  });
@@ -107,7 +109,7 @@ export class ContextualMenu extends Component {
107
109
  value: {
108
110
  name: 'insert_row'
109
111
  },
110
- elemAfter: /*#__PURE__*/React.createElement("div", {
112
+ elemAfter: jsx("div", {
111
113
  css: shortcutStyle
112
114
  }, tooltip(addRowAfter))
113
115
  });
@@ -191,7 +193,7 @@ export class ContextualMenu extends Component {
191
193
  value: {
192
194
  name: 'clear'
193
195
  },
194
- elemAfter: /*#__PURE__*/React.createElement("div", {
196
+ elemAfter: jsx("div", {
195
197
  css: shortcutStyle
196
198
  }, tooltip(backspace))
197
199
  });
@@ -373,10 +375,10 @@ export class ContextualMenu extends Component {
373
375
  if (!items) {
374
376
  return null;
375
377
  }
376
- return /*#__PURE__*/React.createElement("div", {
378
+ return jsx("div", {
377
379
  "data-testid": "table-cell-contextual-menu",
378
380
  onMouseLeave: this.closeSubmenu
379
- }, /*#__PURE__*/React.createElement(DropdownMenu, {
381
+ }, jsx(DropdownMenu, {
380
382
  mountTo: mountPoint
381
383
  //This needs be removed when the a11y is completely handled
382
384
  //Disabling key navigation now as it works only partially
@@ -1,3 +1,5 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
1
3
  import { Popup } from '@atlaskit/editor-common/ui';
2
4
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
3
5
  import { akEditorFloatingDialogZIndex, akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
@@ -36,7 +38,7 @@ const FloatingContextualMenu = ({
36
38
  return null;
37
39
  }
38
40
  const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
39
- return /*#__PURE__*/React.createElement(Popup, {
41
+ return jsx(Popup, {
40
42
  alignX: "right",
41
43
  alignY: "top",
42
44
  target: targetCellRef,
@@ -52,9 +54,9 @@ const FloatingContextualMenu = ({
52
54
  forcePlacement: true,
53
55
  offset: [-7, 0],
54
56
  stick: true
55
- }, /*#__PURE__*/React.createElement("div", {
57
+ }, jsx("div", {
56
58
  css: tablePopupStyles
57
- }, /*#__PURE__*/React.createElement(ContextualMenu, {
59
+ }, jsx(ContextualMenu, {
58
60
  editorView: editorView,
59
61
  offset: [contextualMenuTriggerSize / 2, -contextualMenuTriggerSize],
60
62
  isOpen: isOpen,
@@ -1,3 +1,5 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
1
3
  import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
2
4
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
3
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
@@ -24,15 +26,15 @@ const convertToDropdownItems = dragMenuConfig => {
24
26
  name: item.id
25
27
  },
26
28
  isDisabled: item.disabled,
27
- elemBefore: item.icon ? /*#__PURE__*/React.createElement("div", {
29
+ elemBefore: item.icon ? jsx("div", {
28
30
  style: {
29
31
  marginRight: "var(--ds-space-negative-075, -6px)",
30
32
  display: 'flex'
31
33
  }
32
- }, /*#__PURE__*/React.createElement(item.icon, {
34
+ }, jsx(item.icon, {
33
35
  label: item.title
34
36
  })) : undefined,
35
- elemAfter: item.keymap ? /*#__PURE__*/React.createElement("div", {
37
+ elemAfter: item.keymap ? jsx("div", {
36
38
  css: shortcutStyle
37
39
  }, item.keymap) : undefined
38
40
  });
@@ -135,7 +137,7 @@ export const DragMenu = ({
135
137
  if (!menuItems) {
136
138
  return null;
137
139
  }
138
- return /*#__PURE__*/React.createElement(DropdownMenu, {
140
+ return jsx(DropdownMenu, {
139
141
  mountTo: mountPoint
140
142
  //This needs be removed when the a11y is completely handled
141
143
  //Disabling key navigation now as it works only partially
@@ -27,9 +27,10 @@ export const ColumnControls = ({
27
27
  isInDanger,
28
28
  rowHeights,
29
29
  colWidths,
30
- hasHeaderColumn
30
+ hasHeaderColumn,
31
+ isTableHovered
31
32
  }) => {
32
- var _colWidths$map$join, _rowHeights$;
33
+ var _colWidths$map$join, _rowHeights$, _rowHeights$reduce, _colWidths;
33
34
  const widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(width => width ? `${width - 1}px` : '0px').join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
34
35
  // TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
35
36
  const columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
@@ -73,10 +74,14 @@ export const ColumnControls = ({
73
74
  state,
74
75
  dispatch
75
76
  } = editorView;
76
- if (tableActive && (hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) !== Number(colIndex)) {
77
- hoverCell(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, Number(colIndex))(state, dispatch);
77
+ if (tableActive) {
78
+ // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
79
+ // of the opposite dimension. For example; here when we mouse over the column drag handle then we're technically
80
+ // also hovering over row 0 index. And vice-versa with rows. This means we don't need to worry about knowing the
81
+ // current row index. We can just force it to 0.
82
+ hoverCell(0, Number(colIndex))(state, dispatch);
78
83
  }
79
- }, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, tableActive]);
84
+ }, [editorView, tableActive]);
80
85
  const handleMouseOut = useCallback(() => {
81
86
  if (tableActive) {
82
87
  const {
@@ -96,6 +101,7 @@ export const ColumnControls = ({
96
101
  const colIndexes = useMemo(() => {
97
102
  return [colIndex];
98
103
  }, [colIndex]);
104
+ const previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce((sum, cur) => sum + cur, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
99
105
  return /*#__PURE__*/React.createElement("div", {
100
106
  className: ClassName.DRAG_COLUMN_CONTROLS,
101
107
  onMouseMove: handleMouseMove
@@ -123,7 +129,7 @@ export const ColumnControls = ({
123
129
  style: columnParams.length - 1 === index ? {
124
130
  right: '0'
125
131
  } : {}
126
- }))), tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
132
+ }))), tableActive && !isResizing && isTableHovered && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
127
133
  style: {
128
134
  gridColumn: gridColumnPosition,
129
135
  display: 'flex',
@@ -139,8 +145,8 @@ export const ColumnControls = ({
139
145
  direction: "column",
140
146
  tableLocalId: localId || '',
141
147
  indexes: colIndexes,
142
- previewWidth: hoveredCell.colWidth,
143
- previewHeight: hoveredCell.colHeight,
148
+ previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
149
+ previewHeight: previewHeight,
144
150
  appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
145
151
  onClick: handleClick,
146
152
  onMouseOver: handleMouseOver,
@@ -14,7 +14,8 @@ export const TableFloatingColumnControls = ({
14
14
  isResizing,
15
15
  stickyHeader,
16
16
  selection,
17
- isInDanger
17
+ isInDanger,
18
+ isTableHovered
18
19
  }) => {
19
20
  const [tableRect, setTableRect] = useState({
20
21
  width: 0,
@@ -84,6 +85,7 @@ export const TableFloatingColumnControls = ({
84
85
  tableRef: tableRef,
85
86
  isResizing: isResizing,
86
87
  tableActive: tableActive,
88
+ isTableHovered: isTableHovered,
87
89
  stickyTop: tableActive ? stickyTop : undefined,
88
90
  localId: currentNodeLocalId,
89
91
  isInDanger: isInDanger,
@@ -30,6 +30,7 @@ const DragControlsComponent = ({
30
30
  editorView,
31
31
  isInDanger,
32
32
  isResizing,
33
+ isTableHovered,
33
34
  hoverRows,
34
35
  selectRow,
35
36
  updateCellHoverLocation
@@ -146,7 +147,7 @@ const DragControlsComponent = ({
146
147
  position: 'relative',
147
148
  left: "var(--ds-space-negative-100, -8px)"
148
149
  }
149
- }))), !isResizing && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
150
+ }))), !isResizing && isTableHovered && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
150
151
  style: {
151
152
  gridRow: gridRowPosition,
152
153
  gridColumn: '2',
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { Component } from 'react';
3
3
  import { browser } from '@atlaskit/editor-common/utils';
4
4
  import { hoverCell, hoverRows, selectRow } from '../../commands';
5
- import { getPluginState } from '../../pm-plugins/plugin-factory';
6
5
  import { TableCssClassName as ClassName } from '../../types';
7
6
  import { isSelectionUpdated } from '../../utils';
8
7
  import { CornerControls, DragCornerControls } from './CornerControls';
@@ -42,11 +41,12 @@ export default class TableFloatingControls extends Component {
42
41
  state,
43
42
  dispatch
44
43
  } = editorView;
45
- const {
46
- hoveredCell
47
- } = getPluginState(state);
48
- if (tableActive && hoveredCell.rowIndex !== rowIndex) {
49
- hoverCell(rowIndex, hoveredCell.colIndex)(state, dispatch);
44
+ if (tableActive) {
45
+ // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
46
+ // of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
47
+ // also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
48
+ // current column index. We can just force it to 0.
49
+ hoverCell(rowIndex, 0)(state, dispatch);
50
50
  }
51
51
  });
52
52
  this.state = {
@@ -98,9 +98,10 @@ export default class TableFloatingControls extends Component {
98
98
  ordering,
99
99
  headerRowHeight,
100
100
  stickyHeader,
101
- hoveredCell
101
+ hoveredCell,
102
+ isTableHovered
102
103
  } = this.props;
103
- return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || isSelectionUpdated(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell;
104
+ return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || isSelectionUpdated(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell || isTableHovered !== nextProps.isTableHovered;
104
105
  }
105
106
  componentWillUnmount() {
106
107
  if (this.resizeObserver) {
@@ -122,7 +123,8 @@ export default class TableFloatingControls extends Component {
122
123
  hoveredRows,
123
124
  stickyHeader,
124
125
  isDragAndDropEnabled,
125
- hoveredCell
126
+ hoveredCell,
127
+ isTableHovered
126
128
  } = this.props;
127
129
  if (!tableRef) {
128
130
  return null;
@@ -155,6 +157,7 @@ export default class TableFloatingControls extends Component {
155
157
  tableRef: tableRef,
156
158
  tableNode: tableNode,
157
159
  hoveredCell: hoveredCell,
160
+ isTableHovered: isTableHovered,
158
161
  editorView: editorView,
159
162
  tableActive: tableActive,
160
163
  isInDanger: isInDanger,
@@ -177,4 +177,17 @@ export const getTop = element => {
177
177
  return 0;
178
178
  }
179
179
  return (_element$getBoundingC = element === null || element === void 0 ? void 0 : (_element$getBoundingC2 = element.getBoundingClientRect) === null || _element$getBoundingC2 === void 0 ? void 0 : (_element$getBoundingC3 = _element$getBoundingC2.call(element)) === null || _element$getBoundingC3 === void 0 ? void 0 : _element$getBoundingC3.top) !== null && _element$getBoundingC !== void 0 ? _element$getBoundingC : 0;
180
+ };
181
+ export const findNearestCellIndexToPoint = (x, y) => {
182
+ var _cell$parentElement;
183
+ const elements = document.elementsFromPoint(x, y);
184
+ const cell = elements.find(el => el.nodeName.toUpperCase() === 'TD' || el.nodeName.toUpperCase() === 'TH');
185
+ const row = (_cell$parentElement = cell === null || cell === void 0 ? void 0 : cell.parentElement) !== null && _cell$parentElement !== void 0 ? _cell$parentElement : undefined;
186
+ if (!Number.isFinite(row === null || row === void 0 ? void 0 : row.rowIndex) || !Number.isFinite(cell === null || cell === void 0 ? void 0 : cell.cellIndex)) {
187
+ return undefined;
188
+ }
189
+ return {
190
+ row: row.rowIndex,
191
+ col: cell.cellIndex
192
+ };
180
193
  };
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
3
3
  export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
5
- export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
5
+ export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
8
8
  export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';