@atlaskit/editor-plugin-table 7.2.3 → 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 (49) hide show
  1. package/CHANGELOG.md +6 -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/keymap.js +1 -0
  8. package/dist/cjs/pm-plugins/main.js +43 -9
  9. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +37 -7
  10. package/dist/cjs/pm-plugins/table-resizing/plugin.js +20 -6
  11. package/dist/cjs/reducer.js +5 -2
  12. package/dist/es2019/commands/column-resize.js +100 -35
  13. package/dist/es2019/commands/go-to-next-cell.js +7 -9
  14. package/dist/es2019/commands/misc.js +3 -2
  15. package/dist/es2019/commands/selection.js +5 -5
  16. package/dist/es2019/event-handlers.js +17 -3
  17. package/dist/es2019/pm-plugins/keymap.js +3 -2
  18. package/dist/es2019/pm-plugins/main.js +41 -5
  19. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +37 -4
  20. package/dist/es2019/pm-plugins/table-resizing/plugin.js +16 -1
  21. package/dist/es2019/reducer.js +5 -2
  22. package/dist/esm/commands/column-resize.js +105 -35
  23. package/dist/esm/commands/go-to-next-cell.js +7 -11
  24. package/dist/esm/commands/misc.js +3 -2
  25. package/dist/esm/commands/selection.js +5 -5
  26. package/dist/esm/event-handlers.js +38 -25
  27. package/dist/esm/pm-plugins/keymap.js +3 -2
  28. package/dist/esm/pm-plugins/main.js +38 -4
  29. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +34 -4
  30. package/dist/esm/pm-plugins/table-resizing/plugin.js +15 -1
  31. package/dist/esm/reducer.js +5 -2
  32. package/dist/types/commands/column-resize.d.ts +2 -0
  33. package/dist/types/commands/misc.d.ts +1 -1
  34. package/dist/types/types.d.ts +16 -0
  35. package/dist/types-ts4.5/commands/column-resize.d.ts +2 -0
  36. package/dist/types-ts4.5/commands/misc.d.ts +1 -1
  37. package/dist/types-ts4.5/types.d.ts +16 -0
  38. package/package.json +2 -2
  39. package/src/commands/column-resize.ts +155 -40
  40. package/src/commands/go-to-next-cell.ts +6 -15
  41. package/src/commands/misc.ts +2 -0
  42. package/src/commands/selection.ts +5 -5
  43. package/src/event-handlers.ts +21 -4
  44. package/src/pm-plugins/keymap.ts +3 -0
  45. package/src/pm-plugins/main.ts +47 -2
  46. package/src/pm-plugins/table-resizing/event-handlers.ts +33 -5
  47. package/src/pm-plugins/table-resizing/plugin.ts +18 -1
  48. package/src/reducer.ts +5 -2
  49. package/src/types.ts +16 -0
@@ -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';
@@ -22,6 +24,9 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
22
24
  if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
23
25
  return false;
24
26
  }
27
+ const {
28
+ isKeyboardResize
29
+ } = getTablePluginState(state);
25
30
  event.preventDefault();
26
31
  const tr = view.state.tr;
27
32
  tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
@@ -96,6 +101,9 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
96
101
  dragging,
97
102
  resizeHandlePos
98
103
  } = getPluginState(state);
104
+ const {
105
+ isTableHovered
106
+ } = getTablePluginState(state);
99
107
  if (resizeHandlePos === null) {
100
108
  return stopResizing()(state, dispatch);
101
109
  }
@@ -108,9 +116,20 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
108
116
  const start = $cell.start(-1);
109
117
  const table = $cell.node(-1);
110
118
 
111
- // If we let go in the same place we started, dont need to do anything.
119
+ // If we let go in the same place we started, don't need to do anything.
112
120
  if (dragging && clientX === dragging.startX) {
113
- return stopResizing()(state, dispatch);
121
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
122
+ if (isKeyboardResize || !isTableHovered) {
123
+ /** if column resize had started via keyboard but continued by mouse
124
+ * or mouse pointer leaves the table but mouse button still pressed
125
+ */
126
+ return stopKeyboardColumnResizing()(state, dispatch, view);
127
+ } else {
128
+ return stopResizing()(state, dispatch);
129
+ }
130
+ } else {
131
+ return stopResizing()(state, dispatch);
132
+ }
114
133
  }
115
134
  let {
116
135
  tr
@@ -148,7 +167,18 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
148
167
  })(tr);
149
168
  }
150
169
  }
151
- return stopResizing(tr)(state, dispatch);
170
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
171
+ if (isKeyboardResize || !isTableHovered) {
172
+ /** if column resize had started via keyboard but continued by mouse
173
+ * or mouse pointer leaves the table but mouse button still pressed
174
+ */
175
+ return stopKeyboardColumnResizing(tr)(state, dispatch, view);
176
+ } else {
177
+ return stopResizing(tr)(state, dispatch);
178
+ }
179
+ } else {
180
+ return stopResizing(tr)(state, dispatch);
181
+ }
152
182
  }
153
183
  }
154
184
  function move(event) {
@@ -163,7 +193,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
163
193
  dragging,
164
194
  resizeHandlePos
165
195
  } = getPluginState(state);
166
- if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos))) {
196
+ const {
197
+ isTableHovered
198
+ } = getTablePluginState(state);
199
+ if (!which || !dragging || resizeHandlePos === null || !pointsAtCell(state.doc.resolve(resizeHandlePos)) || !isTableHovered && getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
167
200
  return finish(event);
168
201
  }
169
202
  const $cell = state.doc.resolve(resizeHandlePos);
@@ -1,6 +1,8 @@
1
1
  import classnames from 'classnames';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
4
  import { TableCssClassName as ClassName } from '../../types';
5
+ import { getPluginState as getTablePluginState } from '../plugin-factory';
4
6
  import { setResizeHandlePos } from './commands';
5
7
  import { handleMouseDown } from './event-handlers';
6
8
  import { createPluginState, getPluginState } from './plugin-factory';
@@ -38,7 +40,20 @@ export function createPlugin(dispatch, {
38
40
  const {
39
41
  dragging
40
42
  } = getPluginState(state);
41
- if (resizeHandlePos !== null && !dragging) {
43
+ let isColumnKeyboardResizeStarted = false;
44
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
45
+ /*
46
+ We need to start listening mouse events if column resize started from keyboard.
47
+ This will allow continue resizing via mouse
48
+ */
49
+ const {
50
+ isKeyboardResize
51
+ } = getTablePluginState(state);
52
+ if (isKeyboardResize) {
53
+ isColumnKeyboardResizeStarted = isKeyboardResize;
54
+ }
55
+ }
56
+ if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
42
57
  if (handleMouseDown(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI)) {
43
58
  const {
44
59
  state,
@@ -75,8 +75,9 @@ export default ((pluginState, action) => {
75
75
  resizeHandleColumnIndex: undefined,
76
76
  resizeHandleRowIndex: undefined
77
77
  };
78
+ case 'START_KEYBOARD_COLUMN_RESIZE':
78
79
  case 'ADD_RESIZE_HANDLE_DECORATIONS':
79
- if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip) {
80
+ if (action.data.resizeHandleColumnIndex === pluginState.resizeHandleColumnIndex && action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex && action.data.resizeHandleIncludeTooltip === pluginState.resizeHandleIncludeTooltip && action.data.isKeyboardResize === pluginState.isKeyboardResize) {
80
81
  return pluginState;
81
82
  }
82
83
  return {
@@ -99,6 +100,7 @@ export default ((pluginState, action) => {
99
100
  resizeHandleRowIndex: resizeHandleRowIndex !== null && resizeHandleRowIndex !== void 0 ? resizeHandleRowIndex : pluginState.resizeHandleRowIndex,
100
101
  resizeHandleIncludeTooltip: resizeHandleIncludeTooltip !== null && resizeHandleIncludeTooltip !== void 0 ? resizeHandleIncludeTooltip : pluginState.resizeHandleIncludeTooltip
101
102
  };
103
+ case 'STOP_KEYBOARD_COLUMN_RESIZE':
102
104
  case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
103
105
  if (!pluginState.isResizeHandleWidgetAdded) {
104
106
  return pluginState;
@@ -108,7 +110,8 @@ export default ((pluginState, action) => {
108
110
  ...action.data,
109
111
  resizeHandleColumnIndex: undefined,
110
112
  resizeHandleRowIndex: undefined,
111
- isResizeHandleWidgetAdded: false
113
+ isResizeHandleWidgetAdded: false,
114
+ isKeyboardResize: undefined
112
115
  };
113
116
  case 'SET_TABLE_REF':
114
117
  case 'HOVER_ROWS':
@@ -2,25 +2,61 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
2
  import { TableMap } from '@atlaskit/editor-tables';
3
3
  import { findCellClosestToPos, findCellRectClosestToPos, findTableClosestToPos, getSelectionRect, isSelectionType, nextCell } from '@atlaskit/editor-tables/utils';
4
4
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
+ import { getDecorations } from '../pm-plugins/decorations/plugin';
6
+ import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
7
+ import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
5
8
  import { getPluginState as getTableResizingPluginState, createCommand as tableResizingPluginCreateCommand } from '../pm-plugins/table-resizing/plugin-factory';
9
+ import { pluginKey as tableResizingPK } from '../pm-plugins/table-resizing/plugin-key';
6
10
  import { currentColWidth, getResizeState, getTableMaxWidth, resizeColumn, updateControls } from '../pm-plugins/table-resizing/utils';
7
11
  import { updateColumnWidths } from '../transforms';
8
- import { getSelectedColumnIndexes } from '../utils';
9
- import { addResizeHandleDecorations, showResizeHandleLine } from './index';
12
+ import { TableDecorations } from '../types';
13
+ import { createColumnLineResize, getSelectedColumnIndexes, updateDecorations } from '../utils';
14
+ var getTablePluginCommand = function getTablePluginCommand(actionPayload, originalTr) {
15
+ return createCommand(function () {
16
+ return actionPayload;
17
+ }, function (tr) {
18
+ return (originalTr || tr).setMeta('addToHistory', false);
19
+ });
20
+ };
10
21
  var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosition(rowIndex, columnIndex, nextResizeHandlePos) {
11
22
  return function (state, dispatch) {
12
- addResizeHandleDecorations(rowIndex, columnIndex, true)(state, dispatch);
13
- // Currently only 'right' position is used in showResizeHandleLine
14
- showResizeHandleLine({
15
- left: 0,
23
+ var customTr = state.tr;
24
+ var _getPluginState = getPluginState(state),
25
+ allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
26
+ getIntl = _getPluginState.getIntl;
27
+ var fakeDispatch = function fakeDispatch(tr) {
28
+ customTr = tr;
29
+ };
30
+ if (!allowColumnResizing) {
31
+ return false;
32
+ }
33
+ var decorationsWithWidget = buildColumnResizingDecorations(rowIndex, columnIndex, true, getIntl)({
34
+ tr: customTr,
35
+ decorationSet: getDecorations(state)
36
+ });
37
+ var decorationsWithWidgetAndHandle = updateDecorations(customTr.doc, decorationsWithWidget, createColumnLineResize(state.selection, {
16
38
  right: columnIndex
17
- })(state, dispatch);
18
- tableResizingPluginCreateCommand({
39
+ }), TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
40
+ getTablePluginCommand({
41
+ type: 'START_KEYBOARD_COLUMN_RESIZE',
42
+ data: {
43
+ resizeHandleRowIndex: rowIndex,
44
+ resizeHandleColumnIndex: columnIndex,
45
+ resizeHandleIncludeTooltip: true,
46
+ isKeyboardResize: true,
47
+ decorationSet: decorationsWithWidgetAndHandle
48
+ }
49
+ }, customTr)(state, fakeDispatch);
50
+ customTr.setMeta(tableResizingPK, {
19
51
  type: 'SET_RESIZE_HANDLE_POSITION',
20
52
  data: {
21
53
  resizeHandlePos: nextResizeHandlePos
22
54
  }
23
- })(state, dispatch);
55
+ });
56
+ if (dispatch) {
57
+ dispatch(customTr);
58
+ return true;
59
+ }
24
60
  return false;
25
61
  };
26
62
  };
@@ -32,32 +68,19 @@ export var initiateKeyboardColumnResizing = function initiateKeyboardColumnResiz
32
68
  var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
33
69
  var cell = findCellClosestToPos(selection.$from);
34
70
  if (selectionRect && cell && view) {
35
- var cellAttrs = cell.node.attrs;
36
- var width = currentColWidth(view, cell.pos, cellAttrs);
37
- updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
38
- tableResizingPluginCreateCommand({
39
- type: 'SET_DRAGGING',
40
- data: {
41
- dragging: {
42
- startX: 0,
43
- startWidth: width
44
- }
45
- }
46
- })(state, dispatch);
47
- return true;
71
+ return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
48
72
  }
49
73
  return false;
50
74
  };
51
75
  export var activateNextResizeArea = function activateNextResizeArea(direction) {
52
- return function (state, dispatch) {
76
+ return function (state, dispatch, view) {
53
77
  if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
54
78
  return false;
55
79
  }
56
80
  var _ref = getTableResizingPluginState(state) || {},
57
- resizeHandlePos = _ref.resizeHandlePos,
58
- dragging = _ref.dragging;
81
+ resizeHandlePos = _ref.resizeHandlePos;
59
82
  // If No resizing has initiated, skip to regular handler
60
- if (!resizeHandlePos || !dragging) {
83
+ if (!resizeHandlePos) {
61
84
  return false;
62
85
  }
63
86
  var selection = state.selection;
@@ -82,31 +105,35 @@ export var activateNextResizeArea = function activateNextResizeArea(direction) {
82
105
  // we are somewhere in between the side columns of the table
83
106
  var offset = $nextCell.pos - $nextCell.start(-1);
84
107
  var rectForNextCell = tableMap.findCell(offset);
85
- updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch);
108
+ return updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch, view);
86
109
  } else {
87
110
  // current position is in the one of the side columns of the table(left or right)
88
111
  if (currentCellRect.left === 0) {
89
112
  var lastCellInCurrentRow = tableMap.positionAt(currentCellRect.top, tableMap.width - 1, tableNode) + closestTable.start;
90
113
  var $lastCell = state.doc.resolve(lastCellInCurrentRow);
91
- updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch);
114
+ return updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch, view);
92
115
  } else if (tableMap.width === currentCellRect.right) {
93
116
  var firsCellInCurrentRow = tableMap.positionAt(currentCellRect.top, 0, tableNode) + closestTable.start;
94
117
  var _$nextCell = state.doc.resolve(firsCellInCurrentRow);
95
- updateResizeHandleAndStatePosition(currentCellRect.top, 1, _$nextCell.pos)(state, dispatch);
118
+ return updateResizeHandleAndStatePosition(currentCellRect.top, 1, _$nextCell.pos)(state, dispatch);
96
119
  }
97
120
  }
98
- return true;
121
+ return false;
99
122
  };
100
123
  };
101
124
  export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize, getEditorContainerWidth) {
102
125
  return function (state, dispatch, view) {
126
+ var customTr = state.tr;
127
+ var fakeDispatch = function fakeDispatch(tr) {
128
+ customTr = tr;
129
+ };
103
130
  if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
104
131
  return false;
105
132
  }
106
133
  var _getTableResizingPlug = getTableResizingPluginState(state),
107
- resizeHandlePos = _getTableResizingPlug.resizeHandlePos,
108
- dragging = _getTableResizingPlug.dragging;
109
- if (!view || !resizeHandlePos || !dragging) {
134
+ resizeHandlePos = _getTableResizingPlug.resizeHandlePos;
135
+ var cell = findCellClosestToPos(state.selection.$from);
136
+ if (!view || !resizeHandlePos || !cell) {
110
137
  return false;
111
138
  }
112
139
  var $cell = state.doc.resolve(resizeHandlePos);
@@ -119,6 +146,17 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize,
119
146
  if (dom && dom.nodeName !== 'TABLE') {
120
147
  dom = dom.closest('table');
121
148
  }
149
+ var cellAttrs = cell === null || cell === void 0 ? void 0 : cell.node.attrs;
150
+ var width = currentColWidth(view, cell === null || cell === void 0 ? void 0 : cell.pos, cellAttrs);
151
+ tableResizingPluginCreateCommand({
152
+ type: 'SET_DRAGGING',
153
+ data: {
154
+ dragging: {
155
+ startX: 0,
156
+ startWidth: width
157
+ }
158
+ }
159
+ })(state, fakeDispatch);
122
160
  var maxSize = getTableMaxWidth({
123
161
  table: originalTable,
124
162
  tableStart: tableStartPosition,
@@ -140,10 +178,42 @@ export var changeColumnWidthByStep = function changeColumnWidthByStep(stepSize,
140
178
  // only selected (or selected - 1) columns should be distributed
141
179
  var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
142
180
  var newResizeState = resizeColumn(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
143
- var tr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(state.tr);
181
+ customTr = updateColumnWidths(newResizeState, originalTable, tableStartPosition)(customTr);
144
182
  if (dispatch) {
145
- dispatch(tr);
183
+ dispatch(customTr);
146
184
  }
147
185
  return true;
148
186
  };
187
+ };
188
+ export var stopKeyboardColumnResizing = function stopKeyboardColumnResizing(originalTr) {
189
+ return function (state, dispatch) {
190
+ if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
191
+ return false;
192
+ }
193
+ var customTr = originalTr || state.tr;
194
+ var fakeDispatch = function fakeDispatch(tr) {
195
+ customTr = tr;
196
+ };
197
+ var decorationWithoutWidget = clearColumnResizingDecorations()({
198
+ tr: customTr,
199
+ decorationSet: getDecorations(state)
200
+ });
201
+ var decorationWithoutWidgetAndHandle = updateDecorations(customTr.doc, decorationWithoutWidget, [], TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
202
+ getTablePluginCommand({
203
+ type: 'STOP_KEYBOARD_COLUMN_RESIZE',
204
+ data: {
205
+ decorationSet: decorationWithoutWidgetAndHandle
206
+ }
207
+ }, customTr)(state, fakeDispatch);
208
+ tableResizingPluginCreateCommand({
209
+ type: 'STOP_RESIZING'
210
+ }, function () {
211
+ return customTr.setMeta('scrollIntoView', false);
212
+ })(state, fakeDispatch);
213
+ if (dispatch) {
214
+ dispatch(customTr);
215
+ return true;
216
+ }
217
+ return false;
218
+ };
149
219
  };
@@ -6,27 +6,23 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
6
6
  import { goToNextCell as baseGotoNextCell, findTable } from '@atlaskit/editor-tables/utils';
7
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
8
  import { insertRowWithAnalytics } from '../commands-with-analytics';
9
- import { getPluginState as getResizePluginState, createCommand as tableResizingPluginCreateCommand } from '../pm-plugins/table-resizing/plugin-factory';
10
- import { hideResizeHandleLine } from './hover';
9
+ import { getPluginState } from '../pm-plugins/plugin-factory';
10
+ import { stopKeyboardColumnResizing } from './column-resize';
11
11
  var TAB_FORWARD_DIRECTION = 1;
12
12
  var TAB_BACKWARD_DIRECTION = -1;
13
13
  export var goToNextCell = function goToNextCell(editorAnalyticsAPI) {
14
14
  return function (direction) {
15
- return function (state, dispatch) {
15
+ return function (state, dispatch, view) {
16
16
  var table = findTable(state.selection);
17
17
  if (!table) {
18
18
  return false;
19
19
  }
20
20
  if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
21
- var _getResizePluginState;
22
- var isColumnResizing = !!((_getResizePluginState = getResizePluginState(state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
21
+ var _getPluginState;
22
+ var isColumnResizing = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.isKeyboardResize;
23
23
  if (isColumnResizing) {
24
- tableResizingPluginCreateCommand({
25
- type: 'STOP_RESIZING'
26
- }, function (originalTr) {
27
- return (state.tr || originalTr).setMeta('scrollIntoView', false);
28
- })(state, dispatch);
29
- hideResizeHandleLine()(state, dispatch);
24
+ stopKeyboardColumnResizing()(state, dispatch, view);
25
+ return true;
30
26
  }
31
27
  }
32
28
  var map = TableMap.get(table.node);
@@ -447,7 +447,7 @@ export var hideInsertColumnOrRowButton = function hideInsertColumnOrRowButton()
447
447
  return tr.setMeta('addToHistory', false);
448
448
  });
449
449
  };
450
- export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
450
+ export var addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip, isKeyboardResize) {
451
451
  return createCommand(function (state) {
452
452
  var tableNode = findTable(state.selection);
453
453
  var _getPluginState2 = getPluginState(state),
@@ -465,7 +465,8 @@ export var addResizeHandleDecorations = function addResizeHandleDecorations(rowI
465
465
  }),
466
466
  resizeHandleRowIndex: rowIndex,
467
467
  resizeHandleColumnIndex: columnIndex,
468
- resizeHandleIncludeTooltip: includeTooltip
468
+ resizeHandleIncludeTooltip: includeTooltip,
469
+ isKeyboardResize: isKeyboardResize || false
469
470
  }
470
471
  };
471
472
  }, function (tr) {
@@ -5,7 +5,7 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
5
5
  import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
6
6
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
7
  import { selectColumn, selectRow } from '../commands/misc';
8
- import { getPluginState as getResizePluginState } from '../pm-plugins/table-resizing/plugin-factory';
8
+ import { getPluginState } from '../pm-plugins/plugin-factory';
9
9
  import { getClosestSelectionRect } from '../toolbar';
10
10
  export var TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
11
11
  TableSelectionDirection["TopToBottom"] = "TopToBottom";
@@ -196,8 +196,8 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
196
196
  var $from = selection.$from;
197
197
  var isColumnResizing = false;
198
198
  if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
199
- var columResizePluginState = getResizePluginState(state) || {};
200
- isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
199
+ var columResizePluginState = getPluginState(state) || {};
200
+ isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
201
201
  }
202
202
  if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
203
203
  // + 3 for: row, cell & paragraph nodes
@@ -230,8 +230,8 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
230
230
  var $to = selection.$to;
231
231
  var isColumnResizing = false;
232
232
  if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
233
- var columResizePluginState = getResizePluginState(state) || {};
234
- isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
233
+ var columResizePluginState = getPluginState(state) || {};
234
+ isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
235
235
  }
236
236
  if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
237
237
  // + 3 for: row, cell & paragraph nodes
@@ -5,6 +5,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  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
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, setTableHovered, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
9
10
  import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
10
11
  import { getPluginState } from './pm-plugins/plugin-factory';
@@ -163,15 +164,25 @@ export var handleMouseOut = function handleMouseOut(view, mouseEvent) {
163
164
  if (isResizeHandleDecoration(target) && !isResizeHandleDecoration(relatedTarget)) {
164
165
  var _state2 = view.state,
165
166
  _dispatch3 = view.dispatch;
166
- return hideResizeHandleLine()(_state2, _dispatch3);
167
+ if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
168
+ var _getPluginState2 = getPluginState(_state2),
169
+ isKeyboardResize = _getPluginState2.isKeyboardResize;
170
+ if (isKeyboardResize) {
171
+ // no need to hide decoration if column resizing started by keyboard
172
+ return false;
173
+ }
174
+ return hideResizeHandleLine()(_state2, _dispatch3);
175
+ } else {
176
+ return hideResizeHandleLine()(_state2, _dispatch3);
177
+ }
167
178
  }
168
179
  return false;
169
180
  };
170
181
  export var handleMouseEnter = function handleMouseEnter(view, mouseEvent) {
171
182
  var state = view.state,
172
183
  dispatch = view.dispatch;
173
- var _getPluginState2 = getPluginState(state),
174
- isTableHovered = _getPluginState2.isTableHovered;
184
+ var _getPluginState3 = getPluginState(state),
185
+ isTableHovered = _getPluginState3.isTableHovered;
175
186
  if (!isTableHovered) {
176
187
  return setTableHovered(true)(state, dispatch);
177
188
  }
@@ -183,11 +194,11 @@ export var handleMouseLeave = function handleMouseLeave(view, event) {
183
194
  }
184
195
  var state = view.state,
185
196
  dispatch = view.dispatch;
186
- var _getPluginState3 = getPluginState(state),
187
- insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex,
188
- insertRowButtonIndex = _getPluginState3.insertRowButtonIndex,
189
- isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled,
190
- isTableHovered = _getPluginState3.isTableHovered;
197
+ var _getPluginState4 = getPluginState(state),
198
+ insertColumnButtonIndex = _getPluginState4.insertColumnButtonIndex,
199
+ insertRowButtonIndex = _getPluginState4.insertRowButtonIndex,
200
+ isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled,
201
+ isTableHovered = _getPluginState4.isTableHovered;
191
202
  if (isTableHovered) {
192
203
  if (isDragAndDropEnabled) {
193
204
  var _getDragDropPluginSta = getDragDropPluginState(state),
@@ -220,9 +231,9 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
220
231
  if (isColumnControlsDecorations(element) || isDragColumnFloatingInsertDot(element)) {
221
232
  var state = view.state,
222
233
  dispatch = view.dispatch;
223
- var _getPluginState4 = getPluginState(state),
224
- insertColumnButtonIndex = _getPluginState4.insertColumnButtonIndex,
225
- isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
234
+ var _getPluginState5 = getPluginState(state),
235
+ insertColumnButtonIndex = _getPluginState5.insertColumnButtonIndex,
236
+ isDragAndDropEnabled = _getPluginState5.isDragAndDropEnabled;
226
237
  var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
227
238
  _getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
228
239
  startIndex = _getColumnOrRowIndex10[0],
@@ -235,8 +246,8 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
235
246
  if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
236
247
  var _state3 = view.state,
237
248
  _dispatch4 = view.dispatch;
238
- var _getPluginState5 = getPluginState(_state3),
239
- insertRowButtonIndex = _getPluginState5.insertRowButtonIndex;
249
+ var _getPluginState6 = getPluginState(_state3),
250
+ insertRowButtonIndex = _getPluginState6.insertRowButtonIndex;
240
251
  var _getColumnOrRowIndex11 = getColumnOrRowIndex(element),
241
252
  _getColumnOrRowIndex12 = _slicedToArray(_getColumnOrRowIndex11, 2),
242
253
  _startIndex3 = _getColumnOrRowIndex12[0],
@@ -251,19 +262,21 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
251
262
  if (_positionColumn !== null) {
252
263
  var _state4 = view.state,
253
264
  _dispatch5 = view.dispatch;
254
- var _getPluginState6 = getPluginState(_state4),
255
- resizeHandleColumnIndex = _getPluginState6.resizeHandleColumnIndex,
256
- resizeHandleRowIndex = _getPluginState6.resizeHandleRowIndex;
265
+ var _getPluginState7 = getPluginState(_state4),
266
+ resizeHandleColumnIndex = _getPluginState7.resizeHandleColumnIndex,
267
+ resizeHandleRowIndex = _getPluginState7.resizeHandleRowIndex;
268
+ var isKeyboardResize = getBooleanFF('platform.editor.a11y-column-resizing_emcvz') ? getPluginState(_state4).isKeyboardResize : false;
257
269
  var tableCell = closestElement(element, 'td, th');
258
270
  var cellStartPosition = view.posAtDOM(tableCell, 0);
259
271
  var rect = findCellRectClosestToPos(_state4.doc.resolve(cellStartPosition));
260
272
  if (rect) {
261
273
  var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
262
274
  var rowIndexTarget = rect.top;
263
- if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
275
+ if ((columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
264
276
  target: element,
265
277
  columnEndIndexTarget: columnEndIndexTarget
266
- })) {
278
+ })) && !isKeyboardResize // if initiated by keyboard don't need to react on hover for other resize sliders
279
+ ) {
267
280
  return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget, true)(_state4, _dispatch5);
268
281
  }
269
282
  }
@@ -328,8 +341,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
328
341
  if (isTableSelected) {
329
342
  tr = removeTable(tr);
330
343
  } else if (tr.selection.isRowSelection()) {
331
- var _getPluginState7 = getPluginState(newState),
332
- isHeaderRowRequired = _getPluginState7.pluginConfig.isHeaderRowRequired;
344
+ var _getPluginState8 = getPluginState(newState),
345
+ isHeaderRowRequired = _getPluginState8.pluginConfig.isHeaderRowRequired;
333
346
  tr = deleteRows(rect, isHeaderRowRequired)(tr);
334
347
  } else if (tr.selection.isColSelection()) {
335
348
  tr = deleteColumns(rect, getAllowAddColumnCustomStep(oldState), editorView)(tr);
@@ -341,8 +354,8 @@ export var handleCut = function handleCut(oldTr, oldState, newState, editorAnaly
341
354
  return tr;
342
355
  };
343
356
  export var isTableInFocus = function isTableInFocus(view) {
344
- var _getPluginState8, _getResizePluginState;
345
- return !!((_getPluginState8 = getPluginState(view.state)) !== null && _getPluginState8 !== void 0 && _getPluginState8.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
357
+ var _getPluginState9, _getResizePluginState;
358
+ return !!((_getPluginState9 = getPluginState(view.state)) !== null && _getPluginState9 !== void 0 && _getPluginState9.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
346
359
  };
347
360
  export var whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
348
361
  return function (view, mouseEvent) {
@@ -356,9 +369,9 @@ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
356
369
  var _tableElement$dataset;
357
370
  var target = mouseEvent.target;
358
371
  var maybeTableCell = isElementInTableCell(target);
359
- var _getPluginState9 = getPluginState(view.state),
360
- tableNode = _getPluginState9.tableNode,
361
- tableRef = _getPluginState9.tableRef;
372
+ var _getPluginState10 = getPluginState(view.state),
373
+ tableNode = _getPluginState10.tableNode,
374
+ tableRef = _getPluginState10.tableRef;
362
375
  var tableElement = closestElement(target, 'table');
363
376
 
364
377
  // hover will only trigger if target localId is the same with selected localId
@@ -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
  }