@atlaskit/editor-plugin-table 5.4.16 → 5.4.18
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/hover.js +4 -2
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +2 -2
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +5 -3
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +4 -6
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +33 -62
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +31 -62
- package/dist/es2019/plugins/table/commands/hover.js +4 -2
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +2 -2
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +5 -3
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -3
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +33 -63
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +29 -61
- package/dist/esm/plugins/table/commands/hover.js +4 -2
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +2 -2
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +5 -3
- package/dist/esm/plugins/table/ui/DragHandle/index.js +2 -4
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +33 -62
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +29 -60
- package/dist/types/plugins/table/types.d.ts +1 -1
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +0 -1
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +1 -2
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +1 -2
- package/package.json +1 -1
- package/src/plugins/table/commands/hover.ts +2 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +1 -1
- package/src/plugins/table/nodeviews/TableResizer.tsx +4 -2
- package/src/plugins/table/types.ts +1 -2
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +9 -10
- package/src/plugins/table/ui/DragHandle/index.tsx +8 -6
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +3 -2
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +48 -118
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +41 -126
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
-
|
|
3
1
|
import React, { useCallback, useMemo } from 'react';
|
|
4
2
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
3
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
6
4
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn } from '../../../commands';
|
|
7
5
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
8
|
-
import { getPluginState as getDragDropPluginState } from '../../../pm-plugins/drag-and-drop/plugin-factory';
|
|
9
6
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
10
7
|
import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
|
|
11
8
|
import { DragHandle } from '../../DragHandle';
|
|
@@ -33,12 +30,19 @@ export const ColumnControls = ({
|
|
|
33
30
|
hasHeaderColumn,
|
|
34
31
|
isTableHovered
|
|
35
32
|
}) => {
|
|
36
|
-
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
|
|
33
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce, _colWidths;
|
|
37
34
|
const widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(width => width ? `${width - 1}px` : '0px').join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
38
35
|
// TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
39
36
|
const columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
40
37
|
const colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
41
38
|
const selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
39
|
+
const gridColumnPosition = useMemo(() => {
|
|
40
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
41
|
+
if (selectedColIndexes.includes(colIndex)) {
|
|
42
|
+
return `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}`;
|
|
43
|
+
}
|
|
44
|
+
return `${colIndex + 1} / span 1`;
|
|
45
|
+
}, [colIndex, selectedColIndexes]);
|
|
42
46
|
const firstRow = tableRef.querySelector('tr');
|
|
43
47
|
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
44
48
|
const marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
@@ -98,64 +102,6 @@ export const ColumnControls = ({
|
|
|
98
102
|
return [colIndex];
|
|
99
103
|
}, [colIndex]);
|
|
100
104
|
const previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce((sum, cur) => sum + cur, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
101
|
-
const generateHandleByType = useCallback(type => {
|
|
102
|
-
var _colWidths;
|
|
103
|
-
if (!hoveredCell) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const {
|
|
107
|
-
isDragMenuOpen,
|
|
108
|
-
dragMenuIndex,
|
|
109
|
-
dragMenuDirection
|
|
110
|
-
} = getDragDropPluginState(editorView.state);
|
|
111
|
-
const isHover = type === 'hover';
|
|
112
|
-
const isHoveredOnSelectedColumn = isDragMenuOpen && dragMenuDirection === 'column' && dragMenuIndex === colIndex;
|
|
113
|
-
const showCondition = isHover ? !isHoveredOnSelectedColumn && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'column';
|
|
114
|
-
if (!showCondition) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
const selectedColumnPosition = `${dragMenuIndex + 1} / span ${selectedColIndexes.length}`;
|
|
118
|
-
const gridColumnPosition = selectedColIndexes.includes(colIndex) ? `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}` : `${colIndex + 1} / span 1`;
|
|
119
|
-
const selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
120
|
-
const hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
121
|
-
return showCondition && /*#__PURE__*/React.createElement("div", {
|
|
122
|
-
key: type,
|
|
123
|
-
style: {
|
|
124
|
-
gridColumn: isHover ? gridColumnPosition : selectedColumnPosition,
|
|
125
|
-
display: 'flex',
|
|
126
|
-
justifyContent: 'center',
|
|
127
|
-
alignItems: 'center',
|
|
128
|
-
height: 'fit-content',
|
|
129
|
-
placeSelf: 'center',
|
|
130
|
-
zIndex: 99
|
|
131
|
-
},
|
|
132
|
-
"data-column-control-index": hoveredCell.colIndex,
|
|
133
|
-
"data-testid": isHover ? 'table-floating-column-control' : 'table-floating-column-control-selected'
|
|
134
|
-
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
135
|
-
direction: "column",
|
|
136
|
-
tableLocalId: localId || '',
|
|
137
|
-
indexes: isHover ? colIndexes : selectedColIndexes,
|
|
138
|
-
forceDefaultHandle: !isHover,
|
|
139
|
-
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
140
|
-
previewHeight: previewHeight,
|
|
141
|
-
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
142
|
-
onClick: handleClick,
|
|
143
|
-
onMouseOver: handleMouseOver,
|
|
144
|
-
onMouseOut: handleMouseOut,
|
|
145
|
-
onMouseUp: handleMouseUp,
|
|
146
|
-
editorView: editorView
|
|
147
|
-
}));
|
|
148
|
-
}, [colIndex, previewHeight, colWidths, colIndexes, editorView, handleClick, handleMouseOut, handleMouseOver, handleMouseUp, hoveredCell, isInDanger, localId, selectedColIndexes]);
|
|
149
|
-
const columnHandles = useCallback(hoveredCell => {
|
|
150
|
-
if (!hoveredCell) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
if (hoveredCell.colIndex === undefined) {
|
|
154
|
-
return generateHandleByType('selected');
|
|
155
|
-
}
|
|
156
|
-
const sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
157
|
-
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
158
|
-
}, [generateHandleByType, selectedColIndexes]);
|
|
159
105
|
return /*#__PURE__*/React.createElement("div", {
|
|
160
106
|
className: ClassName.DRAG_COLUMN_CONTROLS,
|
|
161
107
|
onMouseMove: handleMouseMove
|
|
@@ -183,6 +129,30 @@ export const ColumnControls = ({
|
|
|
183
129
|
style: columnParams.length - 1 === index ? {
|
|
184
130
|
right: '0'
|
|
185
131
|
} : {}
|
|
186
|
-
}))), tableActive && !isResizing &&
|
|
132
|
+
}))), tableActive && !isResizing && isTableHovered && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
style: {
|
|
134
|
+
gridColumn: gridColumnPosition,
|
|
135
|
+
display: 'flex',
|
|
136
|
+
justifyContent: 'center',
|
|
137
|
+
alignItems: 'center',
|
|
138
|
+
height: 'fit-content',
|
|
139
|
+
placeSelf: 'center',
|
|
140
|
+
zIndex: 99
|
|
141
|
+
},
|
|
142
|
+
"data-column-control-index": hoveredCell.colIndex,
|
|
143
|
+
"data-testid": "table-floating-column-control"
|
|
144
|
+
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
145
|
+
direction: "column",
|
|
146
|
+
tableLocalId: localId || '',
|
|
147
|
+
indexes: colIndexes,
|
|
148
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
149
|
+
previewHeight: previewHeight,
|
|
150
|
+
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
151
|
+
onClick: handleClick,
|
|
152
|
+
onMouseOver: handleMouseOver,
|
|
153
|
+
onMouseOut: handleMouseOut,
|
|
154
|
+
onMouseUp: handleMouseUp,
|
|
155
|
+
editorView: editorView
|
|
156
|
+
}))));
|
|
187
157
|
};
|
|
188
158
|
export default ColumnControls;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
-
|
|
3
1
|
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
2
|
import { injectIntl } from 'react-intl-next';
|
|
5
3
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
@@ -7,7 +5,6 @@ import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
|
7
5
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
8
6
|
import { clearHoverSelection } from '../../../commands';
|
|
9
7
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
10
|
-
import { getPluginState as getDragDropPluginState } from '../../../pm-plugins/drag-and-drop/plugin-factory';
|
|
11
8
|
import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
|
|
12
9
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
13
10
|
import { getRowHeights, getRowsParams, getSelectedRowIndexes } from '../../../utils';
|
|
@@ -77,6 +74,13 @@ const DragControlsComponent = ({
|
|
|
77
74
|
toggleDragMenu(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
78
75
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
79
76
|
const rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
77
|
+
const gridRowPosition = useMemo(() => {
|
|
78
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
79
|
+
if (selectedRowIndexes.includes(rowIndex)) {
|
|
80
|
+
return `${selectedRowIndexes[0] + 1} / span ${selectedRowIndexes.length}`;
|
|
81
|
+
}
|
|
82
|
+
return `${rowIndex + 1} / span 1`;
|
|
83
|
+
}, [rowIndex, selectedRowIndexes]);
|
|
80
84
|
const handleMouseOut = useCallback(() => {
|
|
81
85
|
if (tableActive) {
|
|
82
86
|
const {
|
|
@@ -105,63 +109,6 @@ const DragControlsComponent = ({
|
|
|
105
109
|
const handleClick = useCallback(e => {
|
|
106
110
|
selectRow(rowIndex, e === null || e === void 0 ? void 0 : e.shiftKey);
|
|
107
111
|
}, [rowIndex, selectRow]);
|
|
108
|
-
const generateHandleByType = useCallback(type => {
|
|
109
|
-
if (!hoveredCell) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
const {
|
|
113
|
-
isDragMenuOpen,
|
|
114
|
-
dragMenuIndex,
|
|
115
|
-
dragMenuDirection
|
|
116
|
-
} = getDragDropPluginState(editorView.state);
|
|
117
|
-
const isHover = type === 'hover';
|
|
118
|
-
const isHoveredOnSelectedRow = isDragMenuOpen && dragMenuDirection === 'row' && dragMenuIndex === rowIndex;
|
|
119
|
-
const showCondition = isHover ? !isHoveredOnSelectedRow && !selectedRowIndexes.includes(rowIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'row' && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
120
|
-
if (!showCondition) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
const gridRowPosition =
|
|
124
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
125
|
-
selectedRowIndexes.includes(rowIndex) ? `${selectedRowIndexes[0] + 1} / span ${selectedRowIndexes.length}` : `${rowIndex + 1} / span 1`;
|
|
126
|
-
const selectedRowPosition = `${dragMenuIndex + 1} / span ${selectedRowIndexes.length}`;
|
|
127
|
-
const selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
128
|
-
const hoveredAppearance = selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
129
|
-
return showCondition && /*#__PURE__*/React.createElement("div", {
|
|
130
|
-
key: type,
|
|
131
|
-
style: {
|
|
132
|
-
gridRow: isHover ? gridRowPosition : selectedRowPosition,
|
|
133
|
-
gridColumn: '2',
|
|
134
|
-
display: 'flex',
|
|
135
|
-
height: '100%',
|
|
136
|
-
alignItems: 'center',
|
|
137
|
-
justifyContent: 'center'
|
|
138
|
-
},
|
|
139
|
-
"data-testid": isHover ? 'table-floating-row-drag-handle' : 'table-floating-row-control-selected'
|
|
140
|
-
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
141
|
-
direction: "row",
|
|
142
|
-
tableLocalId: currentNodeLocalId,
|
|
143
|
-
indexes: isHover ? rowIndexes : selectedRowIndexes,
|
|
144
|
-
forceDefaultHandle: !isHover,
|
|
145
|
-
previewWidth: tableWidth,
|
|
146
|
-
previewHeight: rowHeights[rowIndex],
|
|
147
|
-
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
148
|
-
onClick: handleClick,
|
|
149
|
-
onMouseOver: handleMouseOver,
|
|
150
|
-
onMouseOut: handleMouseOut,
|
|
151
|
-
onMouseUp: onMouseUp,
|
|
152
|
-
editorView: editorView
|
|
153
|
-
}));
|
|
154
|
-
}, [currentNodeLocalId, editorView, handleClick, handleMouseOut, handleMouseOver, hoveredCell, isInDanger, onMouseUp, rowHeights, rowIndex, rowIndexes, selectedRowIndexes, tableWidth]);
|
|
155
|
-
const rowHandles = useCallback(hoveredCell => {
|
|
156
|
-
if (!hoveredCell) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
if (hoveredCell.rowIndex === undefined) {
|
|
160
|
-
return generateHandleByType('selected');
|
|
161
|
-
}
|
|
162
|
-
const sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
163
|
-
return hoveredCell.rowIndex < selectedRowIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
164
|
-
}, [generateHandleByType, selectedRowIndexes]);
|
|
165
112
|
return /*#__PURE__*/React.createElement("div", {
|
|
166
113
|
className: ClassName.DRAG_ROW_CONTROLS,
|
|
167
114
|
style: {
|
|
@@ -200,6 +147,27 @@ const DragControlsComponent = ({
|
|
|
200
147
|
position: 'relative',
|
|
201
148
|
left: "var(--ds-space-negative-100, -8px)"
|
|
202
149
|
}
|
|
203
|
-
}))), !isResizing && Number.isFinite(rowIndex) &&
|
|
150
|
+
}))), !isResizing && isTableHovered && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
|
|
151
|
+
style: {
|
|
152
|
+
gridRow: gridRowPosition,
|
|
153
|
+
gridColumn: '2',
|
|
154
|
+
display: 'flex',
|
|
155
|
+
height: '100%',
|
|
156
|
+
alignItems: 'center',
|
|
157
|
+
justifyContent: 'center'
|
|
158
|
+
},
|
|
159
|
+
"data-testid": "table-floating-row-drag-handle"
|
|
160
|
+
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
161
|
+
tableLocalId: currentNodeLocalId,
|
|
162
|
+
indexes: rowIndexes,
|
|
163
|
+
previewWidth: tableWidth,
|
|
164
|
+
previewHeight: rowHeights[rowIndex],
|
|
165
|
+
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
166
|
+
onClick: handleClick,
|
|
167
|
+
onMouseOver: handleMouseOver,
|
|
168
|
+
onMouseOut: handleMouseOut,
|
|
169
|
+
onMouseUp: onMouseUp,
|
|
170
|
+
editorView: editorView
|
|
171
|
+
})));
|
|
204
172
|
};
|
|
205
173
|
export const DragControls = injectIntl(DragControlsComponent);
|
|
@@ -99,7 +99,8 @@ export var hoverTable = function hoverTable(isInDanger, isSelected) {
|
|
|
99
99
|
decorationSet: updatePluginStateDecorations(state, decorations, TableDecorations.TABLE_CONTROLS_HOVER),
|
|
100
100
|
hoveredColumns: hoveredColumns,
|
|
101
101
|
hoveredRows: hoveredRows,
|
|
102
|
-
isInDanger: isInDanger
|
|
102
|
+
isInDanger: isInDanger,
|
|
103
|
+
isWholeTableInDanger: isInDanger
|
|
103
104
|
}
|
|
104
105
|
};
|
|
105
106
|
}, function (tr) {
|
|
@@ -112,7 +113,8 @@ export var clearHoverSelection = function clearHoverSelection() {
|
|
|
112
113
|
type: 'CLEAR_HOVER_SELECTION',
|
|
113
114
|
data: {
|
|
114
115
|
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.ALL_CONTROLS_HOVER),
|
|
115
|
-
isInDanger: false
|
|
116
|
+
isInDanger: false,
|
|
117
|
+
isWholeTableInDanger: false
|
|
116
118
|
}
|
|
117
119
|
};
|
|
118
120
|
});
|
|
@@ -279,7 +279,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
279
279
|
_this.containerWidth = _containerWidth;
|
|
280
280
|
_this.isInitialOverflowSent = false;
|
|
281
281
|
|
|
282
|
-
// store table size using previous full-width mode so can detect if it has changed
|
|
282
|
+
// store table size using previous full-width mode so can detect if it has changed.
|
|
283
283
|
var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
284
284
|
_this.layoutSize = _this.tableNodeLayoutSize(_this.node, _containerWidth.width, {
|
|
285
285
|
isFullWidthModeEnabled: isFullWidthModeEnabled
|
|
@@ -95,7 +95,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
95
95
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
96
96
|
var handleSize = getResizerHandleHeight(tableRef);
|
|
97
97
|
var _getPluginState = getPluginState(editorView.state),
|
|
98
|
-
|
|
98
|
+
isWholeTableInDanger = _getPluginState.isWholeTableInDanger;
|
|
99
99
|
var _useMeasureFramerate = useMeasureFramerate(),
|
|
100
100
|
startMeasure = _useMeasureFramerate.startMeasure,
|
|
101
101
|
endMeasure = _useMeasureFramerate.endMeasure,
|
|
@@ -242,7 +242,7 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
242
242
|
snap: guidelineSnaps,
|
|
243
243
|
handlePositioning: "adjacent",
|
|
244
244
|
isHandleVisible: isTableSelected,
|
|
245
|
-
appearance:
|
|
245
|
+
appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
|
|
246
246
|
handleHighlight: "shadow",
|
|
247
247
|
handleTooltipContent: formatMessage(messages.resizeTable)
|
|
248
248
|
}, children);
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { DragHandleDisabledIcon, DragHandleIcon, MinimisedHandleIcon } from '../icons';
|
|
3
3
|
export var HandleIconComponent = function HandleIconComponent(props) {
|
|
4
4
|
var direction = props.direction,
|
|
5
|
-
forceDefaultHandle = props.forceDefaultHandle,
|
|
6
5
|
isDragMenuOpen = props.isDragMenuOpen,
|
|
7
6
|
isRowHandleHovered = props.isRowHandleHovered,
|
|
8
7
|
isColumnHandleHovered = props.isColumnHandleHovered,
|
|
@@ -13,8 +12,11 @@ export var HandleIconComponent = function HandleIconComponent(props) {
|
|
|
13
12
|
var isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
14
13
|
var isCurrentRowOrColumnSelected = isCurrentRowSelected || isCurrentColumnSelected;
|
|
15
14
|
var isDragMenuOpenOnCurrentRowOrColumn = isDragMenuOpen && dragMenuDirection === direction && isCurrentRowOrColumnSelected;
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
var showNormalHandle = hasMergedCells ? /*#__PURE__*/React.createElement(DragHandleDisabledIcon, null) : /*#__PURE__*/React.createElement(DragHandleIcon, null);
|
|
16
|
+
|
|
17
|
+
// hoverred handle or open drag menu
|
|
18
|
+
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
19
|
+
return showNormalHandle;
|
|
18
20
|
}
|
|
19
21
|
return /*#__PURE__*/React.createElement(MinimisedHandleIcon, null);
|
|
20
22
|
};
|
|
@@ -3,6 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
7
8
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
8
9
|
import { getPluginState as getDragDropPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
@@ -18,8 +19,6 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
18
19
|
_ref$appearance = _ref.appearance,
|
|
19
20
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
20
21
|
indexes = _ref.indexes,
|
|
21
|
-
_ref$forceDefaultHand = _ref.forceDefaultHandle,
|
|
22
|
-
forceDefaultHandle = _ref$forceDefaultHand === void 0 ? false : _ref$forceDefaultHand,
|
|
23
22
|
previewWidth = _ref.previewWidth,
|
|
24
23
|
previewHeight = _ref.previewHeight,
|
|
25
24
|
onMouseOver = _ref.onMouseOver,
|
|
@@ -51,7 +50,6 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
51
50
|
var handleIconProps = {
|
|
52
51
|
hasMergedCells: hasMergedCells,
|
|
53
52
|
direction: direction,
|
|
54
|
-
forceDefaultHandle: forceDefaultHandle,
|
|
55
53
|
isDragMenuOpen: isDragMenuOpen,
|
|
56
54
|
isRowHandleHovered: isRowHandleHovered,
|
|
57
55
|
isColumnHandleHovered: isColumnHandleHovered,
|
|
@@ -121,7 +119,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
121
119
|
_onMouseUp && _onMouseUp(e);
|
|
122
120
|
},
|
|
123
121
|
onClick: onClick
|
|
124
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
122
|
+
}, browser.gecko ? /*#__PURE__*/React.createElement(HandleIconComponent, handleIconProps) : /*#__PURE__*/React.createElement("span", {
|
|
125
123
|
style: {
|
|
126
124
|
pointerEvents: 'none'
|
|
127
125
|
}
|
|
@@ -74,8 +74,8 @@ export var DragMenu = function DragMenu(_ref) {
|
|
|
74
74
|
var selection = state.selection;
|
|
75
75
|
var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
76
76
|
var hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
77
|
-
var
|
|
78
|
-
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth,
|
|
77
|
+
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
78
|
+
var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, shouldMoveDisabled, tableMap, index, targetCellPosition, selectionRect);
|
|
79
79
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
80
80
|
menuItems = _convertToDropdownIte.menuItems,
|
|
81
81
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
-
|
|
3
1
|
import React, { useCallback, useMemo } from 'react';
|
|
4
2
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
3
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
6
4
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn } from '../../../commands';
|
|
7
5
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
8
|
-
import { getPluginState as getDragDropPluginState } from '../../../pm-plugins/drag-and-drop/plugin-factory';
|
|
9
6
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
10
7
|
import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
|
|
11
8
|
import { DragHandle } from '../../DragHandle';
|
|
@@ -20,7 +17,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
|
|
|
20
17
|
return [];
|
|
21
18
|
};
|
|
22
19
|
export var ColumnControls = function ColumnControls(_ref) {
|
|
23
|
-
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
|
|
20
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce, _colWidths;
|
|
24
21
|
var editorView = _ref.editorView,
|
|
25
22
|
tableActive = _ref.tableActive,
|
|
26
23
|
tableRef = _ref.tableRef,
|
|
@@ -40,6 +37,13 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
40
37
|
var columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
41
38
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
42
39
|
var selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
40
|
+
var gridColumnPosition = useMemo(function () {
|
|
41
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
42
|
+
if (selectedColIndexes.includes(colIndex)) {
|
|
43
|
+
return "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
44
|
+
}
|
|
45
|
+
return "".concat(colIndex + 1, " / span 1");
|
|
46
|
+
}, [colIndex, selectedColIndexes]);
|
|
43
47
|
var firstRow = tableRef.querySelector('tr');
|
|
44
48
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
45
49
|
var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
@@ -91,63 +95,6 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
91
95
|
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
92
96
|
return sum + cur;
|
|
93
97
|
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
94
|
-
var generateHandleByType = useCallback(function (type) {
|
|
95
|
-
var _colWidths;
|
|
96
|
-
if (!hoveredCell) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
var _getDragDropPluginSta = getDragDropPluginState(editorView.state),
|
|
100
|
-
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
101
|
-
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
|
|
102
|
-
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
|
|
103
|
-
var isHover = type === 'hover';
|
|
104
|
-
var isHoveredOnSelectedColumn = isDragMenuOpen && dragMenuDirection === 'column' && dragMenuIndex === colIndex;
|
|
105
|
-
var showCondition = isHover ? !isHoveredOnSelectedColumn && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'column';
|
|
106
|
-
if (!showCondition) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
var selectedColumnPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedColIndexes.length);
|
|
110
|
-
var gridColumnPosition = selectedColIndexes.includes(colIndex) ? "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length) : "".concat(colIndex + 1, " / span 1");
|
|
111
|
-
var selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
112
|
-
var hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
113
|
-
return showCondition && /*#__PURE__*/React.createElement("div", {
|
|
114
|
-
key: type,
|
|
115
|
-
style: {
|
|
116
|
-
gridColumn: isHover ? gridColumnPosition : selectedColumnPosition,
|
|
117
|
-
display: 'flex',
|
|
118
|
-
justifyContent: 'center',
|
|
119
|
-
alignItems: 'center',
|
|
120
|
-
height: 'fit-content',
|
|
121
|
-
placeSelf: 'center',
|
|
122
|
-
zIndex: 99
|
|
123
|
-
},
|
|
124
|
-
"data-column-control-index": hoveredCell.colIndex,
|
|
125
|
-
"data-testid": isHover ? 'table-floating-column-control' : 'table-floating-column-control-selected'
|
|
126
|
-
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
127
|
-
direction: "column",
|
|
128
|
-
tableLocalId: localId || '',
|
|
129
|
-
indexes: isHover ? colIndexes : selectedColIndexes,
|
|
130
|
-
forceDefaultHandle: !isHover,
|
|
131
|
-
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
132
|
-
previewHeight: previewHeight,
|
|
133
|
-
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
134
|
-
onClick: handleClick,
|
|
135
|
-
onMouseOver: handleMouseOver,
|
|
136
|
-
onMouseOut: handleMouseOut,
|
|
137
|
-
onMouseUp: handleMouseUp,
|
|
138
|
-
editorView: editorView
|
|
139
|
-
}));
|
|
140
|
-
}, [colIndex, previewHeight, colWidths, colIndexes, editorView, handleClick, handleMouseOut, handleMouseOver, handleMouseUp, hoveredCell, isInDanger, localId, selectedColIndexes]);
|
|
141
|
-
var columnHandles = useCallback(function (hoveredCell) {
|
|
142
|
-
if (!hoveredCell) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
if (hoveredCell.colIndex === undefined) {
|
|
146
|
-
return generateHandleByType('selected');
|
|
147
|
-
}
|
|
148
|
-
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
149
|
-
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
150
|
-
}, [generateHandleByType, selectedColIndexes]);
|
|
151
98
|
return /*#__PURE__*/React.createElement("div", {
|
|
152
99
|
className: ClassName.DRAG_COLUMN_CONTROLS,
|
|
153
100
|
onMouseMove: handleMouseMove
|
|
@@ -176,6 +123,30 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
176
123
|
right: '0'
|
|
177
124
|
} : {}
|
|
178
125
|
}));
|
|
179
|
-
}), tableActive && !isResizing &&
|
|
126
|
+
}), tableActive && !isResizing && isTableHovered && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
style: {
|
|
128
|
+
gridColumn: gridColumnPosition,
|
|
129
|
+
display: 'flex',
|
|
130
|
+
justifyContent: 'center',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
height: 'fit-content',
|
|
133
|
+
placeSelf: 'center',
|
|
134
|
+
zIndex: 99
|
|
135
|
+
},
|
|
136
|
+
"data-column-control-index": hoveredCell.colIndex,
|
|
137
|
+
"data-testid": "table-floating-column-control"
|
|
138
|
+
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
139
|
+
direction: "column",
|
|
140
|
+
tableLocalId: localId || '',
|
|
141
|
+
indexes: colIndexes,
|
|
142
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
143
|
+
previewHeight: previewHeight,
|
|
144
|
+
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
145
|
+
onClick: handleClick,
|
|
146
|
+
onMouseOver: handleMouseOver,
|
|
147
|
+
onMouseOut: handleMouseOut,
|
|
148
|
+
onMouseUp: handleMouseUp,
|
|
149
|
+
editorView: editorView
|
|
150
|
+
}))));
|
|
180
151
|
};
|
|
181
152
|
export default ColumnControls;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
3
|
-
|
|
4
2
|
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
3
|
import { injectIntl } from 'react-intl-next';
|
|
6
4
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
@@ -8,7 +6,6 @@ import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
|
8
6
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
9
7
|
import { clearHoverSelection } from '../../../commands';
|
|
10
8
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
11
|
-
import { getPluginState as getDragDropPluginState } from '../../../pm-plugins/drag-and-drop/plugin-factory';
|
|
12
9
|
import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
|
|
13
10
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
14
11
|
import { getRowHeights, getRowsParams, getSelectedRowIndexes } from '../../../utils';
|
|
@@ -79,6 +76,13 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
79
76
|
toggleDragMenu(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
80
77
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
81
78
|
var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
79
|
+
var gridRowPosition = useMemo(function () {
|
|
80
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
81
|
+
if (selectedRowIndexes.includes(rowIndex)) {
|
|
82
|
+
return "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
|
|
83
|
+
}
|
|
84
|
+
return "".concat(rowIndex + 1, " / span 1");
|
|
85
|
+
}, [rowIndex, selectedRowIndexes]);
|
|
82
86
|
var handleMouseOut = useCallback(function () {
|
|
83
87
|
if (tableActive) {
|
|
84
88
|
var state = editorView.state,
|
|
@@ -105,62 +109,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
105
109
|
var handleClick = useCallback(function (e) {
|
|
106
110
|
selectRow(rowIndex, e === null || e === void 0 ? void 0 : e.shiftKey);
|
|
107
111
|
}, [rowIndex, selectRow]);
|
|
108
|
-
var generateHandleByType = useCallback(function (type) {
|
|
109
|
-
if (!hoveredCell) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
var _getDragDropPluginSta = getDragDropPluginState(editorView.state),
|
|
113
|
-
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
114
|
-
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
|
|
115
|
-
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
|
|
116
|
-
var isHover = type === 'hover';
|
|
117
|
-
var isHoveredOnSelectedRow = isDragMenuOpen && dragMenuDirection === 'row' && dragMenuIndex === rowIndex;
|
|
118
|
-
var showCondition = isHover ? !isHoveredOnSelectedRow && !selectedRowIndexes.includes(rowIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'row' && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
119
|
-
if (!showCondition) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
var gridRowPosition =
|
|
123
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
124
|
-
selectedRowIndexes.includes(rowIndex) ? "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length) : "".concat(rowIndex + 1, " / span 1");
|
|
125
|
-
var selectedRowPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedRowIndexes.length);
|
|
126
|
-
var selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
127
|
-
var hoveredAppearance = selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
128
|
-
return showCondition && /*#__PURE__*/React.createElement("div", {
|
|
129
|
-
key: type,
|
|
130
|
-
style: {
|
|
131
|
-
gridRow: isHover ? gridRowPosition : selectedRowPosition,
|
|
132
|
-
gridColumn: '2',
|
|
133
|
-
display: 'flex',
|
|
134
|
-
height: '100%',
|
|
135
|
-
alignItems: 'center',
|
|
136
|
-
justifyContent: 'center'
|
|
137
|
-
},
|
|
138
|
-
"data-testid": isHover ? 'table-floating-row-drag-handle' : 'table-floating-row-control-selected'
|
|
139
|
-
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
140
|
-
direction: "row",
|
|
141
|
-
tableLocalId: currentNodeLocalId,
|
|
142
|
-
indexes: isHover ? rowIndexes : selectedRowIndexes,
|
|
143
|
-
forceDefaultHandle: !isHover,
|
|
144
|
-
previewWidth: tableWidth,
|
|
145
|
-
previewHeight: rowHeights[rowIndex],
|
|
146
|
-
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
147
|
-
onClick: handleClick,
|
|
148
|
-
onMouseOver: handleMouseOver,
|
|
149
|
-
onMouseOut: handleMouseOut,
|
|
150
|
-
onMouseUp: onMouseUp,
|
|
151
|
-
editorView: editorView
|
|
152
|
-
}));
|
|
153
|
-
}, [currentNodeLocalId, editorView, handleClick, handleMouseOut, handleMouseOver, hoveredCell, isInDanger, onMouseUp, rowHeights, rowIndex, rowIndexes, selectedRowIndexes, tableWidth]);
|
|
154
|
-
var rowHandles = useCallback(function (hoveredCell) {
|
|
155
|
-
if (!hoveredCell) {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
if (hoveredCell.rowIndex === undefined) {
|
|
159
|
-
return generateHandleByType('selected');
|
|
160
|
-
}
|
|
161
|
-
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
162
|
-
return hoveredCell.rowIndex < selectedRowIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
163
|
-
}, [generateHandleByType, selectedRowIndexes]);
|
|
164
112
|
return /*#__PURE__*/React.createElement("div", {
|
|
165
113
|
className: ClassName.DRAG_ROW_CONTROLS,
|
|
166
114
|
style: {
|
|
@@ -200,6 +148,27 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
200
148
|
left: "var(--ds-space-negative-100, -8px)"
|
|
201
149
|
}
|
|
202
150
|
}));
|
|
203
|
-
}), !isResizing && Number.isFinite(rowIndex) &&
|
|
151
|
+
}), !isResizing && isTableHovered && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
style: {
|
|
153
|
+
gridRow: gridRowPosition,
|
|
154
|
+
gridColumn: '2',
|
|
155
|
+
display: 'flex',
|
|
156
|
+
height: '100%',
|
|
157
|
+
alignItems: 'center',
|
|
158
|
+
justifyContent: 'center'
|
|
159
|
+
},
|
|
160
|
+
"data-testid": "table-floating-row-drag-handle"
|
|
161
|
+
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
162
|
+
tableLocalId: currentNodeLocalId,
|
|
163
|
+
indexes: rowIndexes,
|
|
164
|
+
previewWidth: tableWidth,
|
|
165
|
+
previewHeight: rowHeights[rowIndex],
|
|
166
|
+
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
167
|
+
onClick: handleClick,
|
|
168
|
+
onMouseOver: handleMouseOver,
|
|
169
|
+
onMouseOut: handleMouseOut,
|
|
170
|
+
onMouseUp: onMouseUp,
|
|
171
|
+
editorView: editorView
|
|
172
|
+
})));
|
|
204
173
|
};
|
|
205
174
|
export var DragControls = injectIntl(DragControlsComponent);
|
|
@@ -64,6 +64,7 @@ export interface TablePluginState {
|
|
|
64
64
|
tableWrapperTarget?: HTMLElement;
|
|
65
65
|
isContextualMenuOpen?: boolean;
|
|
66
66
|
isInDanger?: boolean;
|
|
67
|
+
isWholeTableInDanger?: boolean;
|
|
67
68
|
insertColumnButtonIndex?: number;
|
|
68
69
|
insertRowButtonIndex?: number;
|
|
69
70
|
isFullWidthModeEnabled?: boolean;
|
|
@@ -420,4 +421,3 @@ export interface DraggableData {
|
|
|
420
421
|
targetClosestEdge: Edge;
|
|
421
422
|
direction: 1 | -1;
|
|
422
423
|
}
|
|
423
|
-
export type HandleTypes = 'hover' | 'selected';
|
|
@@ -5,7 +5,6 @@ type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
|
|
|
5
5
|
type DragHandleProps = {
|
|
6
6
|
tableLocalId: string;
|
|
7
7
|
indexes: number[];
|
|
8
|
-
forceDefaultHandle?: boolean;
|
|
9
8
|
previewWidth?: number;
|
|
10
9
|
previewHeight?: number;
|
|
11
10
|
direction?: TableDirection;
|
|
@@ -16,5 +15,5 @@ type DragHandleProps = {
|
|
|
16
15
|
onMouseUp?: MouseEventHandler;
|
|
17
16
|
editorView: EditorView;
|
|
18
17
|
};
|
|
19
|
-
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes,
|
|
18
|
+
export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, }: DragHandleProps) => JSX.Element;
|
|
20
19
|
export {};
|