@atlaskit/editor-tables 2.5.3 → 2.5.5
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 +12 -0
- package/dist/cjs/table-map.js +31 -11
- package/dist/es2019/table-map.js +24 -6
- package/dist/esm/table-map.js +31 -11
- package/dist/types/table-map.d.ts +4 -1
- package/dist/types-ts4.5/table-map.d.ts +4 -1
- package/package.json +2 -2
- package/tsconfig.json +1 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.5.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#72037](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72037) [`e59f0b7a9115`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e59f0b7a9115) - [ux] add flexiable to make merged cells detection allow to detect edge merged cells
|
|
8
|
+
|
|
9
|
+
## 2.5.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#68572](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68572) [`15d407fe5143`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/15d407fe5143) - Upgrading @atlaskit/editor-prosemirror dependency
|
|
14
|
+
|
|
3
15
|
## 2.5.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/table-map.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.tableNewColumnMinWidth = exports.TableProblemTypes = exports.TableMap = exports.Rect = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
11
|
// Because working with row and column-spanning cells is not quite
|
|
@@ -73,14 +74,16 @@ var tableNewColumnMinWidth = exports.tableNewColumnMinWidth = 140;
|
|
|
73
74
|
// be able to do that, positions saved in the map are relative to the
|
|
74
75
|
// start of the table, rather than the start of the document.
|
|
75
76
|
var TableMap = exports.TableMap = /*#__PURE__*/function () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// The table's height
|
|
79
|
-
|
|
80
|
-
function TableMap(width, height, map, problems) {
|
|
77
|
+
function TableMap(width, height, map, problems, mapByColumn, mapByRow) {
|
|
81
78
|
(0, _classCallCheck2.default)(this, TableMap);
|
|
79
|
+
// The width of the table
|
|
80
|
+
// The table's height
|
|
81
|
+
(0, _defineProperty2.default)(this, "mapByColumn", []);
|
|
82
|
+
(0, _defineProperty2.default)(this, "mapByRow", []);
|
|
82
83
|
this.width = width;
|
|
83
84
|
this.height = height;
|
|
85
|
+
this.mapByColumn = mapByColumn || [];
|
|
86
|
+
this.mapByRow = mapByRow || [];
|
|
84
87
|
// :: [number] A width * height array with the start position of
|
|
85
88
|
// the cell covering that part of the table in each slot
|
|
86
89
|
this.map = map;
|
|
@@ -267,6 +270,12 @@ var TableMap = exports.TableMap = /*#__PURE__*/function () {
|
|
|
267
270
|
return parentRowNode.childCount;
|
|
268
271
|
}
|
|
269
272
|
}
|
|
273
|
+
}, {
|
|
274
|
+
key: "hasMergedCells",
|
|
275
|
+
value: function hasMergedCells() {
|
|
276
|
+
var uniquePositions = new Set(this.map);
|
|
277
|
+
return uniquePositions.size !== this.map.length;
|
|
278
|
+
}
|
|
270
279
|
|
|
271
280
|
// :: (Node) → TableMap
|
|
272
281
|
// Find the table map for the given table node.
|
|
@@ -359,14 +368,25 @@ function computeMap(table) {
|
|
|
359
368
|
}
|
|
360
369
|
pos++;
|
|
361
370
|
}
|
|
362
|
-
var
|
|
371
|
+
var mapByRow = Array(height);
|
|
372
|
+
var mapByColumn = Array(width);
|
|
373
|
+
for (var _i2 = 0; _i2 < map.length; _i2++) {
|
|
374
|
+
var _mapByColumn$columnIn, _mapByRow$rowIndex;
|
|
375
|
+
var columnIndex = _i2 % width;
|
|
376
|
+
mapByColumn[columnIndex] = (_mapByColumn$columnIn = mapByColumn[columnIndex]) !== null && _mapByColumn$columnIn !== void 0 ? _mapByColumn$columnIn : [];
|
|
377
|
+
mapByColumn[columnIndex].push(map[_i2]);
|
|
378
|
+
var rowIndex = Math.trunc(_i2 / width);
|
|
379
|
+
mapByRow[rowIndex] = (_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : [];
|
|
380
|
+
mapByRow[rowIndex].push(map[_i2]);
|
|
381
|
+
}
|
|
382
|
+
var tableMap = new TableMap(width, height, map, problems, mapByColumn, mapByRow);
|
|
363
383
|
var badWidths = false;
|
|
364
384
|
|
|
365
385
|
// For columns that have defined widths, but whose widths disagree
|
|
366
386
|
// between rows, fix up the cells whose width doesn't match the
|
|
367
387
|
// computed one.
|
|
368
|
-
for (var
|
|
369
|
-
if (colWidths[
|
|
388
|
+
for (var _i3 = 0; !badWidths && _i3 < colWidths.length; _i3 += 2) {
|
|
389
|
+
if (colWidths[_i3] != null && colWidths[_i3 + 1] < height) {
|
|
370
390
|
badWidths = true;
|
|
371
391
|
}
|
|
372
392
|
}
|
|
@@ -377,7 +397,7 @@ function computeMap(table) {
|
|
|
377
397
|
// This check exists to make sure that the table has been resized,
|
|
378
398
|
// which means there will be elements in the colWidths array.
|
|
379
399
|
if (colWidths.length > 0 && colWidths.length !== width * 2) {
|
|
380
|
-
for (var
|
|
400
|
+
for (var _i4 = 0; _i4 < width * 2 - colWidths.length; _i4++) {
|
|
381
401
|
colWidths.push(tableNewColumnMinWidth, 0);
|
|
382
402
|
}
|
|
383
403
|
badWidths = true;
|
|
@@ -404,8 +424,8 @@ function findWidth(table) {
|
|
|
404
424
|
}
|
|
405
425
|
}
|
|
406
426
|
}
|
|
407
|
-
for (var
|
|
408
|
-
var _cell = rowNode.child(
|
|
427
|
+
for (var _i5 = 0; _i5 < rowNode.childCount; _i5++) {
|
|
428
|
+
var _cell = rowNode.child(_i5);
|
|
409
429
|
rowWidth += _cell.attrs.colspan;
|
|
410
430
|
if (_cell.attrs.rowspan > 1) {
|
|
411
431
|
hasRowSpan = true;
|
package/dist/es2019/table-map.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
// Because working with row and column-spanning cells is not quite
|
|
2
3
|
// trivial, this code builds up a descriptive structure for a given
|
|
3
4
|
// table node. The structures are cached with the (persistent) table
|
|
@@ -63,13 +64,15 @@ export const tableNewColumnMinWidth = 140;
|
|
|
63
64
|
// be able to do that, positions saved in the map are relative to the
|
|
64
65
|
// start of the table, rather than the start of the document.
|
|
65
66
|
export class TableMap {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
constructor(width, height, map, problems, mapByColumn, mapByRow) {
|
|
68
|
+
// The width of the table
|
|
69
|
+
// The table's height
|
|
70
|
+
_defineProperty(this, "mapByColumn", []);
|
|
71
|
+
_defineProperty(this, "mapByRow", []);
|
|
71
72
|
this.width = width;
|
|
72
73
|
this.height = height;
|
|
74
|
+
this.mapByColumn = mapByColumn || [];
|
|
75
|
+
this.mapByRow = mapByRow || [];
|
|
73
76
|
// :: [number] A width * height array with the start position of
|
|
74
77
|
// the cell covering that part of the table in each slot
|
|
75
78
|
this.map = map;
|
|
@@ -235,6 +238,10 @@ export class TableMap {
|
|
|
235
238
|
return parentRowNode.childCount;
|
|
236
239
|
}
|
|
237
240
|
}
|
|
241
|
+
hasMergedCells() {
|
|
242
|
+
const uniquePositions = new Set(this.map);
|
|
243
|
+
return uniquePositions.size !== this.map.length;
|
|
244
|
+
}
|
|
238
245
|
|
|
239
246
|
// :: (Node) → TableMap
|
|
240
247
|
// Find the table map for the given table node.
|
|
@@ -326,7 +333,18 @@ function computeMap(table) {
|
|
|
326
333
|
}
|
|
327
334
|
pos++;
|
|
328
335
|
}
|
|
329
|
-
let
|
|
336
|
+
let mapByRow = Array(height);
|
|
337
|
+
let mapByColumn = Array(width);
|
|
338
|
+
for (let i = 0; i < map.length; i++) {
|
|
339
|
+
var _mapByColumn$columnIn, _mapByRow$rowIndex;
|
|
340
|
+
const columnIndex = i % width;
|
|
341
|
+
mapByColumn[columnIndex] = (_mapByColumn$columnIn = mapByColumn[columnIndex]) !== null && _mapByColumn$columnIn !== void 0 ? _mapByColumn$columnIn : [];
|
|
342
|
+
mapByColumn[columnIndex].push(map[i]);
|
|
343
|
+
const rowIndex = Math.trunc(i / width);
|
|
344
|
+
mapByRow[rowIndex] = (_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : [];
|
|
345
|
+
mapByRow[rowIndex].push(map[i]);
|
|
346
|
+
}
|
|
347
|
+
let tableMap = new TableMap(width, height, map, problems, mapByColumn, mapByRow);
|
|
330
348
|
let badWidths = false;
|
|
331
349
|
|
|
332
350
|
// For columns that have defined widths, but whose widths disagree
|
package/dist/esm/table-map.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
// Because working with row and column-spanning cells is not quite
|
|
@@ -66,14 +67,16 @@ export var tableNewColumnMinWidth = 140;
|
|
|
66
67
|
// be able to do that, positions saved in the map are relative to the
|
|
67
68
|
// start of the table, rather than the start of the document.
|
|
68
69
|
export var TableMap = /*#__PURE__*/function () {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// The table's height
|
|
72
|
-
|
|
73
|
-
function TableMap(width, height, map, problems) {
|
|
70
|
+
function TableMap(width, height, map, problems, mapByColumn, mapByRow) {
|
|
74
71
|
_classCallCheck(this, TableMap);
|
|
72
|
+
// The width of the table
|
|
73
|
+
// The table's height
|
|
74
|
+
_defineProperty(this, "mapByColumn", []);
|
|
75
|
+
_defineProperty(this, "mapByRow", []);
|
|
75
76
|
this.width = width;
|
|
76
77
|
this.height = height;
|
|
78
|
+
this.mapByColumn = mapByColumn || [];
|
|
79
|
+
this.mapByRow = mapByRow || [];
|
|
77
80
|
// :: [number] A width * height array with the start position of
|
|
78
81
|
// the cell covering that part of the table in each slot
|
|
79
82
|
this.map = map;
|
|
@@ -260,6 +263,12 @@ export var TableMap = /*#__PURE__*/function () {
|
|
|
260
263
|
return parentRowNode.childCount;
|
|
261
264
|
}
|
|
262
265
|
}
|
|
266
|
+
}, {
|
|
267
|
+
key: "hasMergedCells",
|
|
268
|
+
value: function hasMergedCells() {
|
|
269
|
+
var uniquePositions = new Set(this.map);
|
|
270
|
+
return uniquePositions.size !== this.map.length;
|
|
271
|
+
}
|
|
263
272
|
|
|
264
273
|
// :: (Node) → TableMap
|
|
265
274
|
// Find the table map for the given table node.
|
|
@@ -354,14 +363,25 @@ function computeMap(table) {
|
|
|
354
363
|
}
|
|
355
364
|
pos++;
|
|
356
365
|
}
|
|
357
|
-
var
|
|
366
|
+
var mapByRow = Array(height);
|
|
367
|
+
var mapByColumn = Array(width);
|
|
368
|
+
for (var _i2 = 0; _i2 < map.length; _i2++) {
|
|
369
|
+
var _mapByColumn$columnIn, _mapByRow$rowIndex;
|
|
370
|
+
var columnIndex = _i2 % width;
|
|
371
|
+
mapByColumn[columnIndex] = (_mapByColumn$columnIn = mapByColumn[columnIndex]) !== null && _mapByColumn$columnIn !== void 0 ? _mapByColumn$columnIn : [];
|
|
372
|
+
mapByColumn[columnIndex].push(map[_i2]);
|
|
373
|
+
var rowIndex = Math.trunc(_i2 / width);
|
|
374
|
+
mapByRow[rowIndex] = (_mapByRow$rowIndex = mapByRow[rowIndex]) !== null && _mapByRow$rowIndex !== void 0 ? _mapByRow$rowIndex : [];
|
|
375
|
+
mapByRow[rowIndex].push(map[_i2]);
|
|
376
|
+
}
|
|
377
|
+
var tableMap = new TableMap(width, height, map, problems, mapByColumn, mapByRow);
|
|
358
378
|
var badWidths = false;
|
|
359
379
|
|
|
360
380
|
// For columns that have defined widths, but whose widths disagree
|
|
361
381
|
// between rows, fix up the cells whose width doesn't match the
|
|
362
382
|
// computed one.
|
|
363
|
-
for (var
|
|
364
|
-
if (colWidths[
|
|
383
|
+
for (var _i3 = 0; !badWidths && _i3 < colWidths.length; _i3 += 2) {
|
|
384
|
+
if (colWidths[_i3] != null && colWidths[_i3 + 1] < height) {
|
|
365
385
|
badWidths = true;
|
|
366
386
|
}
|
|
367
387
|
}
|
|
@@ -372,7 +392,7 @@ function computeMap(table) {
|
|
|
372
392
|
// This check exists to make sure that the table has been resized,
|
|
373
393
|
// which means there will be elements in the colWidths array.
|
|
374
394
|
if (colWidths.length > 0 && colWidths.length !== width * 2) {
|
|
375
|
-
for (var
|
|
395
|
+
for (var _i4 = 0; _i4 < width * 2 - colWidths.length; _i4++) {
|
|
376
396
|
colWidths.push(tableNewColumnMinWidth, 0);
|
|
377
397
|
}
|
|
378
398
|
badWidths = true;
|
|
@@ -399,8 +419,8 @@ function findWidth(table) {
|
|
|
399
419
|
}
|
|
400
420
|
}
|
|
401
421
|
}
|
|
402
|
-
for (var
|
|
403
|
-
var _cell = rowNode.child(
|
|
422
|
+
for (var _i5 = 0; _i5 < rowNode.childCount; _i5++) {
|
|
423
|
+
var _cell = rowNode.child(_i5);
|
|
404
424
|
rowWidth += _cell.attrs.colspan;
|
|
405
425
|
if (_cell.attrs.rowspan > 1) {
|
|
406
426
|
hasRowSpan = true;
|
|
@@ -51,7 +51,9 @@ export declare class TableMap {
|
|
|
51
51
|
height: number;
|
|
52
52
|
map: number[];
|
|
53
53
|
problems?: TableProblem[] | null;
|
|
54
|
-
|
|
54
|
+
mapByColumn: number[][];
|
|
55
|
+
mapByRow: number[][];
|
|
56
|
+
constructor(width: number, height: number, map: number[], problems?: TableProblem[] | null, mapByColumn?: number[][], mapByRow?: number[][]);
|
|
55
57
|
findCell(pos: number): Rect;
|
|
56
58
|
colCount(pos: number): number;
|
|
57
59
|
rowCount(pos: number): number;
|
|
@@ -64,5 +66,6 @@ export declare class TableMap {
|
|
|
64
66
|
cellsInRect(rect: Rect): number[];
|
|
65
67
|
positionAt(row: number, col: number, table: PMNode): number;
|
|
66
68
|
getMaxColInRow(pos: ResolvedPos): number | undefined;
|
|
69
|
+
hasMergedCells(): boolean;
|
|
67
70
|
static get(table: PMNode): TableMap;
|
|
68
71
|
}
|
|
@@ -51,7 +51,9 @@ export declare class TableMap {
|
|
|
51
51
|
height: number;
|
|
52
52
|
map: number[];
|
|
53
53
|
problems?: TableProblem[] | null;
|
|
54
|
-
|
|
54
|
+
mapByColumn: number[][];
|
|
55
|
+
mapByRow: number[][];
|
|
56
|
+
constructor(width: number, height: number, map: number[], problems?: TableProblem[] | null, mapByColumn?: number[][], mapByRow?: number[][]);
|
|
55
57
|
findCell(pos: number): Rect;
|
|
56
58
|
colCount(pos: number): number;
|
|
57
59
|
rowCount(pos: number): number;
|
|
@@ -64,5 +66,6 @@ export declare class TableMap {
|
|
|
64
66
|
cellsInRect(rect: Rect): number[];
|
|
65
67
|
positionAt(row: number, col: number, table: PMNode): number;
|
|
66
68
|
getMaxColInRow(pos: ResolvedPos): number | undefined;
|
|
69
|
+
hasMergedCells(): boolean;
|
|
67
70
|
static get(table: PMNode): TableMap;
|
|
68
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-tables",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.5",
|
|
4
4
|
"description": "A package that contains common classes and utility functions for editor tables",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"releaseModel": "continuous"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/editor-prosemirror": "
|
|
31
|
+
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
32
32
|
"@atlaskit/platform-feature-flags": "^0.2.4",
|
|
33
33
|
"@babel/runtime": "^7.0.0"
|
|
34
34
|
},
|
package/tsconfig.json
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"baseUrl": "./"
|
|
5
|
-
"paths": {
|
|
6
|
-
"@atlaskit/platform-feature-flags": [
|
|
7
|
-
"../../platform/feature-flags/src/index.ts"
|
|
8
|
-
],
|
|
9
|
-
"@atlassian/feature-flags-test-utils": [
|
|
10
|
-
"../../platform/feature-flags-test-utils/src/index.ts"
|
|
11
|
-
],
|
|
12
|
-
"@atlaskit/editor-tables/cell-bookmark": [
|
|
13
|
-
"src/cell-bookmark.ts"
|
|
14
|
-
],
|
|
15
|
-
"@atlaskit/editor-tables/cell-selection": [
|
|
16
|
-
"src/cell-selection.ts"
|
|
17
|
-
],
|
|
18
|
-
"@atlaskit/editor-tables/pm-plugins": [
|
|
19
|
-
"src/pm-plugins.ts"
|
|
20
|
-
],
|
|
21
|
-
"@atlaskit/editor-tables/table-map": [
|
|
22
|
-
"src/table-map.ts"
|
|
23
|
-
],
|
|
24
|
-
"@atlaskit/editor-tables/types": [
|
|
25
|
-
"src/types.ts"
|
|
26
|
-
],
|
|
27
|
-
"@atlaskit/editor-tables/utils": [
|
|
28
|
-
"src/utils.ts"
|
|
29
|
-
],
|
|
30
|
-
"@atlaskit/editor-tables": [
|
|
31
|
-
"./src"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
4
|
+
"baseUrl": "./"
|
|
34
5
|
},
|
|
35
6
|
"include": [
|
|
36
7
|
"src/**/*.ts",
|