@atlaskit/editor-tables 2.9.41 → 2.9.43

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-tables
2
2
 
3
+ ## 2.9.43
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1d245f9d74df5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1d245f9d74df5) -
8
+ [ux] [EDITOR-1682] modify the logic in determineTableHeaderStateFromTableNode to read the 1st and
9
+ n_th cells instead of 1st and 2nd behind `platform_editor_analyse_table_with_merged_cells`
10
+ - Updated dependencies
11
+
12
+ ## 2.9.42
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 2.9.41
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 2nd cell in the row/col if it's a header, since we only support a single full row/col header on the top & left
9
- // of a table. We can assume that if the 2nd cell is a header then the entire row/col is a header.
10
- // Be carefull though! when checking the 1st cell as it shares its header state with both row/cols.
11
- // This means we wont be able to reliably identify header state on tables smaller the 2x2, however we can do best guess.
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, 1) is a header cell or not
16
- // bit: 2 = Identifies if the cell at (1, 0) is a header cell or not
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, 1) is a header then we set the bit flag to indicate row headers are enabled, otherwise if it's
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 {
@@ -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 2nd cell in the row/col if it's a header, since we only support a single full row/col header on the top & left
3
- // of a table. We can assume that if the 2nd cell is a header then the entire row/col is a header.
4
- // Be carefull though! when checking the 1st cell as it shares its header state with both row/cols.
5
- // This means we wont be able to reliably identify header state on tables smaller the 2x2, however we can do best guess.
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, 1) is a header cell or not
10
- // bit: 2 = Identifies if the cell at (1, 0) is a header cell or not
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, 1) is a header then we set the bit flag to indicate row headers are enabled, otherwise if it's
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 2nd cell in the row/col if it's a header, since we only support a single full row/col header on the top & left
3
- // of a table. We can assume that if the 2nd cell is a header then the entire row/col is a header.
4
- // Be carefull though! when checking the 1st cell as it shares its header state with both row/cols.
5
- // This means we wont be able to reliably identify header state on tables smaller the 2x2, however we can do best guess.
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, 1) is a header cell or not
10
- // bit: 2 = Identifies if the cell at (1, 0) is a header cell or not
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, 1) is a header then we set the bit flag to indicate row headers are enabled, otherwise if it's
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.9.41",
3
+ "version": "2.9.43",
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,11 +29,11 @@
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": "^34.0.0",
32
+ "@atlaskit/tmp-editor-statsig": "^35.4.0",
33
33
  "@babel/runtime": "^7.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@atlassian/a11y-jest-testing": "^0.11.0"
36
+ "@atlassian/a11y-jest-testing": "^0.10.0"
37
37
  },
38
38
  "techstack": {
39
39
  "@atlassian/frontend": {