@atlaskit/editor-plugin-table 5.5.2 → 5.5.4
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/commands/index.js +12 -0
- package/dist/cjs/plugins/table/commands/misc.js +61 -1
- package/dist/cjs/plugins/table/index.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +8 -19
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +70 -36
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +11 -0
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +46 -1
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +25 -29
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +5 -18
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +16 -1
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +61 -1
- package/dist/esm/plugins/table/index.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/esm/plugins/table/ui/DragHandle/index.js +6 -17
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +2 -0
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/package.json +1 -4
- package/src/__tests__/unit/ui/RowDragControls.tsx +2 -0
- package/src/plugins/table/commands/index.ts +2 -0
- package/src/plugins/table/commands/misc.ts +78 -0
- package/src/plugins/table/index.tsx +5 -7
- package/src/plugins/table/nodeviews/TableComponent.tsx +31 -38
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +2 -0
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -7
- package/src/plugins/table/types.ts +2 -0
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +5 -30
- package/src/plugins/table/ui/DragHandle/index.tsx +6 -23
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +134 -49
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +3 -3
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +137 -44
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
1
2
|
import type { MouseEvent } from 'react';
|
|
2
3
|
import React, { useCallback, useMemo } from 'react';
|
|
3
4
|
|
|
@@ -12,9 +13,10 @@ import {
|
|
|
12
13
|
hoverCell,
|
|
13
14
|
hoverColumns,
|
|
14
15
|
selectColumn,
|
|
16
|
+
selectColumns,
|
|
15
17
|
} from '../../../commands';
|
|
16
18
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
17
|
-
import type { CellHoverMeta } from '../../../types';
|
|
19
|
+
import type { CellHoverMeta, HandleTypes } from '../../../types';
|
|
18
20
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
19
21
|
import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
|
|
20
22
|
import { DragHandle } from '../../DragHandle';
|
|
@@ -69,14 +71,6 @@ export const ColumnControls = ({
|
|
|
69
71
|
const colIndex = hoveredCell?.colIndex;
|
|
70
72
|
const selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
71
73
|
|
|
72
|
-
const gridColumnPosition = useMemo(() => {
|
|
73
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
74
|
-
if (selectedColIndexes.includes(colIndex!)) {
|
|
75
|
-
return `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}`;
|
|
76
|
-
}
|
|
77
|
-
return `${colIndex! + 1} / span 1`;
|
|
78
|
-
}, [colIndex, selectedColIndexes]);
|
|
79
|
-
|
|
80
74
|
const firstRow = tableRef.querySelector('tr');
|
|
81
75
|
const hasHeaderRow = firstRow
|
|
82
76
|
? firstRow.getAttribute('data-header-row')
|
|
@@ -88,9 +82,28 @@ export const ColumnControls = ({
|
|
|
88
82
|
const handleClick = useCallback(
|
|
89
83
|
(event: MouseEvent) => {
|
|
90
84
|
const { state, dispatch } = editorView;
|
|
91
|
-
|
|
85
|
+
|
|
86
|
+
const isClickOutsideSelectedCols =
|
|
87
|
+
selectedColIndexes.length >= 1 &&
|
|
88
|
+
!selectedColIndexes.includes(colIndex!);
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
!selectedColIndexes ||
|
|
92
|
+
selectedColIndexes.length === 0 ||
|
|
93
|
+
isClickOutsideSelectedCols
|
|
94
|
+
) {
|
|
95
|
+
selectColumn(colIndex!, event.shiftKey)(state, dispatch);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
selectedColIndexes.length > 1 &&
|
|
100
|
+
selectedColIndexes.includes(colIndex!) &&
|
|
101
|
+
!event.shiftKey
|
|
102
|
+
) {
|
|
103
|
+
selectColumns(selectedColIndexes)(state, dispatch);
|
|
104
|
+
}
|
|
92
105
|
},
|
|
93
|
-
[colIndex, editorView],
|
|
106
|
+
[colIndex, selectedColIndexes, editorView],
|
|
94
107
|
);
|
|
95
108
|
|
|
96
109
|
const handleMouseOver = useCallback(() => {
|
|
@@ -143,6 +156,114 @@ export const ColumnControls = ({
|
|
|
143
156
|
|
|
144
157
|
const previewHeight = rowHeights?.reduce((sum, cur) => sum + cur, 0) ?? 0;
|
|
145
158
|
|
|
159
|
+
const generateHandleByType = (type: HandleTypes): JSX.Element | null => {
|
|
160
|
+
if (!hoveredCell || !colWidths?.length) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const isHover = type === 'hover';
|
|
164
|
+
|
|
165
|
+
const isColumnsSelected = selectedColIndexes.length > 0;
|
|
166
|
+
|
|
167
|
+
const showCondition = isHover
|
|
168
|
+
? isColumnsSelected &&
|
|
169
|
+
!selectedColIndexes.includes(colIndex!) &&
|
|
170
|
+
Number.isFinite(hoveredCell?.colIndex)
|
|
171
|
+
: selectedColIndexes.length < colWidths?.length &&
|
|
172
|
+
Number.isFinite(hoveredCell?.colIndex);
|
|
173
|
+
|
|
174
|
+
if (!showCondition) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const gridColumnPosition = `${colIndex! + 1} / span 1`;
|
|
179
|
+
const selectedColumnPosition = `${selectedColIndexes[0] + 1} / span ${
|
|
180
|
+
selectedColIndexes.length
|
|
181
|
+
}`;
|
|
182
|
+
|
|
183
|
+
const hoveredAppearance = selectedColIndexes.includes(colIndex!)
|
|
184
|
+
? isInDanger
|
|
185
|
+
? 'danger'
|
|
186
|
+
: 'selected'
|
|
187
|
+
: 'default';
|
|
188
|
+
|
|
189
|
+
const currentSelectionApprearance = isColumnsSelected
|
|
190
|
+
? isInDanger
|
|
191
|
+
? 'danger'
|
|
192
|
+
: 'selected'
|
|
193
|
+
: hoveredAppearance;
|
|
194
|
+
|
|
195
|
+
const istSelecting = isColumnsSelected && !isHover;
|
|
196
|
+
|
|
197
|
+
// this indexes are used to calculate the drag and drop source
|
|
198
|
+
const indexes = isColumnsSelected
|
|
199
|
+
? isHover
|
|
200
|
+
? colIndexes
|
|
201
|
+
: selectedColIndexes
|
|
202
|
+
: colIndexes;
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
showCondition && (
|
|
206
|
+
<div
|
|
207
|
+
key={type}
|
|
208
|
+
style={{
|
|
209
|
+
gridColumn: istSelecting
|
|
210
|
+
? selectedColumnPosition
|
|
211
|
+
: gridColumnPosition,
|
|
212
|
+
display: 'flex',
|
|
213
|
+
justifyContent: 'center',
|
|
214
|
+
alignItems: 'center',
|
|
215
|
+
height: 'fit-content',
|
|
216
|
+
placeSelf: 'center',
|
|
217
|
+
zIndex: 99,
|
|
218
|
+
}}
|
|
219
|
+
data-column-control-index={hoveredCell.colIndex}
|
|
220
|
+
data-testid={
|
|
221
|
+
isHover
|
|
222
|
+
? 'table-floating-column-control-hover'
|
|
223
|
+
: 'table-floating-column-control'
|
|
224
|
+
}
|
|
225
|
+
>
|
|
226
|
+
<DragHandle
|
|
227
|
+
direction="column"
|
|
228
|
+
tableLocalId={localId || ''}
|
|
229
|
+
indexes={indexes}
|
|
230
|
+
forceDefaultHandle={isHover ? false : isColumnsSelected}
|
|
231
|
+
previewWidth={colWidths?.[colIndex!] ?? tableCellMinWidth}
|
|
232
|
+
previewHeight={previewHeight}
|
|
233
|
+
appearance={
|
|
234
|
+
istSelecting ? currentSelectionApprearance : hoveredAppearance
|
|
235
|
+
}
|
|
236
|
+
onClick={handleClick}
|
|
237
|
+
onMouseOver={handleMouseOver}
|
|
238
|
+
onMouseOut={handleMouseOut}
|
|
239
|
+
onMouseUp={handleMouseUp}
|
|
240
|
+
editorView={editorView}
|
|
241
|
+
canDrag={canDrag}
|
|
242
|
+
/>
|
|
243
|
+
</div>
|
|
244
|
+
)
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const columnHandles = (hoveredCell: CellHoverMeta | undefined) => {
|
|
249
|
+
if (!hoveredCell) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (hoveredCell.colIndex === undefined) {
|
|
254
|
+
return generateHandleByType('selected');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const sortedHandles = [
|
|
258
|
+
generateHandleByType('hover'),
|
|
259
|
+
generateHandleByType('selected'),
|
|
260
|
+
];
|
|
261
|
+
|
|
262
|
+
return hoveredCell.colIndex < selectedColIndexes[0]
|
|
263
|
+
? sortedHandles
|
|
264
|
+
: sortedHandles.reverse();
|
|
265
|
+
};
|
|
266
|
+
|
|
146
267
|
return (
|
|
147
268
|
<div
|
|
148
269
|
className={ClassName.DRAG_COLUMN_CONTROLS}
|
|
@@ -185,45 +306,9 @@ export const ColumnControls = ({
|
|
|
185
306
|
</div>
|
|
186
307
|
))}
|
|
187
308
|
{tableActive &&
|
|
188
|
-
!isResizing &&
|
|
189
309
|
isTableHovered &&
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
<div
|
|
193
|
-
style={{
|
|
194
|
-
gridColumn: gridColumnPosition,
|
|
195
|
-
display: 'flex',
|
|
196
|
-
justifyContent: 'center',
|
|
197
|
-
alignItems: 'center',
|
|
198
|
-
height: 'fit-content',
|
|
199
|
-
placeSelf: 'center',
|
|
200
|
-
zIndex: 99,
|
|
201
|
-
}}
|
|
202
|
-
data-column-control-index={hoveredCell.colIndex}
|
|
203
|
-
data-testid="table-floating-column-control"
|
|
204
|
-
>
|
|
205
|
-
<DragHandle
|
|
206
|
-
direction="column"
|
|
207
|
-
tableLocalId={localId || ''}
|
|
208
|
-
indexes={colIndexes}
|
|
209
|
-
previewWidth={colWidths?.[colIndex!] ?? tableCellMinWidth}
|
|
210
|
-
previewHeight={previewHeight}
|
|
211
|
-
appearance={
|
|
212
|
-
selectedColIndexes.includes(hoveredCell.colIndex!)
|
|
213
|
-
? isInDanger
|
|
214
|
-
? 'danger'
|
|
215
|
-
: 'selected'
|
|
216
|
-
: 'default'
|
|
217
|
-
}
|
|
218
|
-
onClick={handleClick}
|
|
219
|
-
onMouseOver={handleMouseOver}
|
|
220
|
-
onMouseOut={handleMouseOut}
|
|
221
|
-
onMouseUp={handleMouseUp}
|
|
222
|
-
editorView={editorView}
|
|
223
|
-
canDrag={canDrag}
|
|
224
|
-
/>
|
|
225
|
-
</div>
|
|
226
|
-
)}
|
|
310
|
+
!isResizing &&
|
|
311
|
+
columnHandles(hoveredCell)}
|
|
227
312
|
</div>
|
|
228
313
|
</div>
|
|
229
314
|
);
|
|
@@ -81,9 +81,9 @@ export default class NumberColumn extends Component<Props, any> {
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
private hoverRows = (index: number) =>
|
|
85
|
-
this.props.tableActive ? this.props.hoverRows([index]) : null;
|
|
86
|
-
|
|
84
|
+
private hoverRows = (index: number) => {
|
|
85
|
+
return this.props.tableActive ? this.props.hoverRows([index]) : null;
|
|
86
|
+
};
|
|
87
87
|
private selectRow = (
|
|
88
88
|
index: number,
|
|
89
89
|
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
1
2
|
import type { MouseEvent } from 'react';
|
|
2
3
|
import React, {
|
|
3
4
|
Fragment,
|
|
@@ -22,7 +23,11 @@ import { clearHoverSelection } from '../../../commands';
|
|
|
22
23
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
23
24
|
import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
|
|
24
25
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
25
|
-
import type {
|
|
26
|
+
import type {
|
|
27
|
+
CellHoverMeta,
|
|
28
|
+
DraggableSourceData,
|
|
29
|
+
HandleTypes,
|
|
30
|
+
} from '../../../types';
|
|
26
31
|
import {
|
|
27
32
|
getRowHeights,
|
|
28
33
|
getRowsParams,
|
|
@@ -45,6 +50,7 @@ type DragControlsProps = {
|
|
|
45
50
|
canDrag?: boolean;
|
|
46
51
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
47
52
|
selectRow: (row: number, expand: boolean) => void;
|
|
53
|
+
selectRows: (rowIndexes: number[]) => void;
|
|
48
54
|
updateCellHoverLocation: (rowIndex: number) => void;
|
|
49
55
|
};
|
|
50
56
|
|
|
@@ -72,6 +78,7 @@ const DragControlsComponent = ({
|
|
|
72
78
|
canDrag,
|
|
73
79
|
hoverRows,
|
|
74
80
|
selectRow,
|
|
81
|
+
selectRows,
|
|
75
82
|
updateCellHoverLocation,
|
|
76
83
|
}: DragControlsProps & WrappedComponentProps) => {
|
|
77
84
|
const [isDragging, setIsDragging] = useState(false);
|
|
@@ -116,14 +123,6 @@ const DragControlsComponent = ({
|
|
|
116
123
|
|
|
117
124
|
const rowIndex = hoveredCell?.rowIndex;
|
|
118
125
|
|
|
119
|
-
const gridRowPosition = useMemo(() => {
|
|
120
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
121
|
-
if (selectedRowIndexes.includes(rowIndex!)) {
|
|
122
|
-
return `${selectedRowIndexes[0] + 1} / span ${selectedRowIndexes.length}`;
|
|
123
|
-
}
|
|
124
|
-
return `${rowIndex! + 1} / span 1`;
|
|
125
|
-
}, [rowIndex, selectedRowIndexes]);
|
|
126
|
-
|
|
127
126
|
const handleMouseOut = useCallback(() => {
|
|
128
127
|
if (tableActive) {
|
|
129
128
|
const { state, dispatch } = editorView;
|
|
@@ -160,11 +159,133 @@ const DragControlsComponent = ({
|
|
|
160
159
|
|
|
161
160
|
const handleClick = useCallback(
|
|
162
161
|
(e: MouseEvent) => {
|
|
163
|
-
|
|
162
|
+
const isClickOutsideSelectedRows =
|
|
163
|
+
selectedRowIndexes.length >= 1 &&
|
|
164
|
+
!selectedRowIndexes.includes(rowIndex!);
|
|
165
|
+
if (
|
|
166
|
+
!selectedRowIndexes ||
|
|
167
|
+
selectedRowIndexes.length === 0 ||
|
|
168
|
+
isClickOutsideSelectedRows
|
|
169
|
+
) {
|
|
170
|
+
selectRow(rowIndex!, e.shiftKey);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (
|
|
174
|
+
selectedRowIndexes.length > 1 &&
|
|
175
|
+
selectedRowIndexes.includes(rowIndex!) &&
|
|
176
|
+
!e.shiftKey
|
|
177
|
+
) {
|
|
178
|
+
selectRows(selectedRowIndexes);
|
|
179
|
+
}
|
|
164
180
|
},
|
|
165
|
-
[rowIndex, selectRow],
|
|
181
|
+
[rowIndex, selectRow, selectRows, selectedRowIndexes],
|
|
166
182
|
);
|
|
167
183
|
|
|
184
|
+
const generateHandleByType = (type: HandleTypes): JSX.Element | null => {
|
|
185
|
+
if (!hoveredCell) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
const isHover = type === 'hover';
|
|
189
|
+
|
|
190
|
+
const isRowsSelected = selectedRowIndexes.length > 0;
|
|
191
|
+
|
|
192
|
+
const showCondition = isHover
|
|
193
|
+
? isRowsSelected &&
|
|
194
|
+
!selectedRowIndexes.includes(rowIndex!) &&
|
|
195
|
+
Number.isFinite(hoveredCell?.colIndex)
|
|
196
|
+
: selectedRowIndexes.length < rowHeights.length &&
|
|
197
|
+
Number.isFinite(hoveredCell?.colIndex);
|
|
198
|
+
|
|
199
|
+
if (!showCondition) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const gridRowPosition = `${rowIndex! + 1} / span 1`;
|
|
204
|
+
|
|
205
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
206
|
+
const selectedRowPosition = `${selectedRowIndexes[0] + 1} / span ${
|
|
207
|
+
selectedRowIndexes.length
|
|
208
|
+
}`;
|
|
209
|
+
|
|
210
|
+
const hoveredAppearance = selectedRowIndexes.includes(rowIndex!)
|
|
211
|
+
? isInDanger
|
|
212
|
+
? 'danger'
|
|
213
|
+
: 'selected'
|
|
214
|
+
: 'default';
|
|
215
|
+
|
|
216
|
+
const currentSelectionAppearance = isRowsSelected
|
|
217
|
+
? isInDanger
|
|
218
|
+
? 'danger'
|
|
219
|
+
: 'selected'
|
|
220
|
+
: hoveredAppearance;
|
|
221
|
+
|
|
222
|
+
const isSelecting = isRowsSelected && !isHover;
|
|
223
|
+
|
|
224
|
+
const indexes = isRowsSelected
|
|
225
|
+
? isHover
|
|
226
|
+
? rowIndexes
|
|
227
|
+
: selectedRowIndexes
|
|
228
|
+
: rowIndexes;
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
showCondition && (
|
|
232
|
+
<div
|
|
233
|
+
key={type}
|
|
234
|
+
style={{
|
|
235
|
+
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
236
|
+
gridColumn: '2',
|
|
237
|
+
// 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
|
|
238
|
+
width: '9px',
|
|
239
|
+
position: 'relative',
|
|
240
|
+
right: '-0.5px',
|
|
241
|
+
}}
|
|
242
|
+
data-testid={
|
|
243
|
+
isHover
|
|
244
|
+
? 'table-floating-row-drag-handle-hover'
|
|
245
|
+
: 'table-floating-row-drag-handle'
|
|
246
|
+
}
|
|
247
|
+
>
|
|
248
|
+
<DragHandle
|
|
249
|
+
direction="row"
|
|
250
|
+
tableLocalId={currentNodeLocalId}
|
|
251
|
+
indexes={indexes}
|
|
252
|
+
forceDefaultHandle={isHover ? false : isRowsSelected}
|
|
253
|
+
previewWidth={tableWidth}
|
|
254
|
+
previewHeight={rowHeights[rowIndex!]}
|
|
255
|
+
appearance={
|
|
256
|
+
isSelecting ? currentSelectionAppearance : hoveredAppearance
|
|
257
|
+
}
|
|
258
|
+
onClick={handleClick}
|
|
259
|
+
onMouseOver={handleMouseOver}
|
|
260
|
+
onMouseOut={handleMouseOut}
|
|
261
|
+
onMouseUp={onMouseUp}
|
|
262
|
+
editorView={editorView}
|
|
263
|
+
canDrag={canDrag}
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
)
|
|
267
|
+
);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const rowHandles = (hoveredCell: CellHoverMeta | undefined) => {
|
|
271
|
+
if (!hoveredCell) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (hoveredCell.rowIndex === undefined) {
|
|
276
|
+
return generateHandleByType('selected');
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const sortedHandles = [
|
|
280
|
+
generateHandleByType('hover'),
|
|
281
|
+
generateHandleByType('selected'),
|
|
282
|
+
];
|
|
283
|
+
|
|
284
|
+
return hoveredCell.rowIndex < selectedRowIndexes[0]
|
|
285
|
+
? sortedHandles
|
|
286
|
+
: sortedHandles.reverse();
|
|
287
|
+
};
|
|
288
|
+
|
|
168
289
|
return (
|
|
169
290
|
<div
|
|
170
291
|
className={ClassName.DRAG_ROW_CONTROLS}
|
|
@@ -221,39 +342,11 @@ const DragControlsComponent = ({
|
|
|
221
342
|
)}
|
|
222
343
|
</Fragment>
|
|
223
344
|
))}
|
|
224
|
-
{
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// 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
|
|
230
|
-
width: '9px',
|
|
231
|
-
position: 'relative',
|
|
232
|
-
right: '-0.5px',
|
|
233
|
-
}}
|
|
234
|
-
data-testid="table-floating-row-drag-handle"
|
|
235
|
-
>
|
|
236
|
-
<DragHandle
|
|
237
|
-
tableLocalId={currentNodeLocalId}
|
|
238
|
-
indexes={rowIndexes}
|
|
239
|
-
previewWidth={tableWidth}
|
|
240
|
-
previewHeight={rowHeights[rowIndex!]}
|
|
241
|
-
appearance={
|
|
242
|
-
selectedRowIndexes.includes(rowIndex!)
|
|
243
|
-
? isInDanger
|
|
244
|
-
? 'danger'
|
|
245
|
-
: 'selected'
|
|
246
|
-
: 'default'
|
|
247
|
-
}
|
|
248
|
-
onClick={handleClick}
|
|
249
|
-
onMouseOver={handleMouseOver}
|
|
250
|
-
onMouseOut={handleMouseOut}
|
|
251
|
-
onMouseUp={onMouseUp}
|
|
252
|
-
editorView={editorView}
|
|
253
|
-
canDrag={canDrag}
|
|
254
|
-
/>
|
|
255
|
-
</div>
|
|
256
|
-
)}
|
|
345
|
+
{tableActive &&
|
|
346
|
+
isTableHovered &&
|
|
347
|
+
!isResizing &&
|
|
348
|
+
Number.isFinite(rowIndex) &&
|
|
349
|
+
rowHandles(hoveredCell)}
|
|
257
350
|
</div>
|
|
258
351
|
);
|
|
259
352
|
};
|
|
@@ -6,7 +6,7 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
6
6
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
|
|
9
|
-
import { hoverCell, hoverRows, selectRow } from '../../commands';
|
|
9
|
+
import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
|
|
10
10
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
11
11
|
import { TableCssClassName as ClassName } from '../../types';
|
|
12
12
|
import type { CellHoverMeta } from '../../types';
|
|
@@ -211,6 +211,7 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
211
211
|
tableWidth={this.state.tableWrapperWidth}
|
|
212
212
|
hoverRows={this.hoverRows}
|
|
213
213
|
selectRow={this.selectRow}
|
|
214
|
+
selectRows={this.selectRows}
|
|
214
215
|
updateCellHoverLocation={this.updateCellHoverLocation}
|
|
215
216
|
canDrag={canDrag}
|
|
216
217
|
/>
|
|
@@ -256,6 +257,16 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
256
257
|
selectRow(row, expand)(state, dispatch);
|
|
257
258
|
};
|
|
258
259
|
|
|
260
|
+
private selectRows = (rowIndexes: number[]) => {
|
|
261
|
+
const { editorView } = this.props;
|
|
262
|
+
const { state, dispatch } = editorView;
|
|
263
|
+
// fix for issue ED-4665
|
|
264
|
+
if (browser.ie_version === 11) {
|
|
265
|
+
(editorView.dom as HTMLElement).blur();
|
|
266
|
+
}
|
|
267
|
+
selectRows(rowIndexes)(state, dispatch);
|
|
268
|
+
};
|
|
269
|
+
|
|
259
270
|
private hoverRows = (rows: Array<number>, danger?: boolean) => {
|
|
260
271
|
const { state, dispatch } = this.props.editorView;
|
|
261
272
|
hoverRows(rows, danger)(state, dispatch);
|