@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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
8
+
9
+ ## 7.2.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#68572](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68572) [`15d407fe5143`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/15d407fe5143) - Upgrading @atlaskit/editor-prosemirror dependency
14
+ - [#70707](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70707) [`01c10b920070`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/01c10b920070) - [ux] Move options in drag menu now have disabled state when target has merged cells.
15
+ - Updated dependencies
16
+
3
17
  ## 7.2.2
4
18
 
5
19
  ### Patch Changes
@@ -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);
@@ -454,7 +454,7 @@ var hideInsertColumnOrRowButton = exports.hideInsertColumnOrRowButton = function
454
454
  return tr.setMeta('addToHistory', false);
455
455
  });
456
456
  };
457
- var addResizeHandleDecorations = exports.addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip) {
457
+ var addResizeHandleDecorations = exports.addResizeHandleDecorations = function addResizeHandleDecorations(rowIndex, columnIndex, includeTooltip, isKeyboardResize) {
458
458
  return (0, _pluginFactory.createCommand)(function (state) {
459
459
  var tableNode = (0, _utils2.findTable)(state.selection);
460
460
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(state),
@@ -472,7 +472,8 @@ var addResizeHandleDecorations = exports.addResizeHandleDecorations = function a
472
472
  }),
473
473
  resizeHandleRowIndex: rowIndex,
474
474
  resizeHandleColumnIndex: columnIndex,
475
- resizeHandleIncludeTooltip: includeTooltip
475
+ resizeHandleIncludeTooltip: includeTooltip,
476
+ isKeyboardResize: isKeyboardResize || false
476
477
  }
477
478
  };
478
479
  }, 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";
@@ -203,7 +203,7 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
203
203
  var isColumnResizing = false;
204
204
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
205
205
  var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
206
- isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
206
+ isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
207
207
  }
208
208
  if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
209
209
  // + 3 for: row, cell & paragraph nodes
@@ -237,7 +237,7 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
237
237
  var isColumnResizing = false;
238
238
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
239
239
  var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
240
- isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.dragging);
240
+ isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
241
241
  }
242
242
  if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
243
243
  // + 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
@@ -11,6 +11,7 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
11
11
  var _utils = require("@atlaskit/editor-tables/utils");
12
12
  var _utils2 = require("../../utils");
13
13
  var _analytics2 = require("../../utils/analytics");
14
+ var _dragMenu = require("../../utils/drag-menu");
14
15
  var _commands = require("./commands");
15
16
  var clearDropTargetWithAnalytics = exports.clearDropTargetWithAnalytics = function clearDropTargetWithAnalytics(editorAnalyticsAPI) {
16
17
  return function (inputMethod, sourceType, sourceIndexes, status, tr) {
@@ -91,30 +92,13 @@ var moveSourceWithAnalyticsViaShortcut = exports.moveSourceWithAnalyticsViaShort
91
92
  if (selectedIndexes.length === 0) {
92
93
  return false;
93
94
  }
94
-
95
- // const sourceIndex = selectedIndexes[0];
96
- // we can move only by one row/column
97
- // 'direction' can only be 1 (for right or down) or -1 (for left or up)
98
- var targetIndex = Math[direction < 0 ? 'min' : 'max'].apply(Math, (0, _toConsumableArray2.default)(selectedIndexes)) + direction;
99
-
100
- // We can move only if targetIndex is a positive number and is not higher than the total number of rows/columns.
101
95
  var _getSelectedTableInfo3 = (0, _utils2.getSelectedTableInfo)(selection),
102
96
  totalRowCount = _getSelectedTableInfo3.totalRowCount,
103
97
  totalColumnCount = _getSelectedTableInfo3.totalColumnCount;
104
- var isValidTargetIndex = targetIndex < 0 ? false : isRow ? targetIndex <= totalRowCount - 1 : targetIndex <= totalColumnCount - 1;
105
- if (!isValidTargetIndex) {
106
- return false;
107
- }
108
-
109
- // We can move only if there are no merged cells in the source or target row/column
110
- var hasMergedCellsInSource = isRow ? (0, _utils2.hasMergedCellsInRow)(selectedIndexes)(selection) : (0, _utils2.hasMergedCellsInColumn)(selectedIndexes)(selection);
111
- if (hasMergedCellsInSource) {
112
- return false;
113
- }
114
- var hasMergedCellsInTarget = isRow ? (0, _utils2.hasMergedCellsInRow)(targetIndex)(selection) : (0, _utils2.hasMergedCellsInColumn)(targetIndex)(selection);
115
- if (hasMergedCellsInTarget) {
98
+ if (!(0, _dragMenu.canMove)(sourceType, direction, isRow ? totalRowCount : totalColumnCount, selection, selectionRect)) {
116
99
  return false;
117
100
  }
101
+ var targetIndex = (0, _dragMenu.getTargetIndex)(selectedIndexes, direction);
118
102
  return moveSourceWithAnalytics(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
119
103
  };
120
104
  };
@@ -57,6 +57,7 @@ function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEn
57
57
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, (0, _columnResize.activateNextResizeArea)(-1), list);
58
58
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.decreaseMediaSize.common, (0, _columnResize.changeColumnWidthByStep)(-10, getEditorContainerWidth), list);
59
59
  (0, _keymaps.bindKeymapWithCommand)(_keymaps.increaseMediaSize.common, (0, _columnResize.changeColumnWidthByStep)(10, getEditorContainerWidth), list);
60
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.escape.common, (0, _columnResize.stopKeyboardColumnResizing)(), list);
60
61
  }
61
62
  return (0, _keymap.keymap)(list);
62
63
  }