@atlaskit/editor-tables 2.9.42 → 2.9.44
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 +15 -0
- package/dist/cjs/utils/analyse-table.js +11 -9
- package/dist/cjs/utils/cells.js +2 -0
- package/dist/es2019/utils/analyse-table.js +11 -9
- package/dist/es2019/utils/cells.js +2 -0
- package/dist/esm/utils/analyse-table.js +11 -9
- package/dist/esm/utils/cells.js +2 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +2 -2
- package/dist/types/utils/cells.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +2 -2
- package/dist/types-ts4.5/utils/cells.d.ts +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.9.44
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.9.43
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`1d245f9d74df5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1d245f9d74df5) -
|
|
14
|
+
[ux] [EDITOR-1682] modify the logic in determineTableHeaderStateFromTableNode to read the 1st and
|
|
15
|
+
n_th cells instead of 1st and 2nd behind `platform_editor_analyse_table_with_merged_cells`
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 2.9.42
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -4,31 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.determineTableHeaderStateFromTableNode = determineTableHeaderStateFromTableNode;
|
|
7
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
7
8
|
function determineTableHeaderStateFromTableNode(table, tableMap, types) {
|
|
8
|
-
// We only really need to check the
|
|
9
|
-
// of a table. We can assume that if the
|
|
10
|
-
// Be
|
|
11
|
-
// This means we
|
|
9
|
+
// We only really need to check the nth (last) cell in the row/col if it's a header, since we only support a single full row/col header on the top & left
|
|
10
|
+
// of a table. We can assume that if the nth (last) cell is also a header then the entire row/col is a header.
|
|
11
|
+
// Be careful though! when checking the 1st cell as it shares its header state with both row/cols.
|
|
12
|
+
// This means we won't be able to reliably identify header state on tables smaller than 2x2, however we can make a best guess.
|
|
12
13
|
|
|
13
14
|
// This is a 3 bit mask;
|
|
14
15
|
// bit: 0 = Identifies if the cell at (0, 0) (row, col - 0-based) is a header cell or not
|
|
15
|
-
// bit: 1 = Identifies if the cell at (0,
|
|
16
|
-
// bit: 2 = Identifies if the cell at (
|
|
16
|
+
// bit: 1 = Identifies if the cell at (0, n) is a header cell or not
|
|
17
|
+
// bit: 2 = Identifies if the cell at (n, 0) is a header cell or not
|
|
17
18
|
var mask = 0;
|
|
19
|
+
var isExperimentEnabled = (0, _expValEquals.expValEquals)('platform_editor_analyse_table_with_merged_cells', 'isEnabled', true);
|
|
18
20
|
|
|
19
21
|
// At minimum we should have 1 cell in the table.
|
|
20
22
|
var topLeftCell = table.nodeAt(tableMap.map[0]);
|
|
21
23
|
// If this cell is a header that could indicate
|
|
22
24
|
mask |= topLeftCell && topLeftCell.type === types.header_cell ? 1 : 0;
|
|
23
25
|
if (tableMap.width > 1) {
|
|
24
|
-
var cell = table.nodeAt(tableMap.map[1]);
|
|
25
|
-
// If the cell at (0,
|
|
26
|
+
var cell = isExperimentEnabled ? table.nodeAt(tableMap.map[tableMap.width - 1]) : table.nodeAt(tableMap.map[1]);
|
|
27
|
+
// If the cell at (0, n) is a header then we set the bit flag to indicate row headers are enabled, otherwise if it's
|
|
26
28
|
// not then we will set the col headers enabled flag (and vice versa in the branch below) only if the cell at (0,0)
|
|
27
29
|
// was a header cell.
|
|
28
30
|
mask |= cell && cell.type === types.header_cell ? 2 : 4 * (mask & 1);
|
|
29
31
|
}
|
|
30
32
|
if (tableMap.height > 1) {
|
|
31
|
-
var _cell = table.nodeAt(tableMap.map[tableMap.width]);
|
|
33
|
+
var _cell = isExperimentEnabled ? table.nodeAt(tableMap.map[tableMap.width * (tableMap.height - 1)]) : table.nodeAt(tableMap.map[tableMap.width]);
|
|
32
34
|
mask |= _cell && _cell.type === types.header_cell ? 4 : 2 * (mask & 1);
|
|
33
35
|
}
|
|
34
36
|
return {
|
package/dist/cjs/utils/cells.js
CHANGED
|
@@ -8,6 +8,8 @@ exports.cellNear = cellNear;
|
|
|
8
8
|
exports.nextCell = nextCell;
|
|
9
9
|
exports.pointsAtCell = pointsAtCell;
|
|
10
10
|
var _tableMap = require("../table-map");
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
12
|
+
|
|
11
13
|
function pointsAtCell($pos) {
|
|
12
14
|
return $pos.parent.type.spec.tableRole === 'row' && $pos.nodeAfter;
|
|
13
15
|
}
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
1
2
|
export function determineTableHeaderStateFromTableNode(table, tableMap, types) {
|
|
2
|
-
// We only really need to check the
|
|
3
|
-
// of a table. We can assume that if the
|
|
4
|
-
// Be
|
|
5
|
-
// This means we
|
|
3
|
+
// We only really need to check the nth (last) cell in the row/col if it's a header, since we only support a single full row/col header on the top & left
|
|
4
|
+
// of a table. We can assume that if the nth (last) cell is also a header then the entire row/col is a header.
|
|
5
|
+
// Be careful though! when checking the 1st cell as it shares its header state with both row/cols.
|
|
6
|
+
// This means we won't be able to reliably identify header state on tables smaller than 2x2, however we can make a best guess.
|
|
6
7
|
|
|
7
8
|
// This is a 3 bit mask;
|
|
8
9
|
// bit: 0 = Identifies if the cell at (0, 0) (row, col - 0-based) is a header cell or not
|
|
9
|
-
// bit: 1 = Identifies if the cell at (0,
|
|
10
|
-
// bit: 2 = Identifies if the cell at (
|
|
10
|
+
// bit: 1 = Identifies if the cell at (0, n) is a header cell or not
|
|
11
|
+
// bit: 2 = Identifies if the cell at (n, 0) is a header cell or not
|
|
11
12
|
let mask = 0;
|
|
13
|
+
const isExperimentEnabled = expValEquals('platform_editor_analyse_table_with_merged_cells', 'isEnabled', true);
|
|
12
14
|
|
|
13
15
|
// At minimum we should have 1 cell in the table.
|
|
14
16
|
const topLeftCell = table.nodeAt(tableMap.map[0]);
|
|
15
17
|
// If this cell is a header that could indicate
|
|
16
18
|
mask |= topLeftCell && topLeftCell.type === types.header_cell ? 1 : 0;
|
|
17
19
|
if (tableMap.width > 1) {
|
|
18
|
-
const cell = table.nodeAt(tableMap.map[1]);
|
|
19
|
-
// If the cell at (0,
|
|
20
|
+
const cell = isExperimentEnabled ? table.nodeAt(tableMap.map[tableMap.width - 1]) : table.nodeAt(tableMap.map[1]);
|
|
21
|
+
// If the cell at (0, n) is a header then we set the bit flag to indicate row headers are enabled, otherwise if it's
|
|
20
22
|
// not then we will set the col headers enabled flag (and vice versa in the branch below) only if the cell at (0,0)
|
|
21
23
|
// was a header cell.
|
|
22
24
|
mask |= cell && cell.type === types.header_cell ? 2 : 4 * (mask & 1);
|
|
23
25
|
}
|
|
24
26
|
if (tableMap.height > 1) {
|
|
25
|
-
const cell = table.nodeAt(tableMap.map[tableMap.width]);
|
|
27
|
+
const cell = isExperimentEnabled ? table.nodeAt(tableMap.map[tableMap.width * (tableMap.height - 1)]) : table.nodeAt(tableMap.map[tableMap.width]);
|
|
26
28
|
mask |= cell && cell.type === types.header_cell ? 4 : 2 * (mask & 1);
|
|
27
29
|
}
|
|
28
30
|
return {
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
1
2
|
export function determineTableHeaderStateFromTableNode(table, tableMap, types) {
|
|
2
|
-
// We only really need to check the
|
|
3
|
-
// of a table. We can assume that if the
|
|
4
|
-
// Be
|
|
5
|
-
// This means we
|
|
3
|
+
// We only really need to check the nth (last) cell in the row/col if it's a header, since we only support a single full row/col header on the top & left
|
|
4
|
+
// of a table. We can assume that if the nth (last) cell is also a header then the entire row/col is a header.
|
|
5
|
+
// Be careful though! when checking the 1st cell as it shares its header state with both row/cols.
|
|
6
|
+
// This means we won't be able to reliably identify header state on tables smaller than 2x2, however we can make a best guess.
|
|
6
7
|
|
|
7
8
|
// This is a 3 bit mask;
|
|
8
9
|
// bit: 0 = Identifies if the cell at (0, 0) (row, col - 0-based) is a header cell or not
|
|
9
|
-
// bit: 1 = Identifies if the cell at (0,
|
|
10
|
-
// bit: 2 = Identifies if the cell at (
|
|
10
|
+
// bit: 1 = Identifies if the cell at (0, n) is a header cell or not
|
|
11
|
+
// bit: 2 = Identifies if the cell at (n, 0) is a header cell or not
|
|
11
12
|
var mask = 0;
|
|
13
|
+
var isExperimentEnabled = expValEquals('platform_editor_analyse_table_with_merged_cells', 'isEnabled', true);
|
|
12
14
|
|
|
13
15
|
// At minimum we should have 1 cell in the table.
|
|
14
16
|
var topLeftCell = table.nodeAt(tableMap.map[0]);
|
|
15
17
|
// If this cell is a header that could indicate
|
|
16
18
|
mask |= topLeftCell && topLeftCell.type === types.header_cell ? 1 : 0;
|
|
17
19
|
if (tableMap.width > 1) {
|
|
18
|
-
var cell = table.nodeAt(tableMap.map[1]);
|
|
19
|
-
// If the cell at (0,
|
|
20
|
+
var cell = isExperimentEnabled ? table.nodeAt(tableMap.map[tableMap.width - 1]) : table.nodeAt(tableMap.map[1]);
|
|
21
|
+
// If the cell at (0, n) is a header then we set the bit flag to indicate row headers are enabled, otherwise if it's
|
|
20
22
|
// not then we will set the col headers enabled flag (and vice versa in the branch below) only if the cell at (0,0)
|
|
21
23
|
// was a header cell.
|
|
22
24
|
mask |= cell && cell.type === types.header_cell ? 2 : 4 * (mask & 1);
|
|
23
25
|
}
|
|
24
26
|
if (tableMap.height > 1) {
|
|
25
|
-
var _cell = table.nodeAt(tableMap.map[tableMap.width]);
|
|
27
|
+
var _cell = isExperimentEnabled ? table.nodeAt(tableMap.map[tableMap.width * (tableMap.height - 1)]) : table.nodeAt(tableMap.map[tableMap.width]);
|
|
26
28
|
mask |= _cell && _cell.type === types.header_cell ? 4 : 2 * (mask & 1);
|
|
27
29
|
}
|
|
28
30
|
return {
|
package/dist/esm/utils/cells.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export declare const tableEditingKey: PluginKey
|
|
3
|
-
export declare const fixTablesKey: PluginKey
|
|
2
|
+
export declare const tableEditingKey: PluginKey;
|
|
3
|
+
export declare const fixTablesKey: PluginKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import { Node, type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { type Axis } from '../types';
|
|
3
|
-
export declare function pointsAtCell($pos: ResolvedPos): false |
|
|
3
|
+
export declare function pointsAtCell($pos: ResolvedPos): false | Node | null;
|
|
4
4
|
export declare function cellNear($pos: ResolvedPos): ResolvedPos | null;
|
|
5
5
|
export declare function cellAround($pos: ResolvedPos): ResolvedPos | null;
|
|
6
6
|
export declare function nextCell($pos: ResolvedPos, axis: Axis, dir: number): ResolvedPos | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export declare const tableEditingKey: PluginKey
|
|
3
|
-
export declare const fixTablesKey: PluginKey
|
|
2
|
+
export declare const tableEditingKey: PluginKey;
|
|
3
|
+
export declare const fixTablesKey: PluginKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import { Node, type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { type Axis } from '../types';
|
|
3
|
-
export declare function pointsAtCell($pos: ResolvedPos): false |
|
|
3
|
+
export declare function pointsAtCell($pos: ResolvedPos): false | Node | null;
|
|
4
4
|
export declare function cellNear($pos: ResolvedPos): ResolvedPos | null;
|
|
5
5
|
export declare function cellAround($pos: ResolvedPos): ResolvedPos | null;
|
|
6
6
|
export declare function nextCell($pos: ResolvedPos, axis: Axis, dir: number): ResolvedPos | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-tables",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.44",
|
|
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/"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
31
31
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
32
|
+
"@atlaskit/tmp-editor-statsig": "^36.0.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|