@atlaskit/editor-plugin-table 7.2.3 → 7.3.1

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 (135) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/commands/column-resize.js +115 -45
  4. package/dist/cjs/commands/go-to-next-cell.js +7 -11
  5. package/dist/cjs/commands/misc.js +7 -4
  6. package/dist/cjs/commands/selection.js +7 -5
  7. package/dist/cjs/event-handlers.js +38 -25
  8. package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -1
  9. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +33 -1
  10. package/dist/cjs/pm-plugins/drag-and-drop/reducer.js +2 -1
  11. package/dist/cjs/pm-plugins/keymap.js +1 -0
  12. package/dist/cjs/pm-plugins/main.js +43 -9
  13. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +37 -7
  14. package/dist/cjs/pm-plugins/table-resizing/plugin.js +20 -6
  15. package/dist/cjs/pm-plugins/table-selection-keymap.js +2 -2
  16. package/dist/cjs/reducer.js +5 -2
  17. package/dist/cjs/ui/DragHandle/HandleIconComponent.js +1 -3
  18. package/dist/cjs/ui/DragHandle/index.js +22 -10
  19. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +75 -33
  20. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +123 -0
  21. package/dist/cjs/ui/FloatingDragMenu/index.js +2 -2
  22. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +24 -35
  23. package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
  24. package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +4 -0
  25. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +26 -33
  26. package/dist/cjs/ui/common-styles.js +1 -1
  27. package/dist/cjs/ui/consts.js +3 -2
  28. package/dist/es2019/commands/column-resize.js +100 -35
  29. package/dist/es2019/commands/go-to-next-cell.js +7 -9
  30. package/dist/es2019/commands/misc.js +7 -6
  31. package/dist/es2019/commands/selection.js +9 -9
  32. package/dist/es2019/event-handlers.js +17 -3
  33. package/dist/es2019/pm-plugins/drag-and-drop/commands.js +3 -3
  34. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +34 -1
  35. package/dist/es2019/pm-plugins/drag-and-drop/reducer.js +2 -1
  36. package/dist/es2019/pm-plugins/keymap.js +3 -2
  37. package/dist/es2019/pm-plugins/main.js +41 -5
  38. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +37 -4
  39. package/dist/es2019/pm-plugins/table-resizing/plugin.js +16 -1
  40. package/dist/es2019/pm-plugins/table-selection-keymap.js +2 -2
  41. package/dist/es2019/reducer.js +5 -2
  42. package/dist/es2019/ui/DragHandle/HandleIconComponent.js +1 -3
  43. package/dist/es2019/ui/DragHandle/index.js +25 -10
  44. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +72 -32
  45. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +109 -0
  46. package/dist/es2019/ui/FloatingDragMenu/index.js +2 -2
  47. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +24 -35
  48. package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
  49. package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +4 -0
  50. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +26 -33
  51. package/dist/es2019/ui/common-styles.js +11 -1
  52. package/dist/es2019/ui/consts.js +2 -1
  53. package/dist/esm/commands/column-resize.js +105 -35
  54. package/dist/esm/commands/go-to-next-cell.js +7 -11
  55. package/dist/esm/commands/misc.js +7 -4
  56. package/dist/esm/commands/selection.js +9 -7
  57. package/dist/esm/event-handlers.js +38 -25
  58. package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -2
  59. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +33 -1
  60. package/dist/esm/pm-plugins/drag-and-drop/reducer.js +2 -1
  61. package/dist/esm/pm-plugins/keymap.js +3 -2
  62. package/dist/esm/pm-plugins/main.js +38 -4
  63. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +34 -4
  64. package/dist/esm/pm-plugins/table-resizing/plugin.js +15 -1
  65. package/dist/esm/pm-plugins/table-selection-keymap.js +2 -2
  66. package/dist/esm/reducer.js +5 -2
  67. package/dist/esm/ui/DragHandle/HandleIconComponent.js +1 -3
  68. package/dist/esm/ui/DragHandle/index.js +21 -9
  69. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +74 -35
  70. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +116 -0
  71. package/dist/esm/ui/FloatingDragMenu/index.js +2 -2
  72. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +24 -35
  73. package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
  74. package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +4 -0
  75. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +26 -33
  76. package/dist/esm/ui/common-styles.js +1 -1
  77. package/dist/esm/ui/consts.js +2 -1
  78. package/dist/types/commands/column-resize.d.ts +2 -0
  79. package/dist/types/commands/misc.d.ts +3 -3
  80. package/dist/types/commands/selection.d.ts +2 -2
  81. package/dist/types/pm-plugins/drag-and-drop/actions.d.ts +1 -0
  82. package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +2 -1
  83. package/dist/types/pm-plugins/drag-and-drop/types.d.ts +2 -0
  84. package/dist/types/types.d.ts +16 -0
  85. package/dist/types/ui/DragHandle/HandleIconComponent.d.ts +1 -2
  86. package/dist/types/ui/DragHandle/index.d.ts +3 -2
  87. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +7 -8
  88. package/dist/types/ui/FloatingDragMenu/DropdownMenu.d.ts +30 -0
  89. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
  90. package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  91. package/dist/types/ui/consts.d.ts +1 -0
  92. package/dist/types-ts4.5/commands/column-resize.d.ts +2 -0
  93. package/dist/types-ts4.5/commands/misc.d.ts +3 -3
  94. package/dist/types-ts4.5/commands/selection.d.ts +2 -2
  95. package/dist/types-ts4.5/pm-plugins/drag-and-drop/actions.d.ts +1 -0
  96. package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +2 -1
  97. package/dist/types-ts4.5/pm-plugins/drag-and-drop/types.d.ts +2 -0
  98. package/dist/types-ts4.5/types.d.ts +16 -0
  99. package/dist/types-ts4.5/ui/DragHandle/HandleIconComponent.d.ts +1 -2
  100. package/dist/types-ts4.5/ui/DragHandle/index.d.ts +3 -2
  101. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +7 -8
  102. package/dist/types-ts4.5/ui/FloatingDragMenu/DropdownMenu.d.ts +30 -0
  103. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
  104. package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  105. package/dist/types-ts4.5/ui/consts.d.ts +1 -0
  106. package/package.json +4 -3
  107. package/src/commands/column-resize.ts +155 -40
  108. package/src/commands/go-to-next-cell.ts +6 -15
  109. package/src/commands/misc.ts +19 -4
  110. package/src/commands/selection.ts +17 -9
  111. package/src/event-handlers.ts +21 -4
  112. package/src/pm-plugins/drag-and-drop/actions.ts +1 -0
  113. package/src/pm-plugins/drag-and-drop/commands.ts +3 -0
  114. package/src/pm-plugins/drag-and-drop/plugin.ts +47 -0
  115. package/src/pm-plugins/drag-and-drop/reducer.ts +1 -0
  116. package/src/pm-plugins/drag-and-drop/types.ts +3 -0
  117. package/src/pm-plugins/keymap.ts +3 -0
  118. package/src/pm-plugins/main.ts +47 -2
  119. package/src/pm-plugins/table-resizing/event-handlers.ts +33 -5
  120. package/src/pm-plugins/table-resizing/plugin.ts +18 -1
  121. package/src/pm-plugins/table-selection-keymap.ts +2 -2
  122. package/src/reducer.ts +5 -2
  123. package/src/types.ts +16 -0
  124. package/src/ui/DragHandle/HandleIconComponent.tsx +2 -9
  125. package/src/ui/DragHandle/index.tsx +37 -16
  126. package/src/ui/FloatingDragMenu/DragMenu.tsx +362 -310
  127. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +150 -0
  128. package/src/ui/FloatingDragMenu/index.tsx +3 -3
  129. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +72 -91
  130. package/src/ui/TableFloatingColumnControls/index.tsx +1 -2
  131. package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +5 -0
  132. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +89 -104
  133. package/src/ui/common-styles.ts +11 -1
  134. package/src/ui/consts.ts +1 -0
  135. package/tsconfig.app.json +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#69911](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69911) [`50161fb5966e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/50161fb5966e) - [ux] Added keyboard shortcut to drag handle and keyboard navigation for drag menu
8
+ - Updated dependencies
9
+
10
+ ## 7.3.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#63203](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63203) [`2bf8f7ffabfd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2bf8f7ffabfd) - ECA11Y-194: Stop keyboard column resizing when table updated or lost focus
15
+
3
16
  ## 7.2.3
4
17
 
5
18
  ### Patch Changes
@@ -51,6 +51,9 @@
51
51
  {
52
52
  "path": "../../../design-system/icon/afm-cc/tsconfig.json"
53
53
  },
54
+ {
55
+ "path": "../../../design-system/menu/afm-cc/tsconfig.json"
56
+ },
54
57
  {
55
58
  "path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
56
59
  },
@@ -3,30 +3,66 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.initiateKeyboardColumnResizing = exports.changeColumnWidthByStep = exports.activateNextResizeArea = void 0;
6
+ exports.stopKeyboardColumnResizing = exports.initiateKeyboardColumnResizing = exports.changeColumnWidthByStep = exports.activateNextResizeArea = void 0;
7
7
  var _styles = require("@atlaskit/editor-common/styles");
8
8
  var _editorTables = require("@atlaskit/editor-tables");
9
9
  var _utils = require("@atlaskit/editor-tables/utils");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
- var _pluginFactory = require("../pm-plugins/table-resizing/plugin-factory");
12
- var _utils2 = require("../pm-plugins/table-resizing/utils");
11
+ var _plugin = require("../pm-plugins/decorations/plugin");
12
+ var _utils2 = require("../pm-plugins/decorations/utils");
13
+ var _pluginFactory = require("../pm-plugins/plugin-factory");
14
+ var _pluginFactory2 = require("../pm-plugins/table-resizing/plugin-factory");
15
+ var _pluginKey = require("../pm-plugins/table-resizing/plugin-key");
16
+ var _utils3 = require("../pm-plugins/table-resizing/utils");
13
17
  var _transforms = require("../transforms");
14
- var _utils3 = require("../utils");
15
- var _index = require("./index");
18
+ var _types = require("../types");
19
+ var _utils4 = require("../utils");
20
+ var getTablePluginCommand = function getTablePluginCommand(actionPayload, originalTr) {
21
+ return (0, _pluginFactory.createCommand)(function () {
22
+ return actionPayload;
23
+ }, function (tr) {
24
+ return (originalTr || tr).setMeta('addToHistory', false);
25
+ });
26
+ };
16
27
  var updateResizeHandleAndStatePosition = function updateResizeHandleAndStatePosition(rowIndex, columnIndex, nextResizeHandlePos) {
17
28
  return function (state, dispatch) {
18
- (0, _index.addResizeHandleDecorations)(rowIndex, columnIndex, true)(state, dispatch);
19
- // Currently only 'right' position is used in showResizeHandleLine
20
- (0, _index.showResizeHandleLine)({
21
- left: 0,
29
+ var customTr = state.tr;
30
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
31
+ allowColumnResizing = _getPluginState.pluginConfig.allowColumnResizing,
32
+ getIntl = _getPluginState.getIntl;
33
+ var fakeDispatch = function fakeDispatch(tr) {
34
+ customTr = tr;
35
+ };
36
+ if (!allowColumnResizing) {
37
+ return false;
38
+ }
39
+ var decorationsWithWidget = (0, _utils2.buildColumnResizingDecorations)(rowIndex, columnIndex, true, getIntl)({
40
+ tr: customTr,
41
+ decorationSet: (0, _plugin.getDecorations)(state)
42
+ });
43
+ var decorationsWithWidgetAndHandle = (0, _utils4.updateDecorations)(customTr.doc, decorationsWithWidget, (0, _utils4.createColumnLineResize)(state.selection, {
22
44
  right: columnIndex
23
- })(state, dispatch);
24
- (0, _pluginFactory.createCommand)({
45
+ }), _types.TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
46
+ getTablePluginCommand({
47
+ type: 'START_KEYBOARD_COLUMN_RESIZE',
48
+ data: {
49
+ resizeHandleRowIndex: rowIndex,
50
+ resizeHandleColumnIndex: columnIndex,
51
+ resizeHandleIncludeTooltip: true,
52
+ isKeyboardResize: true,
53
+ decorationSet: decorationsWithWidgetAndHandle
54
+ }
55
+ }, customTr)(state, fakeDispatch);
56
+ customTr.setMeta(_pluginKey.pluginKey, {
25
57
  type: 'SET_RESIZE_HANDLE_POSITION',
26
58
  data: {
27
59
  resizeHandlePos: nextResizeHandlePos
28
60
  }
29
- })(state, dispatch);
61
+ });
62
+ if (dispatch) {
63
+ dispatch(customTr);
64
+ return true;
65
+ }
30
66
  return false;
31
67
  };
32
68
  };
@@ -38,32 +74,19 @@ var initiateKeyboardColumnResizing = exports.initiateKeyboardColumnResizing = fu
38
74
  var selectionRect = (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
39
75
  var cell = (0, _utils.findCellClosestToPos)(selection.$from);
40
76
  if (selectionRect && cell && view) {
41
- var cellAttrs = cell.node.attrs;
42
- var width = (0, _utils2.currentColWidth)(view, cell.pos, cellAttrs);
43
- updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
44
- (0, _pluginFactory.createCommand)({
45
- type: 'SET_DRAGGING',
46
- data: {
47
- dragging: {
48
- startX: 0,
49
- startWidth: width
50
- }
51
- }
52
- })(state, dispatch);
53
- return true;
77
+ return updateResizeHandleAndStatePosition(selectionRect.top, selectionRect.right, cell.pos)(state, dispatch);
54
78
  }
55
79
  return false;
56
80
  };
57
81
  var activateNextResizeArea = exports.activateNextResizeArea = function activateNextResizeArea(direction) {
58
- return function (state, dispatch) {
82
+ return function (state, dispatch, view) {
59
83
  if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
60
84
  return false;
61
85
  }
62
- var _ref = (0, _pluginFactory.getPluginState)(state) || {},
63
- resizeHandlePos = _ref.resizeHandlePos,
64
- dragging = _ref.dragging;
86
+ var _ref = (0, _pluginFactory2.getPluginState)(state) || {},
87
+ resizeHandlePos = _ref.resizeHandlePos;
65
88
  // If No resizing has initiated, skip to regular handler
66
- if (!resizeHandlePos || !dragging) {
89
+ if (!resizeHandlePos) {
67
90
  return false;
68
91
  }
69
92
  var selection = state.selection;
@@ -88,31 +111,35 @@ var activateNextResizeArea = exports.activateNextResizeArea = function activateN
88
111
  // we are somewhere in between the side columns of the table
89
112
  var offset = $nextCell.pos - $nextCell.start(-1);
90
113
  var rectForNextCell = tableMap.findCell(offset);
91
- updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch);
114
+ return updateResizeHandleAndStatePosition(rectForNextCell.top, rectForNextCell.right, $nextCell.pos)(state, dispatch, view);
92
115
  } else {
93
116
  // current position is in the one of the side columns of the table(left or right)
94
117
  if (currentCellRect.left === 0) {
95
118
  var lastCellInCurrentRow = tableMap.positionAt(currentCellRect.top, tableMap.width - 1, tableNode) + closestTable.start;
96
119
  var $lastCell = state.doc.resolve(lastCellInCurrentRow);
97
- updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch);
120
+ return updateResizeHandleAndStatePosition(currentCellRect.top, tableMap.width, $lastCell.pos)(state, dispatch, view);
98
121
  } else if (tableMap.width === currentCellRect.right) {
99
122
  var firsCellInCurrentRow = tableMap.positionAt(currentCellRect.top, 0, tableNode) + closestTable.start;
100
123
  var _$nextCell = state.doc.resolve(firsCellInCurrentRow);
101
- updateResizeHandleAndStatePosition(currentCellRect.top, 1, _$nextCell.pos)(state, dispatch);
124
+ return updateResizeHandleAndStatePosition(currentCellRect.top, 1, _$nextCell.pos)(state, dispatch);
102
125
  }
103
126
  }
104
- return true;
127
+ return false;
105
128
  };
106
129
  };
107
130
  var changeColumnWidthByStep = exports.changeColumnWidthByStep = function changeColumnWidthByStep(stepSize, getEditorContainerWidth) {
108
131
  return function (state, dispatch, view) {
132
+ var customTr = state.tr;
133
+ var fakeDispatch = function fakeDispatch(tr) {
134
+ customTr = tr;
135
+ };
109
136
  if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
110
137
  return false;
111
138
  }
112
- var _getTableResizingPlug = (0, _pluginFactory.getPluginState)(state),
113
- resizeHandlePos = _getTableResizingPlug.resizeHandlePos,
114
- dragging = _getTableResizingPlug.dragging;
115
- if (!view || !resizeHandlePos || !dragging) {
139
+ var _getTableResizingPlug = (0, _pluginFactory2.getPluginState)(state),
140
+ resizeHandlePos = _getTableResizingPlug.resizeHandlePos;
141
+ var cell = (0, _utils.findCellClosestToPos)(state.selection.$from);
142
+ if (!view || !resizeHandlePos || !cell) {
116
143
  return false;
117
144
  }
118
145
  var $cell = state.doc.resolve(resizeHandlePos);
@@ -125,14 +152,25 @@ var changeColumnWidthByStep = exports.changeColumnWidthByStep = function changeC
125
152
  if (dom && dom.nodeName !== 'TABLE') {
126
153
  dom = dom.closest('table');
127
154
  }
128
- var maxSize = (0, _utils2.getTableMaxWidth)({
155
+ var cellAttrs = cell === null || cell === void 0 ? void 0 : cell.node.attrs;
156
+ var width = (0, _utils3.currentColWidth)(view, cell === null || cell === void 0 ? void 0 : cell.pos, cellAttrs);
157
+ (0, _pluginFactory2.createCommand)({
158
+ type: 'SET_DRAGGING',
159
+ data: {
160
+ dragging: {
161
+ startX: 0,
162
+ startWidth: width
163
+ }
164
+ }
165
+ })(state, fakeDispatch);
166
+ var maxSize = (0, _utils3.getTableMaxWidth)({
129
167
  table: originalTable,
130
168
  tableStart: tableStartPosition,
131
169
  state: state,
132
170
  layout: originalTable.attrs.layout,
133
171
  getEditorContainerWidth: getEditorContainerWidth
134
172
  });
135
- var initialResizeState = (0, _utils2.getResizeState)({
173
+ var initialResizeState = (0, _utils3.getResizeState)({
136
174
  minWidth: _styles.tableCellMinWidth,
137
175
  maxSize: maxSize,
138
176
  table: originalTable,
@@ -140,16 +178,48 @@ var changeColumnWidthByStep = exports.changeColumnWidthByStep = function changeC
140
178
  start: tableStartPosition,
141
179
  domAtPos: domAtPos
142
180
  });
143
- (0, _utils2.updateControls)()(state);
181
+ (0, _utils3.updateControls)()(state);
144
182
  var selectionRect = (0, _utils.getSelectionRect)(state.selection);
145
- var selectedColumns = selectionRect ? (0, _utils3.getSelectedColumnIndexes)(selectionRect) : [];
183
+ var selectedColumns = selectionRect ? (0, _utils4.getSelectedColumnIndexes)(selectionRect) : [];
146
184
  // only selected (or selected - 1) columns should be distributed
147
185
  var resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
148
- var newResizeState = (0, _utils2.resizeColumn)(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
149
- var tr = (0, _transforms.updateColumnWidths)(newResizeState, originalTable, tableStartPosition)(state.tr);
186
+ var newResizeState = (0, _utils3.resizeColumn)(initialResizeState, colIndex, stepSize, dom, resizingSelectedColumns ? selectedColumns : undefined);
187
+ customTr = (0, _transforms.updateColumnWidths)(newResizeState, originalTable, tableStartPosition)(customTr);
150
188
  if (dispatch) {
151
- dispatch(tr);
189
+ dispatch(customTr);
152
190
  }
153
191
  return true;
154
192
  };
193
+ };
194
+ var stopKeyboardColumnResizing = exports.stopKeyboardColumnResizing = function stopKeyboardColumnResizing(originalTr) {
195
+ return function (state, dispatch) {
196
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
197
+ return false;
198
+ }
199
+ var customTr = originalTr || state.tr;
200
+ var fakeDispatch = function fakeDispatch(tr) {
201
+ customTr = tr;
202
+ };
203
+ var decorationWithoutWidget = (0, _utils2.clearColumnResizingDecorations)()({
204
+ tr: customTr,
205
+ decorationSet: (0, _plugin.getDecorations)(state)
206
+ });
207
+ var decorationWithoutWidgetAndHandle = (0, _utils4.updateDecorations)(customTr.doc, decorationWithoutWidget, [], _types.TableDecorations.COLUMN_RESIZING_HANDLE_LINE);
208
+ getTablePluginCommand({
209
+ type: 'STOP_KEYBOARD_COLUMN_RESIZE',
210
+ data: {
211
+ decorationSet: decorationWithoutWidgetAndHandle
212
+ }
213
+ }, customTr)(state, fakeDispatch);
214
+ (0, _pluginFactory2.createCommand)({
215
+ type: 'STOP_RESIZING'
216
+ }, function () {
217
+ return customTr.setMeta('scrollIntoView', false);
218
+ })(state, fakeDispatch);
219
+ if (dispatch) {
220
+ dispatch(customTr);
221
+ return true;
222
+ }
223
+ return false;
224
+ };
155
225
  };
@@ -10,29 +10,25 @@ var _tableMap = require("@atlaskit/editor-tables/table-map");
10
10
  var _utils2 = require("@atlaskit/editor-tables/utils");
11
11
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
12
  var _commandsWithAnalytics = require("../commands-with-analytics");
13
- var _pluginFactory = require("../pm-plugins/table-resizing/plugin-factory");
14
- var _hover = require("./hover");
13
+ var _pluginFactory = require("../pm-plugins/plugin-factory");
14
+ var _columnResize = require("./column-resize");
15
15
  // #region Constants
16
16
 
17
17
  var TAB_FORWARD_DIRECTION = 1;
18
18
  var TAB_BACKWARD_DIRECTION = -1;
19
19
  var goToNextCell = exports.goToNextCell = function goToNextCell(editorAnalyticsAPI) {
20
20
  return function (direction) {
21
- return function (state, dispatch) {
21
+ return function (state, dispatch, view) {
22
22
  var table = (0, _utils2.findTable)(state.selection);
23
23
  if (!table) {
24
24
  return false;
25
25
  }
26
26
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
27
- var _getResizePluginState;
28
- var isColumnResizing = !!((_getResizePluginState = (0, _pluginFactory.getPluginState)(state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
27
+ var _getPluginState;
28
+ var isColumnResizing = (_getPluginState = (0, _pluginFactory.getPluginState)(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.isKeyboardResize;
29
29
  if (isColumnResizing) {
30
- (0, _pluginFactory.createCommand)({
31
- type: 'STOP_RESIZING'
32
- }, function (originalTr) {
33
- return (state.tr || originalTr).setMeta('scrollIntoView', false);
34
- })(state, dispatch);
35
- (0, _hover.hideResizeHandleLine)()(state, dispatch);
30
+ (0, _columnResize.stopKeyboardColumnResizing)()(state, dispatch, view);
31
+ return true;
36
32
  }
37
33
  }
38
34
  var map = _tableMap.TableMap.get(table.node);
@@ -328,6 +328,7 @@ var setMultipleCellAttrs = exports.setMultipleCellAttrs = function setMultipleCe
328
328
  };
329
329
  };
330
330
  var selectColumn = exports.selectColumn = function selectColumn(column, expand) {
331
+ var triggeredByKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
331
332
  return (0, _pluginFactory.createCommand)(function (state) {
332
333
  var cells = (0, _utils2.getCellsInColumn)(column)(state.tr.selection);
333
334
  if (!cells || !cells.length || typeof cells[0].pos !== 'number') {
@@ -344,7 +345,7 @@ var selectColumn = exports.selectColumn = function selectColumn(column, expand)
344
345
  }
345
346
  };
346
347
  }, function (tr) {
347
- return (0, _utils2.selectColumn)(column, expand)(tr).setMeta('addToHistory', false);
348
+ return (0, _utils2.selectColumn)(column, expand)(tr).setMeta('addToHistory', false).setMeta('selectedColumnViaKeyboard', triggeredByKeyboard);
348
349
  });
349
350
  };
350
351
  var selectColumns = exports.selectColumns = function selectColumns(columnIndexes) {
@@ -379,6 +380,7 @@ var selectColumns = exports.selectColumns = function selectColumns(columnIndexes
379
380
  });
380
381
  };
381
382
  var selectRow = exports.selectRow = function selectRow(row, expand) {
383
+ var triggeredByKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
382
384
  return (0, _pluginFactory.createCommand)(function (state) {
383
385
  var targetCellPosition;
384
386
  var cells = (0, _utils2.getCellsInRow)(row)(state.tr.selection);
@@ -392,7 +394,7 @@ var selectRow = exports.selectRow = function selectRow(row, expand) {
392
394
  }
393
395
  };
394
396
  }, function (tr) {
395
- return (0, _utils2.selectRow)(row, expand)(tr).setMeta('addToHistory', false);
397
+ return (0, _utils2.selectRow)(row, expand)(tr).setMeta('addToHistory', false).setMeta('selectedRowViaKeyboard', triggeredByKeyboard);
396
398
  });
397
399
  };
398
400
  var selectRows = exports.selectRows = function selectRows(rowIndexes) {
@@ -454,7 +456,7 @@ var hideInsertColumnOrRowButton = exports.hideInsertColumnOrRowButton = function
454
456
  return tr.setMeta('addToHistory', false);
455
457
  });
456
458
  };
457
- var addResizeHandleDecorations = exports.addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
459
+ var addResizeHandleDecorations = exports.addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip, isKeyboardResize) {
458
460
  return (0, _pluginFactory.createCommand)(function (state) {
459
461
  var tableNode = (0, _utils2.findTable)(state.selection);
460
462
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
@@ -472,7 +474,8 @@ var addResizeHandleDecorations = exports.addResizeHandleDecorations = function a
472
474
  }),
473
475
  resizeHandleRowIndex: rowIndex,
474
476
  resizeHandleColumnIndex: columnIndex,
475
- resizeHandleIncludeTooltip: includeTooltip
477
+ resizeHandleIncludeTooltip: includeTooltip,
478
+ isKeyboardResize: isKeyboardResize || false
476
479
  }
477
480
  };
478
481
  }, function (tr) {
@@ -11,7 +11,7 @@ var _tableMap = require("@atlaskit/editor-tables/table-map");
11
11
  var _utils = require("@atlaskit/editor-tables/utils");
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
13
  var _misc = require("../commands/misc");
14
- var _pluginFactory = require("../pm-plugins/table-resizing/plugin-factory");
14
+ var _pluginFactory = require("../pm-plugins/plugin-factory");
15
15
  var _toolbar = require("../toolbar");
16
16
  var TableSelectionDirection = exports.TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
17
17
  TableSelectionDirection["TopToBottom"] = "TopToBottom";
@@ -88,6 +88,7 @@ var arrowRightFromCellSelection = function arrowRightFromCellSelection(editorSel
88
88
  };
89
89
  var selectColumns = exports.selectColumns = function selectColumns(editorSelectionAPI) {
90
90
  return function () {
91
+ var triggeredByKeyboard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
91
92
  return function (state, dispatch) {
92
93
  var selection = state.selection;
93
94
  var table = (0, _utils.findTable)(selection);
@@ -100,7 +101,7 @@ var selectColumns = exports.selectColumns = function selectColumns(editorSelecti
100
101
  })(state, dispatch);
101
102
  }
102
103
  if (table && rect) {
103
- return (0, _misc.selectColumn)(rect.left)(state, dispatch);
104
+ return (0, _misc.selectColumn)(rect.left, undefined, triggeredByKeyboard)(state, dispatch);
104
105
  }
105
106
  return false;
106
107
  };
@@ -108,6 +109,7 @@ var selectColumns = exports.selectColumns = function selectColumns(editorSelecti
108
109
  };
109
110
  var selectRows = exports.selectRows = function selectRows(editorSelectionAPI) {
110
111
  return function () {
112
+ var triggeredByKeyboard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
111
113
  return function (state, dispatch) {
112
114
  var selection = state.selection;
113
115
  var table = (0, _utils.findTable)(selection);
@@ -120,7 +122,7 @@ var selectRows = exports.selectRows = function selectRows(editorSelectionAPI) {
120
122
  })(state, dispatch);
121
123
  }
122
124
  if (table && rect) {
123
- return (0, _misc.selectRow)(rect.top)(state, dispatch);
125
+ return (0, _misc.selectRow)(rect.top, undefined, triggeredByKeyboard)(state, dispatch);
124
126
  }
125
127
  return false;
126
128
  };
@@ -203,7 +205,7 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
203
205
  var isColumnResizing = false;
204
206
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
205
207
  var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
206
- isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
208
+ isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
207
209
  }
208
210
  if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
209
211
  // + 3 for: row, cell & paragraph nodes
@@ -237,7 +239,7 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
237
239
  var isColumnResizing = false;
238
240
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
239
241
  var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
240
- isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
242
+ isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
241
243
  }
242
244
  if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
243
245
  // + 3 for: row, cell & paragraph nodes
@@ -14,6 +14,7 @@ var _state5 = require("@atlaskit/editor-prosemirror/state");
14
14
  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
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _commands = require("./commands");
18
19
  var _pluginFactory = require("./pm-plugins/drag-and-drop/plugin-factory");
19
20
  var _pluginFactory2 = require("./pm-plugins/plugin-factory");
@@ -172,15 +173,25 @@ var handleMouseOut = exports.handleMouseOut = function handleMouseOut(view, mous
172
173
  if ((0, _utils3.isResizeHandleDecoration)(target) && !(0, _utils3.isResizeHandleDecoration)(relatedTarget)) {
173
174
  var _state2 = view.state,
174
175
  _dispatch3 = view.dispatch;
175
- return (0, _commands.hideResizeHandleLine)()(_state2, _dispatch3);
176
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
177
+ var _getPluginState2 = (0, _pluginFactory2.getPluginState)(_state2),
178
+ isKeyboardResize = _getPluginState2.isKeyboardResize;
179
+ if (isKeyboardResize) {
180
+ // no need to hide decoration if column resizing started by keyboard
181
+ return false;
182
+ }
183
+ return (0, _commands.hideResizeHandleLine)()(_state2, _dispatch3);
184
+ } else {
185
+ return (0, _commands.hideResizeHandleLine)()(_state2, _dispatch3);
186
+ }
176
187
  }
177
188
  return false;
178
189
  };
179
190
  var handleMouseEnter = exports.handleMouseEnter = function handleMouseEnter(view, mouseEvent) {
180
191
  var state = view.state,
181
192
  dispatch = view.dispatch;
182
- var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
183
- isTableHovered = _getPluginState2.isTableHovered;
193
+ var _getPluginState3 = (0, _pluginFactory2.getPluginState)(state),
194
+ isTableHovered = _getPluginState3.isTableHovered;
184
195
  if (!isTableHovered) {
185
196
  return (0, _commands.setTableHovered)(true)(state, dispatch);
186
197
  }
@@ -192,11 +203,11 @@ var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view
192
203
  }
193
204
  var state = view.state,
194
205
  dispatch = view.dispatch;
195
- var _getPluginState3 = (0, _pluginFactory2.getPluginState)(state),
196
- insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex,
197
- insertRowButtonIndex = _getPluginState3.insertRowButtonIndex,
198
- isDragAndDropEnabled = _getPluginState3.isDragAndDropEnabled,
199
- isTableHovered = _getPluginState3.isTableHovered;
206
+ var _getPluginState4 = (0, _pluginFactory2.getPluginState)(state),
207
+ insertColumnButtonIndex = _getPluginState4.insertColumnButtonIndex,
208
+ insertRowButtonIndex = _getPluginState4.insertRowButtonIndex,
209
+ isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled,
210
+ isTableHovered = _getPluginState4.isTableHovered;
200
211
  if (isTableHovered) {
201
212
  if (isDragAndDropEnabled) {
202
213
  var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(state),
@@ -229,9 +240,9 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
229
240
  if ((0, _utils3.isColumnControlsDecorations)(element) || (0, _utils3.isDragColumnFloatingInsertDot)(element)) {
230
241
  var state = view.state,
231
242
  dispatch = view.dispatch;
232
- var _getPluginState4 = (0, _pluginFactory2.getPluginState)(state),
233
- insertColumnButtonIndex = _getPluginState4.insertColumnButtonIndex,
234
- isDragAndDropEnabled = _getPluginState4.isDragAndDropEnabled;
243
+ var _getPluginState5 = (0, _pluginFactory2.getPluginState)(state),
244
+ insertColumnButtonIndex = _getPluginState5.insertColumnButtonIndex,
245
+ isDragAndDropEnabled = _getPluginState5.isDragAndDropEnabled;
235
246
  var _getColumnOrRowIndex9 = (0, _utils3.getColumnOrRowIndex)(element),
236
247
  _getColumnOrRowIndex10 = (0, _slicedToArray2.default)(_getColumnOrRowIndex9, 2),
237
248
  startIndex = _getColumnOrRowIndex10[0],
@@ -244,8 +255,8 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
244
255
  if ((0, _utils3.isRowControlsButton)(element) || (0, _utils3.isDragRowFloatingInsertDot)(element)) {
245
256
  var _state3 = view.state,
246
257
  _dispatch4 = view.dispatch;
247
- var _getPluginState5 = (0, _pluginFactory2.getPluginState)(_state3),
248
- insertRowButtonIndex = _getPluginState5.insertRowButtonIndex;
258
+ var _getPluginState6 = (0, _pluginFactory2.getPluginState)(_state3),
259
+ insertRowButtonIndex = _getPluginState6.insertRowButtonIndex;
249
260
  var _getColumnOrRowIndex11 = (0, _utils3.getColumnOrRowIndex)(element),
250
261
  _getColumnOrRowIndex12 = (0, _slicedToArray2.default)(_getColumnOrRowIndex11, 2),
251
262
  _startIndex3 = _getColumnOrRowIndex12[0],
@@ -260,19 +271,21 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
260
271
  if (_positionColumn !== null) {
261
272
  var _state4 = view.state,
262
273
  _dispatch5 = view.dispatch;
263
- var _getPluginState6 = (0, _pluginFactory2.getPluginState)(_state4),
264
- resizeHandleColumnIndex = _getPluginState6.resizeHandleColumnIndex,
265
- resizeHandleRowIndex = _getPluginState6.resizeHandleRowIndex;
274
+ var _getPluginState7 = (0, _pluginFactory2.getPluginState)(_state4),
275
+ resizeHandleColumnIndex = _getPluginState7.resizeHandleColumnIndex,
276
+ resizeHandleRowIndex = _getPluginState7.resizeHandleRowIndex;
277
+ var isKeyboardResize = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz') ? (0, _pluginFactory2.getPluginState)(_state4).isKeyboardResize : false;
266
278
  var tableCell = (0, _utils.closestElement)(element, 'td, th');
267
279
  var cellStartPosition = view.posAtDOM(tableCell, 0);
268
280
  var rect = (0, _utils2.findCellRectClosestToPos)(_state4.doc.resolve(cellStartPosition));
269
281
  if (rect) {
270
282
  var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
271
283
  var rowIndexTarget = rect.top;
272
- if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !(0, _utils3.hasResizeHandler)({
284
+ if ((columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !(0, _utils3.hasResizeHandler)({
273
285
  target: element,
274
286
  columnEndIndexTarget: columnEndIndexTarget
275
- })) {
287
+ })) && !isKeyboardResize // if initiated by keyboard don't need to react on hover for other resize sliders
288
+ ) {
276
289
  return (0, _commands.addResizeHandleDecorations)(rowIndexTarget, columnEndIndexTarget, true)(_state4, _dispatch5);
277
290
  }
278
291
  }
@@ -337,8 +350,8 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
337
350
  if (isTableSelected) {
338
351
  tr = (0, _utils2.removeTable)(tr);
339
352
  } else if (tr.selection.isRowSelection()) {
340
- var _getPluginState7 = (0, _pluginFactory2.getPluginState)(newState),
341
- isHeaderRowRequired = _getPluginState7.pluginConfig.isHeaderRowRequired;
353
+ var _getPluginState8 = (0, _pluginFactory2.getPluginState)(newState),
354
+ isHeaderRowRequired = _getPluginState8.pluginConfig.isHeaderRowRequired;
342
355
  tr = (0, _transforms.deleteRows)(rect, isHeaderRowRequired)(tr);
343
356
  } else if (tr.selection.isColSelection()) {
344
357
  tr = (0, _transforms.deleteColumns)(rect, (0, _getAllowAddColumnCustomStep.getAllowAddColumnCustomStep)(oldState), editorView)(tr);
@@ -350,8 +363,8 @@ var handleCut = exports.handleCut = function handleCut(oldTr, oldState, newState
350
363
  return tr;
351
364
  };
352
365
  var isTableInFocus = exports.isTableInFocus = function isTableInFocus(view) {
353
- var _getPluginState8, _getResizePluginState;
354
- return !!((_getPluginState8 = (0, _pluginFactory2.getPluginState)(view.state)) !== null && _getPluginState8 !== void 0 && _getPluginState8.tableNode) && !((_getResizePluginState = (0, _pluginFactory3.getPluginState)(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
366
+ var _getPluginState9, _getResizePluginState;
367
+ return !!((_getPluginState9 = (0, _pluginFactory2.getPluginState)(view.state)) !== null && _getPluginState9 !== void 0 && _getPluginState9.tableNode) && !((_getResizePluginState = (0, _pluginFactory3.getPluginState)(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
355
368
  };
356
369
  var whenTableInFocus = exports.whenTableInFocus = function whenTableInFocus(eventHandler, elementContentRects) {
357
370
  return function (view, mouseEvent) {
@@ -365,9 +378,9 @@ var trackCellLocation = function trackCellLocation(view, mouseEvent) {
365
378
  var _tableElement$dataset;
366
379
  var target = mouseEvent.target;
367
380
  var maybeTableCell = (0, _utils.isElementInTableCell)(target);
368
- var _getPluginState9 = (0, _pluginFactory2.getPluginState)(view.state),
369
- tableNode = _getPluginState9.tableNode,
370
- tableRef = _getPluginState9.tableRef;
381
+ var _getPluginState10 = (0, _pluginFactory2.getPluginState)(view.state),
382
+ tableNode = _getPluginState10.tableNode,
383
+ tableRef = _getPluginState10.tableRef;
371
384
  var tableElement = (0, _utils.closestElement)(target, 'table');
372
385
 
373
386
  // hover will only trigger if target localId is the same with selected localId
@@ -84,6 +84,7 @@ var moveSource = exports.moveSource = function moveSource(sourceType, sourceInde
84
84
  });
85
85
  };
86
86
  var toggleDragMenu = exports.toggleDragMenu = function toggleDragMenu(isDragMenuOpen, direction, index) {
87
+ var trigger = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'mouse';
87
88
  return (0, _pluginFactory.createCommand)(function (state) {
88
89
  var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
89
90
  previousOpenState = _getPluginState3.isDragMenuOpen,
@@ -110,7 +111,8 @@ var toggleDragMenu = exports.toggleDragMenu = function toggleDragMenu(isDragMenu
110
111
  data: {
111
112
  isDragMenuOpen: updatedMenuOpenState,
112
113
  direction: direction !== null && direction !== void 0 ? direction : previousDragMenuDirection,
113
- index: index !== null && index !== void 0 ? index : previousDragMenuIndex
114
+ index: index !== null && index !== void 0 ? index : previousDragMenuIndex,
115
+ isKeyboardModeActive: updatedMenuOpenState && trigger === 'keyboard'
114
116
  }
115
117
  };
116
118
  }, function (tr) {
@@ -170,7 +170,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
170
170
  dropTargetIndex: 0,
171
171
  isDragMenuOpen: false,
172
172
  dragMenuIndex: 0,
173
- isDragging: false
173
+ isDragging: false,
174
+ isKeyboardModeActive: false
174
175
  };
175
176
  }),
176
177
  key: _pluginKey2.pluginKey,
@@ -182,6 +183,20 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
182
183
  var _getPluginState = (0, _pluginFactory2.getPluginState)(newState),
183
184
  isDragMenuOpen = _getPluginState.isDragMenuOpen,
184
185
  dragMenuIndex = _getPluginState.dragMenuIndex;
186
+ transactions.forEach(function (transaction) {
187
+ if (transaction.getMeta('selectedRowViaKeyboard')) {
188
+ var button = document.querySelector('#drag-handle-button-row');
189
+ if (button) {
190
+ button.focus();
191
+ }
192
+ }
193
+ if (transaction.getMeta('selectedColumnViaKeyboard')) {
194
+ var _button = document.querySelector('#drag-handle-button-column');
195
+ if (_button) {
196
+ _button.focus();
197
+ }
198
+ }
199
+ });
185
200
 
186
201
  // What's happening here? you asked... In a nutshell;
187
202
  // If the target cell position changes while the drag menu is open then we want to close the drag menu if it has been opened.
@@ -222,6 +237,23 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
222
237
  var _getPluginState2 = (0, _pluginFactory2.getPluginState)(state),
223
238
  decorationSet = _getPluginState2.decorationSet;
224
239
  return decorationSet;
240
+ },
241
+ handleKeyDown: function handleKeyDown(view, event) {
242
+ var _ref8;
243
+ var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((_ref8 = event.target || null) === null || _ref8 === void 0 ? void 0 : _ref8.id);
244
+ var keysToTrap = ['Enter', ' '];
245
+ var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
246
+ var _getPluginState3 = (0, _pluginFactory2.getPluginState)(view.state),
247
+ isDragMenuOpen = _getPluginState3.isDragMenuOpen;
248
+
249
+ // drag handle is focused, and user presses any key return them back to editing
250
+ if (isDragHandleFocused && !isDragMenuOpen && !keysToTrap.includes(event.key)) {
251
+ view.dom.focus();
252
+ return true;
253
+ }
254
+ if (isDragHandleFocused && keysToTrap.includes(event.key) || isDragMenuOpen && keysToTrapWhen.includes(event.key)) {
255
+ return true;
256
+ }
225
257
  }
226
258
  }
227
259
  });
@@ -30,7 +30,8 @@ var _default = exports.default = function _default(pluginState, action) {
30
30
  return _objectSpread(_objectSpread({}, pluginState), {}, {
31
31
  isDragMenuOpen: action.data.isDragMenuOpen,
32
32
  dragMenuDirection: action.data.direction,
33
- dragMenuIndex: action.data.index
33
+ dragMenuIndex: action.data.index,
34
+ isKeyboardModeActive: action.data.isKeyboardModeActive
34
35
  });
35
36
  default:
36
37
  return pluginState;