@atlaskit/editor-plugin-table 5.3.27 → 5.3.28

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.3.28
4
+
5
+ ### Patch Changes
6
+
7
+ - [#43155](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43155) [`9c7cabf1b12`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9c7cabf1b12) - ED-20671:Fixed drag handle not visible when drag menu is open
8
+
3
9
  ## 5.3.27
4
10
 
5
11
  ### Patch Changes
@@ -15,8 +15,9 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
15
15
  var _tableMap = require("@atlaskit/editor-tables/table-map");
16
16
  var _utils2 = require("@atlaskit/editor-tables/utils");
17
17
  var _commands = require("./commands");
18
- var _pluginFactory = require("./pm-plugins/plugin-factory");
19
- var _pluginFactory2 = require("./pm-plugins/table-resizing/plugin-factory");
18
+ var _pluginFactory = require("./pm-plugins/drag-and-drop/plugin-factory");
19
+ var _pluginFactory2 = require("./pm-plugins/plugin-factory");
20
+ var _pluginFactory3 = require("./pm-plugins/table-resizing/plugin-factory");
20
21
  var _transforms = require("./transforms");
21
22
  var _types = require("./types");
22
23
  var _utils3 = require("./utils");
@@ -104,7 +105,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, m
104
105
  var state = view.state,
105
106
  dispatch = view.dispatch;
106
107
  var target = mouseEvent.target;
107
- var _getPluginState = (0, _pluginFactory.getPluginState)(state),
108
+ var _getPluginState = (0, _pluginFactory2.getPluginState)(state),
108
109
  insertColumnButtonIndex = _getPluginState.insertColumnButtonIndex,
109
110
  insertRowButtonIndex = _getPluginState.insertRowButtonIndex;
110
111
  if ((0, _utils3.isInsertRowButton)(target)) {
@@ -174,7 +175,7 @@ var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view
174
175
  }
175
176
  var state = view.state,
176
177
  dispatch = view.dispatch;
177
- var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
178
+ var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
178
179
  insertColumnButtonIndex = _getPluginState2.insertColumnButtonIndex,
179
180
  insertRowButtonIndex = _getPluginState2.insertRowButtonIndex,
180
181
  isDragAndDropEnabled = _getPluginState2.isDragAndDropEnabled;
@@ -183,7 +184,10 @@ var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view
183
184
  return true;
184
185
  }
185
186
  if (isDragAndDropEnabled) {
186
- (0, _commands.hoverCell)()(state, dispatch);
187
+ var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(state),
188
+ isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen;
189
+ // Only set hoveredCell colIndex and rowIndex to undefined if the drag menu is not open
190
+ !isDragMenuOpen && (0, _commands.hoverCell)()(state, dispatch);
187
191
  }
188
192
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && (0, _commands.hideInsertColumnOrRowButton)()(state, dispatch)) {
189
193
  return true;
@@ -198,7 +202,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
198
202
  if ((0, _utils3.isColumnControlsDecorations)(element) || (0, _utils3.isDragColumnFloatingInsertDot)(element)) {
199
203
  var state = view.state,
200
204
  dispatch = view.dispatch;
201
- var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
205
+ var _getPluginState3 = (0, _pluginFactory2.getPluginState)(state),
202
206
  insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex,
203
207
  isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled;
204
208
  var _getColumnOrRowIndex9 = (0, _utils3.getColumnOrRowIndex)(element),
@@ -213,7 +217,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
213
217
  if ((0, _utils3.isRowControlsButton)(element) || (0, _utils3.isDragRowFloatingInsertDot)(element)) {
214
218
  var _state3 = view.state,
215
219
  _dispatch4 = view.dispatch;
216
- var _getPluginState4 = (0, _pluginFactory.getPluginState)(_state3),
220
+ var _getPluginState4 = (0, _pluginFactory2.getPluginState)(_state3),
217
221
  insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
218
222
  var _getColumnOrRowIndex11 = (0, _utils3.getColumnOrRowIndex)(element),
219
223
  _getColumnOrRowIndex12 = (0, _slicedToArray2.default)(_getColumnOrRowIndex11, 2),
@@ -229,7 +233,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
229
233
  if (_positionColumn !== null) {
230
234
  var _state4 = view.state,
231
235
  _dispatch5 = view.dispatch;
232
- var _getPluginState5 = (0, _pluginFactory.getPluginState)(_state4),
236
+ var _getPluginState5 = (0, _pluginFactory2.getPluginState)(_state4),
233
237
  resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
234
238
  resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
235
239
  var tableCell = (0, _utils.closestElement)(element, 'td, th');
@@ -306,7 +310,7 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
306
310
  if (isTableSelected) {
307
311
  tr = (0, _utils2.removeTable)(tr);
308
312
  } else if (tr.selection.isRowSelection()) {
309
- var _getPluginState6 = (0, _pluginFactory.getPluginState)(newState),
313
+ var _getPluginState6 = (0, _pluginFactory2.getPluginState)(newState),
310
314
  isHeaderRowRequired = _getPluginState6.pluginConfig.isHeaderRowRequired;
311
315
  tr = (0, _transforms.deleteRows)(rect, isHeaderRowRequired)(tr);
312
316
  } else if (tr.selection.isColSelection()) {
@@ -321,7 +325,7 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
321
325
  var whenTableInFocus = exports.whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
322
326
  return function (view, mouseEvent) {
323
327
  var _getPluginState7, _getResizePluginState;
324
- if (!((_getPluginState7 = (0, _pluginFactory.getPluginState)(view.state)) !== null && _getPluginState7 !== void 0 && _getPluginState7.tableNode) || !!((_getResizePluginState = (0, _pluginFactory2.getPluginState)(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging)) {
328
+ if (!((_getPluginState7 = (0, _pluginFactory2.getPluginState)(view.state)) !== null && _getPluginState7 !== void 0 && _getPluginState7.tableNode) || !!((_getResizePluginState = (0, _pluginFactory3.getPluginState)(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging)) {
325
329
  return false;
326
330
  }
327
331
  return eventHandler(view, mouseEvent, elementContentRects);
@@ -330,14 +334,14 @@ var whenTableInFocus = exports.whenTableInFocus = function whenTableInFocus(even
330
334
  var trackCellLocation = function trackCellLocation(view, mouseEvent) {
331
335
  var target = mouseEvent.target;
332
336
  var maybeTableCell = (0, _utils.isElementInTableCell)(target);
333
- var tableRef = (0, _pluginFactory.getPluginState)(view.state).tableRef;
337
+ var tableRef = (0, _pluginFactory2.getPluginState)(view.state).tableRef;
334
338
  if (!maybeTableCell || !tableRef) {
335
339
  return;
336
340
  }
337
341
  var colIndex = maybeTableCell.cellIndex;
338
342
  var rowElement = (0, _utils.closestElement)(target, 'tr');
339
343
  var rowIndex = rowElement && rowElement.rowIndex;
340
- var _getPluginState8 = (0, _pluginFactory.getPluginState)(view.state),
344
+ var _getPluginState8 = (0, _pluginFactory2.getPluginState)(view.state),
341
345
  hoveredCell = _getPluginState8.hoveredCell;
342
346
  var colHeight = tableRef.offsetHeight;
343
347
  var colWidth = maybeTableCell.offsetWidth;
@@ -347,7 +351,7 @@ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
347
351
  };
348
352
  var withCellTracking = exports.withCellTracking = function withCellTracking(eventHandler, elementContentRects) {
349
353
  return function (view, mouseEvent) {
350
- if ((0, _pluginFactory.getPluginState)(view.state).isDragAndDropEnabled) {
354
+ if ((0, _pluginFactory2.getPluginState)(view.state).isDragAndDropEnabled) {
351
355
  trackCellLocation(view, mouseEvent);
352
356
  }
353
357
  return eventHandler(view, mouseEvent, elementContentRects);
@@ -5,6 +5,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
6
  import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
7
7
  import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
8
+ import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
8
9
  import { getPluginState } from './pm-plugins/plugin-factory';
9
10
  import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
10
11
  import { deleteColumns, deleteRows } from './transforms';
@@ -180,7 +181,11 @@ export const handleMouseLeave = (view, event) => {
180
181
  return true;
181
182
  }
182
183
  if (isDragAndDropEnabled) {
183
- hoverCell()(state, dispatch);
184
+ const {
185
+ isDragMenuOpen
186
+ } = getDragDropPluginState(state);
187
+ // Only set hoveredCell colIndex and rowIndex to undefined if the drag menu is not open
188
+ !isDragMenuOpen && hoverCell()(state, dispatch);
184
189
  }
185
190
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
186
191
  return true;
@@ -6,6 +6,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
7
7
  import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
8
8
  import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
9
+ import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
9
10
  import { getPluginState } from './pm-plugins/plugin-factory';
10
11
  import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
11
12
  import { deleteColumns, deleteRows } from './transforms';
@@ -174,7 +175,10 @@ export var handleMouseLeave = function handleMouseLeave(view, event) {
174
175
  return true;
175
176
  }
176
177
  if (isDragAndDropEnabled) {
177
- hoverCell()(state, dispatch);
178
+ var _getDragDropPluginSta = getDragDropPluginState(state),
179
+ isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen;
180
+ // Only set hoveredCell colIndex and rowIndex to undefined if the drag menu is not open
181
+ !isDragMenuOpen && hoverCell()(state, dispatch);
178
182
  }
179
183
  if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
180
184
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.3.27",
3
+ "version": "5.3.28",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -41,6 +41,7 @@ import {
41
41
  showInsertRowButton,
42
42
  showResizeHandleLine,
43
43
  } from './commands';
44
+ import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
44
45
  import { getPluginState } from './pm-plugins/plugin-factory';
45
46
  import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
46
47
  import { deleteColumns, deleteRows } from './transforms';
@@ -299,7 +300,9 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
299
300
  }
300
301
 
301
302
  if (isDragAndDropEnabled) {
302
- hoverCell()(state, dispatch);
303
+ const { isDragMenuOpen } = getDragDropPluginState(state);
304
+ // Only set hoveredCell colIndex and rowIndex to undefined if the drag menu is not open
305
+ !isDragMenuOpen && hoverCell()(state, dispatch);
303
306
  }
304
307
 
305
308
  if (