@atlaskit/editor-tables 2.9.0 → 2.9.1
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,14 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#117917](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/117917)
|
|
8
|
+
[`feeb187f3871c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/feeb187f3871c) -
|
|
9
|
+
Fix selections between cells across tables, and cells to content outside tables
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 2.9.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.normalizeSelection = normalizeSelection;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
8
9
|
var _cellSelection = require("../cell-selection");
|
|
9
10
|
var _tableMap = require("../table-map");
|
|
10
11
|
function normalizeSelection(state, transaction, allowTableNodeSelection) {
|
|
@@ -17,6 +18,9 @@ function normalizeSelection(state, transaction, allowTableNodeSelection) {
|
|
|
17
18
|
if (sel instanceof _state.NodeSelection) {
|
|
18
19
|
role = sel.node.type.spec.tableRole;
|
|
19
20
|
}
|
|
21
|
+
var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
22
|
+
exposure: true
|
|
23
|
+
});
|
|
20
24
|
if (sel instanceof _state.NodeSelection && role) {
|
|
21
25
|
if (role === 'cell' || role === 'header_cell') {
|
|
22
26
|
normalize = _cellSelection.CellSelection.create(doc, sel.from);
|
|
@@ -31,7 +35,7 @@ function normalizeSelection(state, transaction, allowTableNodeSelection) {
|
|
|
31
35
|
}
|
|
32
36
|
} else if (sel instanceof _state.TextSelection && isCellBoundarySelection(sel)) {
|
|
33
37
|
normalize = _state.TextSelection.create(doc, sel.from);
|
|
34
|
-
} else if (sel instanceof _state.TextSelection && isTextSelectionAcrossCells(sel)) {
|
|
38
|
+
} else if (sel instanceof _state.TextSelection && isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel)) {
|
|
35
39
|
normalize = _state.TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
36
40
|
}
|
|
37
41
|
if (normalize) {
|
|
@@ -82,4 +86,33 @@ function isTextSelectionAcrossCells(_ref3) {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
|
|
89
|
+
}
|
|
90
|
+
function isTextSelectionAcrossSameTableCells(_ref4) {
|
|
91
|
+
var $from = _ref4.$from,
|
|
92
|
+
$to = _ref4.$to;
|
|
93
|
+
var fromCellBoundaryNode;
|
|
94
|
+
var toCellBoundaryNode;
|
|
95
|
+
var fromCellTableNode;
|
|
96
|
+
var toCellTableNode;
|
|
97
|
+
for (var i = $from.depth; i > 0; i--) {
|
|
98
|
+
var node = $from.node(i);
|
|
99
|
+
if (node.type.spec.tableRole === 'cell' || node.type.spec.tableRole === 'header_cell') {
|
|
100
|
+
fromCellBoundaryNode = node;
|
|
101
|
+
}
|
|
102
|
+
if (node.type.name === 'table') {
|
|
103
|
+
fromCellTableNode = node;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (var _i2 = $to.depth; _i2 > 0; _i2--) {
|
|
108
|
+
var _node2 = $to.node(_i2);
|
|
109
|
+
if (_node2.type.spec.tableRole === 'cell' || _node2.type.spec.tableRole === 'header_cell') {
|
|
110
|
+
toCellBoundaryNode = _node2;
|
|
111
|
+
}
|
|
112
|
+
if (_node2.type.name === 'table') {
|
|
113
|
+
toCellTableNode = _node2;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return fromCellBoundaryNode !== undefined && toCellBoundaryNode !== undefined && fromCellBoundaryNode !== toCellBoundaryNode && toCellTableNode === fromCellTableNode && $to.parentOffset === 0;
|
|
85
118
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
3
|
import { CellSelection } from '../cell-selection';
|
|
3
4
|
import { TableMap } from '../table-map';
|
|
4
5
|
export function normalizeSelection(state, transaction, allowTableNodeSelection) {
|
|
@@ -12,6 +13,9 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
12
13
|
if (sel instanceof NodeSelection) {
|
|
13
14
|
role = sel.node.type.spec.tableRole;
|
|
14
15
|
}
|
|
16
|
+
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
17
|
+
exposure: true
|
|
18
|
+
});
|
|
15
19
|
if (sel instanceof NodeSelection && role) {
|
|
16
20
|
if (role === 'cell' || role === 'header_cell') {
|
|
17
21
|
normalize = CellSelection.create(doc, sel.from);
|
|
@@ -26,7 +30,7 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
26
30
|
}
|
|
27
31
|
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
|
|
28
32
|
normalize = TextSelection.create(doc, sel.from);
|
|
29
|
-
} else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {
|
|
33
|
+
} else if (sel instanceof TextSelection && isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel)) {
|
|
30
34
|
normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
31
35
|
}
|
|
32
36
|
if (normalize) {
|
|
@@ -81,4 +85,34 @@ function isTextSelectionAcrossCells({
|
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
|
|
88
|
+
}
|
|
89
|
+
function isTextSelectionAcrossSameTableCells({
|
|
90
|
+
$from,
|
|
91
|
+
$to
|
|
92
|
+
}) {
|
|
93
|
+
let fromCellBoundaryNode;
|
|
94
|
+
let toCellBoundaryNode;
|
|
95
|
+
let fromCellTableNode;
|
|
96
|
+
let toCellTableNode;
|
|
97
|
+
for (let i = $from.depth; i > 0; i--) {
|
|
98
|
+
const node = $from.node(i);
|
|
99
|
+
if (node.type.spec.tableRole === 'cell' || node.type.spec.tableRole === 'header_cell') {
|
|
100
|
+
fromCellBoundaryNode = node;
|
|
101
|
+
}
|
|
102
|
+
if (node.type.name === 'table') {
|
|
103
|
+
fromCellTableNode = node;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (let i = $to.depth; i > 0; i--) {
|
|
108
|
+
const node = $to.node(i);
|
|
109
|
+
if (node.type.spec.tableRole === 'cell' || node.type.spec.tableRole === 'header_cell') {
|
|
110
|
+
toCellBoundaryNode = node;
|
|
111
|
+
}
|
|
112
|
+
if (node.type.name === 'table') {
|
|
113
|
+
toCellTableNode = node;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return fromCellBoundaryNode !== undefined && toCellBoundaryNode !== undefined && fromCellBoundaryNode !== toCellBoundaryNode && toCellTableNode === fromCellTableNode && $to.parentOffset === 0;
|
|
84
118
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
3
|
import { CellSelection } from '../cell-selection';
|
|
3
4
|
import { TableMap } from '../table-map';
|
|
4
5
|
export function normalizeSelection(state, transaction, allowTableNodeSelection) {
|
|
@@ -11,6 +12,9 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
11
12
|
if (sel instanceof NodeSelection) {
|
|
12
13
|
role = sel.node.type.spec.tableRole;
|
|
13
14
|
}
|
|
15
|
+
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true, {
|
|
16
|
+
exposure: true
|
|
17
|
+
});
|
|
14
18
|
if (sel instanceof NodeSelection && role) {
|
|
15
19
|
if (role === 'cell' || role === 'header_cell') {
|
|
16
20
|
normalize = CellSelection.create(doc, sel.from);
|
|
@@ -25,7 +29,7 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
25
29
|
}
|
|
26
30
|
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
|
|
27
31
|
normalize = TextSelection.create(doc, sel.from);
|
|
28
|
-
} else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {
|
|
32
|
+
} else if (sel instanceof TextSelection && isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel)) {
|
|
29
33
|
normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
30
34
|
}
|
|
31
35
|
if (normalize) {
|
|
@@ -76,4 +80,33 @@ function isTextSelectionAcrossCells(_ref3) {
|
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;
|
|
83
|
+
}
|
|
84
|
+
function isTextSelectionAcrossSameTableCells(_ref4) {
|
|
85
|
+
var $from = _ref4.$from,
|
|
86
|
+
$to = _ref4.$to;
|
|
87
|
+
var fromCellBoundaryNode;
|
|
88
|
+
var toCellBoundaryNode;
|
|
89
|
+
var fromCellTableNode;
|
|
90
|
+
var toCellTableNode;
|
|
91
|
+
for (var i = $from.depth; i > 0; i--) {
|
|
92
|
+
var node = $from.node(i);
|
|
93
|
+
if (node.type.spec.tableRole === 'cell' || node.type.spec.tableRole === 'header_cell') {
|
|
94
|
+
fromCellBoundaryNode = node;
|
|
95
|
+
}
|
|
96
|
+
if (node.type.name === 'table') {
|
|
97
|
+
fromCellTableNode = node;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (var _i2 = $to.depth; _i2 > 0; _i2--) {
|
|
102
|
+
var _node2 = $to.node(_i2);
|
|
103
|
+
if (_node2.type.spec.tableRole === 'cell' || _node2.type.spec.tableRole === 'header_cell') {
|
|
104
|
+
toCellBoundaryNode = _node2;
|
|
105
|
+
}
|
|
106
|
+
if (_node2.type.name === 'table') {
|
|
107
|
+
toCellTableNode = _node2;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return fromCellBoundaryNode !== undefined && toCellBoundaryNode !== undefined && fromCellBoundaryNode !== toCellBoundaryNode && toCellTableNode === fromCellTableNode && $to.parentOffset === 0;
|
|
79
112
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-tables",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.1",
|
|
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,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
31
|
-
"@atlaskit/platform-feature-flags": "^1.
|
|
31
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
|
+
"@atlaskit/tmp-editor-statsig": "^3.2.0",
|
|
32
33
|
"@babel/runtime": "^7.0.0"
|
|
33
34
|
},
|
|
34
35
|
"techstack": {
|