@atlaskit/editor-plugin-table 7.18.3 → 7.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/commands/column-resize.js +0 -12
- package/dist/cjs/commands/go-to-next-cell.js +8 -11
- package/dist/cjs/commands/selection.js +4 -11
- package/dist/cjs/event-handlers.js +7 -11
- package/dist/cjs/pm-plugins/keymap.js +20 -22
- package/dist/cjs/pm-plugins/main.js +26 -30
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +13 -21
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +8 -11
- package/dist/es2019/commands/column-resize.js +0 -12
- package/dist/es2019/commands/go-to-next-cell.js +8 -11
- package/dist/es2019/commands/selection.js +4 -11
- package/dist/es2019/event-handlers.js +8 -12
- package/dist/es2019/pm-plugins/keymap.js +20 -22
- package/dist/es2019/pm-plugins/main.js +27 -31
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +13 -21
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +9 -12
- package/dist/esm/commands/column-resize.js +0 -12
- package/dist/esm/commands/go-to-next-cell.js +8 -11
- package/dist/esm/commands/selection.js +4 -11
- package/dist/esm/event-handlers.js +7 -11
- package/dist/esm/pm-plugins/keymap.js +20 -22
- package/dist/esm/pm-plugins/main.js +26 -30
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +13 -21
- package/dist/esm/pm-plugins/table-resizing/plugin.js +8 -11
- package/package.json +1 -4
- package/src/commands/column-resize.ts +0 -14
- package/src/commands/go-to-next-cell.ts +7 -10
- package/src/commands/selection.ts +4 -11
- package/src/event-handlers.ts +6 -12
- package/src/pm-plugins/keymap.ts +60 -62
- package/src/pm-plugins/main.ts +27 -31
- package/src/pm-plugins/table-resizing/event-handlers.ts +11 -19
- package/src/pm-plugins/table-resizing/plugin.ts +7 -10
- package/src/types.ts +20 -20
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +5 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.18.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#113338](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113338)
|
|
8
|
+
[`6b5439f51eab4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b5439f51eab4) -
|
|
9
|
+
ECA11Y-5 remove FF from codebase
|
|
10
|
+
|
|
3
11
|
## 7.18.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -71,9 +71,6 @@ var initiateKeyboardColumnResizing = exports.initiateKeyboardColumnResizing = fu
|
|
|
71
71
|
var ariaNotify = _ref.ariaNotify,
|
|
72
72
|
getIntl = _ref.getIntl;
|
|
73
73
|
return function (state, dispatch, view) {
|
|
74
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
74
|
var selection = state.selection;
|
|
78
75
|
var selectionRect = (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
|
|
79
76
|
var cell = (0, _utils.findCellClosestToPos)(selection.$from);
|
|
@@ -93,9 +90,6 @@ var activateNextResizeArea = exports.activateNextResizeArea = function activateN
|
|
|
93
90
|
ariaNotify = _ref2.ariaNotify,
|
|
94
91
|
getIntl = _ref2.getIntl;
|
|
95
92
|
return function (state, dispatch, view) {
|
|
96
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
93
|
var _ref3 = (0, _pluginFactory2.getPluginState)(state) || {},
|
|
100
94
|
resizeHandlePos = _ref3.resizeHandlePos;
|
|
101
95
|
// If No resizing has initiated, skip to regular handler
|
|
@@ -168,9 +162,6 @@ var changeColumnWidthByStep = exports.changeColumnWidthByStep = function changeC
|
|
|
168
162
|
var fakeDispatch = function fakeDispatch(tr) {
|
|
169
163
|
customTr = tr;
|
|
170
164
|
};
|
|
171
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
165
|
var _getTableResizingPlug = (0, _pluginFactory2.getPluginState)(state),
|
|
175
166
|
resizeHandlePos = _getTableResizingPlug.resizeHandlePos;
|
|
176
167
|
var cell = (0, _utils.findCellClosestToPos)(state.selection.$from);
|
|
@@ -258,9 +249,6 @@ var stopKeyboardColumnResizing = exports.stopKeyboardColumnResizing = function s
|
|
|
258
249
|
getIntl = _ref5.getIntl,
|
|
259
250
|
originalTr = _ref5.originalTr;
|
|
260
251
|
return function (state, dispatch) {
|
|
261
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-column-resizing_emcvz')) {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
252
|
var customTr = originalTr || state.tr;
|
|
265
253
|
var fakeDispatch = function fakeDispatch(tr) {
|
|
266
254
|
customTr = tr;
|
|
@@ -8,7 +8,6 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
8
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
9
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
10
10
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _commandsWithAnalytics = require("../commands-with-analytics");
|
|
13
12
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
14
13
|
var _columnResize = require("./column-resize");
|
|
@@ -19,20 +18,18 @@ var TAB_BACKWARD_DIRECTION = -1;
|
|
|
19
18
|
var goToNextCell = exports.goToNextCell = function goToNextCell(editorAnalyticsAPI, ariaNotify, getIntl) {
|
|
20
19
|
return function (direction) {
|
|
21
20
|
return function (state, dispatch, view) {
|
|
21
|
+
var _getPluginState;
|
|
22
22
|
var table = (0, _utils2.findTable)(state.selection);
|
|
23
23
|
if (!table) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})(state, dispatch, view);
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
26
|
+
var isColumnResizing = (_getPluginState = (0, _pluginFactory.getPluginState)(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.isKeyboardResize;
|
|
27
|
+
if (isColumnResizing) {
|
|
28
|
+
(0, _columnResize.stopKeyboardColumnResizing)({
|
|
29
|
+
ariaNotify: ariaNotify,
|
|
30
|
+
getIntl: getIntl
|
|
31
|
+
})(state, dispatch, view);
|
|
32
|
+
return true;
|
|
36
33
|
}
|
|
37
34
|
var map = _tableMap.TableMap.get(table.node);
|
|
38
35
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -9,7 +9,6 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
9
9
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
10
10
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
11
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _misc = require("../commands/misc");
|
|
14
13
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
15
14
|
var _toolbar = require("../toolbar");
|
|
@@ -202,11 +201,8 @@ var arrowLeftFromText = function arrowLeftFromText(editorSelectionAPI) {
|
|
|
202
201
|
var table = (0, _utils.findTable)(selection);
|
|
203
202
|
if (table) {
|
|
204
203
|
var $from = selection.$from;
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
|
|
208
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
209
|
-
}
|
|
204
|
+
var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
|
|
205
|
+
var isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
210
206
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
211
207
|
// + 3 for: row, cell & paragraph nodes
|
|
212
208
|
editorSelectionAPI && !isColumnResizing) {
|
|
@@ -236,11 +232,8 @@ var arrowRightFromText = function arrowRightFromText(editorSelectionAPI) {
|
|
|
236
232
|
var table = (0, _utils.findTable)(selection);
|
|
237
233
|
if (table) {
|
|
238
234
|
var $to = selection.$to;
|
|
239
|
-
var
|
|
240
|
-
|
|
241
|
-
var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
|
|
242
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
243
|
-
}
|
|
235
|
+
var columResizePluginState = (0, _pluginFactory.getPluginState)(state) || {};
|
|
236
|
+
var isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
244
237
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
|
|
245
238
|
// + 3 for: row, cell & paragraph nodes
|
|
246
239
|
!isColumnResizing) {
|
|
@@ -199,17 +199,13 @@ var handleMouseOut = exports.handleMouseOut = function handleMouseOut(view, mous
|
|
|
199
199
|
if ((0, _utils3.isResizeHandleDecoration)(target) && !(0, _utils3.isResizeHandleDecoration)(relatedTarget)) {
|
|
200
200
|
var _state2 = view.state,
|
|
201
201
|
_dispatch3 = view.dispatch;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if
|
|
206
|
-
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
return (0, _commands.hideResizeHandleLine)()(_state2, _dispatch3);
|
|
210
|
-
} else {
|
|
211
|
-
return (0, _commands.hideResizeHandleLine)()(_state2, _dispatch3);
|
|
202
|
+
var _getPluginState3 = (0, _pluginFactory2.getPluginState)(_state2),
|
|
203
|
+
isKeyboardResize = _getPluginState3.isKeyboardResize;
|
|
204
|
+
if (isKeyboardResize) {
|
|
205
|
+
// no need to hide decoration if column resizing started by keyboard
|
|
206
|
+
return false;
|
|
212
207
|
}
|
|
208
|
+
return (0, _commands.hideResizeHandleLine)()(_state2, _dispatch3);
|
|
213
209
|
}
|
|
214
210
|
return false;
|
|
215
211
|
};
|
|
@@ -302,7 +298,7 @@ var handleMouseMoveDebounce = (0, _rafSchd.default)(function (view, event, offse
|
|
|
302
298
|
var _getPluginState8 = (0, _pluginFactory2.getPluginState)(_state4),
|
|
303
299
|
resizeHandleColumnIndex = _getPluginState8.resizeHandleColumnIndex,
|
|
304
300
|
resizeHandleRowIndex = _getPluginState8.resizeHandleRowIndex;
|
|
305
|
-
var isKeyboardResize = (0,
|
|
301
|
+
var isKeyboardResize = (0, _pluginFactory2.getPluginState)(_state4).isKeyboardResize;
|
|
306
302
|
var tableCell = (0, _utils.closestElement)(element, 'td, th');
|
|
307
303
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
308
304
|
var rect = (0, _utils2.findCellRectClosestToPos)(_state4.doc.resolve(cellStartPosition));
|
|
@@ -62,28 +62,26 @@ function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEn
|
|
|
62
62
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.deleteColumn.common, (0, _commandsWithAnalytics.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut)(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
63
63
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.deleteRow.common, (0, _commandsWithAnalytics.deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut)(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}), list);
|
|
86
|
-
}
|
|
65
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.startColumnResizing.common, (0, _columnResize.initiateKeyboardColumnResizing)({
|
|
66
|
+
ariaNotify: ariaNotifyPlugin,
|
|
67
|
+
getIntl: getIntl
|
|
68
|
+
}), list);
|
|
69
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, (0, _columnResize.activateNextResizeArea)({
|
|
70
|
+
direction: 1,
|
|
71
|
+
ariaNotify: ariaNotifyPlugin,
|
|
72
|
+
getIntl: getIntl
|
|
73
|
+
}), list);
|
|
74
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveLeft.common, (0, _columnResize.activateNextResizeArea)({
|
|
75
|
+
direction: -1,
|
|
76
|
+
ariaNotify: ariaNotifyPlugin,
|
|
77
|
+
getIntl: getIntl
|
|
78
|
+
}), list);
|
|
79
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.decreaseMediaSize.common, (0, _commandsWithAnalytics.changeColumnWidthByStepWithAnalytics)(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, _analytics.INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
80
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.increaseMediaSize.common, (0, _commandsWithAnalytics.changeColumnWidthByStepWithAnalytics)(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, _analytics.INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
81
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.escape.common, (0, _columnResize.stopKeyboardColumnResizing)({
|
|
82
|
+
ariaNotify: ariaNotifyPlugin,
|
|
83
|
+
getIntl: getIntl
|
|
84
|
+
}), list);
|
|
87
85
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-table-context-menu_y4c9c')) {
|
|
88
86
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.focusToContextMenuTrigger.common, (0, _commands2.setFocusToCellMenu)(), list);
|
|
89
87
|
}
|
|
@@ -117,31 +117,29 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
117
117
|
tableRef = parent.querySelector('table') || undefined;
|
|
118
118
|
}
|
|
119
119
|
var tableNode = (0, _utils3.findTable)(state.selection);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// Jump to another table
|
|
133
|
-
(0, _columnResize.stopKeyboardColumnResizing)({
|
|
134
|
-
ariaNotify: ariaNotifyPlugin,
|
|
135
|
-
getIntl: getIntl
|
|
136
|
-
})(state, dispatch);
|
|
137
|
-
}
|
|
138
|
-
} else if (!tableNode) {
|
|
139
|
-
// selection outside of table
|
|
120
|
+
// when keyboard cursor leaves the table we need to stop column resizing
|
|
121
|
+
var pluginPrevState = (0, _pluginFactory.getPluginState)(prevState);
|
|
122
|
+
var isStopKeyboardColumResizing = pluginPrevState.isResizeHandleWidgetAdded && pluginPrevState.isKeyboardResize;
|
|
123
|
+
if (isStopKeyboardColumResizing) {
|
|
124
|
+
var isTableNodesDifferent = (pluginPrevState === null || pluginPrevState === void 0 ? void 0 : pluginPrevState.tableNode) !== (tableNode === null || tableNode === void 0 ? void 0 : tableNode.node);
|
|
125
|
+
if (pluginPrevState !== null && pluginPrevState !== void 0 && pluginPrevState.tableNode && tableNode && isTableNodesDifferent) {
|
|
126
|
+
var oldRowsNumber = _editorTables.TableMap.get(pluginPrevState.tableNode).height;
|
|
127
|
+
var newRowsNumber = _editorTables.TableMap.get(tableNode.node).height;
|
|
128
|
+
if (oldRowsNumber !== newRowsNumber ||
|
|
129
|
+
// Add/delete row
|
|
130
|
+
tableNode.node.attrs.localId !== pluginPrevState.tableNode.attrs.localId) {
|
|
131
|
+
// Jump to another table
|
|
140
132
|
(0, _columnResize.stopKeyboardColumnResizing)({
|
|
141
133
|
ariaNotify: ariaNotifyPlugin,
|
|
142
134
|
getIntl: getIntl
|
|
143
135
|
})(state, dispatch);
|
|
144
136
|
}
|
|
137
|
+
} else if (!tableNode) {
|
|
138
|
+
// selection outside of table
|
|
139
|
+
(0, _columnResize.stopKeyboardColumnResizing)({
|
|
140
|
+
ariaNotify: ariaNotifyPlugin,
|
|
141
|
+
getIntl: getIntl
|
|
142
|
+
})(state, dispatch);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
}
|
|
@@ -243,16 +241,14 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
243
241
|
handleTextInput: function handleTextInput(view, _from, _to, text) {
|
|
244
242
|
var state = view.state,
|
|
245
243
|
dispatch = view.dispatch;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
244
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(state),
|
|
245
|
+
isKeyboardResize = _getPluginState.isKeyboardResize;
|
|
246
|
+
if (isKeyboardResize) {
|
|
247
|
+
(0, _columnResize.stopKeyboardColumnResizing)({
|
|
248
|
+
ariaNotify: ariaNotifyPlugin,
|
|
249
|
+
getIntl: getIntl
|
|
250
|
+
})(state, dispatch);
|
|
251
|
+
return false;
|
|
256
252
|
}
|
|
257
253
|
var tr = (0, _transforms2.replaceSelectedTable)(state, text, _analytics.INPUT_METHOD.KEYBOARD, editorAnalyticsAPI);
|
|
258
254
|
if (tr.selectionSet) {
|
|
@@ -115,15 +115,11 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
115
115
|
|
|
116
116
|
// If we let go in the same place we started, don't need to do anything.
|
|
117
117
|
if (dragging && clientX === dragging.startX) {
|
|
118
|
-
if (
|
|
119
|
-
if
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return (0, _columnResize.stopKeyboardColumnResizing)({})(state, dispatch, view);
|
|
124
|
-
} else {
|
|
125
|
-
return (0, _commands.stopResizing)()(state, dispatch);
|
|
126
|
-
}
|
|
118
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
119
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
120
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
121
|
+
*/
|
|
122
|
+
return (0, _columnResize.stopKeyboardColumnResizing)({})(state, dispatch, view);
|
|
127
123
|
} else {
|
|
128
124
|
return (0, _commands.stopResizing)()(state, dispatch);
|
|
129
125
|
}
|
|
@@ -190,17 +186,13 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
190
186
|
}
|
|
191
187
|
})(tr);
|
|
192
188
|
}
|
|
193
|
-
if (
|
|
194
|
-
if
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
})(state, dispatch, view);
|
|
201
|
-
} else {
|
|
202
|
-
return (0, _commands.stopResizing)(tr)(state, dispatch);
|
|
203
|
-
}
|
|
189
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
190
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
191
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
192
|
+
*/
|
|
193
|
+
return (0, _columnResize.stopKeyboardColumnResizing)({
|
|
194
|
+
originalTr: tr
|
|
195
|
+
})(state, dispatch, view);
|
|
204
196
|
} else {
|
|
205
197
|
return (0, _commands.stopResizing)(tr)(state, dispatch);
|
|
206
198
|
}
|
|
@@ -215,7 +207,7 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
215
207
|
resizeHandlePos = _getPluginState2.resizeHandlePos;
|
|
216
208
|
var _getTablePluginState3 = (0, _pluginFactory.getPluginState)(state),
|
|
217
209
|
isTableHovered = _getTablePluginState3.isTableHovered;
|
|
218
|
-
if (!which || !dragging || resizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(resizeHandlePos)) || !isTableHovered
|
|
210
|
+
if (!which || !dragging || resizeHandlePos === null || !(0, _utils3.pointsAtCell)(state.doc.resolve(resizeHandlePos)) || !isTableHovered) {
|
|
219
211
|
return finish(event);
|
|
220
212
|
}
|
|
221
213
|
var $cell = state.doc.resolve(resizeHandlePos);
|
|
@@ -8,7 +8,6 @@ exports.createPlugin = createPlugin;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _types = require("../../types");
|
|
13
12
|
var _pluginFactory = require("../plugin-factory");
|
|
14
13
|
var _commands = require("./commands");
|
|
@@ -44,16 +43,14 @@ function createPlugin(dispatch, _ref, getEditorContainerWidth, getEditorFeatureF
|
|
|
44
43
|
var _getPluginState = (0, _pluginFactory2.getPluginState)(state),
|
|
45
44
|
dragging = _getPluginState.dragging;
|
|
46
45
|
var isColumnKeyboardResizeStarted = false;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
56
|
-
}
|
|
46
|
+
/*
|
|
47
|
+
We need to start listening mouse events if column resize started from keyboard.
|
|
48
|
+
This will allow continue resizing via mouse
|
|
49
|
+
*/
|
|
50
|
+
var _getTablePluginState = (0, _pluginFactory.getPluginState)(state),
|
|
51
|
+
isKeyboardResize = _getTablePluginState.isKeyboardResize;
|
|
52
|
+
if (isKeyboardResize) {
|
|
53
|
+
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
57
54
|
}
|
|
58
55
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
|
59
56
|
if ((0, _eventHandlers.handleMouseDown)(view, event, resizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, isTableScalingEnabled || false, editorAnalyticsAPI, isNewColumnResizingEnabled)) {
|
|
@@ -62,9 +62,6 @@ export const initiateKeyboardColumnResizing = ({
|
|
|
62
62
|
ariaNotify,
|
|
63
63
|
getIntl
|
|
64
64
|
}) => (state, dispatch, view) => {
|
|
65
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
65
|
const {
|
|
69
66
|
selection
|
|
70
67
|
} = state;
|
|
@@ -85,9 +82,6 @@ export const activateNextResizeArea = ({
|
|
|
85
82
|
ariaNotify,
|
|
86
83
|
getIntl
|
|
87
84
|
}) => (state, dispatch, view) => {
|
|
88
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
85
|
const {
|
|
92
86
|
resizeHandlePos
|
|
93
87
|
} = getTableResizingPluginState(state) || {};
|
|
@@ -162,9 +156,6 @@ export const changeColumnWidthByStep = ({
|
|
|
162
156
|
const fakeDispatch = tr => {
|
|
163
157
|
customTr = tr;
|
|
164
158
|
};
|
|
165
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
159
|
const {
|
|
169
160
|
resizeHandlePos
|
|
170
161
|
} = getTableResizingPluginState(state);
|
|
@@ -252,9 +243,6 @@ export const stopKeyboardColumnResizing = ({
|
|
|
252
243
|
getIntl,
|
|
253
244
|
originalTr
|
|
254
245
|
}) => (state, dispatch) => {
|
|
255
|
-
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
246
|
let customTr = originalTr || state.tr;
|
|
259
247
|
const fakeDispatch = tr => {
|
|
260
248
|
customTr = tr;
|
|
@@ -4,27 +4,24 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { goToNextCell as baseGotoNextCell, findTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { insertRowWithAnalytics } from '../commands-with-analytics';
|
|
9
8
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
10
9
|
import { stopKeyboardColumnResizing } from './column-resize';
|
|
11
10
|
const TAB_FORWARD_DIRECTION = 1;
|
|
12
11
|
const TAB_BACKWARD_DIRECTION = -1;
|
|
13
12
|
export const goToNextCell = (editorAnalyticsAPI, ariaNotify, getIntl) => direction => (state, dispatch, view) => {
|
|
13
|
+
var _getPluginState;
|
|
14
14
|
const table = findTable(state.selection);
|
|
15
15
|
if (!table) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})(state, dispatch, view);
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
18
|
+
const isColumnResizing = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.isKeyboardResize;
|
|
19
|
+
if (isColumnResizing) {
|
|
20
|
+
stopKeyboardColumnResizing({
|
|
21
|
+
ariaNotify: ariaNotify,
|
|
22
|
+
getIntl: getIntl
|
|
23
|
+
})(state, dispatch, view);
|
|
24
|
+
return true;
|
|
28
25
|
}
|
|
29
26
|
const map = TableMap.get(table.node);
|
|
30
27
|
const {
|
|
@@ -3,7 +3,6 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { findTable, isColumnSelected, isRowSelected, isTableSelected, selectedRect } from '@atlaskit/editor-tables/utils';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { selectColumn, selectRow } from '../commands/misc';
|
|
8
7
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
9
8
|
import { getClosestSelectionRect } from '../toolbar';
|
|
@@ -177,11 +176,8 @@ const arrowLeftFromText = editorSelectionAPI => selection => (state, dispatch) =
|
|
|
177
176
|
const {
|
|
178
177
|
$from
|
|
179
178
|
} = selection;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const columResizePluginState = getPluginState(state) || {};
|
|
183
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
184
|
-
}
|
|
179
|
+
const columResizePluginState = getPluginState(state) || {};
|
|
180
|
+
const isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
185
181
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 &&
|
|
186
182
|
// + 3 for: row, cell & paragraph nodes
|
|
187
183
|
editorSelectionAPI && !isColumnResizing) {
|
|
@@ -209,11 +205,8 @@ const arrowRightFromText = editorSelectionAPI => selection => (state, dispatch)
|
|
|
209
205
|
const {
|
|
210
206
|
$to
|
|
211
207
|
} = selection;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const columResizePluginState = getPluginState(state) || {};
|
|
215
|
-
isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
216
|
-
}
|
|
208
|
+
const columResizePluginState = getPluginState(state) || {};
|
|
209
|
+
const isColumnResizing = Boolean(columResizePluginState === null || columResizePluginState === void 0 ? void 0 : columResizePluginState.isKeyboardResize);
|
|
217
210
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 &&
|
|
218
211
|
// + 3 for: row, cell & paragraph nodes
|
|
219
212
|
!isColumnResizing) {
|
|
@@ -195,18 +195,14 @@ export const handleMouseOut = (view, mouseEvent) => {
|
|
|
195
195
|
state,
|
|
196
196
|
dispatch
|
|
197
197
|
} = view;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if
|
|
203
|
-
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
return hideResizeHandleLine()(state, dispatch);
|
|
207
|
-
} else {
|
|
208
|
-
return hideResizeHandleLine()(state, dispatch);
|
|
198
|
+
const {
|
|
199
|
+
isKeyboardResize
|
|
200
|
+
} = getPluginState(state);
|
|
201
|
+
if (isKeyboardResize) {
|
|
202
|
+
// no need to hide decoration if column resizing started by keyboard
|
|
203
|
+
return false;
|
|
209
204
|
}
|
|
205
|
+
return hideResizeHandleLine()(state, dispatch);
|
|
210
206
|
}
|
|
211
207
|
return false;
|
|
212
208
|
};
|
|
@@ -309,7 +305,7 @@ const handleMouseMoveDebounce = rafSchedule((view, event, offsetX) => {
|
|
|
309
305
|
resizeHandleColumnIndex,
|
|
310
306
|
resizeHandleRowIndex
|
|
311
307
|
} = getPluginState(state);
|
|
312
|
-
const isKeyboardResize =
|
|
308
|
+
const isKeyboardResize = getPluginState(state).isKeyboardResize;
|
|
313
309
|
const tableCell = closestElement(element, 'td, th');
|
|
314
310
|
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
315
311
|
const rect = findCellRectClosestToPos(state.doc.resolve(cellStartPosition));
|
|
@@ -47,28 +47,26 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
47
47
|
bindKeymapWithCommand(deleteColumn.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
48
48
|
bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent), list);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}), list);
|
|
71
|
-
}
|
|
50
|
+
bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing({
|
|
51
|
+
ariaNotify: ariaNotifyPlugin,
|
|
52
|
+
getIntl: getIntl
|
|
53
|
+
}), list);
|
|
54
|
+
bindKeymapWithCommand(moveRight.common, activateNextResizeArea({
|
|
55
|
+
direction: 1,
|
|
56
|
+
ariaNotify: ariaNotifyPlugin,
|
|
57
|
+
getIntl: getIntl
|
|
58
|
+
}), list);
|
|
59
|
+
bindKeymapWithCommand(moveLeft.common, activateNextResizeArea({
|
|
60
|
+
direction: -1,
|
|
61
|
+
ariaNotify: ariaNotifyPlugin,
|
|
62
|
+
getIntl: getIntl
|
|
63
|
+
}), list);
|
|
64
|
+
bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
65
|
+
bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, isTableFixedColumnWidthsOptionEnabled, INPUT_METHOD.SHORTCUT, ariaNotifyPlugin, getIntl), list);
|
|
66
|
+
bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing({
|
|
67
|
+
ariaNotify: ariaNotifyPlugin,
|
|
68
|
+
getIntl: getIntl
|
|
69
|
+
}), list);
|
|
72
70
|
if (getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')) {
|
|
73
71
|
bindKeymapWithCommand(focusToContextMenuTrigger.common, setFocusToCellMenu(), list);
|
|
74
72
|
}
|