@atlaskit/editor-plugin-table 5.3.14 → 5.3.16
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/plugins/table/event-handlers.js +4 -3
- package/dist/cjs/plugins/table/index.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/cjs/plugins/table/types.js +5 -3
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +49 -11
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +5 -2
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +114 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +60 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +11 -112
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/types.js +5 -0
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +7 -2
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/icons/AddColLeftIcon.js +44 -0
- package/dist/cjs/plugins/table/ui/icons/AddColRightIcon.js +44 -0
- package/dist/cjs/plugins/table/ui/icons/AddRowAboveIcon.js +45 -0
- package/dist/cjs/plugins/table/ui/icons/AddRowBelowIcon.js +40 -0
- package/dist/cjs/plugins/table/ui/icons/index.js +29 -1
- package/dist/cjs/plugins/table/ui/messages.js +5 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +28 -25
- package/dist/cjs/plugins/table/utils/dom.js +16 -7
- package/dist/cjs/plugins/table/utils/drag-menu.js +122 -10
- package/dist/cjs/plugins/table/utils/index.js +12 -6
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/index.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/es2019/plugins/table/types.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +52 -8
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +5 -2
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +93 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +61 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -99
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +8 -3
- package/dist/es2019/plugins/table/ui/common-styles.js +8 -6
- package/dist/es2019/plugins/table/ui/icons/AddColLeftIcon.js +35 -0
- package/dist/es2019/plugins/table/ui/icons/AddColRightIcon.js +35 -0
- package/dist/es2019/plugins/table/ui/icons/AddRowAboveIcon.js +36 -0
- package/dist/es2019/plugins/table/ui/icons/AddRowBelowIcon.js +31 -0
- package/dist/es2019/plugins/table/ui/icons/index.js +5 -1
- package/dist/es2019/plugins/table/ui/messages.js +5 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +44 -3
- package/dist/es2019/plugins/table/utils/dom.js +13 -6
- package/dist/es2019/plugins/table/utils/drag-menu.js +118 -8
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +5 -4
- package/dist/esm/plugins/table/index.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
- package/dist/esm/plugins/table/types.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +46 -8
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +5 -2
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +5 -0
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +104 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +50 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -110
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +8 -3
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/icons/AddColLeftIcon.js +37 -0
- package/dist/esm/plugins/table/ui/icons/AddColRightIcon.js +37 -0
- package/dist/esm/plugins/table/ui/icons/AddRowAboveIcon.js +38 -0
- package/dist/esm/plugins/table/ui/icons/AddRowBelowIcon.js +33 -0
- package/dist/esm/plugins/table/ui/icons/index.js +5 -1
- package/dist/esm/plugins/table/ui/messages.js +5 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +27 -24
- package/dist/esm/plugins/table/utils/dom.js +15 -6
- package/dist/esm/plugins/table/utils/drag-menu.js +120 -8
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/types.d.ts +5 -3
- package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -0
- package/dist/types/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/index.d.ts +4 -0
- package/dist/types/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +3 -2
- package/dist/types/plugins/table/utils/drag-menu.d.ts +6 -3
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +5 -3
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +6 -3
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/plugins/table/event-handlers.ts +7 -2
- package/src/plugins/table/index.tsx +1 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +7 -1
- package/src/plugins/table/types.ts +7 -4
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +73 -6
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +5 -0
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +8 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +5 -7
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +1 -1
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +107 -0
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +66 -0
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +2 -125
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/types.ts +12 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +3 -3
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +22 -14
- package/src/plugins/table/ui/common-styles.ts +8 -5
- package/src/plugins/table/ui/icons/AddColLeftIcon.tsx +43 -0
- package/src/plugins/table/ui/icons/AddColRightIcon.tsx +43 -0
- package/src/plugins/table/ui/icons/AddRowAboveIcon.tsx +42 -0
- package/src/plugins/table/ui/icons/AddRowBelowIcon.tsx +36 -0
- package/src/plugins/table/ui/icons/index.ts +4 -0
- package/src/plugins/table/ui/messages.ts +6 -0
- package/src/plugins/table/ui/ui-styles.ts +45 -3
- package/src/plugins/table/utils/dom.ts +16 -4
- package/src/plugins/table/utils/drag-menu.ts +158 -5
- package/src/plugins/table/utils/index.ts +2 -1
|
@@ -187,6 +187,7 @@ export const dragInsertButtonWrapper = (props: ThemeProps) => css`
|
|
|
187
187
|
bottom: -5px;
|
|
188
188
|
left: 3px;
|
|
189
189
|
}
|
|
190
|
+
|
|
190
191
|
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON} {
|
|
191
192
|
${Button(`
|
|
192
193
|
background: ${token('elevation.surface.overlay', 'white')};
|
|
@@ -198,6 +199,7 @@ export const dragInsertButtonWrapper = (props: ThemeProps) => css`
|
|
|
198
199
|
border-radius: 50%;
|
|
199
200
|
`)}
|
|
200
201
|
}
|
|
202
|
+
|
|
201
203
|
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON}:hover {
|
|
202
204
|
background: ${token('color.background.brand.bold', B300)};
|
|
203
205
|
border: 1px solid ${token('color.background.brand.bold', B300)};
|
|
@@ -206,6 +208,46 @@ export const dragInsertButtonWrapper = (props: ThemeProps) => css`
|
|
|
206
208
|
}
|
|
207
209
|
`;
|
|
208
210
|
|
|
211
|
+
export const dragCornerControlButton = (props: ThemeProps) => css`
|
|
212
|
+
.${ClassName.DRAG_CORNER_BUTTON} {
|
|
213
|
+
width: 12px;
|
|
214
|
+
height: 12px;
|
|
215
|
+
display: flex;
|
|
216
|
+
justify-content: center;
|
|
217
|
+
align-items: center;
|
|
218
|
+
position: absolute;
|
|
219
|
+
top: ${token('space.negative.075', '-6px')};
|
|
220
|
+
left: ${token('space.075', '6px')};
|
|
221
|
+
background-color: ${token('elevation.surface', '#FFF')};
|
|
222
|
+
border-radius: 50%;
|
|
223
|
+
border: none;
|
|
224
|
+
padding: 0;
|
|
225
|
+
outline: none;
|
|
226
|
+
z-index: ${akEditorUnitZIndex * 99};
|
|
227
|
+
|
|
228
|
+
&.active .${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
229
|
+
background-color: ${token('color.border.selected', '#0C66E4')};
|
|
230
|
+
border-color: ${token('color.border.selected', '#0C66E4')};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
&:hover {
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
|
|
236
|
+
.${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
237
|
+
border-color: ${token('color.border.selected', '#0C66E4')};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.${ClassName.DRAG_CORNER_BUTTON_INNER} {
|
|
243
|
+
border: 1px solid
|
|
244
|
+
${token('color.background.accent.gray.subtler', '#DCDFE4')};
|
|
245
|
+
border-radius: 50%;
|
|
246
|
+
width: 6px;
|
|
247
|
+
height: 6px;
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
|
|
209
251
|
export const insertColumnButtonWrapper = (props: ThemeProps) => css`
|
|
210
252
|
${InsertButton()}
|
|
211
253
|
${InsertButtonHover()}
|
|
@@ -403,12 +445,12 @@ const getFloatingDotOverrides = (props: ThemeProps) => {
|
|
|
403
445
|
|
|
404
446
|
export const floatingColumnControls = (props: ThemeProps) => {
|
|
405
447
|
return css`
|
|
406
|
-
.${ClassName.
|
|
448
|
+
.${ClassName.DRAG_COLUMN_DROP_TARGET_CONTROLS} {
|
|
407
449
|
box-sizing: border-box;
|
|
408
450
|
position: absolute;
|
|
409
451
|
top: 0;
|
|
410
452
|
|
|
411
|
-
.${ClassName.
|
|
453
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
|
|
412
454
|
display: flex;
|
|
413
455
|
flex-direction: row;
|
|
414
456
|
}
|
|
@@ -417,7 +459,7 @@ export const floatingColumnControls = (props: ThemeProps) => {
|
|
|
417
459
|
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
418
460
|
box-sizing: border-box;
|
|
419
461
|
|
|
420
|
-
.${ClassName.
|
|
462
|
+
.${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
|
|
421
463
|
display: grid;
|
|
422
464
|
justify-items: center;
|
|
423
465
|
}
|
|
@@ -52,7 +52,7 @@ export const isTableContainerOrWrapper = (node: HTMLElement | null): boolean =>
|
|
|
52
52
|
containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
|
|
53
53
|
|
|
54
54
|
/** drag-and-drop classes */
|
|
55
|
-
export const
|
|
55
|
+
export const isDragRowControlsButton = (node: HTMLElement | null) =>
|
|
56
56
|
containsClassName(node, ClassName.DRAG_ROW_CONTROLS) ||
|
|
57
57
|
closestElement(node, `.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
58
58
|
|
|
@@ -62,6 +62,10 @@ export const isDragRowFloatingInsertDot = (node: HTMLElement | null) =>
|
|
|
62
62
|
export const isDragColumnFloatingInsertDot = (node: HTMLElement | null) =>
|
|
63
63
|
containsClassName(node, ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER);
|
|
64
64
|
|
|
65
|
+
export const isDragCornerButton = (node: HTMLElement | null) =>
|
|
66
|
+
containsClassName(node, ClassName.DRAG_CORNER_BUTTON) ||
|
|
67
|
+
containsClassName(node, ClassName.DRAG_CORNER_BUTTON_INNER);
|
|
68
|
+
|
|
65
69
|
/*
|
|
66
70
|
* This function returns which side of a given element the mouse cursor is,
|
|
67
71
|
* using as a base the half of the width by default, for example:
|
|
@@ -120,15 +124,23 @@ export const getMousePositionHorizontalRelativeByElement = (
|
|
|
120
124
|
mouseEvent: MouseEvent,
|
|
121
125
|
elementContentRects?: ElementContentRects,
|
|
122
126
|
gapInPixels?: number,
|
|
127
|
+
isDragAndDropEnabled?: boolean,
|
|
123
128
|
): 'left' | 'right' | null => {
|
|
124
129
|
const element = mouseEvent.target;
|
|
125
130
|
|
|
126
131
|
if (element instanceof HTMLElement) {
|
|
127
132
|
let width, x;
|
|
128
|
-
const closestCell = element.closest(SELECTOR_TABLE_LEAFS);
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
if (isDragAndDropEnabled) {
|
|
135
|
+
// mouse event fires for new overlapping column controls, so the cell can not get detected. Get width
|
|
136
|
+
// directly from element that will be .pm-table-drag-columns-floating-insert-dot-wrapper
|
|
137
|
+
width = element.clientWidth;
|
|
138
|
+
} else {
|
|
139
|
+
const closestCell = element.closest(SELECTOR_TABLE_LEAFS);
|
|
140
|
+
|
|
141
|
+
const id = closestCell?.id ?? '';
|
|
142
|
+
width = elementContentRects?.[id]?.width ?? 0;
|
|
143
|
+
}
|
|
132
144
|
x = mouseEvent.offsetX;
|
|
133
145
|
|
|
134
146
|
if (width <= 0) {
|
|
@@ -1,13 +1,47 @@
|
|
|
1
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
2
|
+
import {
|
|
3
|
+
addColumnAfter,
|
|
4
|
+
addColumnBefore,
|
|
5
|
+
addRowAfter,
|
|
6
|
+
addRowBefore,
|
|
7
|
+
backspace,
|
|
8
|
+
tooltip,
|
|
9
|
+
} from '@atlaskit/editor-common/keymaps';
|
|
1
10
|
import type {
|
|
2
11
|
Command,
|
|
3
12
|
CommandDispatch,
|
|
4
13
|
DropdownOptionT,
|
|
14
|
+
GetEditorContainerWidth,
|
|
15
|
+
IconProps,
|
|
5
16
|
} from '@atlaskit/editor-common/types';
|
|
6
17
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import type { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
18
|
+
import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
19
|
+
import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
|
|
20
|
+
import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
|
|
21
|
+
import ArrowRightIcon from '@atlaskit/icon/glyph/arrow-right';
|
|
22
|
+
import ArrowUpIcon from '@atlaskit/icon/glyph/arrow-up';
|
|
23
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
24
|
+
import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
|
|
25
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
26
|
+
import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
|
|
27
|
+
import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
|
|
8
28
|
|
|
29
|
+
import {
|
|
30
|
+
clearMultipleCells,
|
|
31
|
+
insertColumn,
|
|
32
|
+
insertRow,
|
|
33
|
+
sortByColumn,
|
|
34
|
+
} from '../commands';
|
|
35
|
+
import { deleteColumnsCommand } from '../commands/delete';
|
|
9
36
|
import { moveSource } from '../pm-plugins/drag-and-drop/commands';
|
|
37
|
+
import { deleteRows } from '../transforms';
|
|
10
38
|
import type { TableDirection } from '../types';
|
|
39
|
+
import {
|
|
40
|
+
AddColLeftIcon,
|
|
41
|
+
AddColRightIcon,
|
|
42
|
+
AddRowAboveIcon,
|
|
43
|
+
AddRowBelowIcon,
|
|
44
|
+
} from '../ui/icons';
|
|
11
45
|
|
|
12
46
|
const canDecrease = (index?: number, min: number = 0) =>
|
|
13
47
|
index !== undefined && index > min;
|
|
@@ -16,39 +50,148 @@ const canIncrease = (index?: number, max: number = 0) =>
|
|
|
16
50
|
|
|
17
51
|
export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
18
52
|
id: string;
|
|
53
|
+
icon?: React.ComponentType<IconProps>;
|
|
54
|
+
keymap?: string;
|
|
19
55
|
}
|
|
20
56
|
|
|
21
57
|
export const getDragMenuConfig = (
|
|
22
58
|
direction: TableDirection,
|
|
59
|
+
getEditorContainerWidth: GetEditorContainerWidth,
|
|
23
60
|
tableMap?: TableMap,
|
|
24
61
|
index?: number,
|
|
62
|
+
targetCellPosition?: number,
|
|
63
|
+
selectionRect?: Rect,
|
|
25
64
|
): DragMenuConfig[] => {
|
|
65
|
+
const addOptions =
|
|
66
|
+
direction === 'row'
|
|
67
|
+
? [
|
|
68
|
+
{
|
|
69
|
+
label: 'above',
|
|
70
|
+
offset: 0,
|
|
71
|
+
icon: AddRowAboveIcon,
|
|
72
|
+
keymap: addRowBefore,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: 'below',
|
|
76
|
+
offset: 1,
|
|
77
|
+
icon: AddRowBelowIcon,
|
|
78
|
+
keymap: addRowAfter,
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
: [
|
|
82
|
+
{
|
|
83
|
+
label: 'left',
|
|
84
|
+
offset: 0,
|
|
85
|
+
icon: AddColLeftIcon,
|
|
86
|
+
keymap: addColumnBefore,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: 'right',
|
|
90
|
+
offset: 1,
|
|
91
|
+
icon: AddColRightIcon,
|
|
92
|
+
keymap: addColumnAfter,
|
|
93
|
+
},
|
|
94
|
+
];
|
|
26
95
|
const moveOptions =
|
|
27
96
|
direction === 'row'
|
|
28
97
|
? [
|
|
29
|
-
{ label: 'up', offset: -1, canMove: canDecrease },
|
|
98
|
+
{ label: 'up', offset: -1, canMove: canDecrease, icon: ArrowUpIcon },
|
|
30
99
|
{
|
|
31
100
|
label: 'down',
|
|
32
101
|
offset: 1,
|
|
33
102
|
canMove: (index?: number) =>
|
|
34
103
|
canIncrease(index, (tableMap?.height ?? 0) - 1),
|
|
104
|
+
icon: ArrowDownIcon,
|
|
35
105
|
},
|
|
36
106
|
]
|
|
37
107
|
: [
|
|
38
|
-
{
|
|
108
|
+
{
|
|
109
|
+
label: 'left',
|
|
110
|
+
offset: -1,
|
|
111
|
+
canMove: canDecrease,
|
|
112
|
+
icon: ArrowLeftIcon,
|
|
113
|
+
},
|
|
39
114
|
{
|
|
40
115
|
label: 'right',
|
|
41
116
|
offset: 1,
|
|
42
117
|
canMove: (index?: number) =>
|
|
43
118
|
canIncrease(index, (tableMap?.width ?? 0) - 1),
|
|
119
|
+
icon: ArrowRightIcon,
|
|
44
120
|
},
|
|
45
121
|
];
|
|
46
122
|
|
|
123
|
+
const sortOptions =
|
|
124
|
+
direction === 'column'
|
|
125
|
+
? [
|
|
126
|
+
{
|
|
127
|
+
label: 'increasing',
|
|
128
|
+
order: SortOrder.ASC,
|
|
129
|
+
icon: HipchatChevronDoubleUpIcon,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
label: 'decreasing',
|
|
133
|
+
order: SortOrder.DESC,
|
|
134
|
+
icon: HipchatChevronDoubleDownIcon,
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
: [];
|
|
47
138
|
return [
|
|
48
|
-
...
|
|
139
|
+
...addOptions.map(({ label, offset, icon, keymap }) => ({
|
|
140
|
+
id: `add_${direction}_${label}`,
|
|
141
|
+
title: `Add ${direction} ${label}`,
|
|
142
|
+
icon,
|
|
143
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
144
|
+
if (direction === 'row') {
|
|
145
|
+
insertRow(index! + offset, true)(state, dispatch);
|
|
146
|
+
} else {
|
|
147
|
+
insertColumn(getEditorContainerWidth)(index! + offset)(
|
|
148
|
+
state,
|
|
149
|
+
dispatch,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
},
|
|
154
|
+
keymap: keymap && tooltip(keymap),
|
|
155
|
+
})),
|
|
156
|
+
direction === 'column'
|
|
157
|
+
? {
|
|
158
|
+
id: 'distribute_columns',
|
|
159
|
+
title: 'Distribute columns',
|
|
160
|
+
disabled: true,
|
|
161
|
+
onClick: () => {
|
|
162
|
+
return false;
|
|
163
|
+
},
|
|
164
|
+
icon: EditorLayoutThreeEqualIcon,
|
|
165
|
+
}
|
|
166
|
+
: undefined,
|
|
167
|
+
{
|
|
168
|
+
id: 'clear_cells',
|
|
169
|
+
title: 'Clear cells',
|
|
170
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
171
|
+
clearMultipleCells(targetCellPosition)(state, dispatch);
|
|
172
|
+
return true;
|
|
173
|
+
},
|
|
174
|
+
icon: CrossCircleIcon,
|
|
175
|
+
keymap: tooltip(backspace),
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: `delete_${direction}`,
|
|
179
|
+
title: `Delete ${direction}`,
|
|
180
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
181
|
+
if (direction === 'row') {
|
|
182
|
+
dispatch?.(deleteRows(selectionRect!, false)(state.tr));
|
|
183
|
+
} else {
|
|
184
|
+
deleteColumnsCommand(selectionRect!)(state, dispatch);
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
},
|
|
188
|
+
icon: RemoveIcon,
|
|
189
|
+
},
|
|
190
|
+
...moveOptions.map(({ label, offset, canMove, icon }) => ({
|
|
49
191
|
id: `move_${direction}_${label}`,
|
|
50
192
|
title: `Move ${direction} ${label}`,
|
|
51
193
|
disabled: !canMove(index),
|
|
194
|
+
icon,
|
|
52
195
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
53
196
|
if (canMove(index)) {
|
|
54
197
|
moveSource(
|
|
@@ -61,5 +204,15 @@ export const getDragMenuConfig = (
|
|
|
61
204
|
return false;
|
|
62
205
|
},
|
|
63
206
|
})),
|
|
64
|
-
|
|
207
|
+
|
|
208
|
+
...sortOptions.map(({ label, order, icon }) => ({
|
|
209
|
+
id: `sort_column_${order}`,
|
|
210
|
+
title: `Sort ${label}`,
|
|
211
|
+
icon,
|
|
212
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
213
|
+
sortByColumn(index!, order)(state, dispatch);
|
|
214
|
+
return true;
|
|
215
|
+
},
|
|
216
|
+
})),
|
|
217
|
+
].filter(Boolean) as DragMenuConfig[];
|
|
65
218
|
};
|
|
@@ -46,10 +46,11 @@ export {
|
|
|
46
46
|
isColumnControlsDecorations,
|
|
47
47
|
isTableControlsButton,
|
|
48
48
|
isTableContainerOrWrapper,
|
|
49
|
-
isRowDragControlsButton,
|
|
50
49
|
isRowControlsButton,
|
|
50
|
+
isDragRowControlsButton,
|
|
51
51
|
isDragColumnFloatingInsertDot,
|
|
52
52
|
isDragRowFloatingInsertDot,
|
|
53
|
+
isDragCornerButton,
|
|
53
54
|
getColumnOrRowIndex,
|
|
54
55
|
getMousePositionHorizontalRelativeByElement,
|
|
55
56
|
getMousePositionVerticalRelativeByElement,
|