@atlaskit/editor-plugin-table 7.3.9 → 7.3.10
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 +6 -0
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +20 -1
- package/dist/cjs/pm-plugins/keymap.js +7 -0
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +26 -2
- package/dist/es2019/pm-plugins/keymap.js +7 -0
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +21 -2
- package/dist/esm/pm-plugins/keymap.js +7 -0
- package/package.json +1 -1
- package/src/pm-plugins/drag-and-drop/plugin.ts +41 -6
- package/src/pm-plugins/keymap.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.3.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#75205](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75205) [`add1e7b7f424`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/add1e7b7f424) - Reduce NCS spam when holding the move column/row keyboard shortcut
|
|
8
|
+
|
|
3
9
|
## 7.3.9
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -240,9 +240,28 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
240
240
|
},
|
|
241
241
|
handleKeyDown: function handleKeyDown(view, event) {
|
|
242
242
|
var _ref8;
|
|
243
|
+
var tr = view.state.tr;
|
|
244
|
+
var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
245
|
+
|
|
246
|
+
/** fix for NCS spam update where the user is holding down the move column / row keyboard shortcut
|
|
247
|
+
* if the user is holding down shortcut (ctrl + shift + alt + arrowKey), we want to move the selection only once
|
|
248
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
// Do early check for the keys we want to trap here so we can abort early
|
|
252
|
+
if (event.ctrlKey && event.shiftKey && event.altKey) {
|
|
253
|
+
var _getSelectedCellInfo = (0, _utils.getSelectedCellInfo)(tr.selection),
|
|
254
|
+
verticalCells = _getSelectedCellInfo.verticalCells,
|
|
255
|
+
horizontalCells = _getSelectedCellInfo.horizontalCells,
|
|
256
|
+
totalRowCount = _getSelectedCellInfo.totalRowCount,
|
|
257
|
+
totalColumnCount = _getSelectedCellInfo.totalColumnCount;
|
|
258
|
+
var isRowOrColumnSelected = horizontalCells === totalColumnCount || verticalCells === totalRowCount;
|
|
259
|
+
if (isRowOrColumnSelected && keysToTrapWhen.includes(event.key) && event.repeat) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
243
263
|
var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((_ref8 = event.target || null) === null || _ref8 === void 0 ? void 0 : _ref8.id);
|
|
244
264
|
var keysToTrap = ['Enter', ' '];
|
|
245
|
-
var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
246
265
|
var _getPluginState3 = (0, _pluginFactory2.getPluginState)(view.state),
|
|
247
266
|
isDragMenuOpen = _getPluginState3.isDragMenuOpen;
|
|
248
267
|
|
|
@@ -42,6 +42,13 @@ function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEn
|
|
|
42
42
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.addColumnAfter.common, (0, _insert.addColumnAfter)(getEditorContainerWidth), list);
|
|
43
43
|
if (dragAndDropEnabled) {
|
|
44
44
|
// Move row/column shortcuts
|
|
45
|
+
/**
|
|
46
|
+
* NOTE: If the keyboard shortcut for moving rows or columns is changed, we need to update the handleKeyDown function
|
|
47
|
+
* in packages/editor/editor-plugin-table/src/pm-plugins/drag-and-drop/plugin.ts
|
|
48
|
+
* to make sure the logic for holding the shortcut keys is valid
|
|
49
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
50
|
+
*/
|
|
51
|
+
|
|
45
52
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRowDown.common, (0, _commandsWithAnalytics2.moveSourceWithAnalyticsViaShortcut)(editorAnalyticsAPI)('table-row', 1), list);
|
|
46
53
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRowUp.common, (0, _commandsWithAnalytics2.moveSourceWithAnalyticsViaShortcut)(editorAnalyticsAPI)('table-row', -1), list);
|
|
47
54
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveColumnLeft.common, (0, _commandsWithAnalytics2.moveSourceWithAnalyticsViaShortcut)(editorAnalyticsAPI)('table-column', -1), list);
|
|
@@ -2,7 +2,7 @@ import { INPUT_METHOD, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
-
import { getCellsInRow } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { getCellsInRow, getSelectedCellInfo } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
7
7
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
8
8
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -250,9 +250,33 @@ export const createPlugin = (dispatch, eventDispatcher, editorAnalyticsAPI) => {
|
|
|
250
250
|
},
|
|
251
251
|
handleKeyDown: (view, event) => {
|
|
252
252
|
var _ref;
|
|
253
|
+
const {
|
|
254
|
+
state: {
|
|
255
|
+
tr
|
|
256
|
+
}
|
|
257
|
+
} = view;
|
|
258
|
+
const keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
259
|
+
|
|
260
|
+
/** fix for NCS spam update where the user is holding down the move column / row keyboard shortcut
|
|
261
|
+
* if the user is holding down shortcut (ctrl + shift + alt + arrowKey), we want to move the selection only once
|
|
262
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
// Do early check for the keys we want to trap here so we can abort early
|
|
266
|
+
if (event.ctrlKey && event.shiftKey && event.altKey) {
|
|
267
|
+
const {
|
|
268
|
+
verticalCells,
|
|
269
|
+
horizontalCells,
|
|
270
|
+
totalRowCount,
|
|
271
|
+
totalColumnCount
|
|
272
|
+
} = getSelectedCellInfo(tr.selection);
|
|
273
|
+
const isRowOrColumnSelected = horizontalCells === totalColumnCount || verticalCells === totalRowCount;
|
|
274
|
+
if (isRowOrColumnSelected && keysToTrapWhen.includes(event.key) && event.repeat) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
253
278
|
const isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((_ref = event.target || null) === null || _ref === void 0 ? void 0 : _ref.id);
|
|
254
279
|
const keysToTrap = ['Enter', ' '];
|
|
255
|
-
const keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
256
280
|
const {
|
|
257
281
|
isDragMenuOpen
|
|
258
282
|
} = getPluginState(view.state);
|
|
@@ -33,6 +33,13 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
33
33
|
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(getEditorContainerWidth), list);
|
|
34
34
|
if (dragAndDropEnabled) {
|
|
35
35
|
// Move row/column shortcuts
|
|
36
|
+
/**
|
|
37
|
+
* NOTE: If the keyboard shortcut for moving rows or columns is changed, we need to update the handleKeyDown function
|
|
38
|
+
* in packages/editor/editor-plugin-table/src/pm-plugins/drag-and-drop/plugin.ts
|
|
39
|
+
* to make sure the logic for holding the shortcut keys is valid
|
|
40
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
41
|
+
*/
|
|
42
|
+
|
|
36
43
|
bindKeymapWithCommand(moveRowDown.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', 1), list);
|
|
37
44
|
bindKeymapWithCommand(moveRowUp.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', -1), list);
|
|
38
45
|
bindKeymapWithCommand(moveColumnLeft.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-column', -1), list);
|
|
@@ -2,7 +2,7 @@ import { INPUT_METHOD, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
-
import { getCellsInRow } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { getCellsInRow, getSelectedCellInfo } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
7
7
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
8
8
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -234,9 +234,28 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
|
|
|
234
234
|
},
|
|
235
235
|
handleKeyDown: function handleKeyDown(view, event) {
|
|
236
236
|
var _ref8;
|
|
237
|
+
var tr = view.state.tr;
|
|
238
|
+
var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
239
|
+
|
|
240
|
+
/** fix for NCS spam update where the user is holding down the move column / row keyboard shortcut
|
|
241
|
+
* if the user is holding down shortcut (ctrl + shift + alt + arrowKey), we want to move the selection only once
|
|
242
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
// Do early check for the keys we want to trap here so we can abort early
|
|
246
|
+
if (event.ctrlKey && event.shiftKey && event.altKey) {
|
|
247
|
+
var _getSelectedCellInfo = getSelectedCellInfo(tr.selection),
|
|
248
|
+
verticalCells = _getSelectedCellInfo.verticalCells,
|
|
249
|
+
horizontalCells = _getSelectedCellInfo.horizontalCells,
|
|
250
|
+
totalRowCount = _getSelectedCellInfo.totalRowCount,
|
|
251
|
+
totalColumnCount = _getSelectedCellInfo.totalColumnCount;
|
|
252
|
+
var isRowOrColumnSelected = horizontalCells === totalColumnCount || verticalCells === totalRowCount;
|
|
253
|
+
if (isRowOrColumnSelected && keysToTrapWhen.includes(event.key) && event.repeat) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
237
257
|
var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((_ref8 = event.target || null) === null || _ref8 === void 0 ? void 0 : _ref8.id);
|
|
238
258
|
var keysToTrap = ['Enter', ' '];
|
|
239
|
-
var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
240
259
|
var _getPluginState3 = getPluginState(view.state),
|
|
241
260
|
isDragMenuOpen = _getPluginState3.isDragMenuOpen;
|
|
242
261
|
|
|
@@ -35,6 +35,13 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
|
|
|
35
35
|
bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(getEditorContainerWidth), list);
|
|
36
36
|
if (dragAndDropEnabled) {
|
|
37
37
|
// Move row/column shortcuts
|
|
38
|
+
/**
|
|
39
|
+
* NOTE: If the keyboard shortcut for moving rows or columns is changed, we need to update the handleKeyDown function
|
|
40
|
+
* in packages/editor/editor-plugin-table/src/pm-plugins/drag-and-drop/plugin.ts
|
|
41
|
+
* to make sure the logic for holding the shortcut keys is valid
|
|
42
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
43
|
+
*/
|
|
44
|
+
|
|
38
45
|
bindKeymapWithCommand(moveRowDown.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', 1), list);
|
|
39
46
|
bindKeymapWithCommand(moveRowUp.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', -1), list);
|
|
40
47
|
bindKeymapWithCommand(moveColumnLeft.common, moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-column', -1), list);
|
package/package.json
CHANGED
|
@@ -8,7 +8,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
8
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getCellsInRow,
|
|
13
|
+
getSelectedCellInfo,
|
|
14
|
+
} from '@atlaskit/editor-tables/utils';
|
|
12
15
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
13
16
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
14
17
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -313,17 +316,49 @@ export const createPlugin = (
|
|
|
313
316
|
return decorationSet;
|
|
314
317
|
},
|
|
315
318
|
handleKeyDown: (view, event) => {
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const keysToTrap = ['Enter', ' '];
|
|
319
|
+
const {
|
|
320
|
+
state: { tr },
|
|
321
|
+
} = view;
|
|
322
|
+
|
|
321
323
|
const keysToTrapWhen = [
|
|
322
324
|
'ArrowUp',
|
|
323
325
|
'ArrowDown',
|
|
324
326
|
'ArrowLeft',
|
|
325
327
|
'ArrowRight',
|
|
326
328
|
];
|
|
329
|
+
|
|
330
|
+
/** fix for NCS spam update where the user is holding down the move column / row keyboard shortcut
|
|
331
|
+
* if the user is holding down shortcut (ctrl + shift + alt + arrowKey), we want to move the selection only once
|
|
332
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
// Do early check for the keys we want to trap here so we can abort early
|
|
336
|
+
if (event.ctrlKey && event.shiftKey && event.altKey) {
|
|
337
|
+
const {
|
|
338
|
+
verticalCells,
|
|
339
|
+
horizontalCells,
|
|
340
|
+
totalRowCount,
|
|
341
|
+
totalColumnCount,
|
|
342
|
+
} = getSelectedCellInfo(tr.selection);
|
|
343
|
+
|
|
344
|
+
const isRowOrColumnSelected =
|
|
345
|
+
horizontalCells === totalColumnCount ||
|
|
346
|
+
verticalCells === totalRowCount;
|
|
347
|
+
if (
|
|
348
|
+
isRowOrColumnSelected &&
|
|
349
|
+
keysToTrapWhen.includes(event.key) &&
|
|
350
|
+
event.repeat
|
|
351
|
+
) {
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const isDragHandleFocused = [
|
|
357
|
+
'drag-handle-button-row',
|
|
358
|
+
'drag-handle-button-column',
|
|
359
|
+
].includes(((event.target as HTMLElement) || null)?.id);
|
|
360
|
+
const keysToTrap = ['Enter', ' '];
|
|
361
|
+
|
|
327
362
|
const { isDragMenuOpen } = getPluginState(view.state);
|
|
328
363
|
|
|
329
364
|
// drag handle is focused, and user presses any key return them back to editing
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -129,6 +129,13 @@ export function keymapPlugin(
|
|
|
129
129
|
|
|
130
130
|
if (dragAndDropEnabled) {
|
|
131
131
|
// Move row/column shortcuts
|
|
132
|
+
/**
|
|
133
|
+
* NOTE: If the keyboard shortcut for moving rows or columns is changed, we need to update the handleKeyDown function
|
|
134
|
+
* in packages/editor/editor-plugin-table/src/pm-plugins/drag-and-drop/plugin.ts
|
|
135
|
+
* to make sure the logic for holding the shortcut keys is valid
|
|
136
|
+
* See ticket ED-22154 https://product-fabric.atlassian.net/browse/ED-22154
|
|
137
|
+
*/
|
|
138
|
+
|
|
132
139
|
bindKeymapWithCommand(
|
|
133
140
|
moveRowDown.common!,
|
|
134
141
|
moveSourceWithAnalyticsViaShortcut(editorAnalyticsAPI)('table-row', 1),
|