@atlaskit/editor-plugin-table 5.4.14 → 5.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/afm-cc/tsconfig.json +70 -0
- package/dist/cjs/plugins/table/commands/hover.js +26 -6
- package/dist/cjs/plugins/table/commands/index.js +6 -0
- package/dist/cjs/plugins/table/commands/misc.js +8 -3
- package/dist/cjs/plugins/table/event-handlers.js +56 -34
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +39 -7
- package/dist/cjs/plugins/table/pm-plugins/main.js +5 -3
- package/dist/cjs/plugins/table/reducer.js +1 -0
- package/dist/cjs/plugins/table/toolbar.js +6 -3
- package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +6 -3
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/cjs/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -7
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -10
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +7 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +74 -37
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +63 -31
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +12 -8
- package/dist/cjs/plugins/table/utils/dom.js +16 -1
- package/dist/cjs/plugins/table/utils/index.js +6 -0
- package/dist/es2019/plugins/table/commands/hover.js +22 -5
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +8 -3
- package/dist/es2019/plugins/table/event-handlers.js +45 -20
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +36 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +6 -4
- package/dist/es2019/plugins/table/reducer.js +1 -0
- package/dist/es2019/plugins/table/toolbar.js +5 -3
- package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/es2019/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +9 -7
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +73 -37
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -29
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +12 -9
- package/dist/es2019/plugins/table/utils/dom.js +13 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/commands/hover.js +25 -5
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +8 -3
- package/dist/esm/plugins/table/event-handlers.js +55 -33
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +35 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +6 -4
- package/dist/esm/plugins/table/reducer.js +1 -0
- package/dist/esm/plugins/table/toolbar.js +5 -3
- package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/esm/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/esm/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +9 -7
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +74 -37
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +61 -29
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -8
- package/dist/esm/plugins/table/utils/dom.js +15 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types/plugins/table/event-handlers.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +7 -2
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- 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/plugins/table/utils/dom.d.ts +4 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +7 -2
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- 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/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/unit/event-handlers.ts +2 -2
- package/src/__tests__/unit/ui/RowDragControls.tsx +1 -0
- package/src/plugins/table/commands/hover.ts +37 -7
- package/src/plugins/table/commands/index.ts +1 -0
- package/src/plugins/table/commands/misc.ts +9 -3
- package/src/plugins/table/event-handlers.ts +47 -29
- package/src/plugins/table/nodeviews/TableComponent.tsx +4 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +7 -5
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +37 -2
- package/src/plugins/table/pm-plugins/main.ts +6 -3
- package/src/plugins/table/reducer.ts +1 -0
- package/src/plugins/table/types.ts +9 -2
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +10 -9
- package/src/plugins/table/ui/DragHandle/index.tsx +4 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +129 -50
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +3 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +128 -41
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -5
- package/src/plugins/table/utils/dom.ts +22 -0
- package/src/plugins/table/utils/index.ts +1 -0
|
@@ -16,7 +16,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
18
|
var _commands = require("../../commands");
|
|
19
|
-
var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
20
19
|
var _types = require("../../types");
|
|
21
20
|
var _utils2 = require("../../utils");
|
|
22
21
|
var _CornerControls = require("./CornerControls");
|
|
@@ -59,10 +58,12 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
59
58
|
tableActive = _this$props.tableActive;
|
|
60
59
|
var state = editorView.state,
|
|
61
60
|
dispatch = editorView.dispatch;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
if (tableActive) {
|
|
62
|
+
// For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
|
|
63
|
+
// of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
|
|
64
|
+
// also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
|
|
65
|
+
// current column index. We can just force it to 0.
|
|
66
|
+
(0, _commands.hoverCell)(rowIndex, 0)(state, dispatch);
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
_this.state = {
|
|
@@ -134,8 +135,9 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
134
135
|
ordering = _this$props2.ordering,
|
|
135
136
|
headerRowHeight = _this$props2.headerRowHeight,
|
|
136
137
|
stickyHeader = _this$props2.stickyHeader,
|
|
137
|
-
hoveredCell = _this$props2.hoveredCell
|
|
138
|
-
|
|
138
|
+
hoveredCell = _this$props2.hoveredCell,
|
|
139
|
+
isTableHovered = _this$props2.isTableHovered;
|
|
140
|
+
return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || (0, _utils2.isSelectionUpdated)(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell || isTableHovered !== nextProps.isTableHovered;
|
|
139
141
|
}
|
|
140
142
|
}, {
|
|
141
143
|
key: "componentWillUnmount",
|
|
@@ -161,7 +163,8 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
161
163
|
hoveredRows = _this$props3.hoveredRows,
|
|
162
164
|
stickyHeader = _this$props3.stickyHeader,
|
|
163
165
|
isDragAndDropEnabled = _this$props3.isDragAndDropEnabled,
|
|
164
|
-
hoveredCell = _this$props3.hoveredCell
|
|
166
|
+
hoveredCell = _this$props3.hoveredCell,
|
|
167
|
+
isTableHovered = _this$props3.isTableHovered;
|
|
165
168
|
if (!tableRef) {
|
|
166
169
|
return null;
|
|
167
170
|
}
|
|
@@ -195,6 +198,7 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
195
198
|
tableRef: tableRef,
|
|
196
199
|
tableNode: tableNode,
|
|
197
200
|
hoveredCell: hoveredCell,
|
|
201
|
+
isTableHovered: isTableHovered,
|
|
198
202
|
editorView: editorView,
|
|
199
203
|
tableActive: tableActive,
|
|
200
204
|
isInDanger: isInDanger,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.updateResizeHandles = exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragRowControlsButton = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = void 0;
|
|
6
|
+
exports.updateResizeHandles = exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isDragRowFloatingInsertDot = exports.isDragRowControlsButton = exports.isDragCornerButton = exports.isDragColumnFloatingInsertDot = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = exports.findNearestCellIndexToPoint = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
8
|
var _types = require("../types");
|
|
9
9
|
var _consts = require("../ui/consts");
|
|
@@ -206,4 +206,19 @@ var getTop = exports.getTop = function getTop(element) {
|
|
|
206
206
|
return 0;
|
|
207
207
|
}
|
|
208
208
|
return (_element$getBoundingC = element === null || element === void 0 || (_element$getBoundingC2 = element.getBoundingClientRect) === null || _element$getBoundingC2 === void 0 || (_element$getBoundingC2 = _element$getBoundingC2.call(element)) === null || _element$getBoundingC2 === void 0 ? void 0 : _element$getBoundingC2.top) !== null && _element$getBoundingC !== void 0 ? _element$getBoundingC : 0;
|
|
209
|
+
};
|
|
210
|
+
var findNearestCellIndexToPoint = exports.findNearestCellIndexToPoint = function findNearestCellIndexToPoint(x, y) {
|
|
211
|
+
var _cell$parentElement;
|
|
212
|
+
var elements = document.elementsFromPoint(x, y);
|
|
213
|
+
var cell = elements.find(function (el) {
|
|
214
|
+
return el.nodeName.toUpperCase() === 'TD' || el.nodeName.toUpperCase() === 'TH';
|
|
215
|
+
});
|
|
216
|
+
var row = (_cell$parentElement = cell === null || cell === void 0 ? void 0 : cell.parentElement) !== null && _cell$parentElement !== void 0 ? _cell$parentElement : undefined;
|
|
217
|
+
if (!Number.isFinite(row === null || row === void 0 ? void 0 : row.rowIndex) || !Number.isFinite(cell === null || cell === void 0 ? void 0 : cell.cellIndex)) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
row: row.rowIndex,
|
|
222
|
+
col: cell.cellIndex
|
|
223
|
+
};
|
|
209
224
|
};
|
|
@@ -105,6 +105,12 @@ Object.defineProperty(exports, "findControlsHoverDecoration", {
|
|
|
105
105
|
return _decoration.findControlsHoverDecoration;
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
|
+
Object.defineProperty(exports, "findNearestCellIndexToPoint", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function get() {
|
|
111
|
+
return _dom.findNearestCellIndexToPoint;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
108
114
|
Object.defineProperty(exports, "getColumnClassNames", {
|
|
109
115
|
enumerable: true,
|
|
110
116
|
get: function get() {
|
|
@@ -108,15 +108,32 @@ export const hideResizeHandleLine = () => createCommand(state => ({
|
|
|
108
108
|
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.COLUMN_RESIZING_HANDLE_LINE)
|
|
109
109
|
}
|
|
110
110
|
}));
|
|
111
|
-
export const
|
|
111
|
+
export const setTableHovered = hovered => createCommand(() => {
|
|
112
|
+
return {
|
|
113
|
+
type: 'TABLE_HOVERED',
|
|
114
|
+
data: {
|
|
115
|
+
isTableHovered: hovered
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}, tr => tr.setMeta('addToHistory', false));
|
|
119
|
+
export const hoverCell = (rowIndex, colIndex) => createCommand(state => {
|
|
120
|
+
const {
|
|
121
|
+
hoveredCell: prevHoveredCell
|
|
122
|
+
} = getPluginState(state);
|
|
123
|
+
|
|
124
|
+
// If no arguments have been passed then the intention it to reset the hover cell data
|
|
125
|
+
const clear = rowIndex === undefined && colIndex === undefined;
|
|
126
|
+
const nextRowIndex = clear ? undefined : rowIndex !== null && rowIndex !== void 0 ? rowIndex : prevHoveredCell.rowIndex;
|
|
127
|
+
const nextColIndex = clear ? undefined : colIndex !== null && colIndex !== void 0 ? colIndex : prevHoveredCell.colIndex;
|
|
128
|
+
if (nextRowIndex === prevHoveredCell.rowIndex && nextColIndex === prevHoveredCell.colIndex) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
112
131
|
return {
|
|
113
132
|
type: 'HOVER_CELL',
|
|
114
133
|
data: {
|
|
115
134
|
hoveredCell: {
|
|
116
|
-
rowIndex,
|
|
117
|
-
colIndex
|
|
118
|
-
colWidth,
|
|
119
|
-
colHeight
|
|
135
|
+
rowIndex: nextRowIndex,
|
|
136
|
+
colIndex: nextColIndex
|
|
120
137
|
}
|
|
121
138
|
}
|
|
122
139
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine } from './hover';
|
|
1
|
+
export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, setTableHovered } from './hover';
|
|
2
2
|
export { insertColumn, insertRow, createTable } from './insert';
|
|
3
3
|
export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './toggle';
|
|
4
4
|
export { clearMultipleCells } from './clear';
|
|
@@ -209,11 +209,16 @@ export const getTableElementMoveTypeBySlice = (slice, state) => {
|
|
|
209
209
|
export const isInsideFirstCellOfRowOrColumn = (selection, type) => {
|
|
210
210
|
const table = findTable(selection);
|
|
211
211
|
if (!table || !type) {
|
|
212
|
-
return;
|
|
212
|
+
return false;
|
|
213
213
|
}
|
|
214
214
|
const map = TableMap.get(table.node);
|
|
215
|
-
const cell =
|
|
216
|
-
|
|
215
|
+
const cell = findCellClosestToPos(selection.$anchor);
|
|
216
|
+
if (!cell) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const pos = cell.pos - table.pos - 1;
|
|
220
|
+
// cell positions in table map always start at 1, as they're offsets not positions
|
|
221
|
+
const index = map.map.findIndex(value => value === pos);
|
|
217
222
|
return type === 'row' ? index % map.width === 0 : index < map.width;
|
|
218
223
|
};
|
|
219
224
|
export const deleteTable = (state, dispatch) => {
|
|
@@ -4,7 +4,7 @@ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
7
|
-
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
7
|
+
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverCell, hoverColumns, selectColumn, setEditorFocus, setTableHovered, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
8
8
|
import { getPluginState as getDragDropPluginState } from './pm-plugins/drag-and-drop/plugin-factory';
|
|
9
9
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
10
10
|
import { getPluginState as getResizePluginState } from './pm-plugins/table-resizing/plugin-factory';
|
|
@@ -102,7 +102,8 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
102
102
|
const target = mouseEvent.target;
|
|
103
103
|
const {
|
|
104
104
|
insertColumnButtonIndex,
|
|
105
|
-
insertRowButtonIndex
|
|
105
|
+
insertRowButtonIndex,
|
|
106
|
+
isTableHovered
|
|
106
107
|
} = getPluginState(state);
|
|
107
108
|
if (isInsertRowButton(target)) {
|
|
108
109
|
const [startIndex, endIndex] = getColumnOrRowIndex(target);
|
|
@@ -127,6 +128,9 @@ export const handleMouseOver = (view, mouseEvent) => {
|
|
|
127
128
|
right: endIndex
|
|
128
129
|
})(state, dispatch);
|
|
129
130
|
}
|
|
131
|
+
if (!isTableHovered) {
|
|
132
|
+
return setTableHovered(true)(state, dispatch);
|
|
133
|
+
}
|
|
130
134
|
return false;
|
|
131
135
|
};
|
|
132
136
|
|
|
@@ -163,6 +167,19 @@ export const handleMouseOut = (view, mouseEvent) => {
|
|
|
163
167
|
}
|
|
164
168
|
return false;
|
|
165
169
|
};
|
|
170
|
+
export const handleMouseEnter = (view, mouseEvent) => {
|
|
171
|
+
const {
|
|
172
|
+
state,
|
|
173
|
+
dispatch
|
|
174
|
+
} = view;
|
|
175
|
+
const {
|
|
176
|
+
isTableHovered
|
|
177
|
+
} = getPluginState(state);
|
|
178
|
+
if (!isTableHovered) {
|
|
179
|
+
return setTableHovered(true)(state, dispatch);
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
182
|
+
};
|
|
166
183
|
export const handleMouseLeave = (view, event) => {
|
|
167
184
|
if (!(event.target instanceof HTMLElement)) {
|
|
168
185
|
return false;
|
|
@@ -174,19 +191,29 @@ export const handleMouseLeave = (view, event) => {
|
|
|
174
191
|
const {
|
|
175
192
|
insertColumnButtonIndex,
|
|
176
193
|
insertRowButtonIndex,
|
|
177
|
-
isDragAndDropEnabled
|
|
194
|
+
isDragAndDropEnabled,
|
|
195
|
+
isTableHovered
|
|
178
196
|
} = getPluginState(state);
|
|
197
|
+
if (isTableHovered) {
|
|
198
|
+
if (isDragAndDropEnabled) {
|
|
199
|
+
const {
|
|
200
|
+
isDragMenuOpen
|
|
201
|
+
} = getDragDropPluginState(state);
|
|
202
|
+
!isDragMenuOpen && setTableHovered(false)(state, dispatch);
|
|
203
|
+
} else {
|
|
204
|
+
setTableHovered(false)(state, dispatch);
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// If this table doesn't have focus then we want to skip everything after this.
|
|
210
|
+
if (!isTableInFocus(view)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
179
213
|
const target = event.target;
|
|
180
214
|
if (isTableControlsButton(target)) {
|
|
181
215
|
return true;
|
|
182
216
|
}
|
|
183
|
-
if (isDragAndDropEnabled) {
|
|
184
|
-
const {
|
|
185
|
-
isDragMenuOpen
|
|
186
|
-
} = getDragDropPluginState(state);
|
|
187
|
-
// Only set hoveredCell colIndex and rowIndex to undefined if the drag menu is not open
|
|
188
|
-
!isDragMenuOpen && hoverCell()(state, dispatch);
|
|
189
|
-
}
|
|
190
217
|
if ((typeof insertColumnButtonIndex !== 'undefined' || typeof insertRowButtonIndex !== 'undefined') && hideInsertColumnOrRowButton()(state, dispatch)) {
|
|
191
218
|
return true;
|
|
192
219
|
}
|
|
@@ -331,9 +358,12 @@ export const handleCut = (oldTr, oldState, newState, editorAnalyticsAPI, editorV
|
|
|
331
358
|
}
|
|
332
359
|
return tr;
|
|
333
360
|
};
|
|
334
|
-
export const
|
|
361
|
+
export const isTableInFocus = view => {
|
|
335
362
|
var _getPluginState, _getResizePluginState;
|
|
336
|
-
|
|
363
|
+
return !!((_getPluginState = getPluginState(view.state)) !== null && _getPluginState !== void 0 && _getPluginState.tableNode) && !((_getResizePluginState = getResizePluginState(view.state)) !== null && _getResizePluginState !== void 0 && _getResizePluginState.dragging);
|
|
364
|
+
};
|
|
365
|
+
export const whenTableInFocus = (eventHandler, elementContentRects) => (view, mouseEvent) => {
|
|
366
|
+
if (!isTableInFocus(view)) {
|
|
337
367
|
return false;
|
|
338
368
|
}
|
|
339
369
|
return eventHandler(view, mouseEvent, elementContentRects);
|
|
@@ -342,10 +372,9 @@ const trackCellLocation = (view, mouseEvent) => {
|
|
|
342
372
|
var _tableElement$dataset;
|
|
343
373
|
const target = mouseEvent.target;
|
|
344
374
|
const maybeTableCell = isElementInTableCell(target);
|
|
345
|
-
const tableRef = getPluginState(view.state).tableRef;
|
|
346
375
|
const {
|
|
347
|
-
|
|
348
|
-
|
|
376
|
+
tableNode,
|
|
377
|
+
tableRef
|
|
349
378
|
} = getPluginState(view.state);
|
|
350
379
|
const tableElement = closestElement(target, 'table');
|
|
351
380
|
|
|
@@ -359,17 +388,13 @@ const trackCellLocation = (view, mouseEvent) => {
|
|
|
359
388
|
const htmlColIndex = maybeTableCell.cellIndex;
|
|
360
389
|
const rowElement = closestElement(target, 'tr');
|
|
361
390
|
const htmlRowIndex = rowElement && rowElement.rowIndex;
|
|
362
|
-
const colHeight = tableRef.offsetHeight;
|
|
363
|
-
const colWidth = maybeTableCell.offsetWidth;
|
|
364
391
|
const tableMap = tableNode && TableMap.get(tableNode);
|
|
365
392
|
let colIndex = htmlColIndex;
|
|
366
393
|
if (tableMap) {
|
|
367
394
|
const convertedColIndex = convertHTMLCellIndexToColumnIndex(htmlColIndex, htmlRowIndex, tableMap);
|
|
368
395
|
colIndex = getColumnIndexMappedToColumnIndexInFirstRow(convertedColIndex, htmlRowIndex, tableMap);
|
|
369
396
|
}
|
|
370
|
-
|
|
371
|
-
hoverCell(htmlRowIndex, colIndex, colWidth, colHeight)(view.state, view.dispatch);
|
|
372
|
-
}
|
|
397
|
+
hoverCell(htmlRowIndex, colIndex)(view.state, view.dispatch);
|
|
373
398
|
};
|
|
374
399
|
export const withCellTracking = (eventHandler, elementContentRects) => (view, mouseEvent) => {
|
|
375
400
|
if (getPluginState(view.state).isDragAndDropEnabled && !getDragDropPluginState(view.state).isDragging) {
|
|
@@ -528,7 +528,8 @@ class TableComponent extends React.Component {
|
|
|
528
528
|
const {
|
|
529
529
|
isInDanger,
|
|
530
530
|
hoveredRows,
|
|
531
|
-
hoveredCell
|
|
531
|
+
hoveredCell,
|
|
532
|
+
isTableHovered
|
|
532
533
|
} = getPluginState(view.state);
|
|
533
534
|
const tableRef = this.table || undefined;
|
|
534
535
|
const headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
|
|
@@ -540,6 +541,7 @@ class TableComponent extends React.Component {
|
|
|
540
541
|
tableActive: tableActive,
|
|
541
542
|
hoveredRows: hoveredRows,
|
|
542
543
|
hoveredCell: hoveredCell,
|
|
544
|
+
isTableHovered: isTableHovered,
|
|
543
545
|
isInDanger: isInDanger,
|
|
544
546
|
isResizing: isResizing,
|
|
545
547
|
isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
|
|
@@ -562,6 +564,7 @@ class TableComponent extends React.Component {
|
|
|
562
564
|
isInDanger: isInDanger,
|
|
563
565
|
hoveredRows: hoveredRows,
|
|
564
566
|
hoveredCell: hoveredCell,
|
|
567
|
+
isTableHovered: isTableHovered,
|
|
565
568
|
isResizing: isResizing,
|
|
566
569
|
ordering: ordering,
|
|
567
570
|
hasHeaderRow: hasHeaderRow
|
|
@@ -53,24 +53,25 @@ export const clearDropTarget = tr => createCommand(state => {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
}, originalTr => (tr || originalTr).setMeta('addToHistory', false));
|
|
56
|
-
export const moveSource = (sourceType, sourceIndex, targetIndex) => createCommand(state => {
|
|
56
|
+
export const moveSource = (sourceType, sourceIndex, targetIndex, tr) => createCommand(state => {
|
|
57
57
|
return {
|
|
58
58
|
type: DragAndDropActionType.CLEAR_DROP_TARGET,
|
|
59
59
|
data: {
|
|
60
60
|
decorationSet: DecorationSet.empty
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
},
|
|
63
|
+
}, originalTr => {
|
|
64
|
+
const nextTr = tr || originalTr;
|
|
64
65
|
if (sourceIndex === targetIndex) {
|
|
65
|
-
return
|
|
66
|
+
return nextTr.setMeta('addToHistory', false);
|
|
66
67
|
}
|
|
67
|
-
const anchor =
|
|
68
|
+
const anchor = nextTr.selection.anchor;
|
|
68
69
|
const selectStartOfTable = newTr => newTr.setSelection(TextSelection.create(newTr.doc, anchor));
|
|
69
70
|
const isTableRow = sourceType === 'table-row';
|
|
70
71
|
if (isTableRow) {
|
|
71
|
-
return combineTransforms([moveRow(sourceIndex, targetIndex), selectStartOfTable, selectRow(targetIndex)],
|
|
72
|
+
return combineTransforms([moveRow(sourceIndex, targetIndex), selectStartOfTable, selectRow(targetIndex)], nextTr);
|
|
72
73
|
}
|
|
73
|
-
return combineTransforms([moveColumn(sourceIndex, targetIndex), selectStartOfTable, selectColumn(targetIndex)],
|
|
74
|
+
return combineTransforms([moveColumn(sourceIndex, targetIndex), selectStartOfTable, selectColumn(targetIndex)], nextTr);
|
|
74
75
|
});
|
|
75
76
|
export const toggleDragMenu = (isDragMenuOpen, direction, index) => createCommand(state => {
|
|
76
77
|
let {
|
|
@@ -3,8 +3,10 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { getCellsInRow } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
6
|
+
import { findNearestCellIndexToPoint } from '../../utils';
|
|
6
7
|
import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
|
|
7
8
|
import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
9
|
+
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
8
10
|
import { DragAndDropActionType } from './actions';
|
|
9
11
|
import { clearDropTarget, moveSource, setDropTarget, toggleDragMenu } from './commands';
|
|
10
12
|
import { DropTargetType } from './consts';
|
|
@@ -112,29 +114,60 @@ export const createPlugin = (dispatch, eventDispatcher) => {
|
|
|
112
114
|
setDropTarget(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
|
|
113
115
|
},
|
|
114
116
|
onDrop(event) {
|
|
117
|
+
var _cell$row, _cell$col;
|
|
115
118
|
const data = getDraggableDataFromEvent(event);
|
|
116
119
|
|
|
120
|
+
// On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
|
|
121
|
+
// over. This is so the drag handles update their positions to correctly align with the users mouse. Unfortunately
|
|
122
|
+
// at this point in time and during the drag opertation, the drop targets are eating all the mouse events so
|
|
123
|
+
// it's not possible to know what row/col the mouse is over (via mouse events). This attempts to locate the nearest cell and
|
|
124
|
+
// then tries to update the main table hoveredCell value by piggy-backing the transaction onto the command
|
|
125
|
+
// triggered by this on drop event.
|
|
126
|
+
const {
|
|
127
|
+
hoveredCell
|
|
128
|
+
} = getTablePluginState(editorView.state);
|
|
129
|
+
const cell = findNearestCellIndexToPoint(event.location.current.input.clientX, event.location.current.input.clientY);
|
|
130
|
+
const tr = editorView.state.tr;
|
|
131
|
+
const action = {
|
|
132
|
+
type: 'HOVER_CELL',
|
|
133
|
+
data: {
|
|
134
|
+
hoveredCell: {
|
|
135
|
+
rowIndex: (_cell$row = cell === null || cell === void 0 ? void 0 : cell.row) !== null && _cell$row !== void 0 ? _cell$row : hoveredCell.rowIndex,
|
|
136
|
+
colIndex: (_cell$col = cell === null || cell === void 0 ? void 0 : cell.col) !== null && _cell$col !== void 0 ? _cell$col : hoveredCell.colIndex
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
tr.setMeta(tablePluginKey, action);
|
|
141
|
+
|
|
117
142
|
// If no data can be found then it's most like we do not want to perform any drop action
|
|
118
143
|
if (!data) {
|
|
119
|
-
clearDropTarget()(editorView.state, editorView.dispatch);
|
|
144
|
+
clearDropTarget(tr)(editorView.state, editorView.dispatch);
|
|
120
145
|
return;
|
|
121
146
|
}
|
|
122
147
|
const {
|
|
123
148
|
sourceType,
|
|
124
149
|
sourceIndexes,
|
|
150
|
+
targetIndex,
|
|
125
151
|
targetAdjustedIndex,
|
|
126
152
|
direction
|
|
127
153
|
} = data;
|
|
128
154
|
|
|
155
|
+
// When we drop on a target we will know the targets row/col index for certain,
|
|
156
|
+
if (sourceType === 'table-row') {
|
|
157
|
+
action.data.hoveredCell.rowIndex = targetIndex;
|
|
158
|
+
} else {
|
|
159
|
+
action.data.hoveredCell.colIndex = targetIndex;
|
|
160
|
+
}
|
|
161
|
+
|
|
129
162
|
// If the drop target index contains merged cells then we should not allow the drop to occur.
|
|
130
163
|
const hasMergedCells = sourceType === 'table-row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
131
164
|
if (hasMergedCells(targetAdjustedIndex)(editorView.state.selection)) {
|
|
132
|
-
clearDropTarget()(editorView.state, editorView.dispatch);
|
|
165
|
+
clearDropTarget(tr)(editorView.state, editorView.dispatch);
|
|
133
166
|
return;
|
|
134
167
|
}
|
|
135
168
|
const [sourceIndex] = sourceIndexes;
|
|
136
169
|
requestAnimationFrame(() => {
|
|
137
|
-
moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1))(editorView.state, editorView.dispatch);
|
|
170
|
+
moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
138
171
|
});
|
|
139
172
|
}
|
|
140
173
|
})
|
|
@@ -8,7 +8,7 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
|
|
10
10
|
import { removeResizeHandleDecorations, transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
|
|
11
|
-
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
11
|
+
import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseEnter, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus, withCellTracking } from '../event-handlers';
|
|
12
12
|
import { createTableView } from '../nodeviews/table';
|
|
13
13
|
import TableCell from '../nodeviews/TableCell';
|
|
14
14
|
import TableRow from '../nodeviews/TableRow';
|
|
@@ -24,6 +24,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
24
24
|
var _window;
|
|
25
25
|
const state = createPluginState(dispatch, {
|
|
26
26
|
pluginConfig,
|
|
27
|
+
isTableHovered: false,
|
|
27
28
|
insertColumnButtonIndex: undefined,
|
|
28
29
|
insertRowButtonIndex: undefined,
|
|
29
30
|
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
@@ -236,11 +237,12 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
236
237
|
focus: handleFocus,
|
|
237
238
|
blur: handleBlur,
|
|
238
239
|
mousedown: withCellTracking(handleMouseDown),
|
|
239
|
-
mouseover: whenTableInFocus(
|
|
240
|
-
mouseleave:
|
|
240
|
+
mouseover: withCellTracking(whenTableInFocus(handleMouseOver)),
|
|
241
|
+
mouseleave: handleMouseLeave,
|
|
241
242
|
mouseout: whenTableInFocus(handleMouseOut),
|
|
242
243
|
mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
|
|
243
|
-
|
|
244
|
+
mouseenter: handleMouseEnter,
|
|
245
|
+
click: withCellTracking(whenTableInFocus(handleClick))
|
|
244
246
|
},
|
|
245
247
|
handleTripleClick
|
|
246
248
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
1
3
|
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
2
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
5
|
import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
@@ -87,7 +89,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
87
89
|
},
|
|
88
90
|
selected: false,
|
|
89
91
|
disabled: false,
|
|
90
|
-
elemAfter:
|
|
92
|
+
elemAfter: jsx("div", {
|
|
91
93
|
css: shortcutStyle
|
|
92
94
|
}, tooltip(addColumnAfter))
|
|
93
95
|
}, {
|
|
@@ -106,7 +108,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
106
108
|
},
|
|
107
109
|
selected: false,
|
|
108
110
|
disabled: false,
|
|
109
|
-
elemAfter:
|
|
111
|
+
elemAfter: jsx("div", {
|
|
110
112
|
css: shortcutStyle
|
|
111
113
|
}, tooltip(addRowAfter))
|
|
112
114
|
}, {
|
|
@@ -239,7 +241,7 @@ export const getToolbarCellOptionsConfig = (editorState, editorView, initialSele
|
|
|
239
241
|
},
|
|
240
242
|
selected: false,
|
|
241
243
|
disabled: false,
|
|
242
|
-
elemAfter:
|
|
244
|
+
elemAfter: jsx("div", {
|
|
243
245
|
css: shortcutStyle
|
|
244
246
|
}, tooltip(backspace))
|
|
245
247
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
2
3
|
import React from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
3
5
|
import { useIntl } from 'react-intl-next';
|
|
4
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
7
|
import Tooltip from '@atlaskit/tooltip';
|
|
@@ -13,19 +15,19 @@ export const ColumnResizeWidget = ({
|
|
|
13
15
|
formatMessage
|
|
14
16
|
} = useIntl();
|
|
15
17
|
if (!includeTooltip) {
|
|
16
|
-
return
|
|
18
|
+
return jsx("div", {
|
|
17
19
|
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
18
20
|
"data-start-index": startIndex,
|
|
19
21
|
"data-end-index": endIndex
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
|
-
return
|
|
24
|
+
return jsx(Tooltip, {
|
|
23
25
|
content: formatMessage(messages.adjustColumns),
|
|
24
26
|
hideTooltipOnClick: true,
|
|
25
27
|
hideTooltipOnMouseDown: true,
|
|
26
28
|
position: "mouse",
|
|
27
29
|
mousePosition: "auto-start"
|
|
28
|
-
}, tooltipProps =>
|
|
30
|
+
}, tooltipProps => jsx("div", _extends({
|
|
29
31
|
className: TableCssClassName.RESIZE_HANDLE_DECORATION,
|
|
30
32
|
"data-start-index": startIndex,
|
|
31
33
|
"data-end-index": endIndex
|
|
@@ -3,6 +3,7 @@ import { DragHandleDisabledIcon, DragHandleIcon, MinimisedHandleIcon } from '../
|
|
|
3
3
|
export const HandleIconComponent = props => {
|
|
4
4
|
const {
|
|
5
5
|
direction,
|
|
6
|
+
forceDefaultHandle,
|
|
6
7
|
isDragMenuOpen,
|
|
7
8
|
isRowHandleHovered,
|
|
8
9
|
isColumnHandleHovered,
|
|
@@ -14,11 +15,8 @@ export const HandleIconComponent = props => {
|
|
|
14
15
|
const isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
15
16
|
const isCurrentRowOrColumnSelected = isCurrentRowSelected || isCurrentColumnSelected;
|
|
16
17
|
const isDragMenuOpenOnCurrentRowOrColumn = isDragMenuOpen && dragMenuDirection === direction && isCurrentRowOrColumnSelected;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// hoverred handle or open drag menu
|
|
20
|
-
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
21
|
-
return showNormalHandle;
|
|
18
|
+
if (forceDefaultHandle || isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
19
|
+
return hasMergedCells ? /*#__PURE__*/React.createElement(DragHandleDisabledIcon, null) : /*#__PURE__*/React.createElement(DragHandleIcon, null);
|
|
22
20
|
}
|
|
23
21
|
return /*#__PURE__*/React.createElement(MinimisedHandleIcon, null);
|
|
24
22
|
};
|
|
@@ -14,6 +14,7 @@ export const DragHandle = ({
|
|
|
14
14
|
direction = 'row',
|
|
15
15
|
appearance = 'default',
|
|
16
16
|
indexes,
|
|
17
|
+
forceDefaultHandle = false,
|
|
17
18
|
previewWidth,
|
|
18
19
|
previewHeight,
|
|
19
20
|
onMouseOver,
|
|
@@ -45,6 +46,7 @@ export const DragHandle = ({
|
|
|
45
46
|
const handleIconProps = {
|
|
46
47
|
hasMergedCells,
|
|
47
48
|
direction,
|
|
49
|
+
forceDefaultHandle,
|
|
48
50
|
isDragMenuOpen,
|
|
49
51
|
isRowHandleHovered,
|
|
50
52
|
isColumnHandleHovered,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
1
2
|
import React from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
2
4
|
import { injectIntl } from 'react-intl-next';
|
|
3
5
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
4
6
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
@@ -48,25 +50,25 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
48
50
|
return null;
|
|
49
51
|
}
|
|
50
52
|
const labelCellOptions = formatMessage(messages.cellOptions);
|
|
51
|
-
const button =
|
|
53
|
+
const button = jsx("div", {
|
|
52
54
|
css: theme => [tableFloatingCellButtonStyles({
|
|
53
55
|
theme
|
|
54
56
|
}), isContextualMenuOpen && tableFloatingCellButtonSelectedStyles({
|
|
55
57
|
theme
|
|
56
58
|
})]
|
|
57
|
-
},
|
|
59
|
+
}, jsx(ToolbarButton, {
|
|
58
60
|
className: ClassName.CONTEXTUAL_MENU_BUTTON,
|
|
59
61
|
selected: isContextualMenuOpen,
|
|
60
62
|
title: labelCellOptions,
|
|
61
63
|
onClick: handleClick,
|
|
62
|
-
iconBefore:
|
|
64
|
+
iconBefore: jsx(ExpandIcon, {
|
|
63
65
|
label: ""
|
|
64
66
|
}),
|
|
65
67
|
"aria-label": labelCellOptions
|
|
66
68
|
}));
|
|
67
69
|
const parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
68
70
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
69
|
-
return
|
|
71
|
+
return jsx(FixedButton, {
|
|
70
72
|
offset: BUTTON_OFFSET,
|
|
71
73
|
stickyHeader: stickyHeader,
|
|
72
74
|
tableWrapper: tableWrapper,
|
|
@@ -76,7 +78,7 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
76
78
|
isContextualMenuOpen: isContextualMenuOpen
|
|
77
79
|
}, button);
|
|
78
80
|
}
|
|
79
|
-
return
|
|
81
|
+
return jsx(Popup, {
|
|
80
82
|
alignX: "right",
|
|
81
83
|
alignY: "start",
|
|
82
84
|
target: targetCellRef,
|
|
@@ -91,9 +93,9 @@ const FloatingContextualButtonInner = /*#__PURE__*/React.memo(props => {
|
|
|
91
93
|
});
|
|
92
94
|
const FloatingContextualButton = injectIntl(FloatingContextualButtonInner);
|
|
93
95
|
export default function (props) {
|
|
94
|
-
return
|
|
96
|
+
return jsx(ErrorBoundary, {
|
|
95
97
|
component: ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON,
|
|
96
98
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
97
99
|
fallbackComponent: null
|
|
98
|
-
},
|
|
100
|
+
}, jsx(FloatingContextualButton, props));
|
|
99
101
|
}
|