@atlaskit/editor-plugin-table 7.2.3 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/commands/column-resize.js +115 -45
- package/dist/cjs/commands/go-to-next-cell.js +7 -11
- package/dist/cjs/commands/misc.js +7 -4
- package/dist/cjs/commands/selection.js +7 -5
- package/dist/cjs/event-handlers.js +38 -25
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -1
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +33 -1
- package/dist/cjs/pm-plugins/drag-and-drop/reducer.js +2 -1
- package/dist/cjs/pm-plugins/keymap.js +1 -0
- package/dist/cjs/pm-plugins/main.js +43 -9
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +37 -7
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +20 -6
- package/dist/cjs/pm-plugins/table-selection-keymap.js +2 -2
- package/dist/cjs/reducer.js +5 -2
- package/dist/cjs/ui/DragHandle/HandleIconComponent.js +1 -3
- package/dist/cjs/ui/DragHandle/index.js +22 -10
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +75 -33
- package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +123 -0
- package/dist/cjs/ui/FloatingDragMenu/index.js +2 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +24 -35
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +1 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +4 -0
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +26 -33
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/cjs/ui/consts.js +3 -2
- package/dist/es2019/commands/column-resize.js +100 -35
- package/dist/es2019/commands/go-to-next-cell.js +7 -9
- package/dist/es2019/commands/misc.js +7 -6
- package/dist/es2019/commands/selection.js +9 -9
- package/dist/es2019/event-handlers.js +17 -3
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +3 -3
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +34 -1
- package/dist/es2019/pm-plugins/drag-and-drop/reducer.js +2 -1
- package/dist/es2019/pm-plugins/keymap.js +3 -2
- package/dist/es2019/pm-plugins/main.js +41 -5
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +37 -4
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +16 -1
- package/dist/es2019/pm-plugins/table-selection-keymap.js +2 -2
- package/dist/es2019/reducer.js +5 -2
- package/dist/es2019/ui/DragHandle/HandleIconComponent.js +1 -3
- package/dist/es2019/ui/DragHandle/index.js +25 -10
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +72 -32
- package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +109 -0
- package/dist/es2019/ui/FloatingDragMenu/index.js +2 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +24 -35
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +1 -2
- package/dist/es2019/ui/TableFloatingControls/CornerControls/DragCornerControls.js +4 -0
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +26 -33
- package/dist/es2019/ui/common-styles.js +11 -1
- package/dist/es2019/ui/consts.js +2 -1
- package/dist/esm/commands/column-resize.js +105 -35
- package/dist/esm/commands/go-to-next-cell.js +7 -11
- package/dist/esm/commands/misc.js +7 -4
- package/dist/esm/commands/selection.js +9 -7
- package/dist/esm/event-handlers.js +38 -25
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -2
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +33 -1
- package/dist/esm/pm-plugins/drag-and-drop/reducer.js +2 -1
- package/dist/esm/pm-plugins/keymap.js +3 -2
- package/dist/esm/pm-plugins/main.js +38 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +34 -4
- package/dist/esm/pm-plugins/table-resizing/plugin.js +15 -1
- package/dist/esm/pm-plugins/table-selection-keymap.js +2 -2
- package/dist/esm/reducer.js +5 -2
- package/dist/esm/ui/DragHandle/HandleIconComponent.js +1 -3
- package/dist/esm/ui/DragHandle/index.js +21 -9
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +74 -35
- package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +116 -0
- package/dist/esm/ui/FloatingDragMenu/index.js +2 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +24 -35
- package/dist/esm/ui/TableFloatingColumnControls/index.js +1 -2
- package/dist/esm/ui/TableFloatingControls/CornerControls/DragCornerControls.js +4 -0
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +26 -33
- package/dist/esm/ui/common-styles.js +1 -1
- package/dist/esm/ui/consts.js +2 -1
- package/dist/types/commands/column-resize.d.ts +2 -0
- package/dist/types/commands/misc.d.ts +3 -3
- package/dist/types/commands/selection.d.ts +2 -2
- package/dist/types/pm-plugins/drag-and-drop/actions.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types/pm-plugins/drag-and-drop/types.d.ts +2 -0
- package/dist/types/types.d.ts +16 -0
- package/dist/types/ui/DragHandle/HandleIconComponent.d.ts +1 -2
- package/dist/types/ui/DragHandle/index.d.ts +3 -2
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +7 -8
- package/dist/types/ui/FloatingDragMenu/DropdownMenu.d.ts +30 -0
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/commands/column-resize.d.ts +2 -0
- package/dist/types-ts4.5/commands/misc.d.ts +3 -3
- package/dist/types-ts4.5/commands/selection.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/actions.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/types.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +16 -0
- package/dist/types-ts4.5/ui/DragHandle/HandleIconComponent.d.ts +1 -2
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +7 -8
- package/dist/types-ts4.5/ui/FloatingDragMenu/DropdownMenu.d.ts +30 -0
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
- package/dist/types-ts4.5/ui/consts.d.ts +1 -0
- package/package.json +4 -3
- package/src/commands/column-resize.ts +155 -40
- package/src/commands/go-to-next-cell.ts +6 -15
- package/src/commands/misc.ts +19 -4
- package/src/commands/selection.ts +17 -9
- package/src/event-handlers.ts +21 -4
- package/src/pm-plugins/drag-and-drop/actions.ts +1 -0
- package/src/pm-plugins/drag-and-drop/commands.ts +3 -0
- package/src/pm-plugins/drag-and-drop/plugin.ts +47 -0
- package/src/pm-plugins/drag-and-drop/reducer.ts +1 -0
- package/src/pm-plugins/drag-and-drop/types.ts +3 -0
- package/src/pm-plugins/keymap.ts +3 -0
- package/src/pm-plugins/main.ts +47 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +33 -5
- package/src/pm-plugins/table-resizing/plugin.ts +18 -1
- package/src/pm-plugins/table-selection-keymap.ts +2 -2
- package/src/reducer.ts +5 -2
- package/src/types.ts +16 -0
- package/src/ui/DragHandle/HandleIconComponent.tsx +2 -9
- package/src/ui/DragHandle/index.tsx +37 -16
- package/src/ui/FloatingDragMenu/DragMenu.tsx +362 -310
- package/src/ui/FloatingDragMenu/DropdownMenu.tsx +150 -0
- package/src/ui/FloatingDragMenu/index.tsx +3 -3
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +72 -91
- package/src/ui/TableFloatingColumnControls/index.tsx +1 -2
- package/src/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +5 -0
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +89 -104
- package/src/ui/common-styles.ts +11 -1
- package/src/ui/consts.ts +1 -0
- package/tsconfig.app.json +3 -0
package/src/pm-plugins/main.ts
CHANGED
|
@@ -38,12 +38,16 @@ import {
|
|
|
38
38
|
findParentNodeOfType,
|
|
39
39
|
} from '@atlaskit/editor-prosemirror/utils';
|
|
40
40
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
41
|
+
import { TableMap } from '@atlaskit/editor-tables';
|
|
42
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
43
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
41
44
|
|
|
42
45
|
import {
|
|
43
46
|
addBoldInEmptyHeaderCells,
|
|
44
47
|
clearHoverSelection,
|
|
45
48
|
setTableRef,
|
|
46
49
|
} from '../commands';
|
|
50
|
+
import { stopKeyboardColumnResizing } from '../commands/column-resize';
|
|
47
51
|
import {
|
|
48
52
|
removeResizeHandleDecorations,
|
|
49
53
|
transformSliceRemoveCellBackgroundColor,
|
|
@@ -202,7 +206,7 @@ export const createPlugin = (
|
|
|
202
206
|
editorViewRef = editorView;
|
|
203
207
|
|
|
204
208
|
return {
|
|
205
|
-
update: (view: EditorView) => {
|
|
209
|
+
update: (view: EditorView, prevState: EditorState) => {
|
|
206
210
|
const { state, dispatch } = view;
|
|
207
211
|
const { selection } = state;
|
|
208
212
|
const pluginState = getPluginState(state);
|
|
@@ -218,6 +222,39 @@ export const createPlugin = (
|
|
|
218
222
|
'table',
|
|
219
223
|
) || undefined;
|
|
220
224
|
}
|
|
225
|
+
const tableNode = findTable(state.selection);
|
|
226
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
227
|
+
// when cursor leaves the table we need to stop column resizing
|
|
228
|
+
const pluginPrevState = getPluginState(prevState);
|
|
229
|
+
const isStopKeyboardColumResizing =
|
|
230
|
+
pluginPrevState.isResizeHandleWidgetAdded &&
|
|
231
|
+
pluginPrevState.isKeyboardResize;
|
|
232
|
+
if (isStopKeyboardColumResizing) {
|
|
233
|
+
const isTableNodesDifferent =
|
|
234
|
+
pluginPrevState?.tableNode !== tableNode?.node;
|
|
235
|
+
if (
|
|
236
|
+
pluginPrevState?.tableNode &&
|
|
237
|
+
tableNode &&
|
|
238
|
+
isTableNodesDifferent
|
|
239
|
+
) {
|
|
240
|
+
const oldRowsNumber = TableMap.get(
|
|
241
|
+
pluginPrevState.tableNode,
|
|
242
|
+
).height;
|
|
243
|
+
const newRowsNumber = TableMap.get(tableNode.node).height;
|
|
244
|
+
if (
|
|
245
|
+
oldRowsNumber !== newRowsNumber || // Add/delete row
|
|
246
|
+
tableNode.node.attrs.localId !==
|
|
247
|
+
pluginPrevState.tableNode.attrs.localId
|
|
248
|
+
) {
|
|
249
|
+
// Jump to another table
|
|
250
|
+
stopKeyboardColumnResizing()(state, dispatch);
|
|
251
|
+
}
|
|
252
|
+
} else if (!tableNode) {
|
|
253
|
+
// selection outside of table
|
|
254
|
+
stopKeyboardColumnResizing()(state, dispatch);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
221
258
|
}
|
|
222
259
|
|
|
223
260
|
if (pluginState.tableRef !== tableRef) {
|
|
@@ -333,7 +370,15 @@ export const createPlugin = (
|
|
|
333
370
|
const maybeTr = closestElement(domRef as HTMLElement | undefined, 'tr');
|
|
334
371
|
return maybeTr ? maybeTr.classList.contains('sticky') : false;
|
|
335
372
|
},
|
|
336
|
-
handleTextInput: (
|
|
373
|
+
handleTextInput: (view, _from, _to, text) => {
|
|
374
|
+
const { state, dispatch } = view;
|
|
375
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
376
|
+
const { isKeyboardResize } = getPluginState(state);
|
|
377
|
+
if (isKeyboardResize) {
|
|
378
|
+
stopKeyboardColumnResizing()(state, dispatch);
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
337
382
|
const tr = replaceSelectedTable(
|
|
338
383
|
state,
|
|
339
384
|
text,
|
|
@@ -18,9 +18,11 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
18
18
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
19
19
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
20
20
|
|
|
21
|
+
import { stopKeyboardColumnResizing } from '../../commands/column-resize';
|
|
21
22
|
import { updateResizeHandleDecorations } from '../../commands/misc';
|
|
22
23
|
import { updateColumnWidths } from '../../transforms';
|
|
23
24
|
import { getSelectedColumnIndexes } from '../../utils';
|
|
25
|
+
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
24
26
|
import { META_KEYS } from '../table-analytics';
|
|
25
27
|
|
|
26
28
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
@@ -54,6 +56,7 @@ export const handleMouseDown = (
|
|
|
54
56
|
) {
|
|
55
57
|
return false;
|
|
56
58
|
}
|
|
59
|
+
const { isKeyboardResize } = getTablePluginState(state);
|
|
57
60
|
event.preventDefault();
|
|
58
61
|
|
|
59
62
|
const tr = view.state.tr;
|
|
@@ -147,6 +150,7 @@ export const handleMouseDown = (
|
|
|
147
150
|
const { clientX } = event;
|
|
148
151
|
const { state, dispatch } = view;
|
|
149
152
|
const { dragging, resizeHandlePos } = getPluginState(state);
|
|
153
|
+
const { isTableHovered } = getTablePluginState(state);
|
|
150
154
|
if (resizeHandlePos === null) {
|
|
151
155
|
return stopResizing()(state, dispatch);
|
|
152
156
|
}
|
|
@@ -160,9 +164,20 @@ export const handleMouseDown = (
|
|
|
160
164
|
const start = $cell.start(-1);
|
|
161
165
|
const table = $cell.node(-1);
|
|
162
166
|
|
|
163
|
-
// If we let go in the same place we started,
|
|
167
|
+
// If we let go in the same place we started, don't need to do anything.
|
|
164
168
|
if (dragging && clientX === dragging.startX) {
|
|
165
|
-
|
|
169
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
170
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
171
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
172
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
173
|
+
*/
|
|
174
|
+
return stopKeyboardColumnResizing()(state, dispatch, view);
|
|
175
|
+
} else {
|
|
176
|
+
return stopResizing()(state, dispatch);
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
return stopResizing()(state, dispatch);
|
|
180
|
+
}
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
let { tr } = state;
|
|
@@ -211,8 +226,18 @@ export const handleMouseDown = (
|
|
|
211
226
|
})(tr);
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
|
-
|
|
215
|
-
|
|
229
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
230
|
+
if (isKeyboardResize || !isTableHovered) {
|
|
231
|
+
/** if column resize had started via keyboard but continued by mouse
|
|
232
|
+
* or mouse pointer leaves the table but mouse button still pressed
|
|
233
|
+
*/
|
|
234
|
+
return stopKeyboardColumnResizing(tr)(state, dispatch, view);
|
|
235
|
+
} else {
|
|
236
|
+
return stopResizing(tr)(state, dispatch);
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
return stopResizing(tr)(state, dispatch);
|
|
240
|
+
}
|
|
216
241
|
}
|
|
217
242
|
}
|
|
218
243
|
|
|
@@ -220,11 +245,14 @@ export const handleMouseDown = (
|
|
|
220
245
|
const { clientX, which } = event;
|
|
221
246
|
const { state } = view;
|
|
222
247
|
const { dragging, resizeHandlePos } = getPluginState(state);
|
|
248
|
+
const { isTableHovered } = getTablePluginState(state);
|
|
223
249
|
if (
|
|
224
250
|
!which ||
|
|
225
251
|
!dragging ||
|
|
226
252
|
resizeHandlePos === null ||
|
|
227
|
-
!pointsAtCell(state.doc.resolve(resizeHandlePos))
|
|
253
|
+
!pointsAtCell(state.doc.resolve(resizeHandlePos)) ||
|
|
254
|
+
(!isTableHovered &&
|
|
255
|
+
getBooleanFF('platform.editor.a11y-column-resizing_emcvz'))
|
|
228
256
|
) {
|
|
229
257
|
return finish(event);
|
|
230
258
|
}
|
|
@@ -7,9 +7,11 @@ import type {
|
|
|
7
7
|
GetEditorContainerWidth,
|
|
8
8
|
GetEditorFeatureFlags,
|
|
9
9
|
} from '@atlaskit/editor-common/types';
|
|
10
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
|
|
11
12
|
import { TableCssClassName as ClassName } from '../../types';
|
|
12
13
|
import type { ColumnResizingPluginState } from '../../types';
|
|
14
|
+
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
13
15
|
|
|
14
16
|
import { setResizeHandlePos } from './commands';
|
|
15
17
|
import { handleMouseDown } from './event-handlers';
|
|
@@ -54,7 +56,22 @@ export function createPlugin(
|
|
|
54
56
|
getResizeCellPos(view, event as MouseEvent);
|
|
55
57
|
|
|
56
58
|
const { dragging } = getPluginState(state);
|
|
57
|
-
|
|
59
|
+
let isColumnKeyboardResizeStarted = false;
|
|
60
|
+
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
61
|
+
/*
|
|
62
|
+
We need to start listening mouse events if column resize started from keyboard.
|
|
63
|
+
This will allow continue resizing via mouse
|
|
64
|
+
*/
|
|
65
|
+
const { isKeyboardResize } = getTablePluginState(state);
|
|
66
|
+
if (isKeyboardResize) {
|
|
67
|
+
isColumnKeyboardResizeStarted = isKeyboardResize;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (
|
|
72
|
+
resizeHandlePos !== null &&
|
|
73
|
+
(!dragging || isColumnKeyboardResizeStarted)
|
|
74
|
+
) {
|
|
58
75
|
if (
|
|
59
76
|
handleMouseDown(
|
|
60
77
|
view,
|
|
@@ -43,13 +43,13 @@ export function tableSelectionKeymapPlugin(
|
|
|
43
43
|
if (getBooleanFF('platform.editor.a11y.table-selection_9uv33')) {
|
|
44
44
|
bindKeymapArrayWithCommand(
|
|
45
45
|
selectColumn,
|
|
46
|
-
selectColumns(editorSelectionAPI)(),
|
|
46
|
+
selectColumns(editorSelectionAPI)(true),
|
|
47
47
|
list,
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
bindKeymapArrayWithCommand(
|
|
51
51
|
selectRow,
|
|
52
|
-
selectRows(editorSelectionAPI)(),
|
|
52
|
+
selectRows(editorSelectionAPI)(true),
|
|
53
53
|
list,
|
|
54
54
|
);
|
|
55
55
|
}
|
package/src/reducer.ts
CHANGED
|
@@ -82,14 +82,15 @@ export default (
|
|
|
82
82
|
resizeHandleColumnIndex: undefined,
|
|
83
83
|
resizeHandleRowIndex: undefined,
|
|
84
84
|
};
|
|
85
|
-
|
|
85
|
+
case 'START_KEYBOARD_COLUMN_RESIZE':
|
|
86
86
|
case 'ADD_RESIZE_HANDLE_DECORATIONS':
|
|
87
87
|
if (
|
|
88
88
|
action.data.resizeHandleColumnIndex ===
|
|
89
89
|
pluginState.resizeHandleColumnIndex &&
|
|
90
90
|
action.data.resizeHandleRowIndex === pluginState.resizeHandleRowIndex &&
|
|
91
91
|
action.data.resizeHandleIncludeTooltip ===
|
|
92
|
-
pluginState.resizeHandleIncludeTooltip
|
|
92
|
+
pluginState.resizeHandleIncludeTooltip &&
|
|
93
|
+
action.data.isKeyboardResize === pluginState.isKeyboardResize
|
|
93
94
|
) {
|
|
94
95
|
return pluginState;
|
|
95
96
|
}
|
|
@@ -128,6 +129,7 @@ export default (
|
|
|
128
129
|
resizeHandleIncludeTooltip ?? pluginState.resizeHandleIncludeTooltip,
|
|
129
130
|
};
|
|
130
131
|
|
|
132
|
+
case 'STOP_KEYBOARD_COLUMN_RESIZE':
|
|
131
133
|
case 'REMOVE_RESIZE_HANDLE_DECORATIONS':
|
|
132
134
|
if (!pluginState.isResizeHandleWidgetAdded) {
|
|
133
135
|
return pluginState;
|
|
@@ -139,6 +141,7 @@ export default (
|
|
|
139
141
|
resizeHandleColumnIndex: undefined,
|
|
140
142
|
resizeHandleRowIndex: undefined,
|
|
141
143
|
isResizeHandleWidgetAdded: false,
|
|
144
|
+
isKeyboardResize: undefined,
|
|
142
145
|
};
|
|
143
146
|
|
|
144
147
|
case 'SET_TABLE_REF':
|
package/src/types.ts
CHANGED
|
@@ -119,6 +119,7 @@ export interface TablePluginState {
|
|
|
119
119
|
resizeHandleRowIndex?: number;
|
|
120
120
|
resizeHandleColumnIndex?: number;
|
|
121
121
|
resizeHandleIncludeTooltip?: boolean;
|
|
122
|
+
isKeyboardResize?: boolean;
|
|
122
123
|
// for table wrap/collapse
|
|
123
124
|
isTableCollapsed?: boolean; // is the current table already in an expand?
|
|
124
125
|
canCollapseTable?: boolean; // enabled/disabled state of collapse option
|
|
@@ -179,6 +180,16 @@ export type TablePluginAction =
|
|
|
179
180
|
isInDanger?: boolean;
|
|
180
181
|
};
|
|
181
182
|
}
|
|
183
|
+
| {
|
|
184
|
+
type: 'START_KEYBOARD_COLUMN_RESIZE';
|
|
185
|
+
data: {
|
|
186
|
+
decorationSet: DecorationSet;
|
|
187
|
+
resizeHandleRowIndex: number;
|
|
188
|
+
resizeHandleColumnIndex: number;
|
|
189
|
+
resizeHandleIncludeTooltip: boolean;
|
|
190
|
+
isKeyboardResize?: boolean;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
182
193
|
| {
|
|
183
194
|
type: 'ADD_RESIZE_HANDLE_DECORATIONS';
|
|
184
195
|
data: {
|
|
@@ -186,6 +197,7 @@ export type TablePluginAction =
|
|
|
186
197
|
resizeHandleRowIndex: number;
|
|
187
198
|
resizeHandleColumnIndex: number;
|
|
188
199
|
resizeHandleIncludeTooltip: boolean;
|
|
200
|
+
isKeyboardResize?: boolean;
|
|
189
201
|
};
|
|
190
202
|
}
|
|
191
203
|
| {
|
|
@@ -201,6 +213,10 @@ export type TablePluginAction =
|
|
|
201
213
|
type: 'REMOVE_RESIZE_HANDLE_DECORATIONS';
|
|
202
214
|
data: { decorationSet: DecorationSet };
|
|
203
215
|
}
|
|
216
|
+
| {
|
|
217
|
+
type: 'STOP_KEYBOARD_COLUMN_RESIZE';
|
|
218
|
+
data: { decorationSet: DecorationSet };
|
|
219
|
+
}
|
|
204
220
|
| { type: 'CLEAR_HOVER_SELECTION'; data: { decorationSet: DecorationSet } }
|
|
205
221
|
| { type: 'SHOW_RESIZE_HANDLE_LINE'; data: { decorationSet: DecorationSet } }
|
|
206
222
|
| { type: 'HIDE_RESIZE_HANDLE_LINE'; data: { decorationSet: DecorationSet } }
|
|
@@ -8,19 +8,12 @@ import {
|
|
|
8
8
|
|
|
9
9
|
type HandleIconProps = {
|
|
10
10
|
forceDefaultHandle: boolean;
|
|
11
|
-
|
|
12
|
-
isColumnHandleHovered: boolean;
|
|
11
|
+
isHandleHovered: boolean;
|
|
13
12
|
hasMergedCells: boolean;
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
export const HandleIconComponent = (props: HandleIconProps) => {
|
|
17
|
-
const {
|
|
18
|
-
forceDefaultHandle,
|
|
19
|
-
isRowHandleHovered,
|
|
20
|
-
isColumnHandleHovered,
|
|
21
|
-
hasMergedCells,
|
|
22
|
-
} = props;
|
|
23
|
-
const isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
16
|
+
const { forceDefaultHandle, isHandleHovered, hasMergedCells } = props;
|
|
24
17
|
|
|
25
18
|
if (isHandleHovered || forceDefaultHandle) {
|
|
26
19
|
return hasMergedCells ? <DragHandleDisabledIcon /> : <DragHandleIcon />;
|
|
@@ -13,6 +13,8 @@ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
|
13
13
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
14
14
|
import { token } from '@atlaskit/tokens';
|
|
15
15
|
|
|
16
|
+
import { getPluginState as getDnDPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
17
|
+
import type { TriggerType } from '../../pm-plugins/drag-and-drop/types';
|
|
16
18
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
17
19
|
import type { TableDirection } from '../../types';
|
|
18
20
|
import { TableCssClassName as ClassName } from '../../types';
|
|
@@ -22,7 +24,12 @@ import { DragPreview } from '../DragPreview';
|
|
|
22
24
|
|
|
23
25
|
import { HandleIconComponent } from './HandleIconComponent';
|
|
24
26
|
|
|
25
|
-
type DragHandleAppearance =
|
|
27
|
+
export type DragHandleAppearance =
|
|
28
|
+
| 'default'
|
|
29
|
+
| 'selected'
|
|
30
|
+
| 'disabled'
|
|
31
|
+
| 'danger'
|
|
32
|
+
| 'placeholder';
|
|
26
33
|
|
|
27
34
|
type DragHandleProps = {
|
|
28
35
|
tableLocalId: string;
|
|
@@ -35,7 +42,10 @@ type DragHandleProps = {
|
|
|
35
42
|
onClick?: MouseEventHandler;
|
|
36
43
|
onMouseOver?: MouseEventHandler;
|
|
37
44
|
onMouseOut?: MouseEventHandler;
|
|
38
|
-
|
|
45
|
+
toggleDragMenu?: (
|
|
46
|
+
trigger: TriggerType,
|
|
47
|
+
event?: React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
|
48
|
+
) => void;
|
|
39
49
|
editorView: EditorView;
|
|
40
50
|
isDragMenuTarget: boolean; // this is identify which current handle component is
|
|
41
51
|
};
|
|
@@ -51,7 +61,7 @@ const DragHandleComponent = ({
|
|
|
51
61
|
previewHeight,
|
|
52
62
|
onMouseOver,
|
|
53
63
|
onMouseOut,
|
|
54
|
-
|
|
64
|
+
toggleDragMenu,
|
|
55
65
|
onClick,
|
|
56
66
|
editorView,
|
|
57
67
|
intl: { formatMessage },
|
|
@@ -60,10 +70,13 @@ const DragHandleComponent = ({
|
|
|
60
70
|
const [previewContainer, setPreviewContainer] = useState<HTMLElement | null>(
|
|
61
71
|
null,
|
|
62
72
|
);
|
|
73
|
+
const {
|
|
74
|
+
state,
|
|
75
|
+
state: { selection },
|
|
76
|
+
} = editorView;
|
|
77
|
+
const { hoveredColumns, hoveredRows } = getPluginState(state);
|
|
78
|
+
const { isDragMenuOpen } = getDnDPluginState(state);
|
|
63
79
|
|
|
64
|
-
const { hoveredColumns, hoveredRows } = getPluginState(editorView.state);
|
|
65
|
-
|
|
66
|
-
const { selection } = editorView.state;
|
|
67
80
|
const isRow = direction === 'row';
|
|
68
81
|
const isColumn = direction === 'column';
|
|
69
82
|
|
|
@@ -80,8 +93,7 @@ const DragHandleComponent = ({
|
|
|
80
93
|
|
|
81
94
|
const handleIconProps = {
|
|
82
95
|
forceDefaultHandle,
|
|
83
|
-
isColumnHandleHovered,
|
|
84
|
-
isRowHandleHovered,
|
|
96
|
+
isHandleHovered: isColumnHandleHovered || isRowHandleHovered,
|
|
85
97
|
hasMergedCells,
|
|
86
98
|
};
|
|
87
99
|
|
|
@@ -179,24 +191,33 @@ const DragHandleComponent = ({
|
|
|
179
191
|
aria-label={formatMessage(
|
|
180
192
|
isRow ? messages.rowDragHandle : messages.columnDragHandle,
|
|
181
193
|
)}
|
|
194
|
+
aria-expanded={isDragMenuOpen && isDragMenuTarget ? 'true' : 'false'}
|
|
195
|
+
aria-haspopup="menu"
|
|
182
196
|
onMouseOver={onMouseOver}
|
|
183
197
|
onMouseOut={onMouseOut}
|
|
184
198
|
onMouseUp={(e) => {
|
|
185
199
|
// return focus to editor so copying table selections whilst still works, i cannot call e.preventDefault in a mousemove event as this stops dragstart events from firing
|
|
186
200
|
// -> this is bad for a11y but is the current standard new copy/paste keyboard shortcuts should be introduced instead
|
|
187
201
|
editorView.focus();
|
|
188
|
-
|
|
202
|
+
toggleDragMenu && toggleDragMenu('mouse', e);
|
|
189
203
|
}}
|
|
190
204
|
onClick={onClick}
|
|
205
|
+
onKeyDown={(e) => {
|
|
206
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
207
|
+
toggleDragMenu && toggleDragMenu('keyboard');
|
|
208
|
+
}
|
|
209
|
+
}}
|
|
191
210
|
>
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
) : (
|
|
196
|
-
<span style={{ pointerEvents: 'none' }}>
|
|
211
|
+
{appearance !== 'placeholder' ? (
|
|
212
|
+
// cannot block pointer events in Firefox as it breaks Dragging functionality
|
|
213
|
+
browser.gecko ? (
|
|
197
214
|
<HandleIconComponent {...handleIconProps} />
|
|
198
|
-
|
|
199
|
-
|
|
215
|
+
) : (
|
|
216
|
+
<span style={{ pointerEvents: 'none' }}>
|
|
217
|
+
<HandleIconComponent {...handleIconProps} />
|
|
218
|
+
</span>
|
|
219
|
+
)
|
|
220
|
+
) : null}
|
|
200
221
|
</button>
|
|
201
222
|
{previewContainer &&
|
|
202
223
|
previewWidth !== undefined &&
|