@atlaskit/editor-plugin-table 7.2.2 → 7.3.0

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 (149) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/commands/column-resize.js +115 -45
  3. package/dist/cjs/commands/go-to-next-cell.js +7 -11
  4. package/dist/cjs/commands/misc.js +3 -2
  5. package/dist/cjs/commands/selection.js +3 -3
  6. package/dist/cjs/event-handlers.js +38 -25
  7. package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -19
  8. package/dist/cjs/pm-plugins/keymap.js +1 -0
  9. package/dist/cjs/pm-plugins/main.js +43 -9
  10. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +37 -7
  11. package/dist/cjs/pm-plugins/table-resizing/plugin.js +20 -6
  12. package/dist/cjs/reducer.js +5 -2
  13. package/dist/cjs/utils/drag-menu.js +37 -23
  14. package/dist/cjs/utils/merged-cells.js +66 -1
  15. package/dist/es2019/commands/column-resize.js +100 -35
  16. package/dist/es2019/commands/go-to-next-cell.js +7 -9
  17. package/dist/es2019/commands/misc.js +3 -2
  18. package/dist/es2019/commands/selection.js +5 -5
  19. package/dist/es2019/event-handlers.js +17 -3
  20. package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
  21. package/dist/es2019/pm-plugins/keymap.js +3 -2
  22. package/dist/es2019/pm-plugins/main.js +41 -5
  23. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +37 -4
  24. package/dist/es2019/pm-plugins/table-resizing/plugin.js +16 -1
  25. package/dist/es2019/reducer.js +5 -2
  26. package/dist/es2019/utils/drag-menu.js +38 -14
  27. package/dist/es2019/utils/merged-cells.js +73 -0
  28. package/dist/esm/commands/column-resize.js +105 -35
  29. package/dist/esm/commands/go-to-next-cell.js +7 -11
  30. package/dist/esm/commands/misc.js +3 -2
  31. package/dist/esm/commands/selection.js +5 -5
  32. package/dist/esm/event-handlers.js +38 -25
  33. package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
  34. package/dist/esm/pm-plugins/keymap.js +3 -2
  35. package/dist/esm/pm-plugins/main.js +38 -4
  36. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +34 -4
  37. package/dist/esm/pm-plugins/table-resizing/plugin.js +15 -1
  38. package/dist/esm/reducer.js +5 -2
  39. package/dist/esm/utils/drag-menu.js +36 -22
  40. package/dist/esm/utils/merged-cells.js +65 -0
  41. package/dist/types/commands/column-resize.d.ts +2 -0
  42. package/dist/types/commands/misc.d.ts +1 -1
  43. package/dist/types/types.d.ts +16 -0
  44. package/dist/types/utils/drag-menu.d.ts +4 -1
  45. package/dist/types/utils/merged-cells.d.ts +2 -0
  46. package/dist/types-ts4.5/commands/column-resize.d.ts +2 -0
  47. package/dist/types-ts4.5/commands/misc.d.ts +1 -1
  48. package/dist/types-ts4.5/types.d.ts +16 -0
  49. package/dist/types-ts4.5/utils/drag-menu.d.ts +4 -1
  50. package/dist/types-ts4.5/utils/merged-cells.d.ts +2 -0
  51. package/package.json +10 -17
  52. package/src/commands/column-resize.ts +155 -40
  53. package/src/commands/go-to-next-cell.ts +6 -15
  54. package/src/commands/misc.ts +2 -0
  55. package/src/commands/selection.ts +5 -5
  56. package/src/event-handlers.ts +21 -4
  57. package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +11 -32
  58. package/src/pm-plugins/keymap.ts +3 -0
  59. package/src/pm-plugins/main.ts +47 -2
  60. package/src/pm-plugins/table-resizing/event-handlers.ts +33 -5
  61. package/src/pm-plugins/table-resizing/plugin.ts +18 -1
  62. package/src/reducer.ts +5 -2
  63. package/src/types.ts +16 -0
  64. package/src/utils/drag-menu.ts +94 -20
  65. package/src/utils/merged-cells.ts +78 -0
  66. package/tsconfig.dev.json +0 -69
  67. package/tsconfig.json +2 -877
  68. package/examples/99-testing.tsx +0 -140
  69. package/examples/config.jsonc +0 -14
  70. package/src/__tests__/unit/analytics.ts +0 -888
  71. package/src/__tests__/unit/collab.ts +0 -93
  72. package/src/__tests__/unit/commands/go-to-next-cell.ts +0 -173
  73. package/src/__tests__/unit/commands/insert.ts +0 -137
  74. package/src/__tests__/unit/commands/misc.ts +0 -185
  75. package/src/__tests__/unit/commands/sort.ts +0 -128
  76. package/src/__tests__/unit/commands.ts +0 -745
  77. package/src/__tests__/unit/copy-button.ts +0 -22
  78. package/src/__tests__/unit/copy-paste.ts +0 -677
  79. package/src/__tests__/unit/event-handlers/index.ts +0 -125
  80. package/src/__tests__/unit/event-handlers.ts +0 -296
  81. package/src/__tests__/unit/fix-tables.ts +0 -164
  82. package/src/__tests__/unit/get-toolbar-config.ts +0 -127
  83. package/src/__tests__/unit/handlers.ts +0 -98
  84. package/src/__tests__/unit/hover-selection.ts +0 -230
  85. package/src/__tests__/unit/index-with-fake-timers.ts +0 -111
  86. package/src/__tests__/unit/index.ts +0 -912
  87. package/src/__tests__/unit/layout.ts +0 -146
  88. package/src/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +0 -162
  89. package/src/__tests__/unit/nodeviews/TableComponent.tsx +0 -280
  90. package/src/__tests__/unit/nodeviews/TableContainer.tsx +0 -525
  91. package/src/__tests__/unit/nodeviews/cell.ts +0 -132
  92. package/src/__tests__/unit/nodeviews/table.ts +0 -129
  93. package/src/__tests__/unit/pm-plugins/analytics.ts +0 -327
  94. package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +0 -94
  95. package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +0 -176
  96. package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +0 -211
  97. package/src/__tests__/unit/pm-plugins/main.ts +0 -214
  98. package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -101
  99. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +0 -562
  100. package/src/__tests__/unit/pm-plugins/table-local-id.ts +0 -507
  101. package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +0 -269
  102. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +0 -192
  103. package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +0 -33
  104. package/src/__tests__/unit/pm-plugins/table-width.ts +0 -292
  105. package/src/__tests__/unit/sort-column.ts +0 -399
  106. package/src/__tests__/unit/toolbar.ts +0 -512
  107. package/src/__tests__/unit/transforms/delete-columns.ts +0 -597
  108. package/src/__tests__/unit/transforms/delete-rows.ts +0 -620
  109. package/src/__tests__/unit/transforms/merging.ts +0 -392
  110. package/src/__tests__/unit/ui/ContextualMenu.tsx +0 -71
  111. package/src/__tests__/unit/ui/CornerControls.tsx +0 -99
  112. package/src/__tests__/unit/ui/DeleteButton.tsx +0 -38
  113. package/src/__tests__/unit/ui/FixedButton.tsx +0 -217
  114. package/src/__tests__/unit/ui/FloatingContextualButton.tsx +0 -123
  115. package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +0 -68
  116. package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +0 -178
  117. package/src/__tests__/unit/ui/FloatingDragMenu.tsx +0 -511
  118. package/src/__tests__/unit/ui/FloatingInsertButton.tsx +0 -322
  119. package/src/__tests__/unit/ui/NumberColumn.tsx +0 -146
  120. package/src/__tests__/unit/ui/RowControls.tsx +0 -294
  121. package/src/__tests__/unit/ui/RowDragControls.tsx +0 -129
  122. package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +0 -189
  123. package/src/__tests__/unit/ui/TableFloatingControls.tsx +0 -118
  124. package/src/__tests__/unit/undo-redo.ts +0 -220
  125. package/src/__tests__/unit/utils/analytics.ts +0 -98
  126. package/src/__tests__/unit/utils/collapse.ts +0 -57
  127. package/src/__tests__/unit/utils/column-controls.ts +0 -205
  128. package/src/__tests__/unit/utils/dom.ts +0 -180
  129. package/src/__tests__/unit/utils/merged-cells.ts +0 -156
  130. package/src/__tests__/unit/utils/nodes.ts +0 -79
  131. package/src/__tests__/unit/utils/row-controls.ts +0 -195
  132. package/src/__tests__/unit/utils/table.ts +0 -96
  133. package/src/__tests__/unit/utils.ts +0 -670
  134. package/src/__tests__/visual-regression/__fixtures__/sticky-header-with-horizontal-scroll.json +0 -5228
  135. package/src/__tests__/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -20272
  136. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -3
  137. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -3
  138. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -3
  139. package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -3
  140. package/src/__tests__/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -3
  141. package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -3
  142. package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -3
  143. package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -3
  144. package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-1-snap.png +0 -3
  145. package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +0 -3
  146. package/src/__tests__/visual-regression/cell-options-menu.ts +0 -101
  147. package/src/__tests__/visual-regression/copy-button.ts +0 -181
  148. package/src/__tests__/visual-regression/index.ts +0 -62
  149. package/src/__tests__/visual-regression/sticky-header.ts +0 -61
@@ -2,8 +2,9 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
3
3
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
4
  import { findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
5
- import { getSelectedColumnIndexes, getSelectedRowIndexes, getSelectedTableInfo, hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
5
+ import { getSelectedColumnIndexes, getSelectedRowIndexes, getSelectedTableInfo } from '../../utils';
6
6
  import { withEditorAnalyticsAPI } from '../../utils/analytics';
7
+ import { canMove, getTargetIndex } from '../../utils/drag-menu';
7
8
  import { clearDropTarget, moveSource } from './commands';
8
9
  export var clearDropTargetWithAnalytics = function clearDropTargetWithAnalytics(editorAnalyticsAPI) {
9
10
  return function (inputMethod, sourceType, sourceIndexes, status, tr) {
@@ -84,30 +85,13 @@ export var moveSourceWithAnalyticsViaShortcut = function moveSourceWithAnalytics
84
85
  if (selectedIndexes.length === 0) {
85
86
  return false;
86
87
  }
87
-
88
- // const sourceIndex = selectedIndexes[0];
89
- // we can move only by one row/column
90
- // 'direction' can only be 1 (for right or down) or -1 (for left or up)
91
- var targetIndex = Math[direction < 0 ? 'min' : 'max'].apply(Math, _toConsumableArray(selectedIndexes)) + direction;
92
-
93
- // We can move only if targetIndex is a positive number and is not higher than the total number of rows/columns.
94
88
  var _getSelectedTableInfo3 = getSelectedTableInfo(selection),
95
89
  totalRowCount = _getSelectedTableInfo3.totalRowCount,
96
90
  totalColumnCount = _getSelectedTableInfo3.totalColumnCount;
97
- var isValidTargetIndex = targetIndex < 0 ? false : isRow ? targetIndex <= totalRowCount - 1 : targetIndex <= totalColumnCount - 1;
98
- if (!isValidTargetIndex) {
99
- return false;
100
- }
101
-
102
- // We can move only if there are no merged cells in the source or target row/column
103
- var hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
104
- if (hasMergedCellsInSource) {
105
- return false;
106
- }
107
- var hasMergedCellsInTarget = isRow ? hasMergedCellsInRow(targetIndex)(selection) : hasMergedCellsInColumn(targetIndex)(selection);
108
- if (hasMergedCellsInTarget) {
91
+ if (!canMove(sourceType, direction, isRow ? totalRowCount : totalColumnCount, selection, selectionRect)) {
109
92
  return false;
110
93
  }
94
+ var targetIndex = getTargetIndex(selectedIndexes, direction);
111
95
  return moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
112
96
  };
113
97
  };
@@ -1,11 +1,11 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
2
+ import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
3
3
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
4
4
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
5
5
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
6
  import { createTable, goToNextCell, moveCursorBackward } from '../commands';
7
7
  import { addRowAroundSelection, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut, deleteTableIfSelectedWithAnalytics, emptyMultipleCellsWithAnalytics } from '../commands-with-analytics';
8
- import { activateNextResizeArea, changeColumnWidthByStep, initiateKeyboardColumnResizing } from '../commands/column-resize';
8
+ import { activateNextResizeArea, changeColumnWidthByStep, initiateKeyboardColumnResizing, stopKeyboardColumnResizing } from '../commands/column-resize';
9
9
  import { addColumnAfter as addColumnAfterCommand, addColumnBefore as addColumnBeforeCommand } from '../commands/insert';
10
10
  import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
11
11
  import { withEditorAnalyticsAPI } from '../utils/analytics';
@@ -50,6 +50,7 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
50
50
  bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
51
51
  bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStep(-10, getEditorContainerWidth), list);
52
52
  bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStep(10, getEditorContainerWidth), list);
53
+ bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing(), list);
53
54
  }
54
55
  return keymap(list);
55
56
  }
@@ -7,7 +7,11 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenExpand, transformSliceToRemoveOpenLayoutNodes, transformSliceToRemoveOpenMultiBodiedExtension } from '@atlaskit/editor-common/transforms';
8
8
  import { browser, closestElement } from '@atlaskit/editor-common/utils';
9
9
  import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
10
+ import { TableMap } from '@atlaskit/editor-tables';
11
+ import { findTable } from '@atlaskit/editor-tables/utils';
12
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
13
  import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
14
+ import { stopKeyboardColumnResizing } from '../commands/column-resize';
11
15
  import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
12
16
  import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
13
17
  import { createTableView } from '../nodeviews/table';
@@ -99,7 +103,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
99
103
  var domAtPos = editorView.domAtPos.bind(editorView);
100
104
  editorViewRef = editorView;
101
105
  return {
102
- update: function update(view) {
106
+ update: function update(view, prevState) {
103
107
  var state = view.state,
104
108
  dispatch = view.dispatch;
105
109
  var selection = state.selection;
@@ -110,6 +114,28 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
110
114
  if (parent) {
111
115
  tableRef = parent.querySelector('table') || undefined;
112
116
  }
117
+ var tableNode = findTable(state.selection);
118
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
119
+ // when cursor leaves the table we need to stop column resizing
120
+ var pluginPrevState = getPluginState(prevState);
121
+ var isStopKeyboardColumResizing = pluginPrevState.isResizeHandleWidgetAdded && pluginPrevState.isKeyboardResize;
122
+ if (isStopKeyboardColumResizing) {
123
+ var isTableNodesDifferent = (pluginPrevState === null || pluginPrevState === void 0 ? void 0 : pluginPrevState.tableNode) !== (tableNode === null || tableNode === void 0 ? void 0 : tableNode.node);
124
+ if (pluginPrevState !== null && pluginPrevState !== void 0 && pluginPrevState.tableNode && tableNode && isTableNodesDifferent) {
125
+ var oldRowsNumber = TableMap.get(pluginPrevState.tableNode).height;
126
+ var newRowsNumber = TableMap.get(tableNode.node).height;
127
+ if (oldRowsNumber !== newRowsNumber ||
128
+ // Add/delete row
129
+ tableNode.node.attrs.localId !== pluginPrevState.tableNode.attrs.localId) {
130
+ // Jump to another table
131
+ stopKeyboardColumnResizing()(state, dispatch);
132
+ }
133
+ } else if (!tableNode) {
134
+ // selection outside of table
135
+ stopKeyboardColumnResizing()(state, dispatch);
136
+ }
137
+ }
138
+ }
113
139
  }
114
140
  if (pluginState.tableRef !== tableRef) {
115
141
  setTableRef(tableRef)(state, dispatch);
@@ -206,9 +232,17 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
206
232
  var maybeTr = closestElement(domRef, 'tr');
207
233
  return maybeTr ? maybeTr.classList.contains('sticky') : false;
208
234
  },
209
- handleTextInput: function handleTextInput(_ref3, _from, _to, text) {
210
- var state = _ref3.state,
211
- dispatch = _ref3.dispatch;
235
+ handleTextInput: function handleTextInput(view, _from, _to, text) {
236
+ var state = view.state,
237
+ dispatch = view.dispatch;
238
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
239
+ var _getPluginState = getPluginState(state),
240
+ isKeyboardResize = _getPluginState.isKeyboardResize;
241
+ if (isKeyboardResize) {
242
+ stopKeyboardColumnResizing()(state, dispatch);
243
+ return false;
244
+ }
245
+ }
212
246
  var tr = replaceSelectedTable(state, text, INPUT_METHOD.KEYBOARD, editorAnalyticsAPI);
213
247
  if (tr.selectionSet) {
214
248
  dispatch(tr);
@@ -5,9 +5,11 @@ import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
6
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
7
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
+ import { stopKeyboardColumnResizing } from '../../commands/column-resize';
8
9
  import { updateResizeHandleDecorations } from '../../commands/misc';
9
10
  import { updateColumnWidths } from '../../transforms';
10
11
  import { getSelectedColumnIndexes } from '../../utils';
12
+ import { getPluginState as getTablePluginState } from '../plugin-factory';
11
13
  import { META_KEYS } from '../table-analytics';
12
14
  import { evenColumns, setDragging, stopResizing } from './commands';
13
15
  import { getPluginState } from './plugin-factory';
@@ -20,6 +22,8 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
20
22
  if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
21
23
  return false;
22
24
  }
25
+ var _getTablePluginState = getTablePluginState(state),
26
+ isKeyboardResize = _getTablePluginState.isKeyboardResize;
23
27
  event.preventDefault();
24
28
  var tr = view.state.tr;
25
29
  tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
@@ -89,6 +93,8 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
89
93
  var _getPluginState = getPluginState(state),
90
94
  dragging = _getPluginState.dragging,
91
95
  resizeHandlePos = _getPluginState.resizeHandlePos;
96
+ var _getTablePluginState2 = getTablePluginState(state),
97
+ isTableHovered = _getTablePluginState2.isTableHovered;
92
98
  if (resizeHandlePos === null) {
93
99
  return stopResizing()(state, dispatch);
94
100
  }
@@ -101,9 +107,20 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
101
107
  var start = $cell.start(-1);
102
108
  var table = $cell.node(-1);
103
109
 
104
- // If we let go in the same place we started, dont need to do anything.
110
+ // If we let go in the same place we started, don't need to do anything.
105
111
  if (dragging && clientX === dragging.startX) {
106
- return stopResizing()(state, dispatch);
112
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
113
+ if (isKeyboardResize || !isTableHovered) {
114
+ /** if column resize had started via keyboard but continued by mouse
115
+ * or mouse pointer leaves the table but mouse button still pressed
116
+ */
117
+ return stopKeyboardColumnResizing()(state, dispatch, view);
118
+ } else {
119
+ return stopResizing()(state, dispatch);
120
+ }
121
+ } else {
122
+ return stopResizing()(state, dispatch);
123
+ }
107
124
  }
108
125
  var tr = state.tr;
109
126
  if (dragging) {
@@ -137,7 +154,18 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
137
154
  })(tr);
138
155
  }
139
156
  }
140
- return stopResizing(tr)(state, dispatch);
157
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
158
+ if (isKeyboardResize || !isTableHovered) {
159
+ /** if column resize had started via keyboard but continued by mouse
160
+ * or mouse pointer leaves the table but mouse button still pressed
161
+ */
162
+ return stopKeyboardColumnResizing(tr)(state, dispatch, view);
163
+ } else {
164
+ return stopResizing(tr)(state, dispatch);
165
+ }
166
+ } else {
167
+ return stopResizing(tr)(state, dispatch);
168
+ }
141
169
  }
142
170
  }
143
171
  function move(event) {
@@ -147,7 +175,9 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
147
175
  var _getPluginState2 = getPluginState(state),
148
176
  dragging = _getPluginState2.dragging,
149
177
  resizeHandlePos = _getPluginState2.resizeHandlePos;
150
- if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos))) {
178
+ var _getTablePluginState3 = getTablePluginState(state),
179
+ isTableHovered = _getTablePluginState3.isTableHovered;
180
+ if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos)) || !isTableHovered && getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
151
181
  return finish(event);
152
182
  }
153
183
  var $cell = state.doc.resolve(resizeHandlePos);
@@ -1,7 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import classnames from 'classnames';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import { TableCssClassName as ClassName } from '../../types';
6
+ import { getPluginState as getTablePluginState } from '../plugin-factory';
5
7
  import { setResizeHandlePos } from './commands';
6
8
  import { handleMouseDown } from './event-handlers';
7
9
  import { createPluginState, getPluginState } from './plugin-factory';
@@ -34,7 +36,19 @@ export function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorF
34
36
  getPluginState(state).resizeHandlePos || getResizeCellPos(view, event);
35
37
  var _getPluginState = getPluginState(state),
36
38
  dragging = _getPluginState.dragging;
37
- if (resizeHandlePos !== null && !dragging) {
39
+ var isColumnKeyboardResizeStarted = false;
40
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
41
+ /*
42
+ We need to start listening mouse events if column resize started from keyboard.
43
+ This will allow continue resizing via mouse
44
+ */
45
+ var _getTablePluginState = getTablePluginState(state),
46
+ isKeyboardResize = _getTablePluginState.isKeyboardResize;
47
+ if (isKeyboardResize) {
48
+ isColumnKeyboardResizeStarted = isKeyboardResize;
49
+ }
50
+ }
51
+ if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
38
52
  if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI)) {
39
53
  var _state = view.state,
40
54
  _dispatch = view.dispatch;
@@ -57,8 +57,9 @@ export default (function (pluginState, action) {
57
57
  resizeHandleColumnIndex: undefined,
58
58
  resizeHandleRowIndex: undefined
59
59
  });
60
+ case 'START_KEYBOARD_COLUMN_RESIZE':
60
61
  case 'ADD_RESIZE_HANDLE_DECORATIONS':
61
- if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip) {
62
+ if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip && action.data.isKeyboardResize === pluginState.isKeyboardResize) {
62
63
  return pluginState;
63
64
  }
64
65
  return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
@@ -77,6 +78,7 @@ export default (function (pluginState, action) {
77
78
  resizeHandleRowIndex: resizeHandleRowIndex !== null && resizeHandleRowIndex !== void 0 ? resizeHandleRowIndex : pluginState.resizeHandleRowIndex,
78
79
  resizeHandleIncludeTooltip: resizeHandleIncludeTooltip !== null && resizeHandleIncludeTooltip !== void 0 ? resizeHandleIncludeTooltip : pluginState.resizeHandleIncludeTooltip
79
80
  });
81
+ case 'STOP_KEYBOARD_COLUMN_RESIZE':
80
82
  case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
81
83
  if (!pluginState.isResizeHandleWidgetAdded) {
82
84
  return pluginState;
@@ -84,7 +86,8 @@ export default (function (pluginState, action) {
84
86
  return _objectSpread(_objectSpread(_objectSpread({}, pluginState), action.data), {}, {
85
87
  resizeHandleColumnIndex: undefined,
86
88
  resizeHandleRowIndex: undefined,
87
- isResizeHandleWidgetAdded: false
89
+ isResizeHandleWidgetAdded: false,
90
+ isKeyboardResize: undefined
88
91
  });
89
92
  case 'SET_TABLE_REF':
90
93
  case 'HOVER_ROWS':
@@ -19,14 +19,36 @@ import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizi
19
19
  import { getClosestSelectionRect } from '../toolbar';
20
20
  import { deleteRows } from '../transforms';
21
21
  import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
22
+ import { hasMergedCellsInColumn, hasMergedCellsInRow, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
22
23
  import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
23
- var canDecrease = function canDecrease(index) {
24
- var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
25
- return index !== undefined && index > min;
24
+ export var getTargetIndex = function getTargetIndex(selectedIndexes, direction) {
25
+ return Math[direction < 0 ? 'min' : 'max'].apply(Math, _toConsumableArray(selectedIndexes)) + direction;
26
26
  };
27
- var canIncrease = function canIncrease(index) {
28
- var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
29
- return index !== undefined && index < max;
27
+ export var canMove = function canMove(sourceType, direction, totalItemsOfSourceTypeCount, selection, selectionRect) {
28
+ if (!selectionRect) {
29
+ return false;
30
+ }
31
+ var isRow = sourceType === 'table-row';
32
+ var selectedIndexes = isRow ? getSelectedRowIndexes(selectionRect) : getSelectedColumnIndexes(selectionRect);
33
+ var targetIndex = getTargetIndex(selectedIndexes, direction);
34
+ var isValidTargetIndex = targetIndex >= 0 && targetIndex < totalItemsOfSourceTypeCount;
35
+ if (!isValidTargetIndex) {
36
+ return false;
37
+ }
38
+
39
+ // We can't move column when target has merges with other columns
40
+ // We can't move row when target has merges with other rows
41
+ var hasMergedCellsInTarget = isRow ? hasMergedCellsWithRowNextToRowIndex(targetIndex, selection) : hasMergedCellsWithColumnNextToColumnIndex(targetIndex, selection);
42
+ if (hasMergedCellsInTarget) {
43
+ return false;
44
+ }
45
+
46
+ // Currently we can't move in any direction if there are merged cells in the source
47
+ var hasMergedCellsInSource = isRow ? hasMergedCellsInRow(selectedIndexes)(selection) : hasMergedCellsInColumn(selectedIndexes)(selection);
48
+ if (hasMergedCellsInSource) {
49
+ return false;
50
+ }
51
+ return true;
30
52
  };
31
53
  var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
32
54
  var rect = getClosestSelectionRect(state);
@@ -37,6 +59,7 @@ var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
37
59
  return false;
38
60
  };
39
61
  export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI) {
62
+ var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
40
63
  var addOptions = direction === 'row' ? [{
41
64
  label: 'above',
42
65
  offset: 0,
@@ -58,13 +81,12 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
58
81
  icon: AddColRightIcon,
59
82
  keymap: addColumnAfter
60
83
  }];
84
+ var selection = editorView.state.selection;
61
85
  var moveOptions = direction === 'row' ? [{
62
86
  label: 'up',
63
87
  icon: ArrowUpIcon,
64
88
  keymap: moveRowUp,
65
- canMove: function canMove(selectionRect) {
66
- return canDrag && canDecrease(selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.top);
67
- },
89
+ canMove: canDrag && canMove('table-row', -1, (_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0, selection, selectionRect),
68
90
  getOriginIndexes: getSelectedRowIndexes,
69
91
  getTargetIndex: function getTargetIndex(selectionRect) {
70
92
  return selectionRect.top - 1;
@@ -73,10 +95,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
73
95
  label: 'down',
74
96
  icon: ArrowDownIcon,
75
97
  keymap: moveRowDown,
76
- canMove: function canMove(selectionRect) {
77
- var _selectionRect$bottom, _tableMap$height;
78
- return canDrag && canIncrease(((_selectionRect$bottom = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.bottom) !== null && _selectionRect$bottom !== void 0 ? _selectionRect$bottom : 0) - 1, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
79
- },
98
+ canMove: canDrag && canMove('table-row', 1, (_tableMap$height2 = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height2 !== void 0 ? _tableMap$height2 : 0, selection, selectionRect),
80
99
  getOriginIndexes: getSelectedRowIndexes,
81
100
  getTargetIndex: function getTargetIndex(selectionRect) {
82
101
  return selectionRect.bottom;
@@ -85,9 +104,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
85
104
  label: 'left',
86
105
  icon: ArrowLeftIcon,
87
106
  keymap: moveColumnLeft,
88
- canMove: function canMove(selectionRect) {
89
- return canDrag && canDecrease(selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.left);
90
- },
107
+ canMove: canDrag && canMove('table-column', -1, (_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0, selection, selectionRect),
91
108
  getOriginIndexes: getSelectedColumnIndexes,
92
109
  getTargetIndex: function getTargetIndex(selectionRect) {
93
110
  return selectionRect.left - 1;
@@ -96,10 +113,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
96
113
  label: 'right',
97
114
  icon: ArrowRightIcon,
98
115
  keymap: moveColumnRight,
99
- canMove: function canMove(selectionRect) {
100
- var _selectionRect$right, _tableMap$width;
101
- return canDrag && canIncrease(((_selectionRect$right = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right) !== null && _selectionRect$right !== void 0 ? _selectionRect$right : 0) - 1, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
102
- },
116
+ canMove: canDrag && canMove('table-column', 1, (_tableMap$width2 = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width2 !== void 0 ? _tableMap$width2 : 0, selection, selectionRect),
103
117
  getOriginIndexes: getSelectedColumnIndexes,
104
118
  getTargetIndex: function getTargetIndex(selectionRect) {
105
119
  return selectionRect.right;
@@ -184,10 +198,10 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
184
198
  return {
185
199
  id: "move_".concat(direction, "_").concat(label),
186
200
  title: "Move ".concat(direction, " ").concat(label),
187
- disabled: !canMove(selectionRect),
201
+ disabled: !canMove,
188
202
  icon: icon,
189
203
  onClick: function onClick(state, dispatch) {
190
- if (canMove(selectionRect)) {
204
+ if (canMove) {
191
205
  requestAnimationFrame(function () {
192
206
  moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction), getOriginIndexes(selectionRect), getTargetIndex(selectionRect))(editorView.state, editorView.dispatch);
193
207
  });
@@ -130,4 +130,69 @@ export var hasMergedCellsInBetween = function hasMergedCellsInBetween(indexes, t
130
130
  return mergedCellsInRectArr[1].includes(cell);
131
131
  });
132
132
  };
133
+ };
134
+
135
+ // Checks if any cell in the column with colIndex is merged with a cell in a column to the left or to the right of it.
136
+ // colIndex is a logical index of the column. It starts at 0 and goes up to tableMap.width - 1.
137
+ export var hasMergedCellsWithColumnNextToColumnIndex = function hasMergedCellsWithColumnNextToColumnIndex(colIndex, selection) {
138
+ var table = findTable(selection);
139
+ if (!table) {
140
+ return false;
141
+ }
142
+ var tableMap = TableMap.get(table.node);
143
+ var width = tableMap.width;
144
+ if (width <= 1) {
145
+ return false;
146
+ }
147
+ if (colIndex < 0 || colIndex > width - 1) {
148
+ return false;
149
+ }
150
+ var map = tableMap.map;
151
+ // j is an index in the tableMap.map array. tableMap.map is a flat array.
152
+ // Each item of this array contains a number.
153
+ // The number represents the position of the corresponding cell in the tableMap. It exists for each cell.
154
+ // If there are merged cells, their positions will be represented by the same number.
155
+ var isFirstColumn = colIndex === 0;
156
+ var isLastColumn = colIndex === width - 1;
157
+ for (var j = colIndex; j < map.length; j += width) {
158
+ if (!isFirstColumn && map[j] === map[j - 1] ||
159
+ // compare with a cell in the column on the left
160
+ !isLastColumn && map[j] === map[j + 1] // compare with a cell in the column on the right
161
+ ) {
162
+ return true;
163
+ }
164
+ }
165
+ return false;
166
+ };
167
+
168
+ // Checks if any cell in the row with rowIndex is merged with a cell in a row above or below it.
169
+ export var hasMergedCellsWithRowNextToRowIndex = function hasMergedCellsWithRowNextToRowIndex(rowIndex, selection) {
170
+ var table = findTable(selection);
171
+ if (!table) {
172
+ return false;
173
+ }
174
+ var tableMap = TableMap.get(table.node);
175
+ var height = tableMap.height;
176
+ if (height <= 1) {
177
+ return false;
178
+ }
179
+ if (rowIndex < 0 || rowIndex > height - 1) {
180
+ return false;
181
+ }
182
+ var map = tableMap.map,
183
+ width = tableMap.width; // map is a flat array representing position of each cell in the table.
184
+ var indexOfFirstCellInTheRow = rowIndex * width;
185
+ var indexOfLastCellInTheRow = indexOfFirstCellInTheRow + width - 1;
186
+ var isFirstRow = rowIndex === 0;
187
+ var isLastRow = rowIndex === height - 1;
188
+ // j is an index of a cell in a row
189
+ for (var j = indexOfFirstCellInTheRow; j <= indexOfLastCellInTheRow; j++) {
190
+ if (!isFirstRow && map[j] === map[j - width] ||
191
+ // compare with a cell in the row above
192
+ !isLastRow && map[j] === map[j + width] // compare with a cell in the row below
193
+ ) {
194
+ return true;
195
+ }
196
+ }
197
+ return false;
133
198
  };
@@ -1,5 +1,7 @@
1
1
  import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { Direction } from '@atlaskit/editor-tables/types';
3
4
  export declare const initiateKeyboardColumnResizing: Command;
4
5
  export declare const activateNextResizeArea: (direction: Direction) => Command;
5
6
  export declare const changeColumnWidthByStep: (stepSize: number, getEditorContainerWidth: GetEditorContainerWidth) => Command;
7
+ export declare const stopKeyboardColumnResizing: (originalTr?: Transaction) => Command;
@@ -26,7 +26,7 @@ export declare const selectRows: (rowIndexes: number[]) => Command;
26
26
  export declare const showInsertColumnButton: (columnIndex: number) => Command;
27
27
  export declare const showInsertRowButton: (rowIndex: number) => Command;
28
28
  export declare const hideInsertColumnOrRowButton: () => Command;
29
- export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number, includeTooltip: boolean) => Command;
29
+ export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number, includeTooltip: boolean, isKeyboardResize?: boolean) => Command;
30
30
  export declare const updateResizeHandleDecorations: (rowIndex?: number, columnIndex?: number, includeTooltip?: boolean) => Command;
31
31
  export declare const removeResizeHandleDecorations: () => Command;
32
32
  export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTMLTableElement, basePos: number | undefined, opts: {
@@ -74,6 +74,7 @@ export interface TablePluginState {
74
74
  resizeHandleRowIndex?: number;
75
75
  resizeHandleColumnIndex?: number;
76
76
  resizeHandleIncludeTooltip?: boolean;
77
+ isKeyboardResize?: boolean;
77
78
  isTableCollapsed?: boolean;
78
79
  canCollapseTable?: boolean;
79
80
  getIntl: () => IntlShape;
@@ -134,6 +135,15 @@ export type TablePluginAction = {
134
135
  hoveredColumns: number[];
135
136
  isInDanger?: boolean;
136
137
  };
138
+ } | {
139
+ type: 'START_KEYBOARD_COLUMN_RESIZE';
140
+ data: {
141
+ decorationSet: DecorationSet;
142
+ resizeHandleRowIndex: number;
143
+ resizeHandleColumnIndex: number;
144
+ resizeHandleIncludeTooltip: boolean;
145
+ isKeyboardResize?: boolean;
146
+ };
137
147
  } | {
138
148
  type: 'ADD_RESIZE_HANDLE_DECORATIONS';
139
149
  data: {
@@ -141,6 +151,7 @@ export type TablePluginAction = {
141
151
  resizeHandleRowIndex: number;
142
152
  resizeHandleColumnIndex: number;
143
153
  resizeHandleIncludeTooltip: boolean;
154
+ isKeyboardResize?: boolean;
144
155
  };
145
156
  } | {
146
157
  type: 'UPDATE_RESIZE_HANDLE_DECORATIONS';
@@ -155,6 +166,11 @@ export type TablePluginAction = {
155
166
  data: {
156
167
  decorationSet: DecorationSet;
157
168
  };
169
+ } | {
170
+ type: 'STOP_KEYBOARD_COLUMN_RESIZE';
171
+ data: {
172
+ decorationSet: DecorationSet;
173
+ };
158
174
  } | {
159
175
  type: 'CLEAR_HOVER_SELECTION';
160
176
  data: {
@@ -1,9 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command, DropdownOptionT, GetEditorContainerWidth, IconProps } from '@atlaskit/editor-common/types';
4
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
6
  import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
6
- import type { TableDirection } from '../types';
7
+ import type { DraggableData, DraggableType, TableDirection } from '../types';
8
+ export declare const getTargetIndex: (selectedIndexes: number[], direction: DraggableData['direction']) => number;
9
+ export declare const canMove: (sourceType: DraggableType, direction: DraggableData['direction'], totalItemsOfSourceTypeCount: number, selection: Selection, selectionRect?: Rect) => boolean;
7
10
  export type DragMenuOptionIdType = 'add_row_above' | 'add_row_below' | 'add_column_left' | 'add_column_right' | 'distribute_columns' | 'clear_cells' | 'delete_row' | 'delete_column' | 'move_column_left' | 'move_column_right' | 'move_row_up' | 'move_row_down' | 'sort_column_asc' | 'sort_column_desc';
8
11
  export interface DragMenuConfig extends DropdownOptionT<Command> {
9
12
  id: DragMenuOptionIdType;
@@ -3,4 +3,6 @@ type MergeType = 'row' | 'column';
3
3
  export declare const hasMergedCellsInColumn: (columnIndexes: number | number[]) => (selection: Selection) => boolean;
4
4
  export declare const hasMergedCellsInRow: (rowIndexes: number | number[]) => (selection: Selection) => boolean;
5
5
  export declare const hasMergedCellsInBetween: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
6
+ export declare const hasMergedCellsWithColumnNextToColumnIndex: (colIndex: number, selection: Selection) => boolean;
7
+ export declare const hasMergedCellsWithRowNextToRowIndex: (rowIndex: number, selection: Selection) => boolean;
6
8
  export {};
@@ -1,5 +1,7 @@
1
1
  import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { Direction } from '@atlaskit/editor-tables/types';
3
4
  export declare const initiateKeyboardColumnResizing: Command;
4
5
  export declare const activateNextResizeArea: (direction: Direction) => Command;
5
6
  export declare const changeColumnWidthByStep: (stepSize: number, getEditorContainerWidth: GetEditorContainerWidth) => Command;
7
+ export declare const stopKeyboardColumnResizing: (originalTr?: Transaction) => Command;
@@ -26,7 +26,7 @@ export declare const selectRows: (rowIndexes: number[]) => Command;
26
26
  export declare const showInsertColumnButton: (columnIndex: number) => Command;
27
27
  export declare const showInsertRowButton: (rowIndex: number) => Command;
28
28
  export declare const hideInsertColumnOrRowButton: () => Command;
29
- export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number, includeTooltip: boolean) => Command;
29
+ export declare const addResizeHandleDecorations: (rowIndex: number, columnIndex: number, includeTooltip: boolean, isKeyboardResize?: boolean) => Command;
30
30
  export declare const updateResizeHandleDecorations: (rowIndex?: number, columnIndex?: number, includeTooltip?: boolean) => Command;
31
31
  export declare const removeResizeHandleDecorations: () => Command;
32
32
  export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTMLTableElement, basePos: number | undefined, opts: {
@@ -74,6 +74,7 @@ export interface TablePluginState {
74
74
  resizeHandleRowIndex?: number;
75
75
  resizeHandleColumnIndex?: number;
76
76
  resizeHandleIncludeTooltip?: boolean;
77
+ isKeyboardResize?: boolean;
77
78
  isTableCollapsed?: boolean;
78
79
  canCollapseTable?: boolean;
79
80
  getIntl: () => IntlShape;
@@ -134,6 +135,15 @@ export type TablePluginAction = {
134
135
  hoveredColumns: number[];
135
136
  isInDanger?: boolean;
136
137
  };
138
+ } | {
139
+ type: 'START_KEYBOARD_COLUMN_RESIZE';
140
+ data: {
141
+ decorationSet: DecorationSet;
142
+ resizeHandleRowIndex: number;
143
+ resizeHandleColumnIndex: number;
144
+ resizeHandleIncludeTooltip: boolean;
145
+ isKeyboardResize?: boolean;
146
+ };
137
147
  } | {
138
148
  type: 'ADD_RESIZE_HANDLE_DECORATIONS';
139
149
  data: {
@@ -141,6 +151,7 @@ export type TablePluginAction = {
141
151
  resizeHandleRowIndex: number;
142
152
  resizeHandleColumnIndex: number;
143
153
  resizeHandleIncludeTooltip: boolean;
154
+ isKeyboardResize?: boolean;
144
155
  };
145
156
  } | {
146
157
  type: 'UPDATE_RESIZE_HANDLE_DECORATIONS';
@@ -155,6 +166,11 @@ export type TablePluginAction = {
155
166
  data: {
156
167
  decorationSet: DecorationSet;
157
168
  };
169
+ } | {
170
+ type: 'STOP_KEYBOARD_COLUMN_RESIZE';
171
+ data: {
172
+ decorationSet: DecorationSet;
173
+ };
158
174
  } | {
159
175
  type: 'CLEAR_HOVER_SELECTION';
160
176
  data: {
@@ -1,9 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command, DropdownOptionT, GetEditorContainerWidth, IconProps } from '@atlaskit/editor-common/types';
4
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
6
  import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
6
- import type { TableDirection } from '../types';
7
+ import type { DraggableData, DraggableType, TableDirection } from '../types';
8
+ export declare const getTargetIndex: (selectedIndexes: number[], direction: DraggableData['direction']) => number;
9
+ export declare const canMove: (sourceType: DraggableType, direction: DraggableData['direction'], totalItemsOfSourceTypeCount: number, selection: Selection, selectionRect?: Rect) => boolean;
7
10
  export type DragMenuOptionIdType = 'add_row_above' | 'add_row_below' | 'add_column_left' | 'add_column_right' | 'distribute_columns' | 'clear_cells' | 'delete_row' | 'delete_column' | 'move_column_left' | 'move_column_right' | 'move_row_up' | 'move_row_down' | 'sort_column_asc' | 'sort_column_desc';
8
11
  export interface DragMenuConfig extends DropdownOptionT<Command> {
9
12
  id: DragMenuOptionIdType;
@@ -3,4 +3,6 @@ type MergeType = 'row' | 'column';
3
3
  export declare const hasMergedCellsInColumn: (columnIndexes: number | number[]) => (selection: Selection) => boolean;
4
4
  export declare const hasMergedCellsInRow: (rowIndexes: number | number[]) => (selection: Selection) => boolean;
5
5
  export declare const hasMergedCellsInBetween: (indexes: number[], type: MergeType) => (selection: Selection) => boolean;
6
+ export declare const hasMergedCellsWithColumnNextToColumnIndex: (colIndex: number, selection: Selection) => boolean;
7
+ export declare const hasMergedCellsWithRowNextToRowIndex: (rowIndex: number, selection: Selection) => boolean;
6
8
  export {};