@atlaskit/editor-plugin-table 7.18.2 → 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 +16 -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/index.js +6 -0
- package/dist/cjs/commands/misc.js +15 -1
- package/dist/cjs/commands/selection.js +4 -11
- package/dist/cjs/event-handlers.js +7 -11
- package/dist/cjs/plugin.js +7 -4
- package/dist/cjs/pm-plugins/keymap.js +22 -21
- 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/cjs/reducer.js +1 -0
- package/dist/cjs/ui/FloatingContextualButton/index.js +18 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +170 -35
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/es2019/commands/column-resize.js +0 -12
- package/dist/es2019/commands/go-to-next-cell.js +8 -11
- package/dist/es2019/commands/index.js +1 -1
- package/dist/es2019/commands/misc.js +9 -1
- package/dist/es2019/commands/selection.js +4 -11
- package/dist/es2019/event-handlers.js +8 -12
- package/dist/es2019/plugin.js +7 -4
- package/dist/es2019/pm-plugins/keymap.js +24 -23
- 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/es2019/reducer.js +1 -0
- package/dist/es2019/ui/FloatingContextualButton/index.js +17 -2
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +159 -24
- package/dist/es2019/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/esm/commands/column-resize.js +0 -12
- package/dist/esm/commands/go-to-next-cell.js +8 -11
- package/dist/esm/commands/index.js +1 -1
- package/dist/esm/commands/misc.js +14 -0
- package/dist/esm/commands/selection.js +4 -11
- package/dist/esm/event-handlers.js +7 -11
- package/dist/esm/plugin.js +7 -4
- package/dist/esm/pm-plugins/keymap.js +24 -23
- 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/dist/esm/reducer.js +1 -0
- package/dist/esm/ui/FloatingContextualButton/index.js +15 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +171 -40
- package/dist/esm/ui/FloatingContextualMenu/index.js +4 -2
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/misc.d.ts +1 -0
- package/dist/types/types.d.ts +6 -0
- package/dist/types/ui/FloatingContextualButton/index.d.ts +1 -0
- package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +7 -3
- package/dist/types/ui/FloatingContextualMenu/index.d.ts +2 -1
- package/dist/types-ts4.5/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/commands/misc.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +6 -0
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +7 -3
- package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +2 -1
- package/package.json +4 -4
- package/src/commands/column-resize.ts +0 -14
- package/src/commands/go-to-next-cell.ts +7 -10
- package/src/commands/index.ts +1 -0
- package/src/commands/misc.ts +13 -0
- package/src/commands/selection.ts +4 -11
- package/src/event-handlers.ts +6 -12
- package/src/plugin.tsx +6 -1
- package/src/pm-plugins/keymap.ts +65 -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/reducer.ts +1 -0
- package/src/types.ts +8 -1
- package/src/ui/FloatingContextualButton/index.tsx +19 -1
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +207 -30
- package/src/ui/FloatingContextualMenu/index.tsx +3 -0
|
@@ -8,7 +8,6 @@ import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
|
8
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
9
|
import type { Direction } from '@atlaskit/editor-tables/types';
|
|
10
10
|
import { goToNextCell as baseGotoNextCell, findTable } from '@atlaskit/editor-tables/utils';
|
|
11
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
|
|
13
12
|
import { insertRowWithAnalytics } from '../commands-with-analytics';
|
|
14
13
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -31,15 +30,13 @@ export const goToNextCell =
|
|
|
31
30
|
return false;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
33
|
+
const isColumnResizing = getPluginState(state)?.isKeyboardResize;
|
|
34
|
+
if (isColumnResizing) {
|
|
35
|
+
stopKeyboardColumnResizing({
|
|
36
|
+
ariaNotify: ariaNotify,
|
|
37
|
+
getIntl: getIntl,
|
|
38
|
+
})(state, dispatch, view);
|
|
39
|
+
return true;
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
const map = TableMap.get(table.node);
|
package/src/commands/index.ts
CHANGED
package/src/commands/misc.ts
CHANGED
|
@@ -773,3 +773,16 @@ export const setTableAlignmentWithTableContentWithPos =
|
|
|
773
773
|
|
|
774
774
|
return tr;
|
|
775
775
|
};
|
|
776
|
+
|
|
777
|
+
export const setFocusToCellMenu = (isCellMenuOpenByKeyboard = true, originalTr?: Transaction) =>
|
|
778
|
+
createCommand(
|
|
779
|
+
() => {
|
|
780
|
+
return {
|
|
781
|
+
type: 'SET_CELL_MENU_OPEN',
|
|
782
|
+
data: {
|
|
783
|
+
isCellMenuOpenByKeyboard: isCellMenuOpenByKeyboard,
|
|
784
|
+
},
|
|
785
|
+
};
|
|
786
|
+
},
|
|
787
|
+
(tr) => (originalTr || tr).setMeta('addToHistory', false),
|
|
788
|
+
);
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
isTableSelected,
|
|
19
19
|
selectedRect,
|
|
20
20
|
} from '@atlaskit/editor-tables/utils';
|
|
21
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
22
21
|
|
|
23
22
|
import { selectColumn, selectRow } from '../commands/misc';
|
|
24
23
|
import type tablePlugin from '../plugin';
|
|
@@ -219,12 +218,9 @@ const arrowLeftFromText =
|
|
|
219
218
|
const table = findTable(selection);
|
|
220
219
|
if (table) {
|
|
221
220
|
const { $from } = selection;
|
|
222
|
-
let isColumnResizing = false;
|
|
223
221
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
isColumnResizing = Boolean(columResizePluginState?.isKeyboardResize);
|
|
227
|
-
}
|
|
222
|
+
const columResizePluginState = getPluginState(state) || {};
|
|
223
|
+
const isColumnResizing = Boolean(columResizePluginState?.isKeyboardResize);
|
|
228
224
|
|
|
229
225
|
if (
|
|
230
226
|
isSelectionAtStartOfTable($from, selection) &&
|
|
@@ -261,12 +257,9 @@ const arrowRightFromText =
|
|
|
261
257
|
const table = findTable(selection);
|
|
262
258
|
if (table) {
|
|
263
259
|
const { $to } = selection;
|
|
264
|
-
let isColumnResizing = false;
|
|
265
260
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
isColumnResizing = Boolean(columResizePluginState?.isKeyboardResize);
|
|
269
|
-
}
|
|
261
|
+
const columResizePluginState = getPluginState(state) || {};
|
|
262
|
+
const isColumnResizing = Boolean(columResizePluginState?.isKeyboardResize);
|
|
270
263
|
if (
|
|
271
264
|
isSelectionAtEndOfTable($to, selection) &&
|
|
272
265
|
$to.parent.type.name === 'paragraph' &&
|
package/src/event-handlers.ts
CHANGED
|
@@ -286,16 +286,12 @@ export const handleMouseOut = (view: EditorView, mouseEvent: Event): boolean =>
|
|
|
286
286
|
// we don't need to hide the resize handle decoration
|
|
287
287
|
if (isResizeHandleDecoration(target) && !isResizeHandleDecoration(relatedTarget)) {
|
|
288
288
|
const { state, dispatch } = view;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if
|
|
292
|
-
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
|
-
return hideResizeHandleLine()(state, dispatch);
|
|
296
|
-
} else {
|
|
297
|
-
return hideResizeHandleLine()(state, dispatch);
|
|
289
|
+
const { isKeyboardResize } = getPluginState(state);
|
|
290
|
+
if (isKeyboardResize) {
|
|
291
|
+
// no need to hide decoration if column resizing started by keyboard
|
|
292
|
+
return false;
|
|
298
293
|
}
|
|
294
|
+
return hideResizeHandleLine()(state, dispatch);
|
|
299
295
|
}
|
|
300
296
|
|
|
301
297
|
return false;
|
|
@@ -401,9 +397,7 @@ const handleMouseMoveDebounce = rafSchedule(
|
|
|
401
397
|
const { state, dispatch } = view;
|
|
402
398
|
const { resizeHandleColumnIndex, resizeHandleRowIndex } = getPluginState(state);
|
|
403
399
|
|
|
404
|
-
const isKeyboardResize =
|
|
405
|
-
? getPluginState(state).isKeyboardResize
|
|
406
|
-
: false;
|
|
400
|
+
const isKeyboardResize = getPluginState(state).isKeyboardResize;
|
|
407
401
|
const tableCell = closestElement(element, 'td, th') as HTMLTableCellElement;
|
|
408
402
|
const cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
409
403
|
const rect = findCellRectClosestToPos(state.doc.resolve(cellStartPosition));
|
package/src/plugin.tsx
CHANGED
|
@@ -514,6 +514,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
514
514
|
isHeaderRowEnabled,
|
|
515
515
|
isDragAndDropEnabled,
|
|
516
516
|
tableWrapperTarget,
|
|
517
|
+
isCellMenuOpenByKeyboard,
|
|
517
518
|
} = tablePluginState!;
|
|
518
519
|
|
|
519
520
|
const { allowControls } = pluginConfig;
|
|
@@ -525,7 +526,9 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
525
526
|
return (
|
|
526
527
|
<>
|
|
527
528
|
{targetCellPosition &&
|
|
528
|
-
tableRef
|
|
529
|
+
(tableRef ||
|
|
530
|
+
(getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c') &&
|
|
531
|
+
isCellMenuOpenByKeyboard)) &&
|
|
529
532
|
!isResizing &&
|
|
530
533
|
options &&
|
|
531
534
|
options.allowContextualMenu && (
|
|
@@ -540,6 +543,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
540
543
|
isContextualMenuOpen={isContextualMenuOpen}
|
|
541
544
|
stickyHeader={stickyHeader}
|
|
542
545
|
tableWrapper={tableWrapperTarget}
|
|
546
|
+
isCellMenuOpenByKeyboard={isCellMenuOpenByKeyboard}
|
|
543
547
|
/>
|
|
544
548
|
)}
|
|
545
549
|
{allowControls && (
|
|
@@ -578,6 +582,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
578
582
|
getEditorFeatureFlags={
|
|
579
583
|
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags
|
|
580
584
|
}
|
|
585
|
+
isCellMenuOpenByKeyboard={isCellMenuOpenByKeyboard}
|
|
581
586
|
/>
|
|
582
587
|
)}
|
|
583
588
|
{isDragAndDropEnabled && (
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
deleteColumn,
|
|
18
18
|
deleteRow,
|
|
19
19
|
escape,
|
|
20
|
+
focusToContextMenuTrigger,
|
|
20
21
|
increaseMediaSize,
|
|
21
22
|
moveColumnLeft,
|
|
22
23
|
moveColumnRight,
|
|
@@ -35,7 +36,7 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
|
35
36
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
36
37
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
37
38
|
|
|
38
|
-
import { goToNextCell, moveCursorBackward } from '../commands';
|
|
39
|
+
import { goToNextCell, moveCursorBackward, setFocusToCellMenu } from '../commands';
|
|
39
40
|
import {
|
|
40
41
|
addRowAroundSelection,
|
|
41
42
|
changeColumnWidthByStepWithAnalytics,
|
|
@@ -231,71 +232,73 @@ export function keymapPlugin(
|
|
|
231
232
|
);
|
|
232
233
|
}
|
|
233
234
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
);
|
|
235
|
+
bindKeymapWithCommand(
|
|
236
|
+
startColumnResizing.common!,
|
|
237
|
+
initiateKeyboardColumnResizing({
|
|
238
|
+
ariaNotify: ariaNotifyPlugin,
|
|
239
|
+
getIntl: getIntl,
|
|
240
|
+
}),
|
|
241
|
+
list,
|
|
242
|
+
);
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
244
|
+
bindKeymapWithCommand(
|
|
245
|
+
moveRight.common!,
|
|
246
|
+
activateNextResizeArea({
|
|
247
|
+
direction: 1,
|
|
248
|
+
ariaNotify: ariaNotifyPlugin,
|
|
249
|
+
getIntl: getIntl,
|
|
250
|
+
}),
|
|
251
|
+
list,
|
|
252
|
+
);
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
254
|
+
bindKeymapWithCommand(
|
|
255
|
+
moveLeft.common!,
|
|
256
|
+
activateNextResizeArea({
|
|
257
|
+
direction: -1,
|
|
258
|
+
ariaNotify: ariaNotifyPlugin,
|
|
259
|
+
getIntl: getIntl,
|
|
260
|
+
}),
|
|
261
|
+
list,
|
|
262
|
+
);
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
264
|
+
bindKeymapWithCommand(
|
|
265
|
+
decreaseMediaSize.common!,
|
|
266
|
+
changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(
|
|
267
|
+
-10,
|
|
268
|
+
getEditorContainerWidth,
|
|
269
|
+
isTableScalingEnabled,
|
|
270
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
271
|
+
INPUT_METHOD.SHORTCUT,
|
|
272
|
+
ariaNotifyPlugin,
|
|
273
|
+
getIntl,
|
|
274
|
+
),
|
|
275
|
+
list,
|
|
276
|
+
);
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
278
|
+
bindKeymapWithCommand(
|
|
279
|
+
increaseMediaSize.common!,
|
|
280
|
+
changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(
|
|
281
|
+
10,
|
|
282
|
+
getEditorContainerWidth,
|
|
283
|
+
isTableScalingEnabled,
|
|
284
|
+
isTableFixedColumnWidthsOptionEnabled,
|
|
285
|
+
INPUT_METHOD.SHORTCUT,
|
|
286
|
+
ariaNotifyPlugin,
|
|
287
|
+
getIntl,
|
|
288
|
+
),
|
|
289
|
+
list,
|
|
290
|
+
);
|
|
291
|
+
bindKeymapWithCommand(
|
|
292
|
+
escape.common!,
|
|
293
|
+
stopKeyboardColumnResizing({
|
|
294
|
+
ariaNotify: ariaNotifyPlugin,
|
|
295
|
+
getIntl: getIntl,
|
|
296
|
+
}),
|
|
297
|
+
list,
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
if (getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')) {
|
|
301
|
+
bindKeymapWithCommand(focusToContextMenuTrigger.common!, setFocusToCellMenu(), list);
|
|
299
302
|
}
|
|
300
303
|
|
|
301
304
|
return keymap(list) as SafePlugin;
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -193,33 +193,31 @@ export const createPlugin = (
|
|
|
193
193
|
(parent as HTMLElement).querySelector<HTMLTableElement>('table') || undefined;
|
|
194
194
|
}
|
|
195
195
|
const tableNode = findTable(state.selection);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
// Jump to another table
|
|
211
|
-
stopKeyboardColumnResizing({
|
|
212
|
-
ariaNotify: ariaNotifyPlugin,
|
|
213
|
-
getIntl: getIntl,
|
|
214
|
-
})(state, dispatch);
|
|
215
|
-
}
|
|
216
|
-
} else if (!tableNode) {
|
|
217
|
-
// selection outside of table
|
|
196
|
+
// when keyboard cursor leaves the table we need to stop column resizing
|
|
197
|
+
const pluginPrevState = getPluginState(prevState);
|
|
198
|
+
const isStopKeyboardColumResizing =
|
|
199
|
+
pluginPrevState.isResizeHandleWidgetAdded && pluginPrevState.isKeyboardResize;
|
|
200
|
+
if (isStopKeyboardColumResizing) {
|
|
201
|
+
const isTableNodesDifferent = pluginPrevState?.tableNode !== tableNode?.node;
|
|
202
|
+
if (pluginPrevState?.tableNode && tableNode && isTableNodesDifferent) {
|
|
203
|
+
const oldRowsNumber = TableMap.get(pluginPrevState.tableNode).height;
|
|
204
|
+
const newRowsNumber = TableMap.get(tableNode.node).height;
|
|
205
|
+
if (
|
|
206
|
+
oldRowsNumber !== newRowsNumber || // Add/delete row
|
|
207
|
+
tableNode.node.attrs.localId !== pluginPrevState.tableNode.attrs.localId
|
|
208
|
+
) {
|
|
209
|
+
// Jump to another table
|
|
218
210
|
stopKeyboardColumnResizing({
|
|
219
211
|
ariaNotify: ariaNotifyPlugin,
|
|
220
212
|
getIntl: getIntl,
|
|
221
213
|
})(state, dispatch);
|
|
222
214
|
}
|
|
215
|
+
} else if (!tableNode) {
|
|
216
|
+
// selection outside of table
|
|
217
|
+
stopKeyboardColumnResizing({
|
|
218
|
+
ariaNotify: ariaNotifyPlugin,
|
|
219
|
+
getIntl: getIntl,
|
|
220
|
+
})(state, dispatch);
|
|
223
221
|
}
|
|
224
222
|
}
|
|
225
223
|
}
|
|
@@ -337,15 +335,13 @@ export const createPlugin = (
|
|
|
337
335
|
},
|
|
338
336
|
handleTextInput: (view, _from, _to, text) => {
|
|
339
337
|
const { state, dispatch } = view;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
338
|
+
const { isKeyboardResize } = getPluginState(state);
|
|
339
|
+
if (isKeyboardResize) {
|
|
340
|
+
stopKeyboardColumnResizing({
|
|
341
|
+
ariaNotify: ariaNotifyPlugin,
|
|
342
|
+
getIntl: getIntl,
|
|
343
|
+
})(state, dispatch);
|
|
344
|
+
return false;
|
|
349
345
|
}
|
|
350
346
|
const tr = replaceSelectedTable(state, text, INPUT_METHOD.KEYBOARD, editorAnalyticsAPI);
|
|
351
347
|
if (tr.selectionSet) {
|
|
@@ -152,15 +152,11 @@ export const handleMouseDown = (
|
|
|
152
152
|
|
|
153
153
|
// If we let go in the same place we started, don't need to do anything.
|
|
154
154
|
if (dragging && clientX === dragging.startX) {
|
|
155
|
-
if (
|
|
156
|
-
if
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return stopKeyboardColumnResizing({})(state, dispatch, view);
|
|
161
|
-
} else {
|
|
162
|
-
return stopResizing()(state, dispatch);
|
|
163
|
-
}
|
|
155
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
156
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
157
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
158
|
+
*/
|
|
159
|
+
return stopKeyboardColumnResizing({})(state, dispatch, view);
|
|
164
160
|
} else {
|
|
165
161
|
return stopResizing()(state, dispatch);
|
|
166
162
|
}
|
|
@@ -255,15 +251,11 @@ export const handleMouseDown = (
|
|
|
255
251
|
},
|
|
256
252
|
})(tr);
|
|
257
253
|
}
|
|
258
|
-
if (
|
|
259
|
-
if
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return stopKeyboardColumnResizing({ originalTr: tr })(state, dispatch, view);
|
|
264
|
-
} else {
|
|
265
|
-
return stopResizing(tr)(state, dispatch);
|
|
266
|
-
}
|
|
254
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
255
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
256
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
257
|
+
*/
|
|
258
|
+
return stopKeyboardColumnResizing({ originalTr: tr })(state, dispatch, view);
|
|
267
259
|
} else {
|
|
268
260
|
return stopResizing(tr)(state, dispatch);
|
|
269
261
|
}
|
|
@@ -280,7 +272,7 @@ export const handleMouseDown = (
|
|
|
280
272
|
!dragging ||
|
|
281
273
|
resizeHandlePos === null ||
|
|
282
274
|
!pointsAtCell(state.doc.resolve(resizeHandlePos)) ||
|
|
283
|
-
|
|
275
|
+
!isTableHovered
|
|
284
276
|
) {
|
|
285
277
|
return finish(event);
|
|
286
278
|
}
|
|
@@ -4,7 +4,6 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
|
|
9
8
|
import { TableCssClassName as ClassName } from '../../types';
|
|
10
9
|
import type { ColumnResizingPluginState } from '../../types';
|
|
@@ -55,15 +54,13 @@ export function createPlugin(
|
|
|
55
54
|
|
|
56
55
|
const { dragging } = getPluginState(state);
|
|
57
56
|
let isColumnKeyboardResizeStarted = false;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
66
|
-
}
|
|
57
|
+
/*
|
|
58
|
+
We need to start listening mouse events if column resize started from keyboard.
|
|
59
|
+
This will allow continue resizing via mouse
|
|
60
|
+
*/
|
|
61
|
+
const { isKeyboardResize } = getTablePluginState(state);
|
|
62
|
+
if (isKeyboardResize) {
|
|
63
|
+
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
if (resizeHandlePos !== null && (!dragging || isColumnKeyboardResizeStarted)) {
|
package/src/reducer.ts
CHANGED
|
@@ -135,6 +135,7 @@ export default (pluginState: TablePluginState, action: TablePluginAction): Table
|
|
|
135
135
|
case 'HOVER_CELL':
|
|
136
136
|
case 'SHOW_RESIZE_HANDLE_LINE':
|
|
137
137
|
case 'SET_EDITOR_FOCUS':
|
|
138
|
+
case 'SET_CELL_MENU_OPEN':
|
|
138
139
|
return { ...pluginState, ...action.data };
|
|
139
140
|
|
|
140
141
|
default:
|
package/src/types.ts
CHANGED
|
@@ -178,6 +178,7 @@ export interface TablePluginState {
|
|
|
178
178
|
// use options.isTableScalingEnabled and avoid using pluginState.isTableScalingEnabled or
|
|
179
179
|
// const { isTableScalingEnabled } = getPluginState(state) for that purpose.
|
|
180
180
|
isTableScalingEnabled?: boolean;
|
|
181
|
+
isCellMenuOpenByKeyboard?: boolean;
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
export type TablePluginAction =
|
|
@@ -297,7 +298,13 @@ export type TablePluginAction =
|
|
|
297
298
|
| {
|
|
298
299
|
type: 'HIDE_INSERT_COLUMN_OR_ROW_BUTTON';
|
|
299
300
|
}
|
|
300
|
-
| { type: 'TOGGLE_CONTEXTUAL_MENU' }
|
|
301
|
+
| { type: 'TOGGLE_CONTEXTUAL_MENU' }
|
|
302
|
+
| {
|
|
303
|
+
type: 'SET_CELL_MENU_OPEN';
|
|
304
|
+
data: {
|
|
305
|
+
isCellMenuOpenByKeyboard: boolean;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
301
308
|
|
|
302
309
|
export type ColumnResizingPluginAction =
|
|
303
310
|
| {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
@@ -17,6 +17,7 @@ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
|
17
17
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
18
18
|
import { akEditorSmallZIndex } from '@atlaskit/editor-shared-styles';
|
|
19
19
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
20
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
20
21
|
|
|
21
22
|
import { toggleContextualMenu } from '../../commands';
|
|
22
23
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
@@ -37,6 +38,7 @@ export interface Props {
|
|
|
37
38
|
isNumberColumnEnabled?: boolean;
|
|
38
39
|
stickyHeader?: RowStickyState;
|
|
39
40
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
41
|
+
isCellMenuOpenByKeyboard?: boolean;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
const BUTTON_OFFSET = 3;
|
|
@@ -50,6 +52,7 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
|
|
|
50
52
|
stickyHeader,
|
|
51
53
|
tableWrapper,
|
|
52
54
|
targetCellPosition,
|
|
55
|
+
isCellMenuOpenByKeyboard,
|
|
53
56
|
intl: { formatMessage },
|
|
54
57
|
} = props; // : Props & WrappedComponentProps
|
|
55
58
|
|
|
@@ -69,6 +72,16 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
|
|
|
69
72
|
let targetCellRef: Node | undefined;
|
|
70
73
|
targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
|
|
71
74
|
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')) {
|
|
77
|
+
if (isCellMenuOpenByKeyboard && !isContextualMenuOpen) {
|
|
78
|
+
const { state, dispatch } = editorView;
|
|
79
|
+
// open the menu when the keyboard shortcut is pressed
|
|
80
|
+
toggleContextualMenu()(state, dispatch);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, [isCellMenuOpenByKeyboard, isContextualMenuOpen, editorView]);
|
|
84
|
+
|
|
72
85
|
if (!targetCellRef || !(targetCellRef instanceof HTMLElement)) {
|
|
73
86
|
return null;
|
|
74
87
|
}
|
|
@@ -92,6 +105,11 @@ const FloatingContextualButtonInner = React.memo((props: Props & WrappedComponen
|
|
|
92
105
|
onClick={handleClick}
|
|
93
106
|
iconBefore={<ExpandIcon label="" />}
|
|
94
107
|
aria-label={labelCellOptions}
|
|
108
|
+
aria-expanded={
|
|
109
|
+
getBooleanFF('platform.editor.a11y-table-context-menu_y4c9c')
|
|
110
|
+
? isContextualMenuOpen
|
|
111
|
+
: undefined
|
|
112
|
+
}
|
|
95
113
|
/>
|
|
96
114
|
</div>
|
|
97
115
|
);
|