@atlaskit/editor-plugin-table 5.5.2 → 5.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/plugins/table/commands/index.js +12 -0
- package/dist/cjs/plugins/table/commands/misc.js +61 -1
- package/dist/cjs/plugins/table/index.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +8 -19
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +70 -36
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +11 -0
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +46 -1
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +25 -29
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +5 -18
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +16 -1
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +61 -1
- package/dist/esm/plugins/table/index.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/esm/plugins/table/ui/DragHandle/index.js +6 -17
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +71 -37
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +67 -32
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +2 -0
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/package.json +1 -4
- package/src/__tests__/unit/ui/RowDragControls.tsx +2 -0
- package/src/plugins/table/commands/index.ts +2 -0
- package/src/plugins/table/commands/misc.ts +78 -0
- package/src/plugins/table/index.tsx +5 -7
- package/src/plugins/table/nodeviews/TableComponent.tsx +31 -38
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +2 -0
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -7
- package/src/plugins/table/types.ts +2 -0
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +5 -30
- package/src/plugins/table/ui/DragHandle/index.tsx +6 -23
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +134 -49
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +3 -3
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +137 -44
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.5.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#60278](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60278) [`bc2785a02329`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bc2785a02329) - Selection of multiple rows / column should remain when clicking the drag handle
|
|
8
|
+
- [#60323](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60323) [`e0c900d97140`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e0c900d97140) - Fix undo of drag and drop using keyboard
|
|
9
|
+
|
|
10
|
+
## 5.5.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#59569](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59569) [`dffa156814cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dffa156814cd) - [ux] re-implement feature with fixed handle when drag menu off and fix issue when numbered column enabled.
|
|
15
|
+
- [#60153](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60153) [`5764d44cc93b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5764d44cc93b) - Cleaned references for feature flag: platform.editor.table.overflow-state-analytics
|
|
16
|
+
|
|
3
17
|
## 5.5.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -135,12 +135,24 @@ Object.defineProperty(exports, "selectColumn", {
|
|
|
135
135
|
return _misc.selectColumn;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
+
Object.defineProperty(exports, "selectColumns", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function get() {
|
|
141
|
+
return _misc.selectColumns;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
138
144
|
Object.defineProperty(exports, "selectRow", {
|
|
139
145
|
enumerable: true,
|
|
140
146
|
get: function get() {
|
|
141
147
|
return _misc.selectRow;
|
|
142
148
|
}
|
|
143
149
|
});
|
|
150
|
+
Object.defineProperty(exports, "selectRows", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function get() {
|
|
153
|
+
return _misc.selectRows;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
144
156
|
Object.defineProperty(exports, "setCellAttr", {
|
|
145
157
|
enumerable: true,
|
|
146
158
|
get: function get() {
|
|
@@ -4,7 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRow = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
7
|
+
exports.updateResizeHandleDecorations = exports.triggerUnlessTableHeader = exports.transformSliceToRemoveColumnsWidths = exports.transformSliceToAddTableHeaders = exports.transformSliceRemoveCellBackgroundColor = exports.showInsertRowButton = exports.showInsertColumnButton = exports.setTableRef = exports.setMultipleCellAttrs = exports.setEditorFocus = exports.setCellAttr = exports.selectRows = exports.selectRow = exports.selectColumns = exports.selectColumn = exports.removeResizeHandleDecorations = exports.moveCursorBackward = exports.isInsideFirstCellOfRowOrColumn = exports.hideInsertColumnOrRowButton = exports.getTableSelectionType = exports.getTableElementMoveTypeBySlice = exports.deleteTableIfSelected = exports.deleteTable = exports.countCellsInSlice = exports.convertFirstRowToHeader = exports.autoSizeTable = exports.addResizeHandleDecorations = exports.addBoldInEmptyHeaderCells = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -346,6 +347,37 @@ var selectColumn = exports.selectColumn = function selectColumn(column, expand)
|
|
|
346
347
|
return (0, _utils2.selectColumn)(column, expand)(tr).setMeta('addToHistory', false);
|
|
347
348
|
});
|
|
348
349
|
};
|
|
350
|
+
var selectColumns = exports.selectColumns = function selectColumns(columnIndexes) {
|
|
351
|
+
return (0, _pluginFactory.createCommand)(function (state) {
|
|
352
|
+
if (!columnIndexes) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
var cells = columnIndexes.map(function (column) {
|
|
356
|
+
return (0, _utils2.getCellsInColumn)(column)(state.tr.selection);
|
|
357
|
+
}).flat();
|
|
358
|
+
if (!cells || !cells.length || cells.some(function (cell) {
|
|
359
|
+
return cell && typeof cell.pos !== 'number';
|
|
360
|
+
})) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
var decorations = (0, _decoration.createColumnSelectedDecoration)((0, _utils2.selectColumns)(columnIndexes)(state.tr));
|
|
364
|
+
var decorationSet = (0, _updatePluginStateDecorations.updatePluginStateDecorations)(state, decorations, _types.TableDecorations.COLUMN_SELECTED);
|
|
365
|
+
var cellsInFirstColumn = (0, _utils2.getCellsInColumn)(Math.min.apply(Math, (0, _toConsumableArray2.default)(columnIndexes)))(state.tr.selection);
|
|
366
|
+
if (!cellsInFirstColumn || cellsInFirstColumn.length === 0) {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
var targetCellPosition = cellsInFirstColumn[0].pos;
|
|
370
|
+
return {
|
|
371
|
+
type: 'SELECT_COLUMN',
|
|
372
|
+
data: {
|
|
373
|
+
targetCellPosition: targetCellPosition,
|
|
374
|
+
decorationSet: decorationSet
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
}, function (tr) {
|
|
378
|
+
return (0, _utils2.selectColumns)(columnIndexes)(tr).setMeta('addToHistory', false);
|
|
379
|
+
});
|
|
380
|
+
};
|
|
349
381
|
var selectRow = exports.selectRow = function selectRow(row, expand) {
|
|
350
382
|
return (0, _pluginFactory.createCommand)(function (state) {
|
|
351
383
|
var targetCellPosition;
|
|
@@ -363,6 +395,34 @@ var selectRow = exports.selectRow = function selectRow(row, expand) {
|
|
|
363
395
|
return (0, _utils2.selectRow)(row, expand)(tr).setMeta('addToHistory', false);
|
|
364
396
|
});
|
|
365
397
|
};
|
|
398
|
+
var selectRows = exports.selectRows = function selectRows(rowIndexes) {
|
|
399
|
+
return (0, _pluginFactory.createCommand)(function (state) {
|
|
400
|
+
if (rowIndexes.length === 0) {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
var cells = rowIndexes.map(function (row) {
|
|
404
|
+
return (0, _utils2.getCellsInRow)(row)(state.tr.selection);
|
|
405
|
+
}).flat();
|
|
406
|
+
if (!cells || !cells.length || cells.some(function (cell) {
|
|
407
|
+
return cell && typeof cell.pos !== 'number';
|
|
408
|
+
})) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
var cellsInFirstRow = (0, _utils2.getCellsInRow)(Math.min.apply(Math, (0, _toConsumableArray2.default)(rowIndexes)))(state.tr.selection);
|
|
412
|
+
if (!cellsInFirstRow || cellsInFirstRow.length === 0) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
var targetCellPosition = cellsInFirstRow[0].pos;
|
|
416
|
+
return {
|
|
417
|
+
type: 'SET_TARGET_CELL_POSITION',
|
|
418
|
+
data: {
|
|
419
|
+
targetCellPosition: targetCellPosition
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
}, function (tr) {
|
|
423
|
+
return (0, _utils2.selectRows)(rowIndexes)(tr).setMeta('addToHistory', false);
|
|
424
|
+
});
|
|
425
|
+
};
|
|
366
426
|
var showInsertColumnButton = exports.showInsertColumnButton = function showInsertColumnButton(columnIndex) {
|
|
367
427
|
return (0, _pluginFactory.createCommand)(function (_) {
|
|
368
428
|
return columnIndex > -1 ? {
|
|
@@ -211,7 +211,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
211
211
|
var _options$tableResizin;
|
|
212
212
|
var dispatch = _ref12.dispatch,
|
|
213
213
|
dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent;
|
|
214
|
-
return (0,
|
|
214
|
+
return (0, _tableAnalytics.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false);
|
|
215
215
|
}
|
|
216
216
|
}, {
|
|
217
217
|
name: 'tableAnalyticsPlugin',
|
|
@@ -393,10 +393,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
393
393
|
this.onStickyState(currentStickyState);
|
|
394
394
|
}
|
|
395
395
|
eventDispatcher.on(_stickyHeaders.pluginKey.key, this.onStickyState);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
399
|
-
}
|
|
396
|
+
var initialIsOveflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
397
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
400
398
|
}
|
|
401
399
|
}, {
|
|
402
400
|
key: "componentWillUnmount",
|
|
@@ -483,28 +481,26 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
483
481
|
}
|
|
484
482
|
this.handleTableResizingDebounced();
|
|
485
483
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}));
|
|
507
|
-
}
|
|
484
|
+
var newIsOverflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
485
|
+
var prevIsOverflowing = prevState[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
486
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
487
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
488
|
+
}
|
|
489
|
+
if (!this.isInitialOverflowSent) {
|
|
490
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
491
|
+
}
|
|
492
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
493
|
+
var _this$state2;
|
|
494
|
+
var _this$props$view = this.props.view,
|
|
495
|
+
dispatch = _this$props$view.dispatch,
|
|
496
|
+
tr = _this$props$view.state.tr;
|
|
497
|
+
dispatch(tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
498
|
+
isOverflowing: newIsOverflowing,
|
|
499
|
+
wasOverflowing: prevIsOverflowing,
|
|
500
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
501
|
+
width: this.node.attrs.width || 0,
|
|
502
|
+
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
503
|
+
}));
|
|
508
504
|
}
|
|
509
505
|
}
|
|
510
506
|
}, {
|
|
@@ -191,6 +191,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
191
191
|
sourceIndex = _sourceIndexes[0];
|
|
192
192
|
requestAnimationFrame(function () {
|
|
193
193
|
(0, _commands.moveSource)(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
194
|
+
editorView.focus();
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
197
|
})
|
|
@@ -27,13 +27,11 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
event.preventDefault();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
dispatch(tr);
|
|
36
|
-
}
|
|
30
|
+
var tr = view.state.tr;
|
|
31
|
+
tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
|
|
32
|
+
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
|
|
33
|
+
});
|
|
34
|
+
dispatch(tr);
|
|
37
35
|
var mouseDownTime = event.timeStamp;
|
|
38
36
|
var cell = state.doc.nodeAt(localResizeHandlePos);
|
|
39
37
|
var $cell = state.doc.resolve(localResizeHandlePos);
|
|
@@ -8,24 +8,13 @@ exports.HandleIconComponent = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _icons = require("../icons");
|
|
10
10
|
var HandleIconComponent = exports.HandleIconComponent = function HandleIconComponent(props) {
|
|
11
|
-
var
|
|
12
|
-
direction = props.direction,
|
|
13
|
-
isDragMenuOpen = props.isDragMenuOpen,
|
|
11
|
+
var forceDefaultHandle = props.forceDefaultHandle,
|
|
14
12
|
isRowHandleHovered = props.isRowHandleHovered,
|
|
15
13
|
isColumnHandleHovered = props.isColumnHandleHovered,
|
|
16
|
-
hasMergedCells = props.hasMergedCells
|
|
17
|
-
isCurrentRowSelected = props.isCurrentRowSelected,
|
|
18
|
-
isCurrentColumnSelected = props.isCurrentColumnSelected,
|
|
19
|
-
dragMenuDirection = props.dragMenuDirection;
|
|
14
|
+
hasMergedCells = props.hasMergedCells;
|
|
20
15
|
var isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var isDragPossible = canDrag && !hasMergedCells;
|
|
24
|
-
var showNormalHandle = !isDragPossible ? /*#__PURE__*/_react.default.createElement(_icons.DragHandleDisabledIcon, null) : /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null);
|
|
25
|
-
|
|
26
|
-
// hoverred handle or open drag menu
|
|
27
|
-
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
28
|
-
return showNormalHandle;
|
|
16
|
+
if (isHandleHovered || forceDefaultHandle) {
|
|
17
|
+
return hasMergedCells ? /*#__PURE__*/_react.default.createElement(_icons.DragHandleDisabledIcon, null) : /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null);
|
|
29
18
|
}
|
|
30
19
|
return /*#__PURE__*/_react.default.createElement(_icons.MinimisedHandleIcon, null);
|
|
31
20
|
};
|
|
@@ -14,8 +14,7 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
14
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
15
|
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
16
16
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview");
|
|
17
|
-
var _pluginFactory = require("../../pm-plugins/
|
|
18
|
-
var _pluginFactory2 = require("../../pm-plugins/plugin-factory");
|
|
17
|
+
var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
19
18
|
var _types = require("../../types");
|
|
20
19
|
var _utils2 = require("../../utils");
|
|
21
20
|
var _DragPreview = require("../DragPreview");
|
|
@@ -29,6 +28,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
29
28
|
_ref$appearance = _ref.appearance,
|
|
30
29
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
31
30
|
indexes = _ref.indexes,
|
|
31
|
+
_ref$forceDefaultHand = _ref.forceDefaultHandle,
|
|
32
|
+
forceDefaultHandle = _ref$forceDefaultHand === void 0 ? false : _ref$forceDefaultHand,
|
|
32
33
|
previewWidth = _ref.previewWidth,
|
|
33
34
|
previewHeight = _ref.previewHeight,
|
|
34
35
|
onMouseOver = _ref.onMouseOver,
|
|
@@ -43,32 +44,20 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
43
44
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
44
45
|
previewContainer = _useState2[0],
|
|
45
46
|
setPreviewContainer = _useState2[1];
|
|
46
|
-
var _getPluginState = (0,
|
|
47
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
47
48
|
hoveredColumns = _getPluginState.hoveredColumns,
|
|
48
|
-
hoveredRows = _getPluginState.hoveredRows
|
|
49
|
-
hoveredCell = _getPluginState.hoveredCell;
|
|
50
|
-
var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
51
|
-
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection,
|
|
52
|
-
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
53
|
-
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex;
|
|
49
|
+
hoveredRows = _getPluginState.hoveredRows;
|
|
54
50
|
var selection = editorView.state.selection;
|
|
55
|
-
var isCurrentRowSelected = isDragMenuOpen && direction === 'row' && hoveredCell.rowIndex === dragMenuIndex;
|
|
56
|
-
var isCurrentColumnSelected = isDragMenuOpen && direction === 'column' && hoveredCell.colIndex === dragMenuIndex;
|
|
57
51
|
var isRowHandleHovered = direction === 'row' && hoveredRows.length > 0;
|
|
58
52
|
var isColumnHandleHovered = direction === 'column' && hoveredColumns.length > 0;
|
|
59
53
|
var hasMergedCells = (0, _react.useMemo)(function () {
|
|
60
54
|
return direction === 'row' ? (0, _utils2.hasMergedCellsInRow)(indexes[0])(selection) : (0, _utils2.hasMergedCellsInColumn)(indexes[0])(selection);
|
|
61
55
|
}, [indexes, direction, selection]);
|
|
62
56
|
var handleIconProps = {
|
|
63
|
-
|
|
64
|
-
hasMergedCells: hasMergedCells,
|
|
65
|
-
direction: direction,
|
|
66
|
-
isDragMenuOpen: isDragMenuOpen,
|
|
67
|
-
isRowHandleHovered: isRowHandleHovered,
|
|
57
|
+
forceDefaultHandle: forceDefaultHandle,
|
|
68
58
|
isColumnHandleHovered: isColumnHandleHovered,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
dragMenuDirection: dragMenuDirection
|
|
59
|
+
isRowHandleHovered: isRowHandleHovered,
|
|
60
|
+
hasMergedCells: hasMergedCells
|
|
72
61
|
};
|
|
73
62
|
(0, _react.useEffect)(function () {
|
|
74
63
|
var dragHandleDivRefCurrent = dragHandleDivRef.current;
|
|
@@ -16,6 +16,8 @@ var _utils2 = require("../../../utils");
|
|
|
16
16
|
var _DragHandle = require("../../DragHandle");
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
20
|
+
|
|
19
21
|
var getSelectedColumns = function getSelectedColumns(selection) {
|
|
20
22
|
if (selection instanceof _editorTables.CellSelection && selection.isColSelection()) {
|
|
21
23
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -27,7 +29,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
|
|
|
27
29
|
return [];
|
|
28
30
|
};
|
|
29
31
|
var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
30
|
-
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce
|
|
32
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
|
|
31
33
|
var editorView = _ref.editorView,
|
|
32
34
|
tableActive = _ref.tableActive,
|
|
33
35
|
tableRef = _ref.tableRef,
|
|
@@ -48,21 +50,20 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
48
50
|
var columnParams = (0, _utils2.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
49
51
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
50
52
|
var selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
51
|
-
var gridColumnPosition = (0, _react.useMemo)(function () {
|
|
52
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
53
|
-
if (selectedColIndexes.includes(colIndex)) {
|
|
54
|
-
return "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
55
|
-
}
|
|
56
|
-
return "".concat(colIndex + 1, " / span 1");
|
|
57
|
-
}, [colIndex, selectedColIndexes]);
|
|
58
53
|
var firstRow = tableRef.querySelector('tr');
|
|
59
54
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
60
55
|
var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
61
56
|
var handleClick = (0, _react.useCallback)(function (event) {
|
|
62
57
|
var state = editorView.state,
|
|
63
58
|
dispatch = editorView.dispatch;
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
var isClickOutsideSelectedCols = selectedColIndexes.length >= 1 && !selectedColIndexes.includes(colIndex);
|
|
60
|
+
if (!selectedColIndexes || selectedColIndexes.length === 0 || isClickOutsideSelectedCols) {
|
|
61
|
+
(0, _commands.selectColumn)(colIndex, event.shiftKey)(state, dispatch);
|
|
62
|
+
}
|
|
63
|
+
if (selectedColIndexes.length > 1 && selectedColIndexes.includes(colIndex) && !event.shiftKey) {
|
|
64
|
+
(0, _commands.selectColumns)(selectedColIndexes)(state, dispatch);
|
|
65
|
+
}
|
|
66
|
+
}, [colIndex, selectedColIndexes, editorView]);
|
|
66
67
|
var handleMouseOver = (0, _react.useCallback)(function () {
|
|
67
68
|
var state = editorView.state,
|
|
68
69
|
dispatch = editorView.dispatch;
|
|
@@ -106,6 +107,64 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
106
107
|
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
107
108
|
return sum + cur;
|
|
108
109
|
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
110
|
+
var generateHandleByType = function generateHandleByType(type) {
|
|
111
|
+
var _colWidths;
|
|
112
|
+
if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
var isHover = type === 'hover';
|
|
116
|
+
var isColumnsSelected = selectedColIndexes.length > 0;
|
|
117
|
+
var showCondition = isHover ? isColumnsSelected && !selectedColIndexes.includes(colIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : selectedColIndexes.length < (colWidths === null || colWidths === void 0 ? void 0 : colWidths.length) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
118
|
+
if (!showCondition) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
var gridColumnPosition = "".concat(colIndex + 1, " / span 1");
|
|
122
|
+
var selectedColumnPosition = "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
123
|
+
var hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
124
|
+
var currentSelectionApprearance = isColumnsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
125
|
+
var istSelecting = isColumnsSelected && !isHover;
|
|
126
|
+
|
|
127
|
+
// this indexes are used to calculate the drag and drop source
|
|
128
|
+
var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
|
|
129
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
130
|
+
key: type,
|
|
131
|
+
style: {
|
|
132
|
+
gridColumn: istSelecting ? selectedColumnPosition : gridColumnPosition,
|
|
133
|
+
display: 'flex',
|
|
134
|
+
justifyContent: 'center',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
height: 'fit-content',
|
|
137
|
+
placeSelf: 'center',
|
|
138
|
+
zIndex: 99
|
|
139
|
+
},
|
|
140
|
+
"data-column-control-index": hoveredCell.colIndex,
|
|
141
|
+
"data-testid": isHover ? 'table-floating-column-control-hover' : 'table-floating-column-control'
|
|
142
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
143
|
+
direction: "column",
|
|
144
|
+
tableLocalId: localId || '',
|
|
145
|
+
indexes: indexes,
|
|
146
|
+
forceDefaultHandle: isHover ? false : isColumnsSelected,
|
|
147
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : _styles.tableCellMinWidth,
|
|
148
|
+
previewHeight: previewHeight,
|
|
149
|
+
appearance: istSelecting ? currentSelectionApprearance : hoveredAppearance,
|
|
150
|
+
onClick: handleClick,
|
|
151
|
+
onMouseOver: handleMouseOver,
|
|
152
|
+
onMouseOut: handleMouseOut,
|
|
153
|
+
onMouseUp: handleMouseUp,
|
|
154
|
+
editorView: editorView,
|
|
155
|
+
canDrag: canDrag
|
|
156
|
+
}));
|
|
157
|
+
};
|
|
158
|
+
var columnHandles = function columnHandles(hoveredCell) {
|
|
159
|
+
if (!hoveredCell) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (hoveredCell.colIndex === undefined) {
|
|
163
|
+
return generateHandleByType('selected');
|
|
164
|
+
}
|
|
165
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
166
|
+
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
167
|
+
};
|
|
109
168
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
110
169
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS,
|
|
111
170
|
onMouseMove: handleMouseMove
|
|
@@ -134,31 +193,6 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
134
193
|
right: '0'
|
|
135
194
|
} : {}
|
|
136
195
|
}));
|
|
137
|
-
}), tableActive &&
|
|
138
|
-
style: {
|
|
139
|
-
gridColumn: gridColumnPosition,
|
|
140
|
-
display: 'flex',
|
|
141
|
-
justifyContent: 'center',
|
|
142
|
-
alignItems: 'center',
|
|
143
|
-
height: 'fit-content',
|
|
144
|
-
placeSelf: 'center',
|
|
145
|
-
zIndex: 99
|
|
146
|
-
},
|
|
147
|
-
"data-column-control-index": hoveredCell.colIndex,
|
|
148
|
-
"data-testid": "table-floating-column-control"
|
|
149
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
150
|
-
direction: "column",
|
|
151
|
-
tableLocalId: localId || '',
|
|
152
|
-
indexes: colIndexes,
|
|
153
|
-
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : _styles.tableCellMinWidth,
|
|
154
|
-
previewHeight: previewHeight,
|
|
155
|
-
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
156
|
-
onClick: handleClick,
|
|
157
|
-
onMouseOver: handleMouseOver,
|
|
158
|
-
onMouseOut: handleMouseOut,
|
|
159
|
-
onMouseUp: handleMouseUp,
|
|
160
|
-
editorView: editorView,
|
|
161
|
-
canDrag: canDrag
|
|
162
|
-
}))));
|
|
196
|
+
}), tableActive && isTableHovered && !isResizing && columnHandles(hoveredCell)));
|
|
163
197
|
};
|
|
164
198
|
var _default = exports.default = ColumnControls;
|
|
@@ -22,6 +22,8 @@ var _DragHandle = require("../../DragHandle");
|
|
|
22
22
|
var _RowDropTarget = _interopRequireDefault(require("../RowDropTarget"));
|
|
23
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
26
|
+
|
|
25
27
|
var getSelectedRows = function getSelectedRows(selection) {
|
|
26
28
|
if (selection instanceof _editorTables.CellSelection && selection.isRowSelection()) {
|
|
27
29
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -46,6 +48,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
46
48
|
canDrag = _ref.canDrag,
|
|
47
49
|
hoverRows = _ref.hoverRows,
|
|
48
50
|
selectRow = _ref.selectRow,
|
|
51
|
+
selectRows = _ref.selectRows,
|
|
49
52
|
updateCellHoverLocation = _ref.updateCellHoverLocation;
|
|
50
53
|
var _useState = (0, _react.useState)(false),
|
|
51
54
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -87,13 +90,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
87
90
|
(0, _commands2.toggleDragMenu)(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
88
91
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
89
92
|
var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
90
|
-
var gridRowPosition = (0, _react.useMemo)(function () {
|
|
91
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
92
|
-
if (selectedRowIndexes.includes(rowIndex)) {
|
|
93
|
-
return "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
|
|
94
|
-
}
|
|
95
|
-
return "".concat(rowIndex + 1, " / span 1");
|
|
96
|
-
}, [rowIndex, selectedRowIndexes]);
|
|
97
93
|
var handleMouseOut = (0, _react.useCallback)(function () {
|
|
98
94
|
if (tableActive) {
|
|
99
95
|
var state = editorView.state,
|
|
@@ -118,8 +114,69 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
118
114
|
hoverRows([rowIndex]);
|
|
119
115
|
}, [hoverRows, rowIndex]);
|
|
120
116
|
var handleClick = (0, _react.useCallback)(function (e) {
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
var isClickOutsideSelectedRows = selectedRowIndexes.length >= 1 && !selectedRowIndexes.includes(rowIndex);
|
|
118
|
+
if (!selectedRowIndexes || selectedRowIndexes.length === 0 || isClickOutsideSelectedRows) {
|
|
119
|
+
selectRow(rowIndex, e.shiftKey);
|
|
120
|
+
}
|
|
121
|
+
if (selectedRowIndexes.length > 1 && selectedRowIndexes.includes(rowIndex) && !e.shiftKey) {
|
|
122
|
+
selectRows(selectedRowIndexes);
|
|
123
|
+
}
|
|
124
|
+
}, [rowIndex, selectRow, selectRows, selectedRowIndexes]);
|
|
125
|
+
var generateHandleByType = function generateHandleByType(type) {
|
|
126
|
+
if (!hoveredCell) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
var isHover = type === 'hover';
|
|
130
|
+
var isRowsSelected = selectedRowIndexes.length > 0;
|
|
131
|
+
var showCondition = isHover ? isRowsSelected && !selectedRowIndexes.includes(rowIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : selectedRowIndexes.length < rowHeights.length && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
132
|
+
if (!showCondition) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
var gridRowPosition = "".concat(rowIndex + 1, " / span 1");
|
|
136
|
+
|
|
137
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
138
|
+
var selectedRowPosition = "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
|
|
139
|
+
var hoveredAppearance = selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
140
|
+
var currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
141
|
+
var isSelecting = isRowsSelected && !isHover;
|
|
142
|
+
var indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
|
|
143
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
144
|
+
key: type,
|
|
145
|
+
style: {
|
|
146
|
+
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
147
|
+
gridColumn: '2',
|
|
148
|
+
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
149
|
+
width: '9px',
|
|
150
|
+
position: 'relative',
|
|
151
|
+
right: '-0.5px'
|
|
152
|
+
},
|
|
153
|
+
"data-testid": isHover ? 'table-floating-row-drag-handle-hover' : 'table-floating-row-drag-handle'
|
|
154
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
155
|
+
direction: "row",
|
|
156
|
+
tableLocalId: currentNodeLocalId,
|
|
157
|
+
indexes: indexes,
|
|
158
|
+
forceDefaultHandle: isHover ? false : isRowsSelected,
|
|
159
|
+
previewWidth: tableWidth,
|
|
160
|
+
previewHeight: rowHeights[rowIndex],
|
|
161
|
+
appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
|
|
162
|
+
onClick: handleClick,
|
|
163
|
+
onMouseOver: handleMouseOver,
|
|
164
|
+
onMouseOut: handleMouseOut,
|
|
165
|
+
onMouseUp: onMouseUp,
|
|
166
|
+
editorView: editorView,
|
|
167
|
+
canDrag: canDrag
|
|
168
|
+
}));
|
|
169
|
+
};
|
|
170
|
+
var rowHandles = function rowHandles(hoveredCell) {
|
|
171
|
+
if (!hoveredCell) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
if (hoveredCell.rowIndex === undefined) {
|
|
175
|
+
return generateHandleByType('selected');
|
|
176
|
+
}
|
|
177
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
178
|
+
return hoveredCell.rowIndex < selectedRowIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
179
|
+
};
|
|
123
180
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
124
181
|
className: _types.TableCssClassName.DRAG_ROW_CONTROLS,
|
|
125
182
|
style: {
|
|
@@ -159,28 +216,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
159
216
|
left: "var(--ds-space-negative-100, -8px)"
|
|
160
217
|
}
|
|
161
218
|
}));
|
|
162
|
-
}),
|
|
163
|
-
style: {
|
|
164
|
-
gridRow: gridRowPosition,
|
|
165
|
-
gridColumn: '2',
|
|
166
|
-
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
167
|
-
width: '9px',
|
|
168
|
-
position: 'relative',
|
|
169
|
-
right: '-0.5px'
|
|
170
|
-
},
|
|
171
|
-
"data-testid": "table-floating-row-drag-handle"
|
|
172
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
173
|
-
tableLocalId: currentNodeLocalId,
|
|
174
|
-
indexes: rowIndexes,
|
|
175
|
-
previewWidth: tableWidth,
|
|
176
|
-
previewHeight: rowHeights[rowIndex],
|
|
177
|
-
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
178
|
-
onClick: handleClick,
|
|
179
|
-
onMouseOver: handleMouseOver,
|
|
180
|
-
onMouseOut: handleMouseOut,
|
|
181
|
-
onMouseUp: onMouseUp,
|
|
182
|
-
editorView: editorView,
|
|
183
|
-
canDrag: canDrag
|
|
184
|
-
})));
|
|
219
|
+
}), tableActive && isTableHovered && !isResizing && Number.isFinite(rowIndex) && rowHandles(hoveredCell));
|
|
185
220
|
};
|
|
186
221
|
var DragControls = exports.DragControls = (0, _reactIntlNext.injectIntl)(DragControlsComponent);
|
|
@@ -45,6 +45,16 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
45
45
|
}
|
|
46
46
|
(0, _commands.selectRow)(row, expand)(state, dispatch);
|
|
47
47
|
});
|
|
48
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectRows", function (rowIndexes) {
|
|
49
|
+
var editorView = _this.props.editorView;
|
|
50
|
+
var state = editorView.state,
|
|
51
|
+
dispatch = editorView.dispatch;
|
|
52
|
+
// fix for issue ED-4665
|
|
53
|
+
if (_utils.browser.ie_version === 11) {
|
|
54
|
+
editorView.dom.blur();
|
|
55
|
+
}
|
|
56
|
+
(0, _commands.selectRows)(rowIndexes)(state, dispatch);
|
|
57
|
+
});
|
|
48
58
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hoverRows", function (rows, danger) {
|
|
49
59
|
var _this$props$editorVie = _this.props.editorView,
|
|
50
60
|
state = _this$props$editorVie.state,
|
|
@@ -208,6 +218,7 @@ var TableFloatingControls = exports.default = /*#__PURE__*/function (_Component)
|
|
|
208
218
|
tableWidth: this.state.tableWrapperWidth,
|
|
209
219
|
hoverRows: this.hoverRows,
|
|
210
220
|
selectRow: this.selectRow,
|
|
221
|
+
selectRows: this.selectRows,
|
|
211
222
|
updateCellHoverLocation: this.updateCellHoverLocation,
|
|
212
223
|
canDrag: canDrag
|
|
213
224
|
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CornerControls.CornerControls, {
|
|
@@ -2,7 +2,7 @@ export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clear
|
|
|
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';
|
|
5
|
-
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectRow, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations } from './misc';
|
|
5
|
+
export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations } from './misc';
|
|
6
6
|
export { sortByColumn } from './sort';
|
|
7
7
|
export { goToNextCell } from './go-to-next-cell';
|
|
8
8
|
export { removeDescendantNodes } from './referentiality';
|