@atlaskit/editor-plugin-table 7.28.9 → 7.28.11
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 +17 -0
- package/dist/cjs/ui/FloatingContextualButton/index.js +2 -1
- package/dist/cjs/ui/FloatingContextualButton/styles.js +9 -4
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +79 -48
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +1 -10
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +19 -12
- package/dist/cjs/ui/FloatingDragMenu/styles.js +1 -7
- package/dist/cjs/utils/drag-menu.js +47 -14
- package/dist/es2019/ui/FloatingContextualButton/index.js +2 -1
- package/dist/es2019/ui/FloatingContextualButton/styles.js +6 -1
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +80 -49
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +0 -9
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +20 -13
- package/dist/es2019/ui/FloatingDragMenu/styles.js +0 -6
- package/dist/es2019/utils/drag-menu.js +50 -17
- package/dist/esm/ui/FloatingContextualButton/index.js +2 -1
- package/dist/esm/ui/FloatingContextualButton/styles.js +8 -2
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +80 -49
- package/dist/esm/ui/FloatingContextualMenu/styles.js +0 -9
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +20 -13
- package/dist/esm/ui/FloatingDragMenu/styles.js +0 -6
- package/dist/esm/utils/drag-menu.js +47 -14
- package/dist/types/ui/FloatingContextualMenu/styles.d.ts +0 -1
- package/dist/types/ui/FloatingDragMenu/styles.d.ts +0 -1
- package/dist/types/utils/drag-menu.d.ts +4 -2
- package/dist/types-ts4.5/ui/FloatingContextualMenu/styles.d.ts +0 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/styles.d.ts +0 -1
- package/dist/types-ts4.5/utils/drag-menu.d.ts +4 -2
- package/package.json +5 -5
- package/src/ui/FloatingContextualButton/index.tsx +2 -2
- package/src/ui/FloatingContextualButton/styles.ts +5 -0
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +78 -45
- package/src/ui/FloatingContextualMenu/styles.ts +0 -8
- package/src/ui/FloatingDragMenu/DragMenu.tsx +20 -15
- package/src/ui/FloatingDragMenu/styles.ts +0 -6
- package/src/utils/drag-menu.ts +73 -43
|
@@ -42,10 +42,19 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
42
42
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
43
43
|
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
44
44
|
import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
45
|
-
import CrossCircleIcon from '@atlaskit/icon/
|
|
46
|
-
import
|
|
47
|
-
import
|
|
45
|
+
import CrossCircleIcon from '@atlaskit/icon/core/migration/cross-circle';
|
|
46
|
+
import RemoveIcon from '@atlaskit/icon/core/migration/delete--editor-remove';
|
|
47
|
+
import EditorBackgroundColorIcon from '@atlaskit/icon/core/migration/paint-bucket--editor-background-color';
|
|
48
|
+
import PaintBucketIcon from '@atlaskit/icon/core/paint-bucket';
|
|
49
|
+
import TableCellClearIcon from '@atlaskit/icon/core/table-cell-clear';
|
|
50
|
+
import TableCellMergeIcon from '@atlaskit/icon/core/table-cell-merge';
|
|
51
|
+
import TableCellSplitIcon from '@atlaskit/icon/core/table-cell-split';
|
|
52
|
+
import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right';
|
|
53
|
+
import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
|
|
54
|
+
import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
|
|
55
|
+
import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
|
|
48
56
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
57
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
49
58
|
|
|
50
59
|
import {
|
|
51
60
|
clearHoverSelection,
|
|
@@ -85,7 +94,7 @@ import {
|
|
|
85
94
|
} from '../consts';
|
|
86
95
|
import { AddColRightIcon, AddRowBelowIcon, MergeCellsIcon, SplitCellIcon } from '../icons';
|
|
87
96
|
|
|
88
|
-
import { cellColourPreviewStyles
|
|
97
|
+
import { cellColourPreviewStyles } from './styles';
|
|
89
98
|
|
|
90
99
|
interface Props {
|
|
91
100
|
editorView: EditorView;
|
|
@@ -111,6 +120,12 @@ interface State {
|
|
|
111
120
|
isOpenAllowed: boolean;
|
|
112
121
|
}
|
|
113
122
|
const arrowsList = new Set(['ArrowRight', 'ArrowLeft']);
|
|
123
|
+
|
|
124
|
+
const elementBeforeIconStyles = xcss({
|
|
125
|
+
marginRight: 'space.negative.075',
|
|
126
|
+
display: 'flex',
|
|
127
|
+
});
|
|
128
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
114
129
|
export class ContextualMenu extends Component<Props & WrappedComponentProps, State> {
|
|
115
130
|
state: State = {
|
|
116
131
|
isSubmenuOpen: false,
|
|
@@ -248,13 +263,14 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
248
263
|
: formatMessage(messages.cellBackground),
|
|
249
264
|
value: { name: 'background' },
|
|
250
265
|
elemBefore: isDragAndDropEnabled ? (
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
266
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
267
|
+
<PaintBucketIcon
|
|
268
|
+
color="currentColor"
|
|
269
|
+
spacing="spacious"
|
|
254
270
|
label={formatMessage(messages.backgroundColor)}
|
|
255
|
-
|
|
271
|
+
LEGACY_fallbackIcon={EditorBackgroundColorIcon}
|
|
256
272
|
/>
|
|
257
|
-
</
|
|
273
|
+
</Box>
|
|
258
274
|
) : undefined,
|
|
259
275
|
elemAfter: (
|
|
260
276
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -345,10 +361,14 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
345
361
|
value: { name: 'merge' },
|
|
346
362
|
isDisabled: !canMergeCells(state.tr),
|
|
347
363
|
elemBefore: isDragAndDropEnabled ? (
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
364
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
365
|
+
<TableCellMergeIcon
|
|
366
|
+
color="currentColor"
|
|
367
|
+
spacing="spacious"
|
|
368
|
+
label={formatMessage(messages.mergeCells)}
|
|
369
|
+
LEGACY_fallbackIcon={MergeCellsIcon}
|
|
370
|
+
/>
|
|
371
|
+
</Box>
|
|
352
372
|
) : undefined,
|
|
353
373
|
},
|
|
354
374
|
{
|
|
@@ -356,10 +376,14 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
356
376
|
value: { name: 'split' },
|
|
357
377
|
isDisabled: !splitCell(state),
|
|
358
378
|
elemBefore: isDragAndDropEnabled ? (
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
379
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
380
|
+
<TableCellSplitIcon
|
|
381
|
+
color="currentColor"
|
|
382
|
+
spacing="spacious"
|
|
383
|
+
label={formatMessage(messages.splitCell)}
|
|
384
|
+
LEGACY_fallbackIcon={SplitCellIcon}
|
|
385
|
+
/>
|
|
386
|
+
</Box>
|
|
363
387
|
) : undefined,
|
|
364
388
|
},
|
|
365
389
|
] as MenuItem[];
|
|
@@ -384,13 +408,16 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
384
408
|
elemAfter: <div css={shortcutStyle}>{tooltip(addColumnAfter)}</div>,
|
|
385
409
|
elemBefore: isDragAndDropEnabled ? (
|
|
386
410
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
387
|
-
<
|
|
388
|
-
<
|
|
389
|
-
|
|
411
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
412
|
+
<TableColumnAddRightIcon
|
|
413
|
+
color="currentColor"
|
|
414
|
+
spacing="spacious"
|
|
415
|
+
label={formatMessage(messages.addColumnRight)}
|
|
416
|
+
LEGACY_fallbackIcon={AddColRightIcon}
|
|
417
|
+
/>
|
|
418
|
+
</Box>
|
|
390
419
|
) : undefined,
|
|
391
|
-
'aria-label':
|
|
392
|
-
? tooltip(addColumnAfter, String(content))
|
|
393
|
-
: undefined,
|
|
420
|
+
'aria-label': tooltip(addColumnAfter, String(content)),
|
|
394
421
|
} as MenuItem;
|
|
395
422
|
};
|
|
396
423
|
|
|
@@ -408,14 +435,16 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
408
435
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
409
436
|
elemAfter: <div css={shortcutStyle}>{tooltip(addRowAfter)}</div>,
|
|
410
437
|
elemBefore: isDragAndDropEnabled ? (
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
438
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
439
|
+
<TableRowAddBelowIcon
|
|
440
|
+
color="currentColor"
|
|
441
|
+
spacing="spacious"
|
|
442
|
+
label={formatMessage(messages.addRowBelow)}
|
|
443
|
+
LEGACY_fallbackIcon={AddRowBelowIcon}
|
|
444
|
+
/>
|
|
445
|
+
</Box>
|
|
415
446
|
) : undefined,
|
|
416
|
-
'aria-label':
|
|
417
|
-
? tooltip(addRowAfter, String(content))
|
|
418
|
-
: undefined,
|
|
447
|
+
'aria-label': tooltip(addRowAfter, String(content)),
|
|
419
448
|
} as MenuItem;
|
|
420
449
|
};
|
|
421
450
|
|
|
@@ -440,18 +469,18 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
440
469
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
441
470
|
elemAfter: <div css={shortcutStyle}>{tooltip(backspace)}</div>,
|
|
442
471
|
elemBefore: isDragAndDropEnabled ? (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
472
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
473
|
+
<TableCellClearIcon
|
|
474
|
+
color="currentColor"
|
|
475
|
+
spacing="spacious"
|
|
446
476
|
label={formatMessage(messages.clearCells, {
|
|
447
477
|
0: Math.max(noOfColumns, noOfRows),
|
|
448
478
|
})}
|
|
479
|
+
LEGACY_fallbackIcon={CrossCircleIcon}
|
|
449
480
|
/>
|
|
450
|
-
</
|
|
481
|
+
</Box>
|
|
451
482
|
) : undefined,
|
|
452
|
-
'aria-label':
|
|
453
|
-
? tooltip(backspace, String(content))
|
|
454
|
-
: undefined,
|
|
483
|
+
'aria-label': tooltip(backspace, String(content)),
|
|
455
484
|
} as MenuItem;
|
|
456
485
|
};
|
|
457
486
|
|
|
@@ -472,14 +501,16 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
472
501
|
}),
|
|
473
502
|
value: { name: 'delete_column' },
|
|
474
503
|
elemBefore: isDragAndDropEnabled ? (
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
504
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
505
|
+
<TableColumnDeleteIcon
|
|
506
|
+
color="currentColor"
|
|
507
|
+
spacing="spacious"
|
|
478
508
|
label={formatMessage(messages.removeColumns, {
|
|
479
509
|
0: noOfColumns,
|
|
480
510
|
})}
|
|
511
|
+
LEGACY_fallbackIcon={RemoveIcon}
|
|
481
512
|
/>
|
|
482
|
-
</
|
|
513
|
+
</Box>
|
|
483
514
|
) : undefined,
|
|
484
515
|
} as MenuItem;
|
|
485
516
|
};
|
|
@@ -501,14 +532,16 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
|
|
|
501
532
|
}),
|
|
502
533
|
value: { name: 'delete_row' },
|
|
503
534
|
elemBefore: isDragAndDropEnabled ? (
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
535
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
536
|
+
<TableRowDeleteIcon
|
|
537
|
+
color="currentColor"
|
|
538
|
+
spacing="spacious"
|
|
507
539
|
label={formatMessage(messages.removeRows, {
|
|
508
540
|
0: noOfRows,
|
|
509
541
|
})}
|
|
542
|
+
LEGACY_fallbackIcon={RemoveIcon}
|
|
510
543
|
/>
|
|
511
|
-
</
|
|
544
|
+
</Box>
|
|
512
545
|
) : undefined,
|
|
513
546
|
} as MenuItem;
|
|
514
547
|
};
|
|
@@ -16,14 +16,6 @@ export const cellColourPreviewStyles = (selectedColor: string) =>
|
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
20
|
-
export const elementBeforeIconStyles = css({
|
|
21
|
-
marginRight: token('space.negative.075', '-6px'),
|
|
22
|
-
display: 'flex',
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// TODO Delete this comment after verifying space token -> previous value `padding: 8px`
|
|
26
|
-
// TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
|
|
27
19
|
export const tablePopupStyles = (
|
|
28
20
|
isDragAndDropEnabled: boolean | undefined,
|
|
29
21
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
|
|
@@ -42,7 +42,9 @@ import {
|
|
|
42
42
|
getSelectionRect,
|
|
43
43
|
isSelectionType,
|
|
44
44
|
} from '@atlaskit/editor-tables/utils';
|
|
45
|
-
import EditorBackgroundColorIcon from '@atlaskit/icon/
|
|
45
|
+
import EditorBackgroundColorIcon from '@atlaskit/icon/core/migration/paint-bucket--editor-background-color';
|
|
46
|
+
import PaintBucketIcon from '@atlaskit/icon/core/paint-bucket';
|
|
47
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
46
48
|
import Toggle from '@atlaskit/toggle';
|
|
47
49
|
|
|
48
50
|
import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
|
|
@@ -69,12 +71,7 @@ import { getDragMenuConfig } from '../../utils/drag-menu';
|
|
|
69
71
|
import { colorPalletteColumns } from '../consts';
|
|
70
72
|
|
|
71
73
|
import { DropdownMenu } from './DropdownMenu';
|
|
72
|
-
import {
|
|
73
|
-
cellColourPreviewStyles,
|
|
74
|
-
dragMenuBackgroundColorStyles,
|
|
75
|
-
elementBeforeIconStyles,
|
|
76
|
-
toggleStyles,
|
|
77
|
-
} from './styles';
|
|
74
|
+
import { cellColourPreviewStyles, dragMenuBackgroundColorStyles, toggleStyles } from './styles';
|
|
78
75
|
|
|
79
76
|
type DragMenuProps = {
|
|
80
77
|
direction?: TableDirection;
|
|
@@ -192,6 +189,11 @@ const getGroupedDragMenuConfig = (tableSortColumnReorder: boolean) => {
|
|
|
192
189
|
return groupedDragMenuConfig;
|
|
193
190
|
};
|
|
194
191
|
|
|
192
|
+
const elementBeforeIconStyles = xcss({
|
|
193
|
+
marginRight: 'space.negative.075',
|
|
194
|
+
display: 'flex',
|
|
195
|
+
});
|
|
196
|
+
|
|
195
197
|
const convertToDropdownItems = (
|
|
196
198
|
dragMenuConfig: DragMenuConfig[],
|
|
197
199
|
formatMessage: IntlShape['formatMessage'],
|
|
@@ -237,12 +239,14 @@ const convertToDropdownItems = (
|
|
|
237
239
|
value: { name: item.id },
|
|
238
240
|
isDisabled: item.disabled,
|
|
239
241
|
elemBefore: item.icon ? (
|
|
240
|
-
|
|
241
|
-
<span css={elementBeforeIconStyles}>
|
|
242
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
242
243
|
<item.icon
|
|
244
|
+
color="currentColor"
|
|
245
|
+
spacing="spacious"
|
|
243
246
|
label={formatMessage(MapDragMenuOptionIdToMessage[item.id].message, options)}
|
|
247
|
+
LEGACY_fallbackIcon={item.iconFallback ? item.iconFallback : undefined}
|
|
244
248
|
/>
|
|
245
|
-
</
|
|
249
|
+
</Box>
|
|
246
250
|
) : undefined,
|
|
247
251
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
248
252
|
elemAfter: item.keymap ? <div css={shortcutStyle}>{item.keymap}</div> : undefined,
|
|
@@ -368,13 +372,14 @@ const DragMenu = React.memo(
|
|
|
368
372
|
content: formatMessage(messages.backgroundColor),
|
|
369
373
|
value: { name: 'background' },
|
|
370
374
|
elemBefore: (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
375
|
+
<Box xcss={elementBeforeIconStyles}>
|
|
376
|
+
<PaintBucketIcon
|
|
377
|
+
color="currentColor"
|
|
378
|
+
spacing="spacious"
|
|
374
379
|
label={formatMessage(messages.backgroundColor)}
|
|
375
|
-
|
|
380
|
+
LEGACY_fallbackIcon={EditorBackgroundColorIcon}
|
|
376
381
|
/>
|
|
377
|
-
</
|
|
382
|
+
</Box>
|
|
378
383
|
),
|
|
379
384
|
elemAfter: (
|
|
380
385
|
<div
|
|
@@ -21,12 +21,6 @@ export const cellColourPreviewStyles = (selectedColor: string) =>
|
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
25
|
-
export const elementBeforeIconStyles = css({
|
|
26
|
-
marginRight: token('space.negative.075', '-6px'),
|
|
27
|
-
display: 'flex',
|
|
28
|
-
});
|
|
29
|
-
|
|
30
24
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
|
|
31
25
|
export const dragMenuBackgroundColorStyles = (tableSortColumnReorder: boolean = false) => css`
|
|
32
26
|
.${ClassName.DRAG_SUBMENU} {
|
package/src/utils/drag-menu.ts
CHANGED
|
@@ -20,12 +20,25 @@ import type {
|
|
|
20
20
|
CommandDispatch,
|
|
21
21
|
DropdownOptionT,
|
|
22
22
|
GetEditorContainerWidth,
|
|
23
|
-
IconProps,
|
|
24
23
|
} from '@atlaskit/editor-common/types';
|
|
25
24
|
import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
26
25
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
27
26
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
28
27
|
import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
28
|
+
import SortAscendingIcon from '@atlaskit/icon/core/sort-ascending';
|
|
29
|
+
import SortDescendingIcon from '@atlaskit/icon/core/sort-descending';
|
|
30
|
+
import TableCellClearIcon from '@atlaskit/icon/core/table-cell-clear';
|
|
31
|
+
import TableColumnAddLeftIcon from '@atlaskit/icon/core/table-column-add-left';
|
|
32
|
+
import TableColumnAddRightIcon from '@atlaskit/icon/core/table-column-add-right';
|
|
33
|
+
import TableColumnDeleteIcon from '@atlaskit/icon/core/table-column-delete';
|
|
34
|
+
import TableColumnMoveLeftIcon from '@atlaskit/icon/core/table-column-move-left';
|
|
35
|
+
import TableColumnMoveRightIcon from '@atlaskit/icon/core/table-column-move-right';
|
|
36
|
+
import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
|
|
37
|
+
import TableRowAddAboveIcon from '@atlaskit/icon/core/table-row-add-above';
|
|
38
|
+
import TableRowAddBelowIcon from '@atlaskit/icon/core/table-row-add-below';
|
|
39
|
+
import TableRowDeleteIcon from '@atlaskit/icon/core/table-row-delete';
|
|
40
|
+
import TableRowMoveDownIcon from '@atlaskit/icon/core/table-row-move-down';
|
|
41
|
+
import TableRowMoveUpIcon from '@atlaskit/icon/core/table-row-move-up';
|
|
29
42
|
import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
|
|
30
43
|
import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
|
|
31
44
|
import ArrowRightIcon from '@atlaskit/icon/glyph/arrow-right';
|
|
@@ -35,6 +48,7 @@ import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three
|
|
|
35
48
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
36
49
|
import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
|
|
37
50
|
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
51
|
+
import type { UNSAFE_NewIconProps } from '@atlaskit/icon/types';
|
|
38
52
|
|
|
39
53
|
import {
|
|
40
54
|
deleteColumnsWithAnalytics,
|
|
@@ -128,7 +142,8 @@ export type DragMenuOptionIdType =
|
|
|
128
142
|
|
|
129
143
|
export interface DragMenuConfig extends Omit<DropdownOptionT<Command>, 'icon'> {
|
|
130
144
|
id: DragMenuOptionIdType;
|
|
131
|
-
icon?: React.ComponentType<React.PropsWithChildren<
|
|
145
|
+
icon?: React.ComponentType<React.PropsWithChildren<UNSAFE_NewIconProps>>;
|
|
146
|
+
iconFallback?: React.ComponentType<React.PropsWithChildren<UNSAFE_NewIconProps>>;
|
|
132
147
|
keymap?: string;
|
|
133
148
|
}
|
|
134
149
|
|
|
@@ -165,13 +180,15 @@ export const getDragMenuConfig = (
|
|
|
165
180
|
{
|
|
166
181
|
label: 'above',
|
|
167
182
|
offset: 0,
|
|
168
|
-
icon:
|
|
183
|
+
icon: TableRowAddAboveIcon,
|
|
184
|
+
iconFallback: AddRowAboveIcon,
|
|
169
185
|
keymap: addRowBefore,
|
|
170
186
|
},
|
|
171
187
|
{
|
|
172
188
|
label: 'below',
|
|
173
189
|
offset: 1,
|
|
174
|
-
icon:
|
|
190
|
+
icon: TableRowAddBelowIcon,
|
|
191
|
+
iconFallback: AddRowBelowIcon,
|
|
175
192
|
keymap: addRowAfter,
|
|
176
193
|
},
|
|
177
194
|
]
|
|
@@ -179,13 +196,15 @@ export const getDragMenuConfig = (
|
|
|
179
196
|
{
|
|
180
197
|
label: 'left',
|
|
181
198
|
offset: 0,
|
|
182
|
-
icon:
|
|
199
|
+
icon: TableColumnAddLeftIcon,
|
|
200
|
+
iconFallback: AddColLeftIcon,
|
|
183
201
|
keymap: addColumnBefore,
|
|
184
202
|
},
|
|
185
203
|
{
|
|
186
204
|
label: 'right',
|
|
187
205
|
offset: 1,
|
|
188
|
-
icon:
|
|
206
|
+
icon: TableColumnAddRightIcon,
|
|
207
|
+
iconFallback: AddColRightIcon,
|
|
189
208
|
keymap: addColumnAfter,
|
|
190
209
|
},
|
|
191
210
|
];
|
|
@@ -194,7 +213,8 @@ export const getDragMenuConfig = (
|
|
|
194
213
|
? [
|
|
195
214
|
{
|
|
196
215
|
label: 'up',
|
|
197
|
-
icon:
|
|
216
|
+
icon: TableRowMoveUpIcon,
|
|
217
|
+
iconFallback: ArrowUpIcon,
|
|
198
218
|
keymap: moveRowUp,
|
|
199
219
|
canMove: canMove('table-row', -1, tableMap?.height ?? 0, selection, selectionRect),
|
|
200
220
|
getOriginIndexes: getSelectedRowIndexes,
|
|
@@ -202,7 +222,8 @@ export const getDragMenuConfig = (
|
|
|
202
222
|
},
|
|
203
223
|
{
|
|
204
224
|
label: 'down',
|
|
205
|
-
icon:
|
|
225
|
+
icon: TableRowMoveDownIcon,
|
|
226
|
+
iconFallback: ArrowDownIcon,
|
|
206
227
|
keymap: moveRowDown,
|
|
207
228
|
canMove: canMove('table-row', 1, tableMap?.height ?? 0, selection, selectionRect),
|
|
208
229
|
getOriginIndexes: getSelectedRowIndexes,
|
|
@@ -212,7 +233,8 @@ export const getDragMenuConfig = (
|
|
|
212
233
|
: [
|
|
213
234
|
{
|
|
214
235
|
label: 'left',
|
|
215
|
-
icon:
|
|
236
|
+
icon: TableColumnMoveLeftIcon,
|
|
237
|
+
iconFallback: ArrowLeftIcon,
|
|
216
238
|
keymap: moveColumnLeft,
|
|
217
239
|
canMove: canMove('table-column', -1, tableMap?.width ?? 0, selection, selectionRect),
|
|
218
240
|
getOriginIndexes: getSelectedColumnIndexes,
|
|
@@ -220,36 +242,38 @@ export const getDragMenuConfig = (
|
|
|
220
242
|
},
|
|
221
243
|
{
|
|
222
244
|
label: 'right',
|
|
223
|
-
icon:
|
|
245
|
+
icon: TableColumnMoveRightIcon,
|
|
246
|
+
iconFallback: ArrowRightIcon,
|
|
224
247
|
keymap: moveColumnRight,
|
|
225
248
|
canMove: canMove('table-column', 1, tableMap?.width ?? 0, selection, selectionRect),
|
|
226
249
|
getOriginIndexes: getSelectedColumnIndexes,
|
|
227
250
|
getTargetIndex: (selectionRect: Rect) => selectionRect.right,
|
|
228
251
|
},
|
|
229
252
|
];
|
|
230
|
-
|
|
231
253
|
const sortOptions =
|
|
232
254
|
direction === 'column'
|
|
233
255
|
? [
|
|
234
256
|
{
|
|
235
257
|
label: 'increasing',
|
|
236
258
|
order: SortOrder.ASC,
|
|
237
|
-
icon:
|
|
259
|
+
icon: SortAscendingIcon,
|
|
260
|
+
iconFallback: HipchatChevronDoubleUpIcon,
|
|
238
261
|
},
|
|
239
262
|
{
|
|
240
263
|
label: 'decreasing',
|
|
241
264
|
order: SortOrder.DESC,
|
|
242
|
-
icon:
|
|
265
|
+
icon: SortDescendingIcon,
|
|
266
|
+
iconFallback: HipchatChevronDoubleDownIcon,
|
|
243
267
|
},
|
|
244
268
|
]
|
|
245
269
|
: [];
|
|
246
|
-
|
|
247
270
|
const sortConfigs = [
|
|
248
|
-
...sortOptions.map(({ label, order, icon }) => ({
|
|
271
|
+
...sortOptions.map(({ label, order, icon, iconFallback }) => ({
|
|
249
272
|
id: `sort_column_${order}`,
|
|
250
273
|
title: `Sort ${label}`,
|
|
251
274
|
disabled: hasMergedCellsInTable,
|
|
252
|
-
icon,
|
|
275
|
+
icon: icon,
|
|
276
|
+
iconFallback: iconFallback,
|
|
253
277
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
254
278
|
sortColumnWithAnalytics(editorAnalyticsAPI)(
|
|
255
279
|
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
@@ -260,12 +284,12 @@ export const getDragMenuConfig = (
|
|
|
260
284
|
},
|
|
261
285
|
})),
|
|
262
286
|
];
|
|
263
|
-
|
|
264
287
|
const restConfigs = [
|
|
265
|
-
...addOptions.map(({ label, offset, icon, keymap }) => ({
|
|
288
|
+
...addOptions.map(({ label, offset, icon, iconFallback, keymap }) => ({
|
|
266
289
|
id: `add_${direction}_${label}`,
|
|
267
290
|
title: `Add ${direction} ${label}`,
|
|
268
|
-
icon,
|
|
291
|
+
icon: icon,
|
|
292
|
+
iconFallback: iconFallback,
|
|
269
293
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
270
294
|
if (direction === 'row') {
|
|
271
295
|
insertRowWithAnalytics(editorAnalyticsAPI, tableDuplicateCellColouring)(
|
|
@@ -318,7 +342,8 @@ export const getDragMenuConfig = (
|
|
|
318
342
|
}
|
|
319
343
|
return false;
|
|
320
344
|
},
|
|
321
|
-
icon:
|
|
345
|
+
icon: TableColumnsDistributeIcon,
|
|
346
|
+
iconFallback: EditorLayoutThreeEqualIcon,
|
|
322
347
|
}
|
|
323
348
|
: undefined,
|
|
324
349
|
{
|
|
@@ -331,7 +356,8 @@ export const getDragMenuConfig = (
|
|
|
331
356
|
)(state, dispatch);
|
|
332
357
|
return true;
|
|
333
358
|
},
|
|
334
|
-
icon:
|
|
359
|
+
icon: TableCellClearIcon,
|
|
360
|
+
iconFallback: CrossCircleIcon,
|
|
335
361
|
keymap: tooltip(backspace),
|
|
336
362
|
},
|
|
337
363
|
{
|
|
@@ -360,30 +386,34 @@ export const getDragMenuConfig = (
|
|
|
360
386
|
}
|
|
361
387
|
return true;
|
|
362
388
|
},
|
|
363
|
-
icon:
|
|
389
|
+
icon: direction === 'row' ? TableRowDeleteIcon : TableColumnDeleteIcon,
|
|
390
|
+
iconFallback: RemoveIcon,
|
|
364
391
|
keymap: direction === 'row' ? tooltip(deleteRow) : tooltip(deleteColumn),
|
|
365
392
|
},
|
|
366
|
-
...moveOptions.map(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
393
|
+
...moveOptions.map(
|
|
394
|
+
({ label, canMove, icon, iconFallback, keymap, getOriginIndexes, getTargetIndex }) => ({
|
|
395
|
+
id: `move_${direction}_${label}`,
|
|
396
|
+
title: `Move ${direction} ${label}`,
|
|
397
|
+
disabled: !canMove,
|
|
398
|
+
icon: icon,
|
|
399
|
+
iconFallback: iconFallback,
|
|
400
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
401
|
+
if (canMove) {
|
|
402
|
+
requestAnimationFrame(() => {
|
|
403
|
+
moveSourceWithAnalytics(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(
|
|
404
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
405
|
+
`table-${direction}`,
|
|
406
|
+
getOriginIndexes(selectionRect!),
|
|
407
|
+
getTargetIndex(selectionRect!),
|
|
408
|
+
)(editorView.state, editorView.dispatch);
|
|
409
|
+
});
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
return false;
|
|
413
|
+
},
|
|
414
|
+
keymap: keymap && tooltip(keymap),
|
|
415
|
+
}),
|
|
416
|
+
),
|
|
387
417
|
];
|
|
388
418
|
|
|
389
419
|
let allConfigs = [...restConfigs];
|