@atlaskit/editor-plugin-table 5.5.3 → 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 +7 -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/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +8 -2
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +9 -2
- 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/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +9 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +9 -2
- 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/pm-plugins/drag-and-drop/plugin.js +1 -0
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +9 -3
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +9 -2
- 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/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/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 -1
- 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/pm-plugins/drag-and-drop/plugin.ts +2 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +22 -2
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +21 -2
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
3
10
|
## 5.5.3
|
|
4
11
|
|
|
5
12
|
### 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 ? {
|
|
@@ -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
|
})
|
|
@@ -56,8 +56,14 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
56
56
|
var handleClick = (0, _react.useCallback)(function (event) {
|
|
57
57
|
var state = editorView.state,
|
|
58
58
|
dispatch = editorView.dispatch;
|
|
59
|
-
|
|
60
|
-
|
|
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]);
|
|
61
67
|
var handleMouseOver = (0, _react.useCallback)(function () {
|
|
62
68
|
var state = editorView.state,
|
|
63
69
|
dispatch = editorView.dispatch;
|
|
@@ -48,6 +48,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
48
48
|
canDrag = _ref.canDrag,
|
|
49
49
|
hoverRows = _ref.hoverRows,
|
|
50
50
|
selectRow = _ref.selectRow,
|
|
51
|
+
selectRows = _ref.selectRows,
|
|
51
52
|
updateCellHoverLocation = _ref.updateCellHoverLocation;
|
|
52
53
|
var _useState = (0, _react.useState)(false),
|
|
53
54
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -113,8 +114,14 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
113
114
|
hoverRows([rowIndex]);
|
|
114
115
|
}, [hoverRows, rowIndex]);
|
|
115
116
|
var handleClick = (0, _react.useCallback)(function (e) {
|
|
116
|
-
|
|
117
|
-
|
|
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]);
|
|
118
125
|
var generateHandleByType = function generateHandleByType(type) {
|
|
119
126
|
if (!hoveredCell) {
|
|
120
127
|
return null;
|
|
@@ -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';
|
|
@@ -2,7 +2,7 @@ import { closestElement, isParagraph, isTextSelection, mapSlice } from '@atlaski
|
|
|
2
2
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
|
-
import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumn as selectColumnTransform, selectionCell, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
|
|
5
|
+
import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumns as selectColumnsTransform, selectColumn as selectColumnTransform, selectionCell, selectRows as selectRowsTransform, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
7
7
|
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
8
8
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -350,6 +350,31 @@ export const selectColumn = (column, expand) => createCommand(state => {
|
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
}, tr => selectColumnTransform(column, expand)(tr).setMeta('addToHistory', false));
|
|
353
|
+
export const selectColumns = columnIndexes => createCommand(state => {
|
|
354
|
+
if (!columnIndexes) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
const cells = columnIndexes.map(column => getCellsInColumn(column)(state.tr.selection)).flat();
|
|
358
|
+
if (!cells || !cells.length || cells.some(cell => cell && typeof cell.pos !== 'number')) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
const decorations = createColumnSelectedDecoration(selectColumnsTransform(columnIndexes)(state.tr));
|
|
362
|
+
const decorationSet = updatePluginStateDecorations(state, decorations, TableDecorations.COLUMN_SELECTED);
|
|
363
|
+
const cellsInFirstColumn = getCellsInColumn(Math.min(...columnIndexes))(state.tr.selection);
|
|
364
|
+
if (!cellsInFirstColumn || cellsInFirstColumn.length === 0) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
const targetCellPosition = cellsInFirstColumn[0].pos;
|
|
368
|
+
return {
|
|
369
|
+
type: 'SELECT_COLUMN',
|
|
370
|
+
data: {
|
|
371
|
+
targetCellPosition,
|
|
372
|
+
decorationSet
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}, tr => {
|
|
376
|
+
return selectColumnsTransform(columnIndexes)(tr).setMeta('addToHistory', false);
|
|
377
|
+
});
|
|
353
378
|
export const selectRow = (row, expand) => createCommand(state => {
|
|
354
379
|
let targetCellPosition;
|
|
355
380
|
const cells = getCellsInRow(row)(state.tr.selection);
|
|
@@ -363,6 +388,26 @@ export const selectRow = (row, expand) => createCommand(state => {
|
|
|
363
388
|
}
|
|
364
389
|
};
|
|
365
390
|
}, tr => selectRowTransform(row, expand)(tr).setMeta('addToHistory', false));
|
|
391
|
+
export const selectRows = rowIndexes => createCommand(state => {
|
|
392
|
+
if (rowIndexes.length === 0) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
const cells = rowIndexes.map(row => getCellsInRow(row)(state.tr.selection)).flat();
|
|
396
|
+
if (!cells || !cells.length || cells.some(cell => cell && typeof cell.pos !== 'number')) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
const cellsInFirstRow = getCellsInRow(Math.min(...rowIndexes))(state.tr.selection);
|
|
400
|
+
if (!cellsInFirstRow || cellsInFirstRow.length === 0) {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
const targetCellPosition = cellsInFirstRow[0].pos;
|
|
404
|
+
return {
|
|
405
|
+
type: 'SET_TARGET_CELL_POSITION',
|
|
406
|
+
data: {
|
|
407
|
+
targetCellPosition
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
}, tr => selectRowsTransform(rowIndexes)(tr).setMeta('addToHistory', false));
|
|
366
411
|
export const showInsertColumnButton = columnIndex => createCommand(_ => columnIndex > -1 ? {
|
|
367
412
|
type: 'SHOW_INSERT_COLUMN_BUTTON',
|
|
368
413
|
data: {
|
|
@@ -192,6 +192,7 @@ export const createPlugin = (dispatch, eventDispatcher) => {
|
|
|
192
192
|
const [sourceIndex] = sourceIndexes;
|
|
193
193
|
requestAnimationFrame(() => {
|
|
194
194
|
moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
195
|
+
editorView.focus();
|
|
195
196
|
});
|
|
196
197
|
}
|
|
197
198
|
})
|
|
@@ -4,7 +4,7 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
6
6
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
|
-
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn } from '../../../commands';
|
|
7
|
+
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../commands';
|
|
8
8
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
9
9
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
10
10
|
import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
|
|
@@ -48,8 +48,14 @@ export const ColumnControls = ({
|
|
|
48
48
|
state,
|
|
49
49
|
dispatch
|
|
50
50
|
} = editorView;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const isClickOutsideSelectedCols = selectedColIndexes.length >= 1 && !selectedColIndexes.includes(colIndex);
|
|
52
|
+
if (!selectedColIndexes || selectedColIndexes.length === 0 || isClickOutsideSelectedCols) {
|
|
53
|
+
selectColumn(colIndex, event.shiftKey)(state, dispatch);
|
|
54
|
+
}
|
|
55
|
+
if (selectedColIndexes.length > 1 && selectedColIndexes.includes(colIndex) && !event.shiftKey) {
|
|
56
|
+
selectColumns(selectedColIndexes)(state, dispatch);
|
|
57
|
+
}
|
|
58
|
+
}, [colIndex, selectedColIndexes, editorView]);
|
|
53
59
|
const handleMouseOver = useCallback(() => {
|
|
54
60
|
const {
|
|
55
61
|
state,
|
|
@@ -36,6 +36,7 @@ const DragControlsComponent = ({
|
|
|
36
36
|
canDrag,
|
|
37
37
|
hoverRows,
|
|
38
38
|
selectRow,
|
|
39
|
+
selectRows,
|
|
39
40
|
updateCellHoverLocation
|
|
40
41
|
}) => {
|
|
41
42
|
var _tableNode$attrs$loca, _tableNode$attrs;
|
|
@@ -103,8 +104,14 @@ const DragControlsComponent = ({
|
|
|
103
104
|
hoverRows([rowIndex]);
|
|
104
105
|
}, [hoverRows, rowIndex]);
|
|
105
106
|
const handleClick = useCallback(e => {
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
const isClickOutsideSelectedRows = selectedRowIndexes.length >= 1 && !selectedRowIndexes.includes(rowIndex);
|
|
108
|
+
if (!selectedRowIndexes || selectedRowIndexes.length === 0 || isClickOutsideSelectedRows) {
|
|
109
|
+
selectRow(rowIndex, e.shiftKey);
|
|
110
|
+
}
|
|
111
|
+
if (selectedRowIndexes.length > 1 && selectedRowIndexes.includes(rowIndex) && !e.shiftKey) {
|
|
112
|
+
selectRows(selectedRowIndexes);
|
|
113
|
+
}
|
|
114
|
+
}, [rowIndex, selectRow, selectRows, selectedRowIndexes]);
|
|
108
115
|
const generateHandleByType = type => {
|
|
109
116
|
if (!hoveredCell) {
|
|
110
117
|
return null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
3
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import { hoverCell, hoverRows, selectRow } from '../../commands';
|
|
4
|
+
import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
|
|
5
5
|
import { TableCssClassName as ClassName } from '../../types';
|
|
6
6
|
import { isSelectionUpdated } from '../../utils';
|
|
7
7
|
import { CornerControls, DragCornerControls } from './CornerControls';
|
|
@@ -24,6 +24,20 @@ export default class TableFloatingControls extends Component {
|
|
|
24
24
|
}
|
|
25
25
|
selectRow(row, expand)(state, dispatch);
|
|
26
26
|
});
|
|
27
|
+
_defineProperty(this, "selectRows", rowIndexes => {
|
|
28
|
+
const {
|
|
29
|
+
editorView
|
|
30
|
+
} = this.props;
|
|
31
|
+
const {
|
|
32
|
+
state,
|
|
33
|
+
dispatch
|
|
34
|
+
} = editorView;
|
|
35
|
+
// fix for issue ED-4665
|
|
36
|
+
if (browser.ie_version === 11) {
|
|
37
|
+
editorView.dom.blur();
|
|
38
|
+
}
|
|
39
|
+
selectRows(rowIndexes)(state, dispatch);
|
|
40
|
+
});
|
|
27
41
|
_defineProperty(this, "hoverRows", (rows, danger) => {
|
|
28
42
|
const {
|
|
29
43
|
state,
|
|
@@ -167,6 +181,7 @@ export default class TableFloatingControls extends Component {
|
|
|
167
181
|
tableWidth: this.state.tableWrapperWidth,
|
|
168
182
|
hoverRows: this.hoverRows,
|
|
169
183
|
selectRow: this.selectRow,
|
|
184
|
+
selectRows: this.selectRows,
|
|
170
185
|
updateCellHoverLocation: this.updateCellHoverLocation,
|
|
171
186
|
canDrag: canDrag
|
|
172
187
|
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(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';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -5,7 +6,7 @@ import { closestElement, isParagraph, isTextSelection, mapSlice } from '@atlaski
|
|
|
5
6
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
8
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
|
-
import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumn as selectColumnTransform, selectionCell, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
|
|
9
|
+
import { findCellClosestToPos, findTable, getCellsInColumn, getCellsInRow, getSelectionRect, isSelectionType, isTableSelected, removeTable, selectColumns as selectColumnsTransform, selectColumn as selectColumnTransform, selectionCell, selectRows as selectRowsTransform, selectRow as selectRowTransform, setCellAttrs } from '@atlaskit/editor-tables/utils';
|
|
9
10
|
import { getDecorations } from '../pm-plugins/decorations/plugin';
|
|
10
11
|
import { buildColumnResizingDecorations, clearColumnResizingDecorations } from '../pm-plugins/decorations/utils';
|
|
11
12
|
import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -339,6 +340,37 @@ export var selectColumn = function selectColumn(column, expand) {
|
|
|
339
340
|
return selectColumnTransform(column, expand)(tr).setMeta('addToHistory', false);
|
|
340
341
|
});
|
|
341
342
|
};
|
|
343
|
+
export var selectColumns = function selectColumns(columnIndexes) {
|
|
344
|
+
return createCommand(function (state) {
|
|
345
|
+
if (!columnIndexes) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
var cells = columnIndexes.map(function (column) {
|
|
349
|
+
return getCellsInColumn(column)(state.tr.selection);
|
|
350
|
+
}).flat();
|
|
351
|
+
if (!cells || !cells.length || cells.some(function (cell) {
|
|
352
|
+
return cell && typeof cell.pos !== 'number';
|
|
353
|
+
})) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
var decorations = createColumnSelectedDecoration(selectColumnsTransform(columnIndexes)(state.tr));
|
|
357
|
+
var decorationSet = updatePluginStateDecorations(state, decorations, TableDecorations.COLUMN_SELECTED);
|
|
358
|
+
var cellsInFirstColumn = getCellsInColumn(Math.min.apply(Math, _toConsumableArray(columnIndexes)))(state.tr.selection);
|
|
359
|
+
if (!cellsInFirstColumn || cellsInFirstColumn.length === 0) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
var targetCellPosition = cellsInFirstColumn[0].pos;
|
|
363
|
+
return {
|
|
364
|
+
type: 'SELECT_COLUMN',
|
|
365
|
+
data: {
|
|
366
|
+
targetCellPosition: targetCellPosition,
|
|
367
|
+
decorationSet: decorationSet
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}, function (tr) {
|
|
371
|
+
return selectColumnsTransform(columnIndexes)(tr).setMeta('addToHistory', false);
|
|
372
|
+
});
|
|
373
|
+
};
|
|
342
374
|
export var selectRow = function selectRow(row, expand) {
|
|
343
375
|
return createCommand(function (state) {
|
|
344
376
|
var targetCellPosition;
|
|
@@ -356,6 +388,34 @@ export var selectRow = function selectRow(row, expand) {
|
|
|
356
388
|
return selectRowTransform(row, expand)(tr).setMeta('addToHistory', false);
|
|
357
389
|
});
|
|
358
390
|
};
|
|
391
|
+
export var selectRows = function selectRows(rowIndexes) {
|
|
392
|
+
return createCommand(function (state) {
|
|
393
|
+
if (rowIndexes.length === 0) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
var cells = rowIndexes.map(function (row) {
|
|
397
|
+
return getCellsInRow(row)(state.tr.selection);
|
|
398
|
+
}).flat();
|
|
399
|
+
if (!cells || !cells.length || cells.some(function (cell) {
|
|
400
|
+
return cell && typeof cell.pos !== 'number';
|
|
401
|
+
})) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
var cellsInFirstRow = getCellsInRow(Math.min.apply(Math, _toConsumableArray(rowIndexes)))(state.tr.selection);
|
|
405
|
+
if (!cellsInFirstRow || cellsInFirstRow.length === 0) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
var targetCellPosition = cellsInFirstRow[0].pos;
|
|
409
|
+
return {
|
|
410
|
+
type: 'SET_TARGET_CELL_POSITION',
|
|
411
|
+
data: {
|
|
412
|
+
targetCellPosition: targetCellPosition
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}, function (tr) {
|
|
416
|
+
return selectRowsTransform(rowIndexes)(tr).setMeta('addToHistory', false);
|
|
417
|
+
});
|
|
418
|
+
};
|
|
359
419
|
export var showInsertColumnButton = function showInsertColumnButton(columnIndex) {
|
|
360
420
|
return createCommand(function (_) {
|
|
361
421
|
return columnIndex > -1 ? {
|
|
@@ -184,6 +184,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
|
184
184
|
sourceIndex = _sourceIndexes[0];
|
|
185
185
|
requestAnimationFrame(function () {
|
|
186
186
|
moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
187
|
+
editorView.focus();
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
190
|
})
|
|
@@ -4,7 +4,7 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
6
6
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
|
-
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn } from '../../../commands';
|
|
7
|
+
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../commands';
|
|
8
8
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
9
9
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
10
10
|
import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
|
|
@@ -47,8 +47,14 @@ export var ColumnControls = function ColumnControls(_ref) {
|
|
|
47
47
|
var handleClick = useCallback(function (event) {
|
|
48
48
|
var state = editorView.state,
|
|
49
49
|
dispatch = editorView.dispatch;
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
var isClickOutsideSelectedCols = selectedColIndexes.length >= 1 && !selectedColIndexes.includes(colIndex);
|
|
51
|
+
if (!selectedColIndexes || selectedColIndexes.length === 0 || isClickOutsideSelectedCols) {
|
|
52
|
+
selectColumn(colIndex, event.shiftKey)(state, dispatch);
|
|
53
|
+
}
|
|
54
|
+
if (selectedColIndexes.length > 1 && selectedColIndexes.includes(colIndex) && !event.shiftKey) {
|
|
55
|
+
selectColumns(selectedColIndexes)(state, dispatch);
|
|
56
|
+
}
|
|
57
|
+
}, [colIndex, selectedColIndexes, editorView]);
|
|
52
58
|
var handleMouseOver = useCallback(function () {
|
|
53
59
|
var state = editorView.state,
|
|
54
60
|
dispatch = editorView.dispatch;
|
|
@@ -38,6 +38,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
38
38
|
canDrag = _ref.canDrag,
|
|
39
39
|
hoverRows = _ref.hoverRows,
|
|
40
40
|
selectRow = _ref.selectRow,
|
|
41
|
+
selectRows = _ref.selectRows,
|
|
41
42
|
updateCellHoverLocation = _ref.updateCellHoverLocation;
|
|
42
43
|
var _useState = useState(false),
|
|
43
44
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -103,8 +104,14 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
103
104
|
hoverRows([rowIndex]);
|
|
104
105
|
}, [hoverRows, rowIndex]);
|
|
105
106
|
var handleClick = useCallback(function (e) {
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
var isClickOutsideSelectedRows = selectedRowIndexes.length >= 1 && !selectedRowIndexes.includes(rowIndex);
|
|
108
|
+
if (!selectedRowIndexes || selectedRowIndexes.length === 0 || isClickOutsideSelectedRows) {
|
|
109
|
+
selectRow(rowIndex, e.shiftKey);
|
|
110
|
+
}
|
|
111
|
+
if (selectedRowIndexes.length > 1 && selectedRowIndexes.includes(rowIndex) && !e.shiftKey) {
|
|
112
|
+
selectRows(selectedRowIndexes);
|
|
113
|
+
}
|
|
114
|
+
}, [rowIndex, selectRow, selectRows, selectedRowIndexes]);
|
|
108
115
|
var generateHandleByType = function generateHandleByType(type) {
|
|
109
116
|
if (!hoveredCell) {
|
|
110
117
|
return null;
|
|
@@ -12,7 +12,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
13
|
import React, { Component } from 'react';
|
|
14
14
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
15
|
-
import { hoverCell, hoverRows, selectRow } from '../../commands';
|
|
15
|
+
import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
|
|
16
16
|
import { TableCssClassName as ClassName } from '../../types';
|
|
17
17
|
import { isSelectionUpdated } from '../../utils';
|
|
18
18
|
import { CornerControls, DragCornerControls } from './CornerControls';
|
|
@@ -35,6 +35,16 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
|
|
|
35
35
|
}
|
|
36
36
|
selectRow(row, expand)(state, dispatch);
|
|
37
37
|
});
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "selectRows", function (rowIndexes) {
|
|
39
|
+
var editorView = _this.props.editorView;
|
|
40
|
+
var state = editorView.state,
|
|
41
|
+
dispatch = editorView.dispatch;
|
|
42
|
+
// fix for issue ED-4665
|
|
43
|
+
if (browser.ie_version === 11) {
|
|
44
|
+
editorView.dom.blur();
|
|
45
|
+
}
|
|
46
|
+
selectRows(rowIndexes)(state, dispatch);
|
|
47
|
+
});
|
|
38
48
|
_defineProperty(_assertThisInitialized(_this), "hoverRows", function (rows, danger) {
|
|
39
49
|
var _this$props$editorVie = _this.props.editorView,
|
|
40
50
|
state = _this$props$editorVie.state,
|
|
@@ -198,6 +208,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
|
|
|
198
208
|
tableWidth: this.state.tableWrapperWidth,
|
|
199
209
|
hoverRows: this.hoverRows,
|
|
200
210
|
selectRow: this.selectRow,
|
|
211
|
+
selectRows: this.selectRows,
|
|
201
212
|
updateCellHoverLocation: this.updateCellHoverLocation,
|
|
202
213
|
canDrag: canDrag
|
|
203
214
|
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(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';
|
|
@@ -20,7 +20,9 @@ export declare const convertFirstRowToHeader: (schema: Schema) => (tr: Transacti
|
|
|
20
20
|
export declare const moveCursorBackward: Command;
|
|
21
21
|
export declare const setMultipleCellAttrs: (attrs: Object, targetCellPosition?: number) => Command;
|
|
22
22
|
export declare const selectColumn: (column: number, expand?: boolean) => Command;
|
|
23
|
+
export declare const selectColumns: (columnIndexes: number[]) => Command;
|
|
23
24
|
export declare const selectRow: (row: number, expand?: boolean) => Command;
|
|
25
|
+
export declare const selectRows: (rowIndexes: number[]) => Command;
|
|
24
26
|
export declare const showInsertColumnButton: (columnIndex: number) => Command;
|
|
25
27
|
export declare const showInsertRowButton: (rowIndex: number) => Command;
|
|
26
28
|
export declare const hideInsertColumnOrRowButton: () => Command;
|
|
@@ -16,6 +16,7 @@ type DragControlsProps = {
|
|
|
16
16
|
canDrag?: boolean;
|
|
17
17
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
18
18
|
selectRow: (row: number, expand: boolean) => void;
|
|
19
|
+
selectRows: (rowIndexes: number[]) => void;
|
|
19
20
|
updateCellHoverLocation: (rowIndex: number) => void;
|
|
20
21
|
};
|
|
21
22
|
export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps<"intl">>> & {
|
|
@@ -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';
|
|
@@ -20,7 +20,9 @@ export declare const convertFirstRowToHeader: (schema: Schema) => (tr: Transacti
|
|
|
20
20
|
export declare const moveCursorBackward: Command;
|
|
21
21
|
export declare const setMultipleCellAttrs: (attrs: Object, targetCellPosition?: number) => Command;
|
|
22
22
|
export declare const selectColumn: (column: number, expand?: boolean) => Command;
|
|
23
|
+
export declare const selectColumns: (columnIndexes: number[]) => Command;
|
|
23
24
|
export declare const selectRow: (row: number, expand?: boolean) => Command;
|
|
25
|
+
export declare const selectRows: (rowIndexes: number[]) => Command;
|
|
24
26
|
export declare const showInsertColumnButton: (columnIndex: number) => Command;
|
|
25
27
|
export declare const showInsertRowButton: (rowIndex: number) => Command;
|
|
26
28
|
export declare const hideInsertColumnOrRowButton: () => Command;
|
package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ type DragControlsProps = {
|
|
|
16
16
|
canDrag?: boolean;
|
|
17
17
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
18
18
|
selectRow: (row: number, expand: boolean) => void;
|
|
19
|
+
selectRows: (rowIndexes: number[]) => void;
|
|
19
20
|
updateCellHoverLocation: (rowIndex: number) => void;
|
|
20
21
|
};
|
|
21
22
|
export declare const DragControls: React.FC<import("react-intl-next").WithIntlProps<DragControlsProps & WrappedComponentProps<"intl">>> & {
|
package/package.json
CHANGED
|
@@ -74,6 +74,7 @@ describe('NumberColumn', () => {
|
|
|
74
74
|
isTableHovered={true}
|
|
75
75
|
hoverRows={jest.fn()}
|
|
76
76
|
selectRow={jest.fn()}
|
|
77
|
+
selectRows={jest.fn()}
|
|
77
78
|
updateCellHoverLocation={jest.fn()}
|
|
78
79
|
tableWidth={760}
|
|
79
80
|
/>
|
|
@@ -111,6 +112,7 @@ describe('NumberColumn', () => {
|
|
|
111
112
|
}}
|
|
112
113
|
hoverRows={jest.fn()}
|
|
113
114
|
selectRow={jest.fn()}
|
|
115
|
+
selectRows={jest.fn()}
|
|
114
116
|
updateCellHoverLocation={jest.fn()}
|
|
115
117
|
tableWidth={760}
|
|
116
118
|
/>
|
|
@@ -30,8 +30,10 @@ import {
|
|
|
30
30
|
isSelectionType,
|
|
31
31
|
isTableSelected,
|
|
32
32
|
removeTable,
|
|
33
|
+
selectColumns as selectColumnsTransform,
|
|
33
34
|
selectColumn as selectColumnTransform,
|
|
34
35
|
selectionCell,
|
|
36
|
+
selectRows as selectRowsTransform,
|
|
35
37
|
selectRow as selectRowTransform,
|
|
36
38
|
setCellAttrs,
|
|
37
39
|
} from '@atlaskit/editor-tables/utils';
|
|
@@ -487,6 +489,53 @@ export const selectColumn = (column: number, expand?: boolean) =>
|
|
|
487
489
|
selectColumnTransform(column, expand)(tr).setMeta('addToHistory', false),
|
|
488
490
|
);
|
|
489
491
|
|
|
492
|
+
export const selectColumns = (columnIndexes: number[]) =>
|
|
493
|
+
createCommand(
|
|
494
|
+
(state) => {
|
|
495
|
+
if (!columnIndexes) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
const cells = columnIndexes
|
|
499
|
+
.map((column) => getCellsInColumn(column)(state.tr.selection))
|
|
500
|
+
.flat();
|
|
501
|
+
if (
|
|
502
|
+
!cells ||
|
|
503
|
+
!cells.length ||
|
|
504
|
+
cells.some((cell) => cell && typeof cell.pos !== 'number')
|
|
505
|
+
) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
const decorations = createColumnSelectedDecoration(
|
|
509
|
+
selectColumnsTransform(columnIndexes)(state.tr),
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
const decorationSet = updatePluginStateDecorations(
|
|
513
|
+
state,
|
|
514
|
+
decorations,
|
|
515
|
+
TableDecorations.COLUMN_SELECTED,
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
const cellsInFirstColumn = getCellsInColumn(Math.min(...columnIndexes))(
|
|
519
|
+
state.tr.selection,
|
|
520
|
+
);
|
|
521
|
+
if (!cellsInFirstColumn || cellsInFirstColumn.length === 0) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
const targetCellPosition = cellsInFirstColumn[0].pos;
|
|
525
|
+
|
|
526
|
+
return {
|
|
527
|
+
type: 'SELECT_COLUMN',
|
|
528
|
+
data: { targetCellPosition, decorationSet },
|
|
529
|
+
};
|
|
530
|
+
},
|
|
531
|
+
(tr: Transaction) => {
|
|
532
|
+
return selectColumnsTransform(columnIndexes)(tr).setMeta(
|
|
533
|
+
'addToHistory',
|
|
534
|
+
false,
|
|
535
|
+
);
|
|
536
|
+
},
|
|
537
|
+
);
|
|
538
|
+
|
|
490
539
|
export const selectRow = (row: number, expand?: boolean) =>
|
|
491
540
|
createCommand(
|
|
492
541
|
(state) => {
|
|
@@ -501,6 +550,35 @@ export const selectRow = (row: number, expand?: boolean) =>
|
|
|
501
550
|
(tr) => selectRowTransform(row, expand)(tr).setMeta('addToHistory', false),
|
|
502
551
|
);
|
|
503
552
|
|
|
553
|
+
export const selectRows = (rowIndexes: number[]) =>
|
|
554
|
+
createCommand(
|
|
555
|
+
(state) => {
|
|
556
|
+
if (rowIndexes.length === 0) {
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
const cells = rowIndexes
|
|
560
|
+
.map((row) => getCellsInRow(row)(state.tr.selection))
|
|
561
|
+
.flat();
|
|
562
|
+
if (
|
|
563
|
+
!cells ||
|
|
564
|
+
!cells.length ||
|
|
565
|
+
cells.some((cell) => cell && typeof cell.pos !== 'number')
|
|
566
|
+
) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
const cellsInFirstRow = getCellsInRow(Math.min(...rowIndexes))(
|
|
570
|
+
state.tr.selection,
|
|
571
|
+
);
|
|
572
|
+
if (!cellsInFirstRow || cellsInFirstRow.length === 0) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
const targetCellPosition = cellsInFirstRow[0].pos;
|
|
576
|
+
|
|
577
|
+
return { type: 'SET_TARGET_CELL_POSITION', data: { targetCellPosition } };
|
|
578
|
+
},
|
|
579
|
+
(tr) => selectRowsTransform(rowIndexes)(tr).setMeta('addToHistory', false),
|
|
580
|
+
);
|
|
581
|
+
|
|
504
582
|
export const showInsertColumnButton = (columnIndex: number) =>
|
|
505
583
|
createCommand(
|
|
506
584
|
(_) =>
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
hoverCell,
|
|
14
14
|
hoverColumns,
|
|
15
15
|
selectColumn,
|
|
16
|
+
selectColumns,
|
|
16
17
|
} from '../../../commands';
|
|
17
18
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
18
19
|
import type { CellHoverMeta, HandleTypes } from '../../../types';
|
|
@@ -81,9 +82,28 @@ export const ColumnControls = ({
|
|
|
81
82
|
const handleClick = useCallback(
|
|
82
83
|
(event: MouseEvent) => {
|
|
83
84
|
const { state, dispatch } = editorView;
|
|
84
|
-
|
|
85
|
+
|
|
86
|
+
const isClickOutsideSelectedCols =
|
|
87
|
+
selectedColIndexes.length >= 1 &&
|
|
88
|
+
!selectedColIndexes.includes(colIndex!);
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
!selectedColIndexes ||
|
|
92
|
+
selectedColIndexes.length === 0 ||
|
|
93
|
+
isClickOutsideSelectedCols
|
|
94
|
+
) {
|
|
95
|
+
selectColumn(colIndex!, event.shiftKey)(state, dispatch);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
selectedColIndexes.length > 1 &&
|
|
100
|
+
selectedColIndexes.includes(colIndex!) &&
|
|
101
|
+
!event.shiftKey
|
|
102
|
+
) {
|
|
103
|
+
selectColumns(selectedColIndexes)(state, dispatch);
|
|
104
|
+
}
|
|
85
105
|
},
|
|
86
|
-
[colIndex, editorView],
|
|
106
|
+
[colIndex, selectedColIndexes, editorView],
|
|
87
107
|
);
|
|
88
108
|
|
|
89
109
|
const handleMouseOver = useCallback(() => {
|
|
@@ -50,6 +50,7 @@ type DragControlsProps = {
|
|
|
50
50
|
canDrag?: boolean;
|
|
51
51
|
hoverRows: (rows: number[], danger?: boolean) => void;
|
|
52
52
|
selectRow: (row: number, expand: boolean) => void;
|
|
53
|
+
selectRows: (rowIndexes: number[]) => void;
|
|
53
54
|
updateCellHoverLocation: (rowIndex: number) => void;
|
|
54
55
|
};
|
|
55
56
|
|
|
@@ -77,6 +78,7 @@ const DragControlsComponent = ({
|
|
|
77
78
|
canDrag,
|
|
78
79
|
hoverRows,
|
|
79
80
|
selectRow,
|
|
81
|
+
selectRows,
|
|
80
82
|
updateCellHoverLocation,
|
|
81
83
|
}: DragControlsProps & WrappedComponentProps) => {
|
|
82
84
|
const [isDragging, setIsDragging] = useState(false);
|
|
@@ -157,9 +159,26 @@ const DragControlsComponent = ({
|
|
|
157
159
|
|
|
158
160
|
const handleClick = useCallback(
|
|
159
161
|
(e: MouseEvent) => {
|
|
160
|
-
|
|
162
|
+
const isClickOutsideSelectedRows =
|
|
163
|
+
selectedRowIndexes.length >= 1 &&
|
|
164
|
+
!selectedRowIndexes.includes(rowIndex!);
|
|
165
|
+
if (
|
|
166
|
+
!selectedRowIndexes ||
|
|
167
|
+
selectedRowIndexes.length === 0 ||
|
|
168
|
+
isClickOutsideSelectedRows
|
|
169
|
+
) {
|
|
170
|
+
selectRow(rowIndex!, e.shiftKey);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (
|
|
174
|
+
selectedRowIndexes.length > 1 &&
|
|
175
|
+
selectedRowIndexes.includes(rowIndex!) &&
|
|
176
|
+
!e.shiftKey
|
|
177
|
+
) {
|
|
178
|
+
selectRows(selectedRowIndexes);
|
|
179
|
+
}
|
|
161
180
|
},
|
|
162
|
-
[rowIndex, selectRow],
|
|
181
|
+
[rowIndex, selectRow, selectRows, selectedRowIndexes],
|
|
163
182
|
);
|
|
164
183
|
|
|
165
184
|
const generateHandleByType = (type: HandleTypes): JSX.Element | null => {
|
|
@@ -6,7 +6,7 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
6
6
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
|
|
9
|
-
import { hoverCell, hoverRows, selectRow } from '../../commands';
|
|
9
|
+
import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
|
|
10
10
|
import type { RowStickyState } from '../../pm-plugins/sticky-headers';
|
|
11
11
|
import { TableCssClassName as ClassName } from '../../types';
|
|
12
12
|
import type { CellHoverMeta } from '../../types';
|
|
@@ -211,6 +211,7 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
211
211
|
tableWidth={this.state.tableWrapperWidth}
|
|
212
212
|
hoverRows={this.hoverRows}
|
|
213
213
|
selectRow={this.selectRow}
|
|
214
|
+
selectRows={this.selectRows}
|
|
214
215
|
updateCellHoverLocation={this.updateCellHoverLocation}
|
|
215
216
|
canDrag={canDrag}
|
|
216
217
|
/>
|
|
@@ -256,6 +257,16 @@ export default class TableFloatingControls extends Component<Props, State> {
|
|
|
256
257
|
selectRow(row, expand)(state, dispatch);
|
|
257
258
|
};
|
|
258
259
|
|
|
260
|
+
private selectRows = (rowIndexes: number[]) => {
|
|
261
|
+
const { editorView } = this.props;
|
|
262
|
+
const { state, dispatch } = editorView;
|
|
263
|
+
// fix for issue ED-4665
|
|
264
|
+
if (browser.ie_version === 11) {
|
|
265
|
+
(editorView.dom as HTMLElement).blur();
|
|
266
|
+
}
|
|
267
|
+
selectRows(rowIndexes)(state, dispatch);
|
|
268
|
+
};
|
|
269
|
+
|
|
259
270
|
private hoverRows = (rows: Array<number>, danger?: boolean) => {
|
|
260
271
|
const { state, dispatch } = this.props.editorView;
|
|
261
272
|
hoverRows(rows, danger)(state, dispatch);
|