@atlaskit/editor-tables 2.3.17 → 2.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/utils/select-nodes.js +40 -1
- package/dist/cjs/utils.js +12 -0
- package/dist/es2019/utils/select-nodes.js +33 -0
- package/dist/es2019/utils.js +1 -1
- package/dist/esm/utils/select-nodes.js +38 -0
- package/dist/esm/utils.js +1 -1
- package/dist/types/utils/select-nodes.d.ts +2 -0
- package/dist/types/utils.d.ts +1 -1
- package/dist/types-ts4.5/utils/select-nodes.d.ts +2 -0
- package/dist/types-ts4.5/utils.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.3.18
|
|
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
|
+
|
|
3
9
|
## 2.3.17
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.selectTableClosestToPos = exports.selectTable = exports.selectRow = exports.selectColumn = void 0;
|
|
7
|
+
exports.selectTableClosestToPos = exports.selectTable = exports.selectRows = exports.selectRow = exports.selectColumns = exports.selectColumn = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
10
|
var _cellSelection = require("../cell-selection");
|
|
9
11
|
var _tableMap = require("../table-map");
|
|
@@ -115,6 +117,43 @@ var selectColumn = exports.selectColumn = select('column');
|
|
|
115
117
|
// Returns a new transaction that selects a row at index `rowIndex`.
|
|
116
118
|
// Use the optional `expand` param to extend from current selection.
|
|
117
119
|
var selectRow = exports.selectRow = select('row');
|
|
120
|
+
var selectRowsOrColumns = function selectRowsOrColumns(type) {
|
|
121
|
+
return function (indexes) {
|
|
122
|
+
return function (tr) {
|
|
123
|
+
var table = (0, _find.findTable)(tr.selection);
|
|
124
|
+
if (!table) {
|
|
125
|
+
return tr;
|
|
126
|
+
}
|
|
127
|
+
var map = _tableMap.TableMap.get(table.node);
|
|
128
|
+
if (!indexes || indexes.length <= 0 || type === 'rows' && Math.max.apply(Math, (0, _toConsumableArray2.default)(indexes)) > map.height || type === 'columns' && Math.max.apply(Math, (0, _toConsumableArray2.default)(indexes)) > map.width || Math.min.apply(Math, (0, _toConsumableArray2.default)(indexes)) < 0) {
|
|
129
|
+
return tr;
|
|
130
|
+
}
|
|
131
|
+
var startCellRect = map.cellsInRect({
|
|
132
|
+
left: type === 'rows' ? 0 : Math.min.apply(Math, (0, _toConsumableArray2.default)(indexes)),
|
|
133
|
+
top: type === 'rows' ? Math.min.apply(Math, (0, _toConsumableArray2.default)(indexes)) : 0,
|
|
134
|
+
right: type === 'rows' ? map.width : Math.min.apply(Math, (0, _toConsumableArray2.default)(indexes)) + 1,
|
|
135
|
+
bottom: type === 'rows' ? Math.min.apply(Math, (0, _toConsumableArray2.default)(indexes)) + 1 : 1
|
|
136
|
+
});
|
|
137
|
+
var endCellRect = map.cellsInRect({
|
|
138
|
+
left: type === 'rows' ? map.width - 1 : Math.max.apply(Math, (0, _toConsumableArray2.default)(indexes)),
|
|
139
|
+
top: type === 'rows' ? Math.max.apply(Math, (0, _toConsumableArray2.default)(indexes)) : map.height - 1,
|
|
140
|
+
right: type === 'rows' ? map.width : Math.max.apply(Math, (0, _toConsumableArray2.default)(indexes)) + 1,
|
|
141
|
+
bottom: type === 'rows' ? Math.max.apply(Math, (0, _toConsumableArray2.default)(indexes)) + 1 : map.height
|
|
142
|
+
});
|
|
143
|
+
var head = table.start + startCellRect[0];
|
|
144
|
+
var anchor = table.start + endCellRect[endCellRect.length - 1];
|
|
145
|
+
var $head = tr.doc.resolve(head);
|
|
146
|
+
var $anchor = tr.doc.resolve(anchor);
|
|
147
|
+
return (0, _cloneTr.cloneTr)(tr.setSelection(new _cellSelection.CellSelection($anchor, $head)));
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Returns a new transaction that selects all rows at `indexes`.
|
|
153
|
+
var selectRows = exports.selectRows = selectRowsOrColumns('rows');
|
|
154
|
+
|
|
155
|
+
// Returns a new transaction that selects all columns at `indexes`.
|
|
156
|
+
var selectColumns = exports.selectColumns = selectRowsOrColumns('columns');
|
|
118
157
|
|
|
119
158
|
// Returns a new transaction that selects a table.
|
|
120
159
|
var selectTable = exports.selectTable = function selectTable(tr) {
|
package/dist/cjs/utils.js
CHANGED
|
@@ -333,12 +333,24 @@ Object.defineProperty(exports, "selectColumn", {
|
|
|
333
333
|
return _selectNodes.selectColumn;
|
|
334
334
|
}
|
|
335
335
|
});
|
|
336
|
+
Object.defineProperty(exports, "selectColumns", {
|
|
337
|
+
enumerable: true,
|
|
338
|
+
get: function get() {
|
|
339
|
+
return _selectNodes.selectColumns;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
336
342
|
Object.defineProperty(exports, "selectRow", {
|
|
337
343
|
enumerable: true,
|
|
338
344
|
get: function get() {
|
|
339
345
|
return _selectNodes.selectRow;
|
|
340
346
|
}
|
|
341
347
|
});
|
|
348
|
+
Object.defineProperty(exports, "selectRows", {
|
|
349
|
+
enumerable: true,
|
|
350
|
+
get: function get() {
|
|
351
|
+
return _selectNodes.selectRows;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
342
354
|
Object.defineProperty(exports, "selectTable", {
|
|
343
355
|
enumerable: true,
|
|
344
356
|
get: function get() {
|
|
@@ -105,6 +105,39 @@ export const selectColumn = select('column');
|
|
|
105
105
|
// Returns a new transaction that selects a row at index `rowIndex`.
|
|
106
106
|
// Use the optional `expand` param to extend from current selection.
|
|
107
107
|
export const selectRow = select('row');
|
|
108
|
+
const selectRowsOrColumns = type => indexes => tr => {
|
|
109
|
+
const table = findTable(tr.selection);
|
|
110
|
+
if (!table) {
|
|
111
|
+
return tr;
|
|
112
|
+
}
|
|
113
|
+
const map = TableMap.get(table.node);
|
|
114
|
+
if (!indexes || indexes.length <= 0 || type === 'rows' && Math.max(...indexes) > map.height || type === 'columns' && Math.max(...indexes) > map.width || Math.min(...indexes) < 0) {
|
|
115
|
+
return tr;
|
|
116
|
+
}
|
|
117
|
+
const startCellRect = map.cellsInRect({
|
|
118
|
+
left: type === 'rows' ? 0 : Math.min(...indexes),
|
|
119
|
+
top: type === 'rows' ? Math.min(...indexes) : 0,
|
|
120
|
+
right: type === 'rows' ? map.width : Math.min(...indexes) + 1,
|
|
121
|
+
bottom: type === 'rows' ? Math.min(...indexes) + 1 : 1
|
|
122
|
+
});
|
|
123
|
+
const endCellRect = map.cellsInRect({
|
|
124
|
+
left: type === 'rows' ? map.width - 1 : Math.max(...indexes),
|
|
125
|
+
top: type === 'rows' ? Math.max(...indexes) : map.height - 1,
|
|
126
|
+
right: type === 'rows' ? map.width : Math.max(...indexes) + 1,
|
|
127
|
+
bottom: type === 'rows' ? Math.max(...indexes) + 1 : map.height
|
|
128
|
+
});
|
|
129
|
+
const head = table.start + startCellRect[0];
|
|
130
|
+
const anchor = table.start + endCellRect[endCellRect.length - 1];
|
|
131
|
+
const $head = tr.doc.resolve(head);
|
|
132
|
+
const $anchor = tr.doc.resolve(anchor);
|
|
133
|
+
return cloneTr(tr.setSelection(new CellSelection($anchor, $head)));
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// Returns a new transaction that selects all rows at `indexes`.
|
|
137
|
+
export const selectRows = selectRowsOrColumns('rows');
|
|
138
|
+
|
|
139
|
+
// Returns a new transaction that selects all columns at `indexes`.
|
|
140
|
+
export const selectColumns = selectRowsOrColumns('columns');
|
|
108
141
|
|
|
109
142
|
// Returns a new transaction that selects a table.
|
|
110
143
|
export const selectTable = tr => {
|
package/dist/es2019/utils.js
CHANGED
|
@@ -27,7 +27,7 @@ export { normalizeSelection } from './utils/normalize-selection';
|
|
|
27
27
|
export { removeColumnAt, removeSelectedColumns, removeColumnClosestToPos } from './utils/remove-column';
|
|
28
28
|
export { removeRowAt, removeSelectedRows, removeRowClosestToPos } from './utils/remove-row';
|
|
29
29
|
export { removeTable } from './utils/remove-table';
|
|
30
|
-
export { selectColumn, selectRow, selectTable } from './utils/select-nodes';
|
|
30
|
+
export { selectColumn, selectColumns, selectRow, selectRows, selectTable } from './utils/select-nodes';
|
|
31
31
|
export { selectionCell } from './utils/selection-cell';
|
|
32
32
|
export { selectedRect } from './utils/selection-rect';
|
|
33
33
|
export { setCellAttrs } from './utils/set-cell-attrs';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { CellSelection } from '../cell-selection';
|
|
3
4
|
import { TableMap } from '../table-map';
|
|
@@ -109,6 +110,43 @@ export var selectColumn = select('column');
|
|
|
109
110
|
// Returns a new transaction that selects a row at index `rowIndex`.
|
|
110
111
|
// Use the optional `expand` param to extend from current selection.
|
|
111
112
|
export var selectRow = select('row');
|
|
113
|
+
var selectRowsOrColumns = function selectRowsOrColumns(type) {
|
|
114
|
+
return function (indexes) {
|
|
115
|
+
return function (tr) {
|
|
116
|
+
var table = findTable(tr.selection);
|
|
117
|
+
if (!table) {
|
|
118
|
+
return tr;
|
|
119
|
+
}
|
|
120
|
+
var map = TableMap.get(table.node);
|
|
121
|
+
if (!indexes || indexes.length <= 0 || type === 'rows' && Math.max.apply(Math, _toConsumableArray(indexes)) > map.height || type === 'columns' && Math.max.apply(Math, _toConsumableArray(indexes)) > map.width || Math.min.apply(Math, _toConsumableArray(indexes)) < 0) {
|
|
122
|
+
return tr;
|
|
123
|
+
}
|
|
124
|
+
var startCellRect = map.cellsInRect({
|
|
125
|
+
left: type === 'rows' ? 0 : Math.min.apply(Math, _toConsumableArray(indexes)),
|
|
126
|
+
top: type === 'rows' ? Math.min.apply(Math, _toConsumableArray(indexes)) : 0,
|
|
127
|
+
right: type === 'rows' ? map.width : Math.min.apply(Math, _toConsumableArray(indexes)) + 1,
|
|
128
|
+
bottom: type === 'rows' ? Math.min.apply(Math, _toConsumableArray(indexes)) + 1 : 1
|
|
129
|
+
});
|
|
130
|
+
var endCellRect = map.cellsInRect({
|
|
131
|
+
left: type === 'rows' ? map.width - 1 : Math.max.apply(Math, _toConsumableArray(indexes)),
|
|
132
|
+
top: type === 'rows' ? Math.max.apply(Math, _toConsumableArray(indexes)) : map.height - 1,
|
|
133
|
+
right: type === 'rows' ? map.width : Math.max.apply(Math, _toConsumableArray(indexes)) + 1,
|
|
134
|
+
bottom: type === 'rows' ? Math.max.apply(Math, _toConsumableArray(indexes)) + 1 : map.height
|
|
135
|
+
});
|
|
136
|
+
var head = table.start + startCellRect[0];
|
|
137
|
+
var anchor = table.start + endCellRect[endCellRect.length - 1];
|
|
138
|
+
var $head = tr.doc.resolve(head);
|
|
139
|
+
var $anchor = tr.doc.resolve(anchor);
|
|
140
|
+
return cloneTr(tr.setSelection(new CellSelection($anchor, $head)));
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Returns a new transaction that selects all rows at `indexes`.
|
|
146
|
+
export var selectRows = selectRowsOrColumns('rows');
|
|
147
|
+
|
|
148
|
+
// Returns a new transaction that selects all columns at `indexes`.
|
|
149
|
+
export var selectColumns = selectRowsOrColumns('columns');
|
|
112
150
|
|
|
113
151
|
// Returns a new transaction that selects a table.
|
|
114
152
|
export var selectTable = function selectTable(tr) {
|
package/dist/esm/utils.js
CHANGED
|
@@ -27,7 +27,7 @@ export { normalizeSelection } from './utils/normalize-selection';
|
|
|
27
27
|
export { removeColumnAt, removeSelectedColumns, removeColumnClosestToPos } from './utils/remove-column';
|
|
28
28
|
export { removeRowAt, removeSelectedRows, removeRowClosestToPos } from './utils/remove-row';
|
|
29
29
|
export { removeTable } from './utils/remove-table';
|
|
30
|
-
export { selectColumn, selectRow, selectTable } from './utils/select-nodes';
|
|
30
|
+
export { selectColumn, selectColumns, selectRow, selectRows, selectTable } from './utils/select-nodes';
|
|
31
31
|
export { selectionCell } from './utils/selection-cell';
|
|
32
32
|
export { selectedRect } from './utils/selection-rect';
|
|
33
33
|
export { setCellAttrs } from './utils/set-cell-attrs';
|
|
@@ -2,5 +2,7 @@ import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare const selectColumn: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
|
|
4
4
|
export declare const selectRow: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
|
|
5
|
+
export declare const selectRows: (indexes: number[]) => (tr: Transaction) => Transaction;
|
|
6
|
+
export declare const selectColumns: (indexes: number[]) => (tr: Transaction) => Transaction;
|
|
5
7
|
export declare const selectTable: (tr: Transaction) => Transaction;
|
|
6
8
|
export declare const selectTableClosestToPos: (tr: Transaction, $pos: ResolvedPos) => Transaction;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { normalizeSelection } from './utils/normalize-selection';
|
|
|
27
27
|
export { removeColumnAt, removeSelectedColumns, removeColumnClosestToPos, } from './utils/remove-column';
|
|
28
28
|
export { removeRowAt, removeSelectedRows, removeRowClosestToPos, } from './utils/remove-row';
|
|
29
29
|
export { removeTable } from './utils/remove-table';
|
|
30
|
-
export { selectColumn, selectRow, selectTable } from './utils/select-nodes';
|
|
30
|
+
export { selectColumn, selectColumns, selectRow, selectRows, selectTable, } from './utils/select-nodes';
|
|
31
31
|
export { selectionCell } from './utils/selection-cell';
|
|
32
32
|
export { selectedRect } from './utils/selection-rect';
|
|
33
33
|
export type { SelectionRect } from './utils/selection-rect';
|
|
@@ -2,5 +2,7 @@ import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare const selectColumn: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
|
|
4
4
|
export declare const selectRow: (index: number, expand?: boolean) => (tr: Transaction) => Transaction;
|
|
5
|
+
export declare const selectRows: (indexes: number[]) => (tr: Transaction) => Transaction;
|
|
6
|
+
export declare const selectColumns: (indexes: number[]) => (tr: Transaction) => Transaction;
|
|
5
7
|
export declare const selectTable: (tr: Transaction) => Transaction;
|
|
6
8
|
export declare const selectTableClosestToPos: (tr: Transaction, $pos: ResolvedPos) => Transaction;
|
|
@@ -27,7 +27,7 @@ export { normalizeSelection } from './utils/normalize-selection';
|
|
|
27
27
|
export { removeColumnAt, removeSelectedColumns, removeColumnClosestToPos, } from './utils/remove-column';
|
|
28
28
|
export { removeRowAt, removeSelectedRows, removeRowClosestToPos, } from './utils/remove-row';
|
|
29
29
|
export { removeTable } from './utils/remove-table';
|
|
30
|
-
export { selectColumn, selectRow, selectTable } from './utils/select-nodes';
|
|
30
|
+
export { selectColumn, selectColumns, selectRow, selectRows, selectTable, } from './utils/select-nodes';
|
|
31
31
|
export { selectionCell } from './utils/selection-cell';
|
|
32
32
|
export { selectedRect } from './utils/selection-rect';
|
|
33
33
|
export type { SelectionRect } from './utils/selection-rect';
|
package/package.json
CHANGED