@atlaskit/editor-plugin-table 7.0.3 → 7.1.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 +26 -0
- package/dist/cjs/event-handlers.js +4 -1
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +9 -9
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +4 -11
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/cjs/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/cjs/pm-plugins/keymap.js +1 -1
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/ui/DragHandle/index.js +27 -9
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/ui/FloatingContextualMenu/index.js +4 -3
- package/dist/cjs/ui/FloatingContextualMenu/styles.js +3 -1
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +7 -2
- package/dist/cjs/ui/common-styles.js +2 -1
- package/dist/cjs/ui/consts.js +3 -3
- package/dist/cjs/ui/icons/AddRowAboveIcon.js +8 -12
- package/dist/cjs/ui/icons/AddRowBelowIcon.js +19 -15
- package/dist/cjs/ui/ui-styles.js +8 -8
- package/dist/cjs/utils/drag-menu.js +42 -29
- package/dist/es2019/event-handlers.js +3 -2
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +8 -8
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +5 -10
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/es2019/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/es2019/pm-plugins/keymap.js +2 -2
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/DragHandle/index.js +26 -8
- package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/es2019/ui/FloatingContextualMenu/index.js +5 -4
- package/dist/es2019/ui/FloatingContextualMenu/styles.js +3 -3
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +7 -2
- package/dist/es2019/ui/common-styles.js +24 -5
- package/dist/es2019/ui/consts.js +2 -2
- package/dist/es2019/ui/icons/AddRowAboveIcon.js +8 -12
- package/dist/es2019/ui/icons/AddRowBelowIcon.js +19 -15
- package/dist/es2019/ui/ui-styles.js +8 -8
- package/dist/es2019/utils/drag-menu.js +29 -24
- package/dist/esm/event-handlers.js +5 -2
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +9 -9
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +5 -12
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/esm/pm-plugins/drag-and-drop/utils/monitor.js +0 -5
- package/dist/esm/pm-plugins/keymap.js +2 -2
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/DragHandle/index.js +27 -9
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +2 -2
- package/dist/esm/ui/FloatingContextualMenu/index.js +5 -4
- package/dist/esm/ui/FloatingContextualMenu/styles.js +4 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +1 -7
- package/dist/esm/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +7 -2
- package/dist/esm/ui/common-styles.js +2 -1
- package/dist/esm/ui/consts.js +2 -2
- package/dist/esm/ui/icons/AddRowAboveIcon.js +8 -12
- package/dist/esm/ui/icons/AddRowBelowIcon.js +19 -15
- package/dist/esm/ui/ui-styles.js +8 -8
- package/dist/esm/utils/drag-menu.js +41 -28
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +0 -2
- package/dist/types/ui/consts.d.ts +2 -1
- package/dist/types/ui/ui-styles.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/FloatingContextualMenu/styles.d.ts +1 -1
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +0 -2
- package/dist/types-ts4.5/ui/consts.d.ts +2 -1
- package/dist/types-ts4.5/ui/ui-styles.d.ts +2 -2
- package/package.json +6 -8
- package/src/__tests__/unit/event-handlers.ts +3 -17
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +46 -17
- package/src/event-handlers.ts +14 -2
- package/src/index.ts +1 -1
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +11 -8
- package/src/pm-plugins/drag-and-drop/commands.ts +5 -33
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -3
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +0 -5
- package/src/pm-plugins/keymap.ts +2 -7
- package/src/types.ts +1 -0
- package/src/ui/DragHandle/index.tsx +33 -14
- package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +9 -2
- package/src/ui/FloatingContextualMenu/index.tsx +10 -3
- package/src/ui/FloatingContextualMenu/styles.ts +10 -3
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +13 -4
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +1 -13
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -2
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +17 -7
- package/src/ui/common-styles.ts +20 -4
- package/src/ui/consts.ts +2 -6
- package/src/ui/icons/AddRowAboveIcon.tsx +2 -16
- package/src/ui/icons/AddRowBelowIcon.tsx +21 -12
- package/src/ui/ui-styles.ts +12 -8
- package/src/utils/drag-menu.ts +48 -32
- package/tsconfig.json +273 -0
|
@@ -23,6 +23,7 @@ import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
|
23
23
|
import type { PluginConfig } from '../../types';
|
|
24
24
|
import {
|
|
25
25
|
contextualMenuDropdownWidth,
|
|
26
|
+
contextualMenuDropdownWidthDnD,
|
|
26
27
|
contextualMenuTriggerSize,
|
|
27
28
|
} from '../consts';
|
|
28
29
|
|
|
@@ -53,7 +54,9 @@ const FloatingContextualMenu = ({
|
|
|
53
54
|
getEditorContainerWidth,
|
|
54
55
|
}: Props) => {
|
|
55
56
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
56
|
-
const { targetCellPosition } = getPluginState(
|
|
57
|
+
const { targetCellPosition, isDragAndDropEnabled } = getPluginState(
|
|
58
|
+
editorView.state,
|
|
59
|
+
);
|
|
57
60
|
if (
|
|
58
61
|
!isOpen ||
|
|
59
62
|
!targetCellPosition ||
|
|
@@ -89,7 +92,11 @@ const FloatingContextualMenu = ({
|
|
|
89
92
|
boundariesElement={boundariesElement}
|
|
90
93
|
scrollableElement={scrollableElement}
|
|
91
94
|
fitHeight={188}
|
|
92
|
-
fitWidth={
|
|
95
|
+
fitWidth={
|
|
96
|
+
isDragAndDropEnabled
|
|
97
|
+
? contextualMenuDropdownWidthDnD
|
|
98
|
+
: contextualMenuDropdownWidth
|
|
99
|
+
}
|
|
93
100
|
// z-index value below is to ensure that this menu is above other floating menu
|
|
94
101
|
// in table, but below floating dialogs like typeaheads, pickers, etc.
|
|
95
102
|
zIndex={
|
|
@@ -101,7 +108,7 @@ const FloatingContextualMenu = ({
|
|
|
101
108
|
offset={[-7, 0]}
|
|
102
109
|
stick={true}
|
|
103
110
|
>
|
|
104
|
-
<div css={tablePopupStyles}>
|
|
111
|
+
<div css={tablePopupStyles(isDragAndDropEnabled)}>
|
|
105
112
|
<ContextualMenu
|
|
106
113
|
editorView={editorView}
|
|
107
114
|
offset={[contextualMenuTriggerSize / 2, -contextualMenuTriggerSize]}
|
|
@@ -5,7 +5,10 @@ import { N60A, N90 } from '@atlaskit/theme/colors';
|
|
|
5
5
|
import { token } from '@atlaskit/tokens';
|
|
6
6
|
|
|
7
7
|
import { TableCssClassName as ClassName } from '../../types';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
contextualMenuDropdownWidth,
|
|
10
|
+
contextualMenuDropdownWidthDnD,
|
|
11
|
+
} from '../consts';
|
|
9
12
|
|
|
10
13
|
export const cellColourPreviewStyles = (selectedColor: string) => css`
|
|
11
14
|
&::before {
|
|
@@ -20,7 +23,9 @@ export const elementBeforeIconStyles = css`
|
|
|
20
23
|
|
|
21
24
|
// TODO Delete this comment after verifying space token -> previous value `padding: 8px`
|
|
22
25
|
// TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
|
|
23
|
-
export const tablePopupStyles =
|
|
26
|
+
export const tablePopupStyles = (
|
|
27
|
+
isDragAndDropEnabled: boolean | undefined,
|
|
28
|
+
) => css`
|
|
24
29
|
.${ClassName.CONTEXTUAL_SUBMENU} {
|
|
25
30
|
border-radius: ${token('border.radius', '3px')};
|
|
26
31
|
background: ${token('elevation.surface.overlay', 'white')};
|
|
@@ -31,7 +36,9 @@ export const tablePopupStyles = css`
|
|
|
31
36
|
display: block;
|
|
32
37
|
position: absolute;
|
|
33
38
|
top: 0;
|
|
34
|
-
left: ${
|
|
39
|
+
left: ${isDragAndDropEnabled
|
|
40
|
+
? contextualMenuDropdownWidthDnD
|
|
41
|
+
: contextualMenuDropdownWidth}px;
|
|
35
42
|
padding: ${token('space.100', '8px')};
|
|
36
43
|
|
|
37
44
|
> div {
|
|
@@ -159,10 +159,17 @@ export const ColumnControls = ({
|
|
|
159
159
|
}
|
|
160
160
|
}, [editorView, tableActive]);
|
|
161
161
|
|
|
162
|
-
const handleMouseUp = useCallback(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
const handleMouseUp = useCallback(
|
|
163
|
+
(event) => {
|
|
164
|
+
const { state, dispatch } = editorView;
|
|
165
|
+
if (event.shiftKey) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
toggleDragMenu(undefined, 'column', colIndex)(state, dispatch);
|
|
170
|
+
},
|
|
171
|
+
[editorView, colIndex],
|
|
172
|
+
);
|
|
166
173
|
|
|
167
174
|
const colIndexes = useMemo(() => {
|
|
168
175
|
return [colIndex!];
|
|
@@ -251,6 +258,8 @@ export const ColumnControls = ({
|
|
|
251
258
|
height: 'fit-content',
|
|
252
259
|
placeSelf: 'center',
|
|
253
260
|
zIndex: 99,
|
|
261
|
+
width: '100%',
|
|
262
|
+
position: 'relative',
|
|
254
263
|
}}
|
|
255
264
|
data-column-control-index={hoveredCell.colIndex}
|
|
256
265
|
data-testid={`table-floating-column-${
|
|
@@ -6,33 +6,21 @@ import { ColumnDropTarget } from './ColumnDropTarget';
|
|
|
6
6
|
|
|
7
7
|
export interface Props {
|
|
8
8
|
tableRef: HTMLTableElement;
|
|
9
|
-
stickyTop?: number;
|
|
10
9
|
tableHeight?: number;
|
|
11
10
|
localId?: string;
|
|
12
|
-
rowHeights?: number[];
|
|
13
11
|
colWidths?: (number | undefined)[];
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export const ColumnDropTargets: React.FC<Props> = ({
|
|
17
15
|
tableRef,
|
|
18
16
|
tableHeight,
|
|
19
|
-
stickyTop,
|
|
20
17
|
localId,
|
|
21
|
-
rowHeights,
|
|
22
18
|
colWidths,
|
|
23
19
|
}) => {
|
|
24
20
|
if (!tableRef) {
|
|
25
21
|
return null;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
const firstRow = tableRef.querySelector('tr');
|
|
29
|
-
const hasHeaderRow = firstRow
|
|
30
|
-
? firstRow.getAttribute('data-header-row')
|
|
31
|
-
: false;
|
|
32
|
-
|
|
33
|
-
const marginTop =
|
|
34
|
-
hasHeaderRow && stickyTop !== undefined ? rowHeights?.[0] ?? 0 : 0;
|
|
35
|
-
|
|
36
24
|
return (
|
|
37
25
|
<div
|
|
38
26
|
className={ClassName.DRAG_COLUMN_DROP_TARGET_CONTROLS}
|
|
@@ -50,7 +38,7 @@ export const ColumnDropTargets: React.FC<Props> = ({
|
|
|
50
38
|
localId={localId}
|
|
51
39
|
width={width}
|
|
52
40
|
height={tableHeight}
|
|
53
|
-
marginTop={
|
|
41
|
+
marginTop={0}
|
|
54
42
|
/>
|
|
55
43
|
);
|
|
56
44
|
})}
|
|
@@ -165,10 +165,8 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
165
165
|
{isDragging && (
|
|
166
166
|
<ColumnDropTargets
|
|
167
167
|
tableRef={tableRef}
|
|
168
|
-
stickyTop={tableActive ? stickyTop : undefined}
|
|
169
168
|
tableHeight={tableRect.height}
|
|
170
169
|
localId={currentNodeLocalId}
|
|
171
|
-
rowHeights={rowHeights}
|
|
172
170
|
colWidths={colWidths}
|
|
173
171
|
/>
|
|
174
172
|
)}
|
|
@@ -113,13 +113,20 @@ const DragControlsComponent = ({
|
|
|
113
113
|
});
|
|
114
114
|
}, [editorView]);
|
|
115
115
|
|
|
116
|
-
const onMouseUp = useCallback(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
const onMouseUp = useCallback(
|
|
117
|
+
(event) => {
|
|
118
|
+
if (event.shiftKey) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
toggleDragMenu(
|
|
123
|
+
undefined,
|
|
124
|
+
'row',
|
|
125
|
+
hoveredCell?.rowIndex,
|
|
126
|
+
)(editorView.state, editorView.dispatch);
|
|
127
|
+
},
|
|
128
|
+
[editorView, hoveredCell?.rowIndex],
|
|
129
|
+
);
|
|
123
130
|
|
|
124
131
|
const rowIndex = hoveredCell?.rowIndex;
|
|
125
132
|
|
|
@@ -194,6 +201,7 @@ const DragControlsComponent = ({
|
|
|
194
201
|
!selectedRowIndexes.includes(rowIndex!) &&
|
|
195
202
|
Number.isFinite(hoveredCell?.colIndex)
|
|
196
203
|
: selectedRowIndexes.length < rowHeights.length &&
|
|
204
|
+
rowIndex! < rowHeights.length &&
|
|
197
205
|
Number.isFinite(hoveredCell?.colIndex);
|
|
198
206
|
|
|
199
207
|
if (!showCondition) {
|
|
@@ -234,7 +242,9 @@ const DragControlsComponent = ({
|
|
|
234
242
|
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
235
243
|
gridColumn: '2',
|
|
236
244
|
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
245
|
+
display: 'flex',
|
|
237
246
|
width: '9px',
|
|
247
|
+
height: '100%',
|
|
238
248
|
position: 'relative',
|
|
239
249
|
right: '-0.5px',
|
|
240
250
|
}}
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -309,8 +309,8 @@ export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
309
309
|
${hoveredDeleteButton()};
|
|
310
310
|
${hoveredCell()};
|
|
311
311
|
${hoveredWarningCell};
|
|
312
|
-
${
|
|
313
|
-
${resizeHandle()};
|
|
312
|
+
${props.featureFlags?.tableDragAndDrop && insertLine()};
|
|
313
|
+
${resizeHandle(props.featureFlags?.tableDragAndDrop)};
|
|
314
314
|
${rangeSelectionStyles};
|
|
315
315
|
|
|
316
316
|
.${ClassName.LAST_ITEM_IN_CELL} {
|
|
@@ -520,7 +520,7 @@ export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
${sentinelStyles}
|
|
523
|
-
${OverflowShadow()}
|
|
523
|
+
${OverflowShadow(props.featureFlags?.tableDragAndDrop)}
|
|
524
524
|
${stickyScrollbarStyles(props.featureFlags)}
|
|
525
525
|
|
|
526
526
|
.${ClassName.TABLE_STICKY} .${ClassName.TABLE_STICKY_SHADOW} {
|
|
@@ -753,6 +753,22 @@ export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
|
|
756
|
+
.${ClassName.DRAG_HANDLE_BUTTON_CLICKABLE_ZONE} {
|
|
757
|
+
background: none;
|
|
758
|
+
border: none;
|
|
759
|
+
outline: none;
|
|
760
|
+
position: absolute;
|
|
761
|
+
margin: 0;
|
|
762
|
+
padding: 0;
|
|
763
|
+
display: flex;
|
|
764
|
+
align-items: center;
|
|
765
|
+
cursor: pointer;
|
|
766
|
+
|
|
767
|
+
:focus {
|
|
768
|
+
outline: none;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
756
772
|
.${ClassName.DRAG_HANDLE_BUTTON_CONTAINER} {
|
|
757
773
|
cursor: grab;
|
|
758
774
|
pointer-events: auto;
|
|
@@ -844,7 +860,7 @@ export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
844
860
|
margin-left: ${getBooleanFF('platform.editor.custom-table-width')
|
|
845
861
|
? akEditorTableToolbarSize
|
|
846
862
|
: akEditorTableToolbarSize - 1}px;
|
|
847
|
-
top: ${
|
|
863
|
+
top: ${props.featureFlags?.tableDragAndDrop
|
|
848
864
|
? 0
|
|
849
865
|
: akEditorTableToolbarSize}px;
|
|
850
866
|
width: ${akEditorTableNumberColumnWidth + 1}px;
|
package/src/ui/consts.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
akEditorUnitZIndex,
|
|
14
14
|
akRichMediaResizeZIndex,
|
|
15
15
|
} from '@atlaskit/editor-shared-styles';
|
|
16
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
16
|
import {
|
|
18
17
|
B200,
|
|
19
18
|
N0,
|
|
@@ -119,11 +118,8 @@ export const resizeLineWidth = 2;
|
|
|
119
118
|
export const resizeHandlerZIndex =
|
|
120
119
|
columnControlsZIndex + akRichMediaResizeZIndex;
|
|
121
120
|
export const contextualMenuTriggerSize = 16;
|
|
122
|
-
export const contextualMenuDropdownWidth =
|
|
123
|
-
|
|
124
|
-
)
|
|
125
|
-
? 250
|
|
126
|
-
: 180;
|
|
121
|
+
export const contextualMenuDropdownWidth = 180;
|
|
122
|
+
export const contextualMenuDropdownWidthDnD = 250;
|
|
127
123
|
export const stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
128
124
|
export const stickyRowOffsetTop = 8;
|
|
129
125
|
export const stickyHeaderBorderBottomWidth = 1;
|
|
@@ -16,22 +16,8 @@ export const AddRowAboveIcon = () => (
|
|
|
16
16
|
fill={token('color.border.inverse', '#FFFFFF')}
|
|
17
17
|
fillOpacity="0.01"
|
|
18
18
|
/>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
fill={token('color.border.inverse', '#FFFFFF')}
|
|
22
|
-
>
|
|
23
|
-
<rect x="6" y="12" width="12" height="8" rx="0.5" />
|
|
24
|
-
</mask>
|
|
25
|
-
<rect
|
|
26
|
-
x="6"
|
|
27
|
-
y="12"
|
|
28
|
-
width="12"
|
|
29
|
-
height="8"
|
|
30
|
-
rx="0.5"
|
|
31
|
-
stroke="currentColor"
|
|
32
|
-
strokeWidth="4"
|
|
33
|
-
mask="url(#path-1-inside-1_896_17822)"
|
|
34
|
-
/>
|
|
19
|
+
<rect x="6" y="12" width="12" height="3" rx="0.5" fill="currentColor" />
|
|
20
|
+
<rect x="6" y="16" width="12" height="3" rx="0.5" fill="currentColor" />
|
|
35
21
|
<path
|
|
36
22
|
fillRule="evenodd"
|
|
37
23
|
clipRule="evenodd"
|
|
@@ -10,26 +10,35 @@ export const AddRowBelowIcon = () => (
|
|
|
10
10
|
fill="none"
|
|
11
11
|
xmlns="http://www.w3.org/2000/svg"
|
|
12
12
|
>
|
|
13
|
-
<
|
|
14
|
-
|
|
13
|
+
<rect
|
|
14
|
+
width="24"
|
|
15
|
+
height="24"
|
|
16
|
+
transform="matrix(-1 0 0 -1 24 24)"
|
|
15
17
|
fill={token('color.border.inverse', '#FFFFFF')}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
fillOpacity="0.01"
|
|
19
|
+
/>
|
|
20
|
+
<rect
|
|
21
|
+
x="18"
|
|
22
|
+
y="12"
|
|
23
|
+
width="12"
|
|
24
|
+
height="3"
|
|
25
|
+
rx="0.5"
|
|
26
|
+
transform="rotate(-180 18 12)"
|
|
27
|
+
fill="currentColor"
|
|
28
|
+
/>
|
|
19
29
|
<rect
|
|
20
|
-
x="
|
|
21
|
-
y="
|
|
30
|
+
x="18"
|
|
31
|
+
y="8"
|
|
22
32
|
width="12"
|
|
23
|
-
height="
|
|
33
|
+
height="3"
|
|
24
34
|
rx="0.5"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
mask="url(#path-1-inside-1_920_47112)"
|
|
35
|
+
transform="rotate(-180 18 8)"
|
|
36
|
+
fill="currentColor"
|
|
28
37
|
/>
|
|
29
38
|
<path
|
|
30
39
|
fillRule="evenodd"
|
|
31
40
|
clipRule="evenodd"
|
|
32
|
-
d="
|
|
41
|
+
d="M11 17V18.01C11.0026 18.2735 11.1092 18.5253 11.2964 18.7107C11.4837 18.896 11.7365 19 12 19C12.556 19 13 18.556 13 18.01V17H14C14.2652 17 14.5196 16.8946 14.7071 16.7071C14.8946 16.5196 15 16.2652 15 16C15 15.7348 14.8946 15.4804 14.7071 15.2929C14.5196 15.1054 14.2652 15 14 15H13V13.99C12.9974 13.7265 12.8908 13.4747 12.7036 13.2893C12.5163 13.104 12.2635 13 12 13C11.444 13 11 13.444 11 13.99V15H10C9.73478 15 9.48043 15.1054 9.29289 15.2929C9.10536 15.4804 9 15.7348 9 16C9 16.2652 9.10536 16.5196 9.29289 16.7071C9.48043 16.8946 9.73478 17 10 17H11Z"
|
|
33
42
|
fill="currentColor"
|
|
34
43
|
/>
|
|
35
44
|
</svg>
|
package/src/ui/ui-styles.ts
CHANGED
|
@@ -331,7 +331,9 @@ export const DeleteButton = () => css`
|
|
|
331
331
|
}
|
|
332
332
|
`;
|
|
333
333
|
|
|
334
|
-
export const OverflowShadow = (
|
|
334
|
+
export const OverflowShadow = (
|
|
335
|
+
isDragAndDropEnabled: boolean | undefined,
|
|
336
|
+
) => css`
|
|
335
337
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
336
338
|
display: block;
|
|
337
339
|
height: calc(100% - ${tableMarginTop}px);
|
|
@@ -395,15 +397,17 @@ export const OverflowShadow = () => css`
|
|
|
395
397
|
}px)`};
|
|
396
398
|
}
|
|
397
399
|
.${ClassName.WITH_CONTROLS} {
|
|
398
|
-
${overflowShadowWidhoutDnD()}
|
|
400
|
+
${overflowShadowWidhoutDnD(isDragAndDropEnabled)}
|
|
399
401
|
.${ClassName.TABLE_LEFT_SHADOW} {
|
|
400
402
|
border-left: 1px solid ${tableBorderColor};
|
|
401
403
|
}
|
|
402
404
|
}
|
|
403
405
|
`;
|
|
404
406
|
|
|
405
|
-
const overflowShadowWidhoutDnD = (
|
|
406
|
-
|
|
407
|
+
const overflowShadowWidhoutDnD = (
|
|
408
|
+
isDragAndDropEnabled: boolean | undefined,
|
|
409
|
+
) => {
|
|
410
|
+
if (!isDragAndDropEnabled) {
|
|
407
411
|
return css`
|
|
408
412
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
409
413
|
height: calc(100% - ${tableMarginTopWithControl}px);
|
|
@@ -791,8 +795,8 @@ const getLastColumnResizerOverrides = () => {
|
|
|
791
795
|
: '';
|
|
792
796
|
};
|
|
793
797
|
|
|
794
|
-
const resizeHandleOverrides = () => {
|
|
795
|
-
if (
|
|
798
|
+
const resizeHandleOverrides = (isDragAndDropEnabled: boolean | undefined) => {
|
|
799
|
+
if (isDragAndDropEnabled) {
|
|
796
800
|
return css`
|
|
797
801
|
th.${ClassName.WITH_RESIZE_LINE}::before,
|
|
798
802
|
td.${ClassName.WITH_RESIZE_LINE}::before {
|
|
@@ -866,7 +870,7 @@ const resizeHandleOverrides = () => {
|
|
|
866
870
|
`;
|
|
867
871
|
};
|
|
868
872
|
|
|
869
|
-
export const resizeHandle = () => css`
|
|
873
|
+
export const resizeHandle = (isDragAndDropEnabled: boolean | undefined) => css`
|
|
870
874
|
.${ClassName.TABLE_CONTAINER} {
|
|
871
875
|
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
872
876
|
background-color: transparent;
|
|
@@ -881,7 +885,7 @@ export const resizeHandle = () => css`
|
|
|
881
885
|
|
|
882
886
|
${getLastColumnResizerOverrides()}
|
|
883
887
|
|
|
884
|
-
${resizeHandleOverrides()}
|
|
888
|
+
${resizeHandleOverrides(isDragAndDropEnabled)}
|
|
885
889
|
|
|
886
890
|
table
|
|
887
891
|
tr:first-of-type
|
package/src/utils/drag-menu.ts
CHANGED
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
AddRowBelowIcon,
|
|
56
56
|
} from '../ui/icons';
|
|
57
57
|
|
|
58
|
-
import { getSelectedColumnIndexes } from './
|
|
58
|
+
import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
59
59
|
|
|
60
60
|
const canDecrease = (index?: number, min: number = 0) =>
|
|
61
61
|
index !== undefined && index > min;
|
|
@@ -140,35 +140,49 @@ export const getDragMenuConfig = (
|
|
|
140
140
|
? [
|
|
141
141
|
{
|
|
142
142
|
label: 'up',
|
|
143
|
-
offset: -1,
|
|
144
|
-
canMove: (index?: number) => canDrag && canDecrease(index),
|
|
145
143
|
icon: ArrowUpIcon,
|
|
146
144
|
keymap: moveRowUp,
|
|
145
|
+
canMove: (selectionRect?: Rect) =>
|
|
146
|
+
canDrag && canDecrease(selectionRect?.top),
|
|
147
|
+
getOriginIndexes: getSelectedRowIndexes,
|
|
148
|
+
getTargetIndex: (selectionRect: Rect) => selectionRect.top - 1,
|
|
147
149
|
},
|
|
148
150
|
{
|
|
149
151
|
label: 'down',
|
|
150
|
-
offset: 1,
|
|
151
|
-
canMove: (index?: number) =>
|
|
152
|
-
canDrag && canIncrease(index, (tableMap?.height ?? 0) - 1),
|
|
153
152
|
icon: ArrowDownIcon,
|
|
154
153
|
keymap: moveRowDown,
|
|
154
|
+
canMove: (selectionRect?: Rect) =>
|
|
155
|
+
canDrag &&
|
|
156
|
+
canIncrease(
|
|
157
|
+
(selectionRect?.bottom ?? 0) - 1,
|
|
158
|
+
(tableMap?.height ?? 0) - 1,
|
|
159
|
+
),
|
|
160
|
+
getOriginIndexes: getSelectedRowIndexes,
|
|
161
|
+
getTargetIndex: (selectionRect: Rect) => selectionRect.bottom,
|
|
155
162
|
},
|
|
156
163
|
]
|
|
157
164
|
: [
|
|
158
165
|
{
|
|
159
166
|
label: 'left',
|
|
160
|
-
offset: -1,
|
|
161
|
-
canMove: (index?: number) => canDrag && canDecrease(index),
|
|
162
167
|
icon: ArrowLeftIcon,
|
|
163
168
|
keymap: moveColumnLeft,
|
|
169
|
+
canMove: (selectionRect?: Rect) =>
|
|
170
|
+
canDrag && canDecrease(selectionRect?.left),
|
|
171
|
+
getOriginIndexes: getSelectedColumnIndexes,
|
|
172
|
+
getTargetIndex: (selectionRect: Rect) => selectionRect.left - 1,
|
|
164
173
|
},
|
|
165
174
|
{
|
|
166
175
|
label: 'right',
|
|
167
|
-
offset: 1,
|
|
168
|
-
canMove: (index?: number) =>
|
|
169
|
-
canDrag && canIncrease(index, (tableMap?.width ?? 0) - 1),
|
|
170
176
|
icon: ArrowRightIcon,
|
|
171
177
|
keymap: moveColumnRight,
|
|
178
|
+
canMove: (selectionRect?: Rect) =>
|
|
179
|
+
canDrag &&
|
|
180
|
+
canIncrease(
|
|
181
|
+
(selectionRect?.right ?? 0) - 1,
|
|
182
|
+
(tableMap?.width ?? 0) - 1,
|
|
183
|
+
),
|
|
184
|
+
getOriginIndexes: getSelectedColumnIndexes,
|
|
185
|
+
getTargetIndex: (selectionRect: Rect) => selectionRect.right,
|
|
172
186
|
},
|
|
173
187
|
];
|
|
174
188
|
|
|
@@ -257,27 +271,29 @@ export const getDragMenuConfig = (
|
|
|
257
271
|
icon: RemoveIcon,
|
|
258
272
|
keymap: direction === 'row' ? tooltip(deleteRow) : tooltip(deleteColumn),
|
|
259
273
|
},
|
|
260
|
-
...moveOptions.map(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
274
|
+
...moveOptions.map(
|
|
275
|
+
({ label, canMove, icon, keymap, getOriginIndexes, getTargetIndex }) => ({
|
|
276
|
+
id: `move_${direction}_${label}`,
|
|
277
|
+
title: `Move ${direction} ${label}`,
|
|
278
|
+
disabled: !canMove(selectionRect),
|
|
279
|
+
icon,
|
|
280
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
281
|
+
if (canMove(selectionRect)) {
|
|
282
|
+
requestAnimationFrame(() => {
|
|
283
|
+
moveSourceWithAnalytics(editorAnalyticsAPI)(
|
|
284
|
+
INPUT_METHOD.TABLE_CONTEXT_MENU,
|
|
285
|
+
`table-${direction}`,
|
|
286
|
+
getOriginIndexes(selectionRect!),
|
|
287
|
+
getTargetIndex(selectionRect!),
|
|
288
|
+
)(editorView.state, editorView.dispatch);
|
|
289
|
+
});
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
return false;
|
|
293
|
+
},
|
|
294
|
+
keymap: keymap && tooltip(keymap),
|
|
295
|
+
}),
|
|
296
|
+
),
|
|
281
297
|
|
|
282
298
|
...sortOptions.map(({ label, order, icon }) => ({
|
|
283
299
|
id: `sort_column_${order}`,
|