@atlaskit/editor-plugin-table 7.6.4 → 7.6.6
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 +14 -0
- package/dist/cjs/commands/column-resize.js +62 -16
- package/dist/cjs/commands/go-to-next-cell.js +5 -2
- package/dist/cjs/commands-with-analytics.js +8 -2
- package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -0
- package/dist/cjs/nodeviews/TableComponent.js +8 -6
- package/dist/cjs/nodeviews/TableResizer.js +2 -1
- package/dist/cjs/plugin.js +58 -57
- package/dist/cjs/pm-plugins/keymap.js +26 -8
- package/dist/cjs/pm-plugins/main.js +15 -4
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +4 -2
- package/dist/cjs/ui/DragHandle/index.js +2 -2
- package/dist/cjs/ui/DragPreview/index.js +2 -0
- package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +10 -6
- package/dist/cjs/ui/FloatingDeleteButton/index.js +2 -0
- package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +1 -0
- package/dist/cjs/ui/LayoutButton/index.js +2 -0
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
- package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -0
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
- package/dist/cjs/ui/common-styles.js +4 -0
- package/dist/cjs/ui/ui-styles.js +93 -37
- package/dist/es2019/commands/column-resize.js +53 -4
- package/dist/es2019/commands/go-to-next-cell.js +5 -2
- package/dist/es2019/commands-with-analytics.js +8 -2
- package/dist/es2019/nodeviews/ExternalDropTargets.js +2 -0
- package/dist/es2019/nodeviews/TableComponent.js +9 -7
- package/dist/es2019/nodeviews/TableResizer.js +2 -1
- package/dist/es2019/plugin.js +4 -2
- package/dist/es2019/pm-plugins/keymap.js +25 -9
- package/dist/es2019/pm-plugins/main.js +15 -4
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +4 -2
- package/dist/es2019/ui/DragHandle/index.js +2 -2
- package/dist/es2019/ui/DragPreview/index.js +2 -0
- package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +10 -6
- package/dist/es2019/ui/FloatingDeleteButton/index.js +2 -0
- package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -0
- package/dist/es2019/ui/LayoutButton/index.js +2 -0
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
- package/dist/es2019/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
- package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -0
- package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
- package/dist/es2019/ui/common-styles.js +4 -0
- package/dist/es2019/ui/ui-styles.js +66 -70
- package/dist/esm/commands/column-resize.js +62 -16
- package/dist/esm/commands/go-to-next-cell.js +5 -2
- package/dist/esm/commands-with-analytics.js +8 -2
- package/dist/esm/nodeviews/ExternalDropTargets.js +2 -0
- package/dist/esm/nodeviews/TableComponent.js +9 -7
- package/dist/esm/nodeviews/TableResizer.js +2 -1
- package/dist/esm/plugin.js +58 -57
- package/dist/esm/pm-plugins/keymap.js +26 -8
- package/dist/esm/pm-plugins/main.js +15 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +4 -2
- package/dist/esm/ui/DragHandle/index.js +2 -2
- package/dist/esm/ui/DragPreview/index.js +2 -0
- package/dist/esm/ui/FloatingContextualButton/FixedButton.js +10 -6
- package/dist/esm/ui/FloatingDeleteButton/index.js +2 -0
- package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -0
- package/dist/esm/ui/LayoutButton/index.js +2 -0
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
- package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
- package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -0
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
- package/dist/esm/ui/common-styles.js +4 -0
- package/dist/esm/ui/ui-styles.js +93 -37
- package/dist/types/commands/column-resize.d.ts +23 -4
- package/dist/types/commands/go-to-next-cell.d.ts +2 -1
- package/dist/types/commands-with-analytics.d.ts +2 -1
- package/dist/types/pm-plugins/keymap.d.ts +3 -1
- package/dist/types/types.d.ts +7 -0
- package/dist/types-ts4.5/commands/column-resize.d.ts +23 -4
- package/dist/types-ts4.5/commands/go-to-next-cell.d.ts +2 -1
- package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -1
- package/dist/types-ts4.5/types.d.ts +7 -0
- package/package.json +4 -4
- package/src/commands/column-resize.ts +105 -29
- package/src/commands/go-to-next-cell.ts +10 -2
- package/src/commands-with-analytics.ts +11 -5
- package/src/nodeviews/ExternalDropTargets.tsx +2 -0
- package/src/nodeviews/TableComponent.tsx +14 -16
- package/src/nodeviews/TableResizer.tsx +2 -1
- package/src/plugin.tsx +3 -1
- package/src/pm-plugins/keymap.ts +44 -6
- package/src/pm-plugins/main.ts +18 -4
- package/src/pm-plugins/table-resizing/event-handlers.ts +6 -2
- package/src/types.ts +8 -0
- package/src/ui/DragHandle/index.tsx +2 -2
- package/src/ui/DragPreview/index.tsx +2 -0
- package/src/ui/FloatingContextualButton/FixedButton.tsx +9 -6
- package/src/ui/FloatingDeleteButton/index.tsx +2 -0
- package/src/ui/FloatingInsertButton/InsertButton.tsx +1 -0
- package/src/ui/LayoutButton/index.tsx +2 -0
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -0
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +3 -0
- package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +1 -0
- package/src/ui/TableFloatingControls/NumberColumn/index.tsx +1 -0
- package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -0
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +5 -1
- package/src/ui/common-styles.ts +2 -0
- package/src/ui/ui-styles.ts +90 -79
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
|
+
|
|
3
|
+
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
1
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
5
|
import type {
|
|
3
6
|
Command,
|
|
@@ -121,36 +124,54 @@ const updateResizeHandleAndStatePosition =
|
|
|
121
124
|
return false;
|
|
122
125
|
};
|
|
123
126
|
|
|
124
|
-
export const initiateKeyboardColumnResizing
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
export const initiateKeyboardColumnResizing =
|
|
128
|
+
({
|
|
129
|
+
ariaNotify,
|
|
130
|
+
getIntl,
|
|
131
|
+
}: {
|
|
132
|
+
ariaNotify?: (message: string) => void;
|
|
133
|
+
getIntl?: () => IntlShape;
|
|
134
|
+
}): Command =>
|
|
135
|
+
(state, dispatch, view) => {
|
|
136
|
+
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const { selection } = state;
|
|
141
|
+
const selectionRect = isSelectionType(selection, 'cell')
|
|
142
|
+
? getSelectionRect(selection)!
|
|
143
|
+
: findCellRectClosestToPos(selection.$from);
|
|
144
|
+
const cell = findCellClosestToPos(selection.$from);
|
|
145
|
+
|
|
146
|
+
if (ariaNotify && getIntl) {
|
|
147
|
+
ariaNotify(getIntl().formatMessage(messages.startedColumnResize));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (selectionRect && cell && view) {
|
|
151
|
+
return updateResizeHandleAndStatePosition(
|
|
152
|
+
selectionRect.top,
|
|
153
|
+
selectionRect.right,
|
|
154
|
+
cell.pos,
|
|
155
|
+
)(state, dispatch);
|
|
156
|
+
}
|
|
130
157
|
return false;
|
|
131
|
-
}
|
|
132
|
-
const { selection } = state;
|
|
133
|
-
const selectionRect = isSelectionType(selection, 'cell')
|
|
134
|
-
? getSelectionRect(selection)!
|
|
135
|
-
: findCellRectClosestToPos(selection.$from);
|
|
136
|
-
const cell = findCellClosestToPos(selection.$from);
|
|
137
|
-
|
|
138
|
-
if (selectionRect && cell && view) {
|
|
139
|
-
return updateResizeHandleAndStatePosition(
|
|
140
|
-
selectionRect.top,
|
|
141
|
-
selectionRect.right,
|
|
142
|
-
cell.pos,
|
|
143
|
-
)(state, dispatch);
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
};
|
|
158
|
+
};
|
|
147
159
|
|
|
148
160
|
export const activateNextResizeArea =
|
|
149
|
-
(
|
|
161
|
+
({
|
|
162
|
+
direction,
|
|
163
|
+
ariaNotify,
|
|
164
|
+
getIntl,
|
|
165
|
+
}: {
|
|
166
|
+
direction: Direction;
|
|
167
|
+
ariaNotify?: (message: string) => void;
|
|
168
|
+
getIntl?: () => IntlShape;
|
|
169
|
+
}): Command =>
|
|
150
170
|
(state, dispatch, view) => {
|
|
151
171
|
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
152
172
|
return false;
|
|
153
173
|
}
|
|
174
|
+
|
|
154
175
|
const { resizeHandlePos } = getTableResizingPluginState(state) || {};
|
|
155
176
|
// If No resizing has initiated, skip to regular handler
|
|
156
177
|
if (!resizeHandlePos) {
|
|
@@ -182,6 +203,23 @@ export const activateNextResizeArea =
|
|
|
182
203
|
);
|
|
183
204
|
|
|
184
205
|
const $nextCell = nextCell($currentCell, 'horiz', direction);
|
|
206
|
+
if (ariaNotify && getIntl) {
|
|
207
|
+
let columnDirection = '';
|
|
208
|
+
|
|
209
|
+
if (direction === 1) {
|
|
210
|
+
columnDirection = getIntl().formatMessage(messages.columnRightResize);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (direction === -1) {
|
|
214
|
+
columnDirection = getIntl().formatMessage(messages.columnLeftResize);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
ariaNotify(
|
|
218
|
+
getIntl().formatMessage(messages.focusedOtherResize, {
|
|
219
|
+
direction: columnDirection,
|
|
220
|
+
}),
|
|
221
|
+
);
|
|
222
|
+
}
|
|
185
223
|
|
|
186
224
|
if ($nextCell) {
|
|
187
225
|
// we are somewhere in between the side columns of the table
|
|
@@ -221,15 +259,25 @@ export const activateNextResizeArea =
|
|
|
221
259
|
)(state, dispatch);
|
|
222
260
|
}
|
|
223
261
|
}
|
|
262
|
+
|
|
224
263
|
return false;
|
|
225
264
|
};
|
|
226
265
|
|
|
227
266
|
export const changeColumnWidthByStep =
|
|
228
|
-
(
|
|
229
|
-
stepSize
|
|
230
|
-
getEditorContainerWidth
|
|
231
|
-
isTableScalingEnabled
|
|
232
|
-
|
|
267
|
+
({
|
|
268
|
+
stepSize,
|
|
269
|
+
getEditorContainerWidth,
|
|
270
|
+
isTableScalingEnabled,
|
|
271
|
+
ariaNotify,
|
|
272
|
+
getIntl,
|
|
273
|
+
}: {
|
|
274
|
+
stepSize: number;
|
|
275
|
+
getEditorContainerWidth: GetEditorContainerWidth;
|
|
276
|
+
isTableScalingEnabled: boolean;
|
|
277
|
+
ariaNotify?: (message: string) => void;
|
|
278
|
+
getIntl?: () => IntlShape;
|
|
279
|
+
originalTr?: Transaction;
|
|
280
|
+
}): Command =>
|
|
233
281
|
(state, dispatch, view) => {
|
|
234
282
|
let customTr = state.tr;
|
|
235
283
|
const fakeDispatch = (tr: Transaction) => {
|
|
@@ -323,11 +371,36 @@ export const changeColumnWidthByStep =
|
|
|
323
371
|
dispatch(customTr);
|
|
324
372
|
}
|
|
325
373
|
|
|
374
|
+
if (ariaNotify && getIntl) {
|
|
375
|
+
ariaNotify(
|
|
376
|
+
getIntl().formatMessage(messages.changedColumnWidth, {
|
|
377
|
+
width: Math.floor(newResizeState.cols[colIndex].width),
|
|
378
|
+
}),
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
if (newResizeState.cols.length === colIndex + 1) {
|
|
382
|
+
if (newResizeState.overflow === true) {
|
|
383
|
+
ariaNotify(getIntl().formatMessage(messages.columnResizeLast));
|
|
384
|
+
}
|
|
385
|
+
if (newResizeState.overflow === false) {
|
|
386
|
+
ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
326
391
|
return true;
|
|
327
392
|
};
|
|
328
393
|
|
|
329
394
|
export const stopKeyboardColumnResizing =
|
|
330
|
-
(
|
|
395
|
+
({
|
|
396
|
+
ariaNotify,
|
|
397
|
+
getIntl,
|
|
398
|
+
originalTr,
|
|
399
|
+
}: {
|
|
400
|
+
ariaNotify?: (message: string) => void;
|
|
401
|
+
getIntl?: () => IntlShape;
|
|
402
|
+
originalTr?: Transaction;
|
|
403
|
+
}): Command =>
|
|
331
404
|
(state, dispatch) => {
|
|
332
405
|
if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
333
406
|
return false;
|
|
@@ -364,6 +437,9 @@ export const stopKeyboardColumnResizing =
|
|
|
364
437
|
},
|
|
365
438
|
() => customTr.setMeta('scrollIntoView', false),
|
|
366
439
|
)(state, fakeDispatch);
|
|
440
|
+
if (ariaNotify && getIntl) {
|
|
441
|
+
ariaNotify(getIntl().formatMessage(messages.columnResizeStop));
|
|
442
|
+
}
|
|
367
443
|
|
|
368
444
|
if (dispatch) {
|
|
369
445
|
dispatch(customTr);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// #region Constants
|
|
2
|
+
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
3
|
|
|
3
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
5
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
@@ -21,7 +22,11 @@ const TAB_FORWARD_DIRECTION = 1;
|
|
|
21
22
|
const TAB_BACKWARD_DIRECTION = -1;
|
|
22
23
|
|
|
23
24
|
export const goToNextCell =
|
|
24
|
-
(
|
|
25
|
+
(
|
|
26
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
27
|
+
ariaNotify?: (message: string) => void,
|
|
28
|
+
getIntl?: () => IntlShape,
|
|
29
|
+
) =>
|
|
25
30
|
(direction: Direction): Command =>
|
|
26
31
|
(state, dispatch, view) => {
|
|
27
32
|
const table = findTable(state.selection);
|
|
@@ -32,7 +37,10 @@ export const goToNextCell =
|
|
|
32
37
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
33
38
|
const isColumnResizing = getPluginState(state)?.isKeyboardResize;
|
|
34
39
|
if (isColumnResizing) {
|
|
35
|
-
stopKeyboardColumnResizing(
|
|
40
|
+
stopKeyboardColumnResizing({
|
|
41
|
+
ariaNotify: ariaNotify,
|
|
42
|
+
getIntl: getIntl,
|
|
43
|
+
})(state, dispatch, view);
|
|
36
44
|
return true;
|
|
37
45
|
}
|
|
38
46
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
|
+
|
|
1
3
|
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
2
4
|
import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
|
|
3
5
|
import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
@@ -259,6 +261,8 @@ export const changeColumnWidthByStepWithAnalytics =
|
|
|
259
261
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
260
262
|
isTableScalingEnabled: boolean,
|
|
261
263
|
inputMethod: INPUT_METHOD.SHORTCUT,
|
|
264
|
+
ariaNotify?: (message: string) => void,
|
|
265
|
+
getIntl?: () => IntlShape,
|
|
262
266
|
) =>
|
|
263
267
|
withEditorAnalyticsAPI((state) => {
|
|
264
268
|
const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(
|
|
@@ -283,11 +287,13 @@ export const changeColumnWidthByStepWithAnalytics =
|
|
|
283
287
|
},
|
|
284
288
|
};
|
|
285
289
|
})(editorAnalyticsAPI)(
|
|
286
|
-
changeColumnWidthByStep(
|
|
287
|
-
stepSize,
|
|
288
|
-
getEditorContainerWidth,
|
|
289
|
-
isTableScalingEnabled,
|
|
290
|
-
|
|
290
|
+
changeColumnWidthByStep({
|
|
291
|
+
stepSize: stepSize,
|
|
292
|
+
getEditorContainerWidth: getEditorContainerWidth,
|
|
293
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
294
|
+
ariaNotify: ariaNotify,
|
|
295
|
+
getIntl: getIntl,
|
|
296
|
+
}),
|
|
291
297
|
);
|
|
292
298
|
|
|
293
299
|
export const insertColumnWithAnalytics =
|
|
@@ -56,6 +56,7 @@ export const ExternalDropTargets = ({
|
|
|
56
56
|
width: getTableWrapperWidth(),
|
|
57
57
|
overflow: 'hidden',
|
|
58
58
|
position: 'absolute',
|
|
59
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
59
60
|
top: `-${dropTargetExtendedWidth - tableMarginTop}px`,
|
|
60
61
|
pointerEvents: 'auto',
|
|
61
62
|
zIndex: `${dropTargetsZIndex}`,
|
|
@@ -66,6 +67,7 @@ export const ExternalDropTargets = ({
|
|
|
66
67
|
style={{
|
|
67
68
|
display: 'flex',
|
|
68
69
|
// move drop targets based on table wrapper scroll
|
|
70
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
69
71
|
marginLeft: `-${getScrollOffset()}px`,
|
|
70
72
|
}}
|
|
71
73
|
>
|
|
@@ -25,14 +25,12 @@ import type {
|
|
|
25
25
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
26
26
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
27
27
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
28
|
-
import {
|
|
29
|
-
MAX_BROWSER_SCROLLBAR_HEIGHT,
|
|
30
|
-
akEditorTableToolbarSize as tableToolbarSize,
|
|
31
|
-
} from '@atlaskit/editor-shared-styles';
|
|
28
|
+
import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
32
29
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
33
30
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
34
31
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
35
32
|
import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
33
|
+
import { token } from '@atlaskit/tokens';
|
|
36
34
|
|
|
37
35
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
38
36
|
import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils';
|
|
@@ -59,10 +57,6 @@ import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
|
|
|
59
57
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
60
58
|
import type { CellHoverMeta, PluginInjectionAPI } from '../types';
|
|
61
59
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
62
|
-
import {
|
|
63
|
-
tableOverflowShadowWidth,
|
|
64
|
-
tableOverflowShadowWidthWide,
|
|
65
|
-
} from '../ui/consts';
|
|
66
60
|
import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
|
|
67
61
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
68
62
|
import {
|
|
@@ -751,7 +745,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
751
745
|
visibility:
|
|
752
746
|
showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
753
747
|
top: `${topStickyShadowPosition}px`,
|
|
754
|
-
paddingBottom: `${
|
|
748
|
+
paddingBottom: `${
|
|
749
|
+
isDragAndDropEnabled && token('space.025', '2px')
|
|
750
|
+
}`,
|
|
755
751
|
}}
|
|
756
752
|
/>
|
|
757
753
|
)}
|
|
@@ -776,10 +772,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
776
772
|
<div
|
|
777
773
|
className={ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER}
|
|
778
774
|
style={{
|
|
779
|
-
height: MAX_BROWSER_SCROLLBAR_HEIGHT
|
|
775
|
+
height: token('space.250', '20px'), // MAX_BROWSER_SCROLLBAR_HEIGHT
|
|
780
776
|
display: 'none',
|
|
781
777
|
// prevent unwanted scroll during table resize without removing scrollbar container from the dom
|
|
782
|
-
width: isResizing ? '0px' : '100%',
|
|
778
|
+
width: isResizing ? token('space.0', '0px') : '100%',
|
|
783
779
|
}}
|
|
784
780
|
>
|
|
785
781
|
<div
|
|
@@ -804,10 +800,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
804
800
|
getBooleanFF(
|
|
805
801
|
'platform.editor.table.increase-shadow-visibility_lh89r',
|
|
806
802
|
)
|
|
807
|
-
? tableOverflowShadowWidthWide
|
|
808
|
-
: tableOverflowShadowWidth
|
|
809
|
-
}
|
|
810
|
-
: '-2px',
|
|
803
|
+
? token('space.400', '32px') // tableOverflowShadowWidthWide
|
|
804
|
+
: token('space.100', '8px') // tableOverflowShadowWidth
|
|
805
|
+
}`
|
|
806
|
+
: token('space.negative.025', '-2px'),
|
|
811
807
|
}}
|
|
812
808
|
>
|
|
813
809
|
<div
|
|
@@ -816,7 +812,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
816
812
|
visibility:
|
|
817
813
|
showAfterShadow && hasHeaderRow ? 'visible' : 'hidden',
|
|
818
814
|
top: `${topStickyShadowPosition}px`,
|
|
819
|
-
paddingBottom: `${
|
|
815
|
+
paddingBottom: `${
|
|
816
|
+
isDragAndDropEnabled && token('space.025', '2px')
|
|
817
|
+
}`,
|
|
820
818
|
}}
|
|
821
819
|
/>
|
|
822
820
|
</div>
|
|
@@ -98,7 +98,7 @@ const RESIZE_STEP_VALUE = 10;
|
|
|
98
98
|
const handles = { right: true };
|
|
99
99
|
const handleStyles = {
|
|
100
100
|
right: {
|
|
101
|
-
// eslint-disable-next-line
|
|
101
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
102
102
|
right: '-14px',
|
|
103
103
|
marginTop: token('space.150', '12px'),
|
|
104
104
|
},
|
|
@@ -491,6 +491,7 @@ export const TableResizer = ({
|
|
|
491
491
|
if (newWidth > maxWidth || newWidth < resizerMinWidth) {
|
|
492
492
|
return;
|
|
493
493
|
}
|
|
494
|
+
setLocalTableWidth(newWidth);
|
|
494
495
|
handleResizeStop(
|
|
495
496
|
{ width: width, x: 0, y: 0, height: 0 },
|
|
496
497
|
{ width: step, height: 0 },
|
package/src/plugin.tsx
CHANGED
|
@@ -306,7 +306,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
306
306
|
// plugin as it is currently swallowing backspace events inside tables
|
|
307
307
|
{
|
|
308
308
|
name: 'tableKeymap',
|
|
309
|
-
plugin: () => {
|
|
309
|
+
plugin: ({ getIntl }) => {
|
|
310
310
|
const {
|
|
311
311
|
dragAndDropEnabled,
|
|
312
312
|
isTableScalingEnabled = false,
|
|
@@ -318,6 +318,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
318
318
|
dragAndDropEnabled,
|
|
319
319
|
isTableScalingEnabled,
|
|
320
320
|
fullWidthEnabled,
|
|
321
|
+
api,
|
|
322
|
+
getIntl,
|
|
321
323
|
);
|
|
322
324
|
},
|
|
323
325
|
},
|
package/src/pm-plugins/keymap.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next/src/types';
|
|
2
|
+
|
|
1
3
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
4
|
import {
|
|
3
5
|
ACTION,
|
|
@@ -53,6 +55,7 @@ import {
|
|
|
53
55
|
addColumnBefore as addColumnBeforeCommand,
|
|
54
56
|
} from '../commands/insert';
|
|
55
57
|
import { moveSourceWithAnalyticsViaShortcut } from '../pm-plugins/drag-and-drop/commands-with-analytics';
|
|
58
|
+
import type { PluginInjectionAPIWithA11y } from '../types';
|
|
56
59
|
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
57
60
|
|
|
58
61
|
const createTableWithAnalytics = (
|
|
@@ -76,17 +79,22 @@ export function keymapPlugin(
|
|
|
76
79
|
dragAndDropEnabled?: boolean,
|
|
77
80
|
isTableScalingEnabled = false,
|
|
78
81
|
isFullWidthEnabled?: boolean,
|
|
82
|
+
pluginInjectionApi?: PluginInjectionAPIWithA11y,
|
|
83
|
+
getIntl?: () => IntlShape,
|
|
79
84
|
): SafePlugin {
|
|
80
85
|
const list = {};
|
|
81
86
|
|
|
87
|
+
const ariaNotifyPlugin =
|
|
88
|
+
pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify;
|
|
89
|
+
|
|
82
90
|
bindKeymapWithCommand(
|
|
83
91
|
nextCell.common!,
|
|
84
|
-
goToNextCell(editorAnalyticsAPI)(1),
|
|
92
|
+
goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(1),
|
|
85
93
|
list,
|
|
86
94
|
);
|
|
87
95
|
bindKeymapWithCommand(
|
|
88
96
|
previousCell.common!,
|
|
89
|
-
goToNextCell(editorAnalyticsAPI)(-1),
|
|
97
|
+
goToNextCell(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(-1),
|
|
90
98
|
list,
|
|
91
99
|
);
|
|
92
100
|
bindKeymapWithCommand(
|
|
@@ -190,13 +198,32 @@ export function keymapPlugin(
|
|
|
190
198
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
191
199
|
bindKeymapWithCommand(
|
|
192
200
|
startColumnResizing.common!,
|
|
193
|
-
initiateKeyboardColumnResizing
|
|
201
|
+
initiateKeyboardColumnResizing({
|
|
202
|
+
ariaNotify: ariaNotifyPlugin,
|
|
203
|
+
getIntl: getIntl,
|
|
204
|
+
}),
|
|
194
205
|
list,
|
|
195
206
|
);
|
|
196
207
|
|
|
197
|
-
bindKeymapWithCommand(
|
|
208
|
+
bindKeymapWithCommand(
|
|
209
|
+
moveRight.common!,
|
|
210
|
+
activateNextResizeArea({
|
|
211
|
+
direction: 1,
|
|
212
|
+
ariaNotify: ariaNotifyPlugin,
|
|
213
|
+
getIntl: getIntl,
|
|
214
|
+
}),
|
|
215
|
+
list,
|
|
216
|
+
);
|
|
198
217
|
|
|
199
|
-
bindKeymapWithCommand(
|
|
218
|
+
bindKeymapWithCommand(
|
|
219
|
+
moveLeft.common!,
|
|
220
|
+
activateNextResizeArea({
|
|
221
|
+
direction: -1,
|
|
222
|
+
ariaNotify: ariaNotifyPlugin,
|
|
223
|
+
getIntl: getIntl,
|
|
224
|
+
}),
|
|
225
|
+
list,
|
|
226
|
+
);
|
|
200
227
|
|
|
201
228
|
bindKeymapWithCommand(
|
|
202
229
|
decreaseMediaSize.common!,
|
|
@@ -205,6 +232,8 @@ export function keymapPlugin(
|
|
|
205
232
|
getEditorContainerWidth,
|
|
206
233
|
isTableScalingEnabled,
|
|
207
234
|
INPUT_METHOD.SHORTCUT,
|
|
235
|
+
ariaNotifyPlugin,
|
|
236
|
+
getIntl,
|
|
208
237
|
),
|
|
209
238
|
list,
|
|
210
239
|
);
|
|
@@ -216,10 +245,19 @@ export function keymapPlugin(
|
|
|
216
245
|
getEditorContainerWidth,
|
|
217
246
|
isTableScalingEnabled,
|
|
218
247
|
INPUT_METHOD.SHORTCUT,
|
|
248
|
+
ariaNotifyPlugin,
|
|
249
|
+
getIntl,
|
|
219
250
|
),
|
|
220
251
|
list,
|
|
221
252
|
);
|
|
222
|
-
bindKeymapWithCommand(
|
|
253
|
+
bindKeymapWithCommand(
|
|
254
|
+
escape.common!,
|
|
255
|
+
stopKeyboardColumnResizing({
|
|
256
|
+
ariaNotify: ariaNotifyPlugin,
|
|
257
|
+
getIntl: getIntl,
|
|
258
|
+
}),
|
|
259
|
+
list,
|
|
260
|
+
);
|
|
223
261
|
}
|
|
224
262
|
|
|
225
263
|
return keymap(list) as SafePlugin;
|
package/src/pm-plugins/main.ts
CHANGED
|
@@ -80,6 +80,7 @@ import type {
|
|
|
80
80
|
InvalidNodeAttr,
|
|
81
81
|
PluginConfig,
|
|
82
82
|
PluginInjectionAPI,
|
|
83
|
+
PluginInjectionAPIWithA11y,
|
|
83
84
|
} from '../types';
|
|
84
85
|
import { TableCssClassName as ClassName } from '../types';
|
|
85
86
|
import {
|
|
@@ -136,6 +137,10 @@ export const createPlugin = (
|
|
|
136
137
|
// Used to prevent invalid table cell spans being reported more than once per editor/document
|
|
137
138
|
const invalidTableIds: string[] = [];
|
|
138
139
|
let editorViewRef: EditorView | null = null;
|
|
140
|
+
|
|
141
|
+
const ariaNotifyPlugin = (pluginInjectionApi as PluginInjectionAPIWithA11y)
|
|
142
|
+
?.accessibilityUtils?.actions.ariaNotify;
|
|
143
|
+
|
|
139
144
|
const getCurrentEditorState = (): EditorState | null => {
|
|
140
145
|
const editorView = editorViewRef;
|
|
141
146
|
if (!editorView) {
|
|
@@ -215,7 +220,7 @@ export const createPlugin = (
|
|
|
215
220
|
}
|
|
216
221
|
const tableNode = findTable(state.selection);
|
|
217
222
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
218
|
-
// when cursor leaves the table we need to stop column resizing
|
|
223
|
+
// when keyboard cursor leaves the table we need to stop column resizing
|
|
219
224
|
const pluginPrevState = getPluginState(prevState);
|
|
220
225
|
const isStopKeyboardColumResizing =
|
|
221
226
|
pluginPrevState.isResizeHandleWidgetAdded &&
|
|
@@ -238,11 +243,17 @@ export const createPlugin = (
|
|
|
238
243
|
pluginPrevState.tableNode.attrs.localId
|
|
239
244
|
) {
|
|
240
245
|
// Jump to another table
|
|
241
|
-
stopKeyboardColumnResizing(
|
|
246
|
+
stopKeyboardColumnResizing({
|
|
247
|
+
ariaNotify: ariaNotifyPlugin,
|
|
248
|
+
getIntl: getIntl,
|
|
249
|
+
})(state, dispatch);
|
|
242
250
|
}
|
|
243
251
|
} else if (!tableNode) {
|
|
244
252
|
// selection outside of table
|
|
245
|
-
stopKeyboardColumnResizing(
|
|
253
|
+
stopKeyboardColumnResizing({
|
|
254
|
+
ariaNotify: ariaNotifyPlugin,
|
|
255
|
+
getIntl: getIntl,
|
|
256
|
+
})(state, dispatch);
|
|
246
257
|
}
|
|
247
258
|
}
|
|
248
259
|
}
|
|
@@ -366,7 +377,10 @@ export const createPlugin = (
|
|
|
366
377
|
if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
|
|
367
378
|
const { isKeyboardResize } = getPluginState(state);
|
|
368
379
|
if (isKeyboardResize) {
|
|
369
|
-
stopKeyboardColumnResizing(
|
|
380
|
+
stopKeyboardColumnResizing({
|
|
381
|
+
ariaNotify: ariaNotifyPlugin,
|
|
382
|
+
getIntl: getIntl,
|
|
383
|
+
})(state, dispatch);
|
|
370
384
|
return false;
|
|
371
385
|
}
|
|
372
386
|
}
|
|
@@ -179,7 +179,7 @@ export const handleMouseDown = (
|
|
|
179
179
|
/** if column resize had started via keyboard but continued by mouse
|
|
180
180
|
* or mouse pointer leaves the table but mouse button still pressed
|
|
181
181
|
*/
|
|
182
|
-
return stopKeyboardColumnResizing()(state, dispatch, view);
|
|
182
|
+
return stopKeyboardColumnResizing({})(state, dispatch, view);
|
|
183
183
|
} else {
|
|
184
184
|
return stopResizing()(state, dispatch);
|
|
185
185
|
}
|
|
@@ -261,7 +261,11 @@ export const handleMouseDown = (
|
|
|
261
261
|
/** if column resize had started via keyboard but continued by mouse
|
|
262
262
|
* or mouse pointer leaves the table but mouse button still pressed
|
|
263
263
|
*/
|
|
264
|
-
return stopKeyboardColumnResizing(tr)(
|
|
264
|
+
return stopKeyboardColumnResizing({ originalTr: tr })(
|
|
265
|
+
state,
|
|
266
|
+
dispatch,
|
|
267
|
+
view,
|
|
268
|
+
);
|
|
265
269
|
} else {
|
|
266
270
|
return stopResizing(tr)(state, dispatch);
|
|
267
271
|
}
|
package/src/types.ts
CHANGED
|
@@ -35,6 +35,14 @@ export interface InsertRowOptions {
|
|
|
35
35
|
|
|
36
36
|
export type PluginInjectionAPI = ExtractInjectionAPI<TablePlugin>;
|
|
37
37
|
|
|
38
|
+
export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
|
|
39
|
+
accessibilityUtils?: {
|
|
40
|
+
actions: {
|
|
41
|
+
ariaNotify: (message: string) => void | undefined;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
38
46
|
// override getPluginState but do not expose publicly as this type is experimental and will change
|
|
39
47
|
// in the future
|
|
40
48
|
export type TableSharedStateInternal = Pick<
|
|
@@ -222,8 +222,8 @@ const DragHandleComponent = ({
|
|
|
222
222
|
width: isRow
|
|
223
223
|
? `${token('space.200', '16px')}` // 16px here because it's the size of drag handle button's large side
|
|
224
224
|
: `calc(100% - ${dragTableInsertColumnButtonSize}px)`,
|
|
225
|
-
left: isRow ? '
|
|
226
|
-
bottom: isColumn ? '0' : undefined,
|
|
225
|
+
left: isRow ? `${token('space.050', '4px')}` : undefined,
|
|
226
|
+
bottom: isColumn ? `${token('space.0', '0px')}` : undefined,
|
|
227
227
|
alignSelf: isColumn ? 'none' : 'center',
|
|
228
228
|
zIndex: isColumn ? '-1' : 'auto',
|
|
229
229
|
}}
|
|
@@ -36,7 +36,9 @@ export const DragPreview = ({
|
|
|
36
36
|
<DragInMotionIcon
|
|
37
37
|
style={{
|
|
38
38
|
position: 'absolute',
|
|
39
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
39
40
|
marginLeft: `${marginLeft}px`,
|
|
41
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
40
42
|
marginTop: `${marginTop}px`,
|
|
41
43
|
transform: transform,
|
|
42
44
|
}}
|
|
@@ -4,6 +4,7 @@ import rafSchedule from 'raf-schd';
|
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
|
|
6
6
|
import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { token } from '@atlaskit/tokens';
|
|
7
8
|
|
|
8
9
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
9
10
|
import { TableCssClassName as ClassName } from '../../types';
|
|
@@ -144,26 +145,28 @@ export const FixedButton = ({
|
|
|
144
145
|
ref={observerTargetRef}
|
|
145
146
|
style={{
|
|
146
147
|
position: 'absolute',
|
|
147
|
-
top: '0px',
|
|
148
|
-
left: '0px',
|
|
149
|
-
width:
|
|
150
|
-
height:
|
|
148
|
+
top: token('space.0', '0px'),
|
|
149
|
+
left: token('space.0', '0px'),
|
|
150
|
+
width: token('space.250', '20px'), // BUTTON_WIDTH
|
|
151
|
+
height: token('space.250', '20px'), // BUTTON_WIDTH
|
|
151
152
|
}}
|
|
152
153
|
>
|
|
153
154
|
<div
|
|
154
155
|
ref={fixedButtonRef}
|
|
155
156
|
style={{
|
|
156
157
|
position: 'fixed',
|
|
158
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
157
159
|
top: stickyHeader.top + stickyHeader.padding + offset * 2,
|
|
158
160
|
zIndex: akEditorTableCellOnStickyHeaderZIndex,
|
|
161
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
159
162
|
left: calcLeftPos({
|
|
160
163
|
buttonWidth: BUTTON_WIDTH,
|
|
161
164
|
cellRectLeft: targetCellRect.left,
|
|
162
165
|
cellRefWidth: targetCellRef.clientWidth,
|
|
163
166
|
offset,
|
|
164
167
|
}),
|
|
165
|
-
width:
|
|
166
|
-
height:
|
|
168
|
+
width: token('space.250', '20px'), // BUTTON_WIDTH
|
|
169
|
+
height: token('space.250', '20px'), // BUTTON_WIDTH
|
|
167
170
|
}}
|
|
168
171
|
className={ClassName.CONTEXTUAL_MENU_BUTTON_FIXED}
|
|
169
172
|
>
|
|
@@ -347,8 +347,10 @@ class FloatingDeleteButton extends Component<Props, State> {
|
|
|
347
347
|
<div
|
|
348
348
|
style={{
|
|
349
349
|
position: 'fixed',
|
|
350
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
350
351
|
top: pos.top,
|
|
351
352
|
zIndex: stickyRowZIndex,
|
|
353
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
352
354
|
left:
|
|
353
355
|
rect.left +
|
|
354
356
|
(pos.left || 0) -
|