@atlaskit/editor-plugin-table 5.4.13 → 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 (119) hide show
  1. package/CHANGELOG.md +16 -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/DragHandle/index.js +7 -5
  15. package/dist/cjs/plugins/table/ui/DragPreview/index.js +0 -2
  16. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -7
  17. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -10
  18. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  19. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +7 -4
  20. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -8
  21. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  22. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  23. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +12 -8
  24. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  25. package/dist/cjs/plugins/table/utils/dom.js +16 -1
  26. package/dist/cjs/plugins/table/utils/index.js +6 -0
  27. package/dist/es2019/plugins/table/commands/hover.js +22 -5
  28. package/dist/es2019/plugins/table/commands/index.js +1 -1
  29. package/dist/es2019/plugins/table/commands/misc.js +8 -3
  30. package/dist/es2019/plugins/table/event-handlers.js +45 -20
  31. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -1
  32. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  33. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +36 -3
  34. package/dist/es2019/plugins/table/pm-plugins/main.js +6 -4
  35. package/dist/es2019/plugins/table/reducer.js +1 -0
  36. package/dist/es2019/plugins/table/toolbar.js +5 -3
  37. package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
  38. package/dist/es2019/plugins/table/ui/DragHandle/index.js +8 -6
  39. package/dist/es2019/plugins/table/ui/DragPreview/index.js +0 -2
  40. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +9 -7
  41. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
  42. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
  43. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
  44. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -8
  45. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  46. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  47. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +12 -9
  48. package/dist/es2019/plugins/table/ui/common-styles.js +6 -4
  49. package/dist/es2019/plugins/table/utils/dom.js +13 -0
  50. package/dist/es2019/plugins/table/utils/index.js +1 -1
  51. package/dist/esm/plugins/table/commands/hover.js +25 -5
  52. package/dist/esm/plugins/table/commands/index.js +1 -1
  53. package/dist/esm/plugins/table/commands/misc.js +8 -3
  54. package/dist/esm/plugins/table/event-handlers.js +55 -33
  55. package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -1
  56. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  57. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +35 -3
  58. package/dist/esm/plugins/table/pm-plugins/main.js +6 -4
  59. package/dist/esm/plugins/table/reducer.js +1 -0
  60. package/dist/esm/plugins/table/toolbar.js +5 -3
  61. package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
  62. package/dist/esm/plugins/table/ui/DragHandle/index.js +7 -5
  63. package/dist/esm/plugins/table/ui/DragPreview/index.js +0 -2
  64. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +9 -7
  65. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
  66. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
  67. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
  68. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +18 -8
  69. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  70. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  71. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -8
  72. package/dist/esm/plugins/table/ui/common-styles.js +1 -1
  73. package/dist/esm/plugins/table/utils/dom.js +15 -0
  74. package/dist/esm/plugins/table/utils/index.js +1 -1
  75. package/dist/types/plugins/table/commands/hover.d.ts +2 -1
  76. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  77. package/dist/types/plugins/table/commands/misc.d.ts +1 -1
  78. package/dist/types/plugins/table/event-handlers.d.ts +2 -0
  79. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  80. package/dist/types/plugins/table/types.d.ts +6 -2
  81. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  82. package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
  83. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  84. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  85. package/dist/types/plugins/table/utils/dom.d.ts +4 -0
  86. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  87. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
  88. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
  89. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +1 -1
  90. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +2 -0
  91. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  92. package/dist/types-ts4.5/plugins/table/types.d.ts +6 -2
  93. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  94. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
  95. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  96. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  97. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -0
  98. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  99. package/package.json +2 -2
  100. package/src/__tests__/unit/event-handlers.ts +2 -2
  101. package/src/__tests__/unit/ui/RowDragControls.tsx +1 -0
  102. package/src/plugins/table/commands/hover.ts +37 -7
  103. package/src/plugins/table/commands/index.ts +1 -0
  104. package/src/plugins/table/commands/misc.ts +9 -3
  105. package/src/plugins/table/event-handlers.ts +47 -29
  106. package/src/plugins/table/nodeviews/TableComponent.tsx +4 -1
  107. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +7 -5
  108. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +37 -2
  109. package/src/plugins/table/pm-plugins/main.ts +6 -3
  110. package/src/plugins/table/reducer.ts +1 -0
  111. package/src/plugins/table/types.ts +7 -2
  112. package/src/plugins/table/ui/DragHandle/index.tsx +7 -7
  113. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +16 -5
  114. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +3 -0
  115. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +3 -1
  116. package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -5
  117. package/src/plugins/table/ui/common-styles.ts +6 -4
  118. package/src/plugins/table/utils/dom.ts +22 -0
  119. package/src/plugins/table/utils/index.ts +1 -0
@@ -4,8 +4,10 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
5
  import { getCellsInRow } from '@atlaskit/editor-tables/utils';
6
6
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
7
+ import { findNearestCellIndexToPoint } from '../../utils';
7
8
  import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
8
9
  import { getPluginState as getTablePluginState } from '../plugin-factory';
10
+ import { pluginKey as tablePluginKey } from '../plugin-key';
9
11
  import { DragAndDropActionType } from './actions';
10
12
  import { clearDropTarget, moveSource, setDropTarget, toggleDragMenu } from './commands';
11
13
  import { DropTargetType } from './consts';
@@ -106,28 +108,58 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
106
108
  setDropTarget(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
107
109
  },
108
110
  onDrop: function onDrop(event) {
111
+ var _cell$row, _cell$col;
109
112
  var data = getDraggableDataFromEvent(event);
110
113
 
114
+ // On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
115
+ // over. This is so the drag handles update their positions to correctly align with the users mouse. Unfortunately
116
+ // at this point in time and during the drag opertation, the drop targets are eating all the mouse events so
117
+ // it's not possible to know what row/col the mouse is over (via mouse events). This attempts to locate the nearest cell and
118
+ // then tries to update the main table hoveredCell value by piggy-backing the transaction onto the command
119
+ // triggered by this on drop event.
120
+ var _getTablePluginState4 = getTablePluginState(editorView.state),
121
+ hoveredCell = _getTablePluginState4.hoveredCell;
122
+ var cell = findNearestCellIndexToPoint(event.location.current.input.clientX, event.location.current.input.clientY);
123
+ var tr = editorView.state.tr;
124
+ var action = {
125
+ type: 'HOVER_CELL',
126
+ data: {
127
+ hoveredCell: {
128
+ rowIndex: (_cell$row = cell === null || cell === void 0 ? void 0 : cell.row) !== null && _cell$row !== void 0 ? _cell$row : hoveredCell.rowIndex,
129
+ colIndex: (_cell$col = cell === null || cell === void 0 ? void 0 : cell.col) !== null && _cell$col !== void 0 ? _cell$col : hoveredCell.colIndex
130
+ }
131
+ }
132
+ };
133
+ tr.setMeta(tablePluginKey, action);
134
+
111
135
  // If no data can be found then it's most like we do not want to perform any drop action
112
136
  if (!data) {
113
- clearDropTarget()(editorView.state, editorView.dispatch);
137
+ clearDropTarget(tr)(editorView.state, editorView.dispatch);
114
138
  return;
115
139
  }
116
140
  var sourceType = data.sourceType,
117
141
  sourceIndexes = data.sourceIndexes,
142
+ targetIndex = data.targetIndex,
118
143
  targetAdjustedIndex = data.targetAdjustedIndex,
119
144
  direction = data.direction;
120
145
 
146
+ // When we drop on a target we will know the targets row/col index for certain,
147
+ if (sourceType === 'table-row') {
148
+ action.data.hoveredCell.rowIndex = targetIndex;
149
+ } else {
150
+ action.data.hoveredCell.colIndex = targetIndex;
151
+ }
152
+
121
153
  // If the drop target index contains merged cells then we should not allow the drop to occur.
122
154
  var hasMergedCells = sourceType === 'table-row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
123
155
  if (hasMergedCells(targetAdjustedIndex)(editorView.state.selection)) {
124
- clearDropTarget()(editorView.state, editorView.dispatch);
156
+ clearDropTarget(tr)(editorView.state, editorView.dispatch);
125
157
  return;
126
158
  }
127
159
  var _sourceIndexes = _slicedToArray(sourceIndexes, 1),
128
160
  sourceIndex = _sourceIndexes[0];
129
161
  requestAnimationFrame(function () {
130
- moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1))(editorView.state, editorView.dispatch);
162
+ moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
131
163
  });
132
164
  }
133
165
  })
@@ -11,7 +11,7 @@ import { findTable } from '@atlaskit/editor-tables/utils';
11
11
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
12
  import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
13
13
  import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
14
- import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
14
+ import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
15
15
  import { createTableView } from '../nodeviews/table';
16
16
  import TableCell from '../nodeviews/TableCell';
17
17
  import TableRow from '../nodeviews/TableRow';
@@ -27,6 +27,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
27
27
  var _window;
28
28
  var state = createPluginState(dispatch, _objectSpread(_objectSpread(_objectSpread({
29
29
  pluginConfig: pluginConfig,
30
+ isTableHovered: false,
30
31
  insertColumnButtonIndex: undefined,
31
32
  insertRowButtonIndex: undefined,
32
33
  isFullWidthModeEnabled: fullWidthModeEnabled,
@@ -241,11 +242,12 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
241
242
  focus: handleFocus,
242
243
  blur: handleBlur,
243
244
  mousedown: withCellTracking(handleMouseDown),
244
- mouseover: whenTableInFocus(withCellTracking(handleMouseOver)),
245
- mouseleave: whenTableInFocus(handleMouseLeave),
245
+ mouseover: withCellTracking(whenTableInFocus(handleMouseOver)),
246
+ mouseleave: handleMouseLeave,
246
247
  mouseout: whenTableInFocus(handleMouseOut),
247
248
  mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
248
- click: whenTableInFocus(handleClick)
249
+ mouseenter: handleMouseEnter,
250
+ click: withCellTracking(whenTableInFocus(handleClick))
249
251
  },
250
252
  handleTripleClick: handleTripleClick
251
253
  }
@@ -90,6 +90,7 @@ export default (function (pluginState, action) {
90
90
  case 'HOVER_ROWS':
91
91
  case 'HOVER_COLUMNS':
92
92
  case 'HOVER_TABLE':
93
+ case 'TABLE_HOVERED':
93
94
  case 'HOVER_MERGED_CELLS':
94
95
  case 'HOVER_CELL':
95
96
  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';
@@ -85,7 +87,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
85
87
  },
86
88
  selected: false,
87
89
  disabled: false,
88
- elemAfter: /*#__PURE__*/React.createElement("div", {
90
+ elemAfter: jsx("div", {
89
91
  css: shortcutStyle
90
92
  }, tooltip(addColumnAfter))
91
93
  }, {
@@ -104,7 +106,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
104
106
  },
105
107
  selected: false,
106
108
  disabled: false,
107
- elemAfter: /*#__PURE__*/React.createElement("div", {
109
+ elemAfter: jsx("div", {
108
110
  css: shortcutStyle
109
111
  }, tooltip(addRowAfter))
110
112
  }, {
@@ -236,7 +238,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
236
238
  },
237
239
  selected: false,
238
240
  disabled: false,
239
- elemAfter: /*#__PURE__*/React.createElement("div", {
241
+ elemAfter: jsx("div", {
240
242
  css: shortcutStyle
241
243
  }, tooltip(backspace))
242
244
  });
@@ -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';
@@ -11,20 +13,20 @@ export var ColumnResizeWidget = function ColumnResizeWidget(_ref) {
11
13
  var _useIntl = useIntl(),
12
14
  formatMessage = _useIntl.formatMessage;
13
15
  if (!includeTooltip) {
14
- return /*#__PURE__*/React.createElement("div", {
16
+ return jsx("div", {
15
17
  className: TableCssClassName.RESIZE_HANDLE_DECORATION,
16
18
  "data-start-index": startIndex,
17
19
  "data-end-index": endIndex
18
20
  });
19
21
  }
20
- return /*#__PURE__*/React.createElement(Tooltip, {
22
+ return jsx(Tooltip, {
21
23
  content: formatMessage(messages.adjustColumns),
22
24
  hideTooltipOnClick: true,
23
25
  hideTooltipOnMouseDown: true,
24
26
  position: "mouse",
25
27
  mousePosition: "auto-start"
26
28
  }, function (tooltipProps) {
27
- return /*#__PURE__*/React.createElement("div", _extends({
29
+ return jsx("div", _extends({
28
30
  className: TableCssClassName.RESIZE_HANDLE_DECORATION,
29
31
  "data-start-index": startIndex,
30
32
  "data-end-index": endIndex
@@ -31,7 +31,6 @@ export var DragHandle = function DragHandle(_ref) {
31
31
  previewContainer = _useState2[0],
32
32
  setPreviewContainer = _useState2[1];
33
33
  var _getPluginState = getPluginState(editorView.state),
34
- isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled,
35
34
  hoveredColumns = _getPluginState.hoveredColumns,
36
35
  hoveredRows = _getPluginState.hoveredRows,
37
36
  hoveredCell = _getPluginState.hoveredCell;
@@ -104,11 +103,10 @@ export var DragHandle = function DragHandle(_ref) {
104
103
  }
105
104
  }, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells]);
106
105
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
107
- className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, ClassName.CONTROLS_BUTTON, appearance, _defineProperty({}, ClassName.DRAG_HANDLE_DISABLED, isDragAndDropEnabled && hasMergedCells)),
106
+ className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, _defineProperty({}, ClassName.DRAG_HANDLE_DISABLED, hasMergedCells)),
108
107
  ref: dragHandleDivRef,
109
108
  style: {
110
- transform: direction === 'column' ? 'none' : 'rotate(90deg)',
111
- pointerEvents: 'auto'
109
+ transform: direction === 'column' ? 'none' : 'rotate(90deg)'
112
110
  },
113
111
  "data-testid": "table-floating-column-controls-drag-handle",
114
112
  onMouseOver: onMouseOver,
@@ -120,7 +118,11 @@ export var DragHandle = function DragHandle(_ref) {
120
118
  _onMouseUp && _onMouseUp(e);
121
119
  },
122
120
  onClick: onClick
123
- }, /*#__PURE__*/React.createElement(HandleIconComponent, handleIconProps)), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
121
+ }, /*#__PURE__*/React.createElement("span", {
122
+ style: {
123
+ pointerEvents: 'none'
124
+ }
125
+ }, /*#__PURE__*/React.createElement(HandleIconComponent, handleIconProps))), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
124
126
  direction: direction,
125
127
  width: previewWidth,
126
128
  height: previewHeight
@@ -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';
@@ -42,7 +44,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
42
44
  return null;
43
45
  }
44
46
  var labelCellOptions = formatMessage(messages.cellOptions);
45
- var button = /*#__PURE__*/React.createElement("div", {
47
+ var button = jsx("div", {
46
48
  css: function css(theme) {
47
49
  return [tableFloatingCellButtonStyles({
48
50
  theme: theme
@@ -50,19 +52,19 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
50
52
  theme: theme
51
53
  })];
52
54
  }
53
- }, /*#__PURE__*/React.createElement(ToolbarButton, {
55
+ }, jsx(ToolbarButton, {
54
56
  className: ClassName.CONTEXTUAL_MENU_BUTTON,
55
57
  selected: isContextualMenuOpen,
56
58
  title: labelCellOptions,
57
59
  onClick: handleClick,
58
- iconBefore: /*#__PURE__*/React.createElement(ExpandIcon, {
60
+ iconBefore: jsx(ExpandIcon, {
59
61
  label: ""
60
62
  }),
61
63
  "aria-label": labelCellOptions
62
64
  }));
63
65
  var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
64
66
  if (stickyHeader && parentSticky && tableWrapper) {
65
- return /*#__PURE__*/React.createElement(FixedButton, {
67
+ return jsx(FixedButton, {
66
68
  offset: BUTTON_OFFSET,
67
69
  stickyHeader: stickyHeader,
68
70
  tableWrapper: tableWrapper,
@@ -72,7 +74,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
72
74
  isContextualMenuOpen: isContextualMenuOpen
73
75
  }, button);
74
76
  }
75
- return /*#__PURE__*/React.createElement(Popup, {
77
+ return jsx(Popup, {
76
78
  alignX: "right",
77
79
  alignY: "start",
78
80
  target: targetCellRef,
@@ -87,9 +89,9 @@ var FloatingContextualButtonInner = /*#__PURE__*/React.memo(function (props) {
87
89
  });
88
90
  var FloatingContextualButton = injectIntl(FloatingContextualButtonInner);
89
91
  export default function (props) {
90
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
92
+ return jsx(ErrorBoundary, {
91
93
  component: ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON,
92
94
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
93
95
  fallbackComponent: null
94
- }, /*#__PURE__*/React.createElement(FloatingContextualButton, props));
96
+ }, jsx(FloatingContextualButton, props));
95
97
  }
@@ -9,7 +9,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+ /** @jsx jsx */
12
13
  import { Component } from 'react';
14
+ import { jsx } from '@emotion/react';
13
15
  import { injectIntl } from 'react-intl-next';
14
16
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
15
17
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
@@ -80,15 +82,15 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
80
82
  value: {
81
83
  name: 'background'
82
84
  },
83
- elemAfter: /*#__PURE__*/React.createElement("div", {
85
+ elemAfter: jsx("div", {
84
86
  className: DropdownMenuSharedCssClassName.SUBMENU
85
- }, /*#__PURE__*/React.createElement("div", {
87
+ }, jsx("div", {
86
88
  css: cellColourPreviewStyles(background),
87
89
  className: ClassName.CONTEXTUAL_MENU_ICON
88
- }), isSubmenuOpen && /*#__PURE__*/React.createElement("div", {
90
+ }), isSubmenuOpen && jsx("div", {
89
91
  className: ClassName.CONTEXTUAL_SUBMENU,
90
92
  ref: _this.handleSubMenuRef
91
- }, /*#__PURE__*/React.createElement(ColorPalette, {
93
+ }, jsx(ColorPalette, {
92
94
  cols: 7,
93
95
  onClick: _this.setColor,
94
96
  selectedColor: background,
@@ -105,7 +107,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
105
107
  value: {
106
108
  name: 'insert_column'
107
109
  },
108
- elemAfter: /*#__PURE__*/React.createElement("div", {
110
+ elemAfter: jsx("div", {
109
111
  css: shortcutStyle
110
112
  }, tooltip(addColumnAfter))
111
113
  });
@@ -114,7 +116,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
114
116
  value: {
115
117
  name: 'insert_row'
116
118
  },
117
- elemAfter: /*#__PURE__*/React.createElement("div", {
119
+ elemAfter: jsx("div", {
118
120
  css: shortcutStyle
119
121
  }, tooltip(addRowAfter))
120
122
  });
@@ -194,7 +196,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
194
196
  value: {
195
197
  name: 'clear'
196
198
  },
197
- elemAfter: /*#__PURE__*/React.createElement("div", {
199
+ elemAfter: jsx("div", {
198
200
  css: shortcutStyle
199
201
  }, tooltip(backspace))
200
202
  });
@@ -356,10 +358,10 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
356
358
  if (!items) {
357
359
  return null;
358
360
  }
359
- return /*#__PURE__*/React.createElement("div", {
361
+ return jsx("div", {
360
362
  "data-testid": "table-cell-contextual-menu",
361
363
  onMouseLeave: this.closeSubmenu
362
- }, /*#__PURE__*/React.createElement(DropdownMenu, {
364
+ }, jsx(DropdownMenu, {
363
365
  mountTo: mountPoint
364
366
  //This needs be removed when the a11y is completely handled
365
367
  //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';
@@ -32,7 +34,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
32
34
  return null;
33
35
  }
34
36
  var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
35
- return /*#__PURE__*/React.createElement(Popup, {
37
+ return jsx(Popup, {
36
38
  alignX: "right",
37
39
  alignY: "top",
38
40
  target: targetCellRef,
@@ -48,9 +50,9 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
48
50
  forcePlacement: true,
49
51
  offset: [-7, 0],
50
52
  stick: true
51
- }, /*#__PURE__*/React.createElement("div", {
53
+ }, jsx("div", {
52
54
  css: tablePopupStyles
53
- }, /*#__PURE__*/React.createElement(ContextualMenu, {
55
+ }, jsx(ContextualMenu, {
54
56
  editorView: editorView,
55
57
  offset: [contextualMenuTriggerSize / 2, -contextualMenuTriggerSize],
56
58
  isOpen: isOpen,
@@ -1,4 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ /** @jsx jsx */
3
+ import { jsx } from '@emotion/react';
2
4
  import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
3
5
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
4
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
@@ -29,15 +31,15 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
29
31
  name: item.id
30
32
  },
31
33
  isDisabled: item.disabled,
32
- elemBefore: item.icon ? /*#__PURE__*/React.createElement("div", {
34
+ elemBefore: item.icon ? jsx("div", {
33
35
  style: {
34
36
  marginRight: "var(--ds-space-negative-075, -6px)",
35
37
  display: 'flex'
36
38
  }
37
- }, /*#__PURE__*/React.createElement(item.icon, {
39
+ }, jsx(item.icon, {
38
40
  label: item.title
39
41
  })) : undefined,
40
- elemAfter: item.keymap ? /*#__PURE__*/React.createElement("div", {
42
+ elemAfter: item.keymap ? jsx("div", {
41
43
  css: shortcutStyle
42
44
  }, item.keymap) : undefined
43
45
  });
@@ -129,7 +131,7 @@ export var DragMenu = function DragMenu(_ref) {
129
131
  if (!menuItems) {
130
132
  return null;
131
133
  }
132
- return /*#__PURE__*/React.createElement(DropdownMenu, {
134
+ return jsx(DropdownMenu, {
133
135
  mountTo: mountPoint
134
136
  //This needs be removed when the a11y is completely handled
135
137
  //Disabling key navigation now as it works only partially
@@ -17,7 +17,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
17
17
  return [];
18
18
  };
19
19
  export var ColumnControls = function ColumnControls(_ref) {
20
- var _colWidths$map$join, _rowHeights$;
20
+ var _colWidths$map$join, _rowHeights$, _rowHeights$reduce, _colWidths;
21
21
  var editorView = _ref.editorView,
22
22
  tableActive = _ref.tableActive,
23
23
  tableRef = _ref.tableRef,
@@ -28,7 +28,8 @@ export var ColumnControls = function ColumnControls(_ref) {
28
28
  isInDanger = _ref.isInDanger,
29
29
  rowHeights = _ref.rowHeights,
30
30
  colWidths = _ref.colWidths,
31
- hasHeaderColumn = _ref.hasHeaderColumn;
31
+ hasHeaderColumn = _ref.hasHeaderColumn,
32
+ isTableHovered = _ref.isTableHovered;
32
33
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
33
34
  return width ? "".concat(width - 1, "px") : '0px';
34
35
  }).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
@@ -68,10 +69,14 @@ export var ColumnControls = function ColumnControls(_ref) {
68
69
  // update hovered cell location
69
70
  var state = editorView.state,
70
71
  dispatch = editorView.dispatch;
71
- if (tableActive && (hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) !== Number(colIndex)) {
72
- hoverCell(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, Number(colIndex))(state, dispatch);
72
+ if (tableActive) {
73
+ // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
74
+ // of the opposite dimension. For example; here when we mouse over the column drag handle then we're technically
75
+ // also hovering over row 0 index. And vice-versa with rows. This means we don't need to worry about knowing the
76
+ // current row index. We can just force it to 0.
77
+ hoverCell(0, Number(colIndex))(state, dispatch);
73
78
  }
74
- }, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, tableActive]);
79
+ }, [editorView, tableActive]);
75
80
  var handleMouseOut = useCallback(function () {
76
81
  if (tableActive) {
77
82
  var state = editorView.state,
@@ -87,6 +92,9 @@ export var ColumnControls = function ColumnControls(_ref) {
87
92
  var colIndexes = useMemo(function () {
88
93
  return [colIndex];
89
94
  }, [colIndex]);
95
+ var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
96
+ return sum + cur;
97
+ }, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
90
98
  return /*#__PURE__*/React.createElement("div", {
91
99
  className: ClassName.DRAG_COLUMN_CONTROLS,
92
100
  onMouseMove: handleMouseMove
@@ -115,12 +123,14 @@ export var ColumnControls = function ColumnControls(_ref) {
115
123
  right: '0'
116
124
  } : {}
117
125
  }));
118
- }), tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
126
+ }), tableActive && !isResizing && isTableHovered && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
119
127
  style: {
120
128
  gridColumn: gridColumnPosition,
121
129
  display: 'flex',
122
130
  justifyContent: 'center',
123
131
  alignItems: 'center',
132
+ height: 'fit-content',
133
+ placeSelf: 'center',
124
134
  zIndex: 99
125
135
  },
126
136
  "data-column-control-index": hoveredCell.colIndex,
@@ -129,8 +139,8 @@ export var ColumnControls = function ColumnControls(_ref) {
129
139
  direction: "column",
130
140
  tableLocalId: localId || '',
131
141
  indexes: colIndexes,
132
- previewWidth: hoveredCell.colWidth,
133
- previewHeight: hoveredCell.colHeight,
142
+ previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
143
+ previewHeight: previewHeight,
134
144
  appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
135
145
  onClick: handleClick,
136
146
  onMouseOver: handleMouseOver,
@@ -18,7 +18,8 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
18
18
  isResizing = _ref.isResizing,
19
19
  stickyHeader = _ref.stickyHeader,
20
20
  selection = _ref.selection,
21
- isInDanger = _ref.isInDanger;
21
+ isInDanger = _ref.isInDanger,
22
+ isTableHovered = _ref.isTableHovered;
22
23
  var _useState = useState({
23
24
  width: 0,
24
25
  height: 0
@@ -103,6 +104,7 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
103
104
  tableRef: tableRef,
104
105
  isResizing: isResizing,
105
106
  tableActive: tableActive,
107
+ isTableHovered: isTableHovered,
106
108
  stickyTop: tableActive ? stickyTop : undefined,
107
109
  localId: currentNodeLocalId,
108
110
  isInDanger: isInDanger,
@@ -32,6 +32,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
32
32
  editorView = _ref.editorView,
33
33
  isInDanger = _ref.isInDanger,
34
34
  isResizing = _ref.isResizing,
35
+ isTableHovered = _ref.isTableHovered,
35
36
  hoverRows = _ref.hoverRows,
36
37
  selectRow = _ref.selectRow,
37
38
  updateCellHoverLocation = _ref.updateCellHoverLocation;
@@ -147,7 +148,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
147
148
  left: "var(--ds-space-negative-100, -8px)"
148
149
  }
149
150
  }));
150
- }), !isResizing && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
151
+ }), !isResizing && isTableHovered && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
151
152
  style: {
152
153
  gridRow: gridRowPosition,
153
154
  gridColumn: '2',
@@ -13,7 +13,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
13
13
  import React, { Component } from 'react';
14
14
  import { browser } from '@atlaskit/editor-common/utils';
15
15
  import { hoverCell, hoverRows, selectRow } from '../../commands';
16
- import { getPluginState } from '../../pm-plugins/plugin-factory';
17
16
  import { TableCssClassName as ClassName } from '../../types';
18
17
  import { isSelectionUpdated } from '../../utils';
19
18
  import { CornerControls, DragCornerControls } from './CornerControls';
@@ -49,10 +48,12 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
49
48
  tableActive = _this$props.tableActive;
50
49
  var state = editorView.state,
51
50
  dispatch = editorView.dispatch;
52
- var _getPluginState = getPluginState(state),
53
- hoveredCell = _getPluginState.hoveredCell;
54
- if (tableActive && hoveredCell.rowIndex !== rowIndex) {
55
- hoverCell(rowIndex, hoveredCell.colIndex)(state, dispatch);
51
+ if (tableActive) {
52
+ // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
53
+ // of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
54
+ // also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
55
+ // current column index. We can just force it to 0.
56
+ hoverCell(rowIndex, 0)(state, dispatch);
56
57
  }
57
58
  });
58
59
  _this.state = {
@@ -124,8 +125,9 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
124
125
  ordering = _this$props2.ordering,
125
126
  headerRowHeight = _this$props2.headerRowHeight,
126
127
  stickyHeader = _this$props2.stickyHeader,
127
- hoveredCell = _this$props2.hoveredCell;
128
- 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;
128
+ hoveredCell = _this$props2.hoveredCell,
129
+ isTableHovered = _this$props2.isTableHovered;
130
+ 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;
129
131
  }
130
132
  }, {
131
133
  key: "componentWillUnmount",
@@ -151,7 +153,8 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
151
153
  hoveredRows = _this$props3.hoveredRows,
152
154
  stickyHeader = _this$props3.stickyHeader,
153
155
  isDragAndDropEnabled = _this$props3.isDragAndDropEnabled,
154
- hoveredCell = _this$props3.hoveredCell;
156
+ hoveredCell = _this$props3.hoveredCell,
157
+ isTableHovered = _this$props3.isTableHovered;
155
158
  if (!tableRef) {
156
159
  return null;
157
160
  }
@@ -185,6 +188,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
185
188
  tableRef: tableRef,
186
189
  tableNode: tableNode,
187
190
  hoveredCell: hoveredCell,
191
+ isTableHovered: isTableHovered,
188
192
  editorView: editorView,
189
193
  tableActive: tableActive,
190
194
  isInDanger: isInDanger,