@atlaskit/editor-plugin-table 5.3.12 → 5.3.14
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 +18 -0
- package/dist/cjs/plugins/table/event-handlers.js +6 -3
- package/dist/cjs/plugins/table/index.js +16 -2
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +22 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -7
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
- package/dist/cjs/plugins/table/types.js +9 -2
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +80 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +62 -0
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +52 -4
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +12 -3
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +44 -5
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +6 -4
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +44 -20
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -0
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +3 -2
- package/dist/cjs/plugins/table/ui/ui-styles.js +27 -24
- package/dist/cjs/plugins/table/utils/dom.js +12 -4
- package/dist/cjs/plugins/table/utils/drag-menu.js +59 -0
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/es2019/plugins/table/event-handlers.js +5 -4
- package/dist/es2019/plugins/table/index.js +16 -2
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +20 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +7 -0
- package/dist/es2019/plugins/table/types.js +9 -2
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +77 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +56 -0
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +53 -2
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +9 -3
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +46 -6
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +45 -22
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +4 -0
- package/dist/es2019/plugins/table/ui/common-styles.js +51 -3
- package/dist/es2019/plugins/table/ui/consts.js +2 -1
- package/dist/es2019/plugins/table/ui/ui-styles.js +23 -1
- package/dist/es2019/plugins/table/utils/dom.js +5 -1
- package/dist/es2019/plugins/table/utils/drag-menu.js +44 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/event-handlers.js +7 -4
- package/dist/esm/plugins/table/index.js +16 -2
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +3 -7
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +1 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +21 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +54 -7
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
- package/dist/esm/plugins/table/types.js +9 -2
- package/dist/esm/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +73 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +55 -0
- package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +51 -3
- package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +10 -8
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +9 -3
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +45 -6
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +7 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +46 -22
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +4 -0
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/ui/consts.js +2 -1
- package/dist/esm/plugins/table/ui/ui-styles.js +26 -23
- package/dist/esm/plugins/table/utils/dom.js +11 -3
- package/dist/esm/plugins/table/utils/drag-menu.js +52 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
- package/dist/types/plugins/table/types.d.ts +10 -2
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +4 -2
- package/dist/types/plugins/table/ui/DragPreview/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
- package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +6 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +5 -5
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +4 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +4 -1
- package/dist/types/plugins/table/utils/drag-menu.d.ts +7 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +10 -2
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +4 -2
- package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +6 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +5 -5
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -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 +4 -1
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +7 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +3 -2
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +40 -194
- package/src/__tests__/unit/ui/RowDragControls.tsx +9 -11
- package/src/plugins/table/event-handlers.ts +15 -3
- package/src/plugins/table/index.tsx +18 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +2 -1
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +2 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -3
- package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +14 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +32 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +50 -2
- package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +7 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +5 -0
- package/src/plugins/table/types.ts +14 -2
- package/src/plugins/table/ui/DragHandle/index.tsx +5 -1
- package/src/plugins/table/ui/DragPreview/index.tsx +2 -1
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +2 -1
- package/src/plugins/table/ui/FloatingDeleteButton/types.ts +3 -1
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +99 -0
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +91 -0
- package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +79 -4
- package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +31 -7
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +28 -13
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +47 -3
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +11 -4
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +65 -25
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +7 -0
- package/src/plugins/table/ui/common-styles.ts +57 -2
- package/src/plugins/table/ui/consts.ts +2 -0
- package/src/plugins/table/ui/ui-styles.ts +27 -1
- package/src/plugins/table/utils/dom.ts +11 -4
- package/src/plugins/table/utils/drag-menu.ts +65 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/tsconfig.app.json +3 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { injectIntl } from 'react-intl-next';
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
4
|
-
import {
|
|
4
|
+
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { clearHoverSelection } from '../../../commands';
|
|
6
|
+
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
6
7
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
7
|
-
import { getRowHeights, getSelectedRowIndexes } from '../../../utils';
|
|
8
|
+
import { getRowHeights, getRowsParams, getSelectedRowIndexes } from '../../../utils';
|
|
8
9
|
import { DragHandle } from '../../DragHandle';
|
|
9
10
|
const getSelectedRows = selection => {
|
|
10
11
|
if (selection instanceof CellSelection && selection.isRowSelection()) {
|
|
@@ -18,18 +19,26 @@ const getSelectedRows = selection => {
|
|
|
18
19
|
};
|
|
19
20
|
const DragControlsComponent = ({
|
|
20
21
|
tableRef,
|
|
22
|
+
tableNode,
|
|
21
23
|
hoveredCell,
|
|
22
24
|
tableActive,
|
|
23
25
|
editorView,
|
|
24
26
|
isInDanger,
|
|
27
|
+
isResizing,
|
|
28
|
+
hasHeaderRow,
|
|
25
29
|
hoverRows,
|
|
26
30
|
selectRow,
|
|
27
31
|
updateCellHoverLocation
|
|
28
32
|
}) => {
|
|
33
|
+
var _tableNode$attrs$loca, _tableNode$attrs;
|
|
29
34
|
const rowHeights = getRowHeights(tableRef);
|
|
35
|
+
const rowsParams = getRowsParams(rowHeights);
|
|
30
36
|
const heights = rowHeights.map(height => `${height - 1}px`).join(' ');
|
|
31
37
|
const selectedRowIndexes = getSelectedRows(editorView.state.selection);
|
|
32
38
|
const rowWidth = tableRef.offsetWidth;
|
|
39
|
+
const onMouseUp = useCallback(() => {
|
|
40
|
+
toggleDragMenu(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
41
|
+
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
33
42
|
const rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
34
43
|
const gridRowPosition = useMemo(() => {
|
|
35
44
|
// if more than one row is selected, ensure the handle spans over the selected range
|
|
@@ -38,11 +47,6 @@ const DragControlsComponent = ({
|
|
|
38
47
|
}
|
|
39
48
|
return `${rowIndex + 1} / span 1`;
|
|
40
49
|
}, [rowIndex, selectedRowIndexes]);
|
|
41
|
-
const getLocalId = () => {
|
|
42
|
-
var _tableNode$node, _tableNode$node$attrs;
|
|
43
|
-
const tableNode = findTable(editorView.state.selection);
|
|
44
|
-
return (tableNode === null || tableNode === void 0 ? void 0 : (_tableNode$node = tableNode.node) === null || _tableNode$node === void 0 ? void 0 : (_tableNode$node$attrs = _tableNode$node.attrs) === null || _tableNode$node$attrs === void 0 ? void 0 : _tableNode$node$attrs.localId) || '';
|
|
45
|
-
};
|
|
46
50
|
const handleMouseOut = useCallback(() => {
|
|
47
51
|
if (tableActive) {
|
|
48
52
|
const {
|
|
@@ -53,18 +57,15 @@ const DragControlsComponent = ({
|
|
|
53
57
|
}
|
|
54
58
|
}, [editorView, tableActive]);
|
|
55
59
|
const handleMouseMove = useCallback(e => {
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
const isParentDragControls = e.nativeEvent.target.closest(`.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
61
|
+
const rowIndex = e.nativeEvent.target.getAttribute('data-start-index');
|
|
62
|
+
|
|
63
|
+
// avoid updating if event target is not related
|
|
64
|
+
if (!isParentDragControls || !rowIndex) {
|
|
58
65
|
return;
|
|
59
66
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const rowIndex = rowHeights.findIndex(row => {
|
|
63
|
-
totalHeight += row;
|
|
64
|
-
return hoverHeight <= totalHeight;
|
|
65
|
-
});
|
|
66
|
-
updateCellHoverLocation(rowIndex);
|
|
67
|
-
}, [updateCellHoverLocation, rowHeights]);
|
|
67
|
+
updateCellHoverLocation(Number(rowIndex));
|
|
68
|
+
}, [updateCellHoverLocation]);
|
|
68
69
|
const handleMouseOver = useCallback(() => {
|
|
69
70
|
hoverRows([rowIndex]);
|
|
70
71
|
}, [hoverRows, rowIndex]);
|
|
@@ -72,28 +73,50 @@ const DragControlsComponent = ({
|
|
|
72
73
|
selectRow(rowIndex, e === null || e === void 0 ? void 0 : e.shiftKey);
|
|
73
74
|
}, [rowIndex, selectRow]);
|
|
74
75
|
return /*#__PURE__*/React.createElement("div", {
|
|
75
|
-
className: ClassName.
|
|
76
|
+
className: ClassName.DRAG_ROW_CONTROLS,
|
|
76
77
|
style: {
|
|
77
78
|
gridTemplateRows: heights
|
|
78
79
|
},
|
|
79
80
|
onMouseMove: handleMouseMove
|
|
80
|
-
},
|
|
81
|
+
}, !isResizing && rowsParams.map(({
|
|
82
|
+
startIndex,
|
|
83
|
+
endIndex
|
|
84
|
+
}, index) => /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
style: {
|
|
86
|
+
gridRow: `${index + 1} / span 1`
|
|
87
|
+
},
|
|
88
|
+
"data-start-index": startIndex,
|
|
89
|
+
"data-end-index": endIndex,
|
|
90
|
+
className: ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER,
|
|
91
|
+
contentEditable: false,
|
|
92
|
+
key: index
|
|
93
|
+
}, !hasHeaderRow && index === 0 && /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
style: {
|
|
95
|
+
top: '0px',
|
|
96
|
+
left: "var(--ds-space-075, 6px)"
|
|
97
|
+
},
|
|
98
|
+
className: ClassName.DRAG_ROW_FLOATING_INSERT_DOT
|
|
99
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
className: ClassName.DRAG_ROW_FLOATING_INSERT_DOT
|
|
101
|
+
}))), !isResizing && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
|
|
81
102
|
style: {
|
|
82
103
|
gridRow: gridRowPosition,
|
|
83
104
|
display: 'flex',
|
|
84
105
|
height: '100%',
|
|
85
106
|
alignItems: 'center',
|
|
86
107
|
justifyContent: 'center'
|
|
87
|
-
}
|
|
108
|
+
},
|
|
109
|
+
"data-testid": "table-floating-row-drag-handle"
|
|
88
110
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
89
|
-
tableLocalId:
|
|
111
|
+
tableLocalId: (_tableNode$attrs$loca = tableNode === null || tableNode === void 0 ? void 0 : (_tableNode$attrs = tableNode.attrs) === null || _tableNode$attrs === void 0 ? void 0 : _tableNode$attrs.localId) !== null && _tableNode$attrs$loca !== void 0 ? _tableNode$attrs$loca : '',
|
|
90
112
|
indexes: [rowIndex],
|
|
91
113
|
previewWidth: rowWidth,
|
|
92
114
|
previewHeight: rowHeights[rowIndex],
|
|
93
115
|
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
94
116
|
onClick: handleClick,
|
|
95
117
|
onMouseOver: handleMouseOver,
|
|
96
|
-
onMouseOut: handleMouseOut
|
|
118
|
+
onMouseOut: handleMouseOut,
|
|
119
|
+
onMouseUp: onMouseUp
|
|
97
120
|
})));
|
|
98
121
|
};
|
|
99
122
|
export const DragControls = injectIntl(DragControlsComponent);
|
|
@@ -105,6 +105,7 @@ export default class TableFloatingControls extends Component {
|
|
|
105
105
|
const {
|
|
106
106
|
editorView,
|
|
107
107
|
tableRef,
|
|
108
|
+
tableNode,
|
|
108
109
|
isInDanger,
|
|
109
110
|
isResizing,
|
|
110
111
|
isNumberColumnEnabled,
|
|
@@ -138,10 +139,13 @@ export default class TableFloatingControls extends Component {
|
|
|
138
139
|
isDragAndDropEnabled: isDragAndDropEnabled
|
|
139
140
|
}) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(DragControls, {
|
|
140
141
|
tableRef: tableRef,
|
|
142
|
+
tableNode: tableNode,
|
|
141
143
|
hoveredCell: hoveredCell,
|
|
142
144
|
editorView: editorView,
|
|
143
145
|
tableActive: tableActive,
|
|
144
146
|
isInDanger: isInDanger,
|
|
147
|
+
isResizing: isResizing,
|
|
148
|
+
hasHeaderRow: hasHeaderRow,
|
|
145
149
|
hoverRows: this.hoverRows,
|
|
146
150
|
selectRow: this.selectRow,
|
|
147
151
|
updateCellHoverLocation: this.updateCellHoverLocation
|
|
@@ -7,7 +7,7 @@ import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
|
|
|
7
7
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
8
8
|
import { TableCssClassName as ClassName } from '../types';
|
|
9
9
|
import { columnControlsDecorationHeight, resizeHandlerAreaWidth, resizeLineWidth, rowControlsZIndex, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableBorderColor, tableBorderDeleteColor, tableBorderRadiusSize, tableBorderSelectedColor, tableCellBackgroundColor, tableCellDeleteColor, tableCellSelectedColor, tableControlsSpacing, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tablePadding, tableScrollbarOffset, tableTextColor, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
10
|
-
import { columnControlsDecoration, columnControlsLineMarker, DeleteButton, floatingColumnControls, HeaderButton, HeaderButtonDanger, HeaderButtonHover, hoveredCell, hoveredDeleteButton, hoveredWarningCell, insertColumnButtonWrapper, insertLine, InsertMarker, insertRowButtonWrapper, OverflowShadow, resizeHandle, rowControlsWrapperDotStyle } from './ui-styles';
|
|
10
|
+
import { columnControlsDecoration, columnControlsLineMarker, DeleteButton, dragInsertButtonWrapper, floatingColumnControls, HeaderButton, HeaderButtonDanger, HeaderButtonHover, hoveredCell, hoveredDeleteButton, hoveredWarningCell, insertColumnButtonWrapper, insertLine, InsertMarker, insertRowButtonWrapper, OverflowShadow, resizeHandle, rowControlsWrapperDotStyle } from './ui-styles';
|
|
11
11
|
const cornerControlHeight = tableToolbarSize + 1;
|
|
12
12
|
|
|
13
13
|
/*
|
|
@@ -270,6 +270,8 @@ export const tableStyles = props => {
|
|
|
270
270
|
${insertRowButtonWrapper(props)}
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
+
${dragInsertButtonWrapper(props)}
|
|
274
|
+
|
|
273
275
|
/* Delete button */
|
|
274
276
|
${DeleteButton(props)}
|
|
275
277
|
/* Ends Delete button */
|
|
@@ -602,12 +604,58 @@ export const tableStyles = props => {
|
|
|
602
604
|
`)}
|
|
603
605
|
}
|
|
604
606
|
|
|
605
|
-
.${ClassName.
|
|
607
|
+
.${ClassName.DRAG_ROW_CONTROLS} {
|
|
606
608
|
display: grid;
|
|
607
609
|
align-items: center;
|
|
608
610
|
position: absolute;
|
|
609
611
|
left: -4px;
|
|
610
612
|
z-index: ${akEditorUnitZIndex};
|
|
613
|
+
|
|
614
|
+
.${ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER} {
|
|
615
|
+
align-self: end;
|
|
616
|
+
position: absolute;
|
|
617
|
+
height: 100%;
|
|
618
|
+
width: 24px;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.${ClassName.DRAG_ROW_FLOATING_INSERT_DOT} {
|
|
622
|
+
position: absolute;
|
|
623
|
+
bottom: -3px;
|
|
624
|
+
left: 6px;
|
|
625
|
+
background-color: ${"var(--ds-background-accent-gray-subtler, #C1C7D0)"};
|
|
626
|
+
height: 4px;
|
|
627
|
+
width: 4px;
|
|
628
|
+
border-radius: 50%;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
633
|
+
.${ClassName.COLUMN_CONTROLS_INNER} {
|
|
634
|
+
height: 24px;
|
|
635
|
+
position: absolute;
|
|
636
|
+
top: ${"var(--ds-space-negative-150, -12px)"};
|
|
637
|
+
z-index: ${akEditorUnitZIndex};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
.${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER} {
|
|
641
|
+
position: absolute;
|
|
642
|
+
height: 24px;
|
|
643
|
+
width: 100%;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT} {
|
|
647
|
+
background-color: ${"var(--ds-background-accent-gray-subtler, #C1C7D0)"};
|
|
648
|
+
height: 4px;
|
|
649
|
+
width: 4px;
|
|
650
|
+
border-radius: 50%;
|
|
651
|
+
position: absolute;
|
|
652
|
+
right: -2px;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.${ClassName.CONTROLS_FLOATING_BUTTON_ROW}
|
|
657
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER} {
|
|
658
|
+
bottom: -1px;
|
|
611
659
|
}
|
|
612
660
|
|
|
613
661
|
.${ClassName.DRAG_HANDLE_BUTTON_CONTAINER} {
|
|
@@ -621,10 +669,10 @@ export const tableStyles = props => {
|
|
|
621
669
|
display: flex;
|
|
622
670
|
justify-content: center;
|
|
623
671
|
align-items: center;
|
|
672
|
+
outline: none !important;
|
|
624
673
|
|
|
625
674
|
svg {
|
|
626
675
|
rect {
|
|
627
|
-
//
|
|
628
676
|
fill: ${"var(--ds-background-accent-gray-subtlest, #F1F2F4)"};
|
|
629
677
|
}
|
|
630
678
|
g {
|
|
@@ -104,4 +104,5 @@ export const tableOverflowShadowWidthWide = 32;
|
|
|
104
104
|
export const TABLE_SNAP_GAP = 9;
|
|
105
105
|
export const TABLE_HIGHLIGHT_GAP = 10;
|
|
106
106
|
export const TABLE_HIGHLIGHT_TOLERANCE = 2;
|
|
107
|
-
export const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
|
|
107
|
+
export const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
|
|
108
|
+
export const dragMenuDropdownWidth = 240;
|
|
@@ -129,6 +129,28 @@ const InsertButtonHover = () => css`
|
|
|
129
129
|
cursor: pointer;
|
|
130
130
|
}
|
|
131
131
|
`;
|
|
132
|
+
export const dragInsertButtonWrapper = props => css`
|
|
133
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON_INNER} {
|
|
134
|
+
position: absolute;
|
|
135
|
+
z-index: ${akEditorUnitZIndex + 10};
|
|
136
|
+
bottom: -5px;
|
|
137
|
+
left: 3px;
|
|
138
|
+
}
|
|
139
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON} {
|
|
140
|
+
${Button(`
|
|
141
|
+
background: ${"var(--ds-surface-overlay, white)"};
|
|
142
|
+
color: ${`var(--ds-icon, ${N300})`};
|
|
143
|
+
border: 1px solid ${"var(--ds-background-accent-gray-subtler, #C1C7D0)"};
|
|
144
|
+
border-radius: 50%;
|
|
145
|
+
`)}
|
|
146
|
+
}
|
|
147
|
+
.${ClassName.DRAG_CONTROLS_INSERT_BUTTON}:hover {
|
|
148
|
+
background: ${`var(--ds-background-brand-bold, ${B300})`};
|
|
149
|
+
border: 1px solid ${`var(--ds-background-brand-bold, ${B300})`};
|
|
150
|
+
color: ${"var(--ds-icon-inverse, white)"};
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
}
|
|
153
|
+
`;
|
|
132
154
|
export const insertColumnButtonWrapper = props => css`
|
|
133
155
|
${InsertButton()}
|
|
134
156
|
${InsertButtonHover()}
|
|
@@ -299,7 +321,7 @@ export const floatingColumnControls = props => {
|
|
|
299
321
|
}
|
|
300
322
|
}
|
|
301
323
|
|
|
302
|
-
.${ClassName.
|
|
324
|
+
.${ClassName.DRAG_COLUMN_CONTROLS} {
|
|
303
325
|
box-sizing: border-box;
|
|
304
326
|
|
|
305
327
|
.${ClassName.COLUMN_CONTROLS_INNER} {
|
|
@@ -10,11 +10,15 @@ export const isInsertRowButton = node => containsClassName(node, ClassName.CONTR
|
|
|
10
10
|
export const getColumnOrRowIndex = target => [parseInt(target.getAttribute('data-start-index') || '-1', 10), parseInt(target.getAttribute('data-end-index') || '-1', 10)];
|
|
11
11
|
export const isColumnControlsDecorations = node => containsClassName(node, ClassName.COLUMN_CONTROLS_DECORATIONS);
|
|
12
12
|
export const isRowControlsButton = node => containsClassName(node, ClassName.ROW_CONTROLS_BUTTON) || containsClassName(node, ClassName.NUMBERED_COLUMN_BUTTON);
|
|
13
|
-
export const isRowDragControlsButton = node => containsClassName(node, ClassName.ROW_CONTROLS_WITH_DRAG) || closestElement(node, `.${ClassName.ROW_CONTROLS_WITH_DRAG}`);
|
|
14
13
|
export const isResizeHandleDecoration = node => containsClassName(node, ClassName.RESIZE_HANDLE_DECORATION);
|
|
15
14
|
export const isTableControlsButton = node => containsClassName(node, ClassName.CONTROLS_BUTTON) || containsClassName(node, ClassName.ROW_CONTROLS_BUTTON_WRAP);
|
|
16
15
|
export const isTableContainerOrWrapper = node => containsClassName(node, ClassName.TABLE_CONTAINER) || containsClassName(node, ClassName.TABLE_NODE_WRAPPER);
|
|
17
16
|
|
|
17
|
+
/** drag-and-drop classes */
|
|
18
|
+
export const isRowDragControlsButton = node => containsClassName(node, ClassName.DRAG_ROW_CONTROLS) || closestElement(node, `.${ClassName.DRAG_ROW_CONTROLS}`);
|
|
19
|
+
export const isDragRowFloatingInsertDot = node => containsClassName(node, ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER);
|
|
20
|
+
export const isDragColumnFloatingInsertDot = node => containsClassName(node, ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER);
|
|
21
|
+
|
|
18
22
|
/*
|
|
19
23
|
* This function returns which side of a given element the mouse cursor is,
|
|
20
24
|
* using as a base the half of the width by default, for example:
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { moveSource } from '../pm-plugins/drag-and-drop/commands';
|
|
2
|
+
const canDecrease = (index, min = 0) => index !== undefined && index > min;
|
|
3
|
+
const canIncrease = (index, max = 0) => index !== undefined && index < max;
|
|
4
|
+
export const getDragMenuConfig = (direction, tableMap, index) => {
|
|
5
|
+
const moveOptions = direction === 'row' ? [{
|
|
6
|
+
label: 'up',
|
|
7
|
+
offset: -1,
|
|
8
|
+
canMove: canDecrease
|
|
9
|
+
}, {
|
|
10
|
+
label: 'down',
|
|
11
|
+
offset: 1,
|
|
12
|
+
canMove: index => {
|
|
13
|
+
var _tableMap$height;
|
|
14
|
+
return canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
|
|
15
|
+
}
|
|
16
|
+
}] : [{
|
|
17
|
+
label: 'left',
|
|
18
|
+
offset: -1,
|
|
19
|
+
canMove: canDecrease
|
|
20
|
+
}, {
|
|
21
|
+
label: 'right',
|
|
22
|
+
offset: 1,
|
|
23
|
+
canMove: index => {
|
|
24
|
+
var _tableMap$width;
|
|
25
|
+
return canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
|
|
26
|
+
}
|
|
27
|
+
}];
|
|
28
|
+
return [...moveOptions.map(({
|
|
29
|
+
label,
|
|
30
|
+
offset,
|
|
31
|
+
canMove
|
|
32
|
+
}) => ({
|
|
33
|
+
id: `move_${direction}_${label}`,
|
|
34
|
+
title: `Move ${direction} ${label}`,
|
|
35
|
+
disabled: !canMove(index),
|
|
36
|
+
onClick: (state, dispatch) => {
|
|
37
|
+
if (canMove(index)) {
|
|
38
|
+
moveSource(`table-${direction}`, index, index + offset)(state, dispatch);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}))];
|
|
44
|
+
};
|
|
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
|
|
|
2
2
|
export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
|
|
3
3
|
export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
|
|
4
4
|
export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
|
|
5
|
-
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowDragControlsButton, isRowControlsButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
5
|
+
export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowDragControlsButton, isRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
|
|
6
6
|
export { getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames } from './column-controls';
|
|
7
7
|
export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
|
|
8
8
|
export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
|
|
@@ -10,7 +10,7 @@ import { getPluginState } from './pm-plugins/plugin-factory';
|
|
|
10
10
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
11
11
|
import { deleteColumns, deleteRows } from './transforms';
|
|
12
12
|
import { RESIZE_HANDLE_AREA_DECORATION_GAP } from './types';
|
|
13
|
-
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
13
|
+
import { getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, getSelectedCellInfo, hasResizeHandler, isCell, isColumnControlsDecorations, isCornerButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isInsertRowButton, isResizeHandleDecoration, isRowControlsButton, isTableContainerOrWrapper, isTableControlsButton } from './utils';
|
|
14
14
|
import { getAllowAddColumnCustomStep } from './utils/get-allow-add-column-custom-step';
|
|
15
15
|
var isFocusingCalendar = function isFocusingCalendar(event) {
|
|
16
16
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.getAttribute('aria-label') === 'calendar';
|
|
@@ -21,12 +21,15 @@ var isFocusingModal = function isFocusingModal(event) {
|
|
|
21
21
|
var isFocusingFloatingToolbar = function isFocusingFloatingToolbar(event) {
|
|
22
22
|
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('[role="toolbar"]');
|
|
23
23
|
};
|
|
24
|
+
var isFocusingDragHandles = function isFocusingDragHandles(event) {
|
|
25
|
+
return event instanceof FocusEvent && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest('button') && event.relatedTarget.getAttribute('draggable') === 'true';
|
|
26
|
+
};
|
|
24
27
|
export var handleBlur = function handleBlur(view, event) {
|
|
25
28
|
var state = view.state,
|
|
26
29
|
dispatch = view.dispatch;
|
|
27
30
|
// IE version check for ED-4665
|
|
28
31
|
// Calendar focus check for ED-10466
|
|
29
|
-
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event)) {
|
|
32
|
+
if (browser.ie_version !== 11 && !isFocusingCalendar(event) && !isFocusingModal(event) && !isFocusingFloatingToolbar(event) && !isFocusingDragHandles(event)) {
|
|
30
33
|
setEditorFocus(false)(state, dispatch);
|
|
31
34
|
}
|
|
32
35
|
event.preventDefault();
|
|
@@ -183,7 +186,7 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
183
186
|
return false;
|
|
184
187
|
}
|
|
185
188
|
var element = event.target;
|
|
186
|
-
if (isColumnControlsDecorations(element)) {
|
|
189
|
+
if (isColumnControlsDecorations(element) || isDragColumnFloatingInsertDot(element)) {
|
|
187
190
|
var state = view.state,
|
|
188
191
|
dispatch = view.dispatch;
|
|
189
192
|
var _getPluginState3 = getPluginState(state),
|
|
@@ -197,7 +200,7 @@ export var handleMouseMove = function handleMouseMove(view, event, elementConten
|
|
|
197
200
|
return showInsertColumnButton(positionColumn)(state, dispatch);
|
|
198
201
|
}
|
|
199
202
|
}
|
|
200
|
-
if (isRowControlsButton(element)) {
|
|
203
|
+
if (isRowControlsButton(element) || isDragRowFloatingInsertDot(element)) {
|
|
201
204
|
var _state3 = view.state,
|
|
202
205
|
_dispatch4 = view.dispatch;
|
|
203
206
|
var _getPluginState4 = getPluginState(_state3),
|
|
@@ -28,6 +28,7 @@ import { getToolbarConfig } from './toolbar';
|
|
|
28
28
|
import FloatingContextualButton from './ui/FloatingContextualButton';
|
|
29
29
|
import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
30
30
|
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
31
|
+
import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
31
32
|
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
32
33
|
import LayoutButton from './ui/LayoutButton';
|
|
33
34
|
import { isLayoutSupported } from './utils';
|
|
@@ -249,7 +250,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
249
250
|
var resizingPluginState = _ref13.tableResizingPluginState,
|
|
250
251
|
stickyHeadersState = _ref13.stickyHeadersState,
|
|
251
252
|
tablePluginState = _ref13.tablePluginState,
|
|
252
|
-
tableWidthPluginState = _ref13.tableWidthPluginState
|
|
253
|
+
tableWidthPluginState = _ref13.tableWidthPluginState,
|
|
254
|
+
dragAndDropState = _ref13.dragAndDropState;
|
|
253
255
|
var state = editorView.state;
|
|
254
256
|
var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
255
257
|
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
@@ -266,6 +268,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
266
268
|
insertRowButtonIndex = _ref14.insertRowButtonIndex,
|
|
267
269
|
isHeaderColumnEnabled = _ref14.isHeaderColumnEnabled,
|
|
268
270
|
isHeaderRowEnabled = _ref14.isHeaderRowEnabled,
|
|
271
|
+
isDragAndDropEnabled = _ref14.isDragAndDropEnabled,
|
|
269
272
|
tableWrapperTarget = _ref14.tableWrapperTarget;
|
|
270
273
|
var allowControls = pluginConfig.allowControls;
|
|
271
274
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
@@ -299,6 +302,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
299
302
|
insertRowButtonIndex: insertRowButtonIndex,
|
|
300
303
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
301
304
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
305
|
+
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
302
306
|
editorView: editorView,
|
|
303
307
|
mountPoint: popupsMountPoint,
|
|
304
308
|
boundariesElement: popupsBoundariesElement,
|
|
@@ -317,7 +321,17 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
317
321
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
318
322
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
319
323
|
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
320
|
-
}),
|
|
324
|
+
}), isDragAndDropEnabled && /*#__PURE__*/React.createElement(FloatingDragMenu, {
|
|
325
|
+
editorView: editorView,
|
|
326
|
+
mountPoint: popupsMountPoint,
|
|
327
|
+
boundariesElement: popupsBoundariesElement,
|
|
328
|
+
tableRef: tableRef,
|
|
329
|
+
tableNode: tableNode,
|
|
330
|
+
targetCellPosition: targetCellPosition,
|
|
331
|
+
direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
|
|
332
|
+
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
333
|
+
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
|
|
334
|
+
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
321
335
|
editorView: editorView,
|
|
322
336
|
selection: editorView.state.selection,
|
|
323
337
|
tableRef: tableRef,
|
|
@@ -472,6 +472,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
472
472
|
}, /*#__PURE__*/React.createElement(TableFloatingControls, {
|
|
473
473
|
editorView: view,
|
|
474
474
|
tableRef: tableRef,
|
|
475
|
+
tableNode: node,
|
|
475
476
|
tableActive: tableActive,
|
|
476
477
|
hoveredRows: hoveredRows,
|
|
477
478
|
hoveredCell: hoveredCell,
|
|
@@ -479,7 +480,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
479
480
|
isResizing: isResizing,
|
|
480
481
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
481
482
|
isHeaderRowEnabled: isHeaderRowEnabled,
|
|
482
|
-
isDragAndDropEnabled:
|
|
483
|
+
isDragAndDropEnabled: isDragAndDropEnabled,
|
|
483
484
|
ordering: ordering,
|
|
484
485
|
isHeaderColumnEnabled: isHeaderColumnEnabled,
|
|
485
486
|
hasHeaderRow: hasHeaderRow
|
|
@@ -11,7 +11,7 @@ export var getDecorations = function getDecorations(state) {
|
|
|
11
11
|
return pluginKey.getState(state);
|
|
12
12
|
};
|
|
13
13
|
export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
|
|
14
|
-
var _tableWidthPluginKey$, _tableWidthPluginKey$2
|
|
14
|
+
var _tableWidthPluginKey$, _tableWidthPluginKey$2;
|
|
15
15
|
var isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
16
16
|
var wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
17
17
|
var changedResizing = isResizing !== wasResizing;
|
|
@@ -19,7 +19,7 @@ export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr
|
|
|
19
19
|
// Remove column controls when resizing and don't add column decoration controls when DnD enabled
|
|
20
20
|
if (isResizing || getBooleanFF('platform.editor.table.drag-and-drop')) {
|
|
21
21
|
return DecorationSet.empty;
|
|
22
|
-
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing
|
|
22
|
+
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
|
|
23
23
|
return buildColumnControlsDecorations({
|
|
24
24
|
decorationSet: decorationSet,
|
|
25
25
|
tr: tr
|
|
@@ -42,16 +42,12 @@ export var createPlugin = function createPlugin() {
|
|
|
42
42
|
return DecorationSet.empty;
|
|
43
43
|
},
|
|
44
44
|
apply: function apply(tr, decorationSet, oldState, newState) {
|
|
45
|
-
var _tablePluginKey$getSt, _tablePluginKey$getSt2;
|
|
46
45
|
var pluginState = decorationSet;
|
|
47
46
|
var meta = tr.getMeta(tablePluginKey);
|
|
48
|
-
var previousHover = (_tablePluginKey$getSt = tablePluginKey.getState(oldState)) === null || _tablePluginKey$getSt === void 0 ? void 0 : _tablePluginKey$getSt.hoveredCell;
|
|
49
|
-
var newHover = (_tablePluginKey$getSt2 = tablePluginKey.getState(newState)) === null || _tablePluginKey$getSt2 === void 0 ? void 0 : _tablePluginKey$getSt2.hoveredCell;
|
|
50
|
-
var changedCellHover = (previousHover === null || previousHover === void 0 ? void 0 : previousHover.colIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.colIndex) || (previousHover === null || previousHover === void 0 ? void 0 : previousHover.rowIndex) !== (newHover === null || newHover === void 0 ? void 0 : newHover.rowIndex);
|
|
51
47
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
52
48
|
pluginState = meta.data.decorationSet;
|
|
53
49
|
}
|
|
54
|
-
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)
|
|
50
|
+
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)) {
|
|
55
51
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
56
52
|
return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
|
|
57
53
|
}
|
|
@@ -4,7 +4,6 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
4
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { TableDecorations } from '../../../types';
|
|
6
6
|
import { createColumnControlsDecoration, createColumnSelectedDecoration, findColumnControlSelectedDecoration, findControlsHoverDecoration, updateDecorations } from '../../../utils/decoration';
|
|
7
|
-
import { pluginKey as tablePluginKey } from '../../plugin-key';
|
|
8
7
|
import { composeDecorations } from './compose-decorations';
|
|
9
8
|
var isColumnSelected = function isColumnSelected(tr) {
|
|
10
9
|
return tr.selection instanceof CellSelection && tr.selection.isColSelection();
|
|
@@ -27,10 +26,9 @@ var maybeUpdateColumnControlsDecoration = function maybeUpdateColumnControlsDeco
|
|
|
27
26
|
var decorationSet = _ref3.decorationSet,
|
|
28
27
|
tr = _ref3.tr;
|
|
29
28
|
var table = findTable(tr.selection);
|
|
30
|
-
var meta = tr.getMeta(tablePluginKey);
|
|
31
29
|
|
|
32
30
|
// avoid re-drawing state if dnd decorations don't need to be updated
|
|
33
|
-
if (!table
|
|
31
|
+
if (!table) {
|
|
34
32
|
return decorationSet;
|
|
35
33
|
}
|
|
36
34
|
return updateDecorations(tr.doc, decorationSet, createColumnControlsDecoration(tr.selection), TableDecorations.COLUMN_CONTROLS_DECORATIONS);
|
|
@@ -77,4 +77,25 @@ export var moveSource = function moveSource(sourceType, sourceIndex, targetIndex
|
|
|
77
77
|
var select = isTableRow ? selectRow : selectColumn;
|
|
78
78
|
return select(targetIndex)(newTr);
|
|
79
79
|
});
|
|
80
|
+
};
|
|
81
|
+
export var toggleDragMenu = function toggleDragMenu(isDragMenuOpen, direction, index) {
|
|
82
|
+
return createCommand(function (state) {
|
|
83
|
+
var _getPluginState3 = getPluginState(state),
|
|
84
|
+
previousOpenState = _getPluginState3.isDragMenuOpen,
|
|
85
|
+
dragMenuDirection = _getPluginState3.dragMenuDirection,
|
|
86
|
+
dragMenuIndex = _getPluginState3.dragMenuIndex;
|
|
87
|
+
if (previousOpenState === isDragMenuOpen) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
type: DragAndDropActionType.TOGGLE_DRAG_MENU,
|
|
92
|
+
data: {
|
|
93
|
+
isDragMenuOpen: isDragMenuOpen === undefined ? !previousOpenState : isDragMenuOpen,
|
|
94
|
+
direction: direction !== null && direction !== void 0 ? direction : dragMenuDirection,
|
|
95
|
+
index: index !== null && index !== void 0 ? index : dragMenuIndex
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}, function (tr) {
|
|
99
|
+
return tr.setMeta('addToHistory', false);
|
|
100
|
+
});
|
|
80
101
|
};
|