@atlaskit/editor-tables 2.9.1 → 2.9.2
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/afm-jira/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/dist/cjs/utils/colspan.js +1 -1
- package/dist/cjs/utils/handle-paste.js +25 -2
- package/dist/cjs/utils/normalize-selection.js +2 -4
- package/dist/es2019/utils/colspan.js +1 -1
- package/dist/es2019/utils/handle-paste.js +25 -2
- package/dist/es2019/utils/normalize-selection.js +2 -4
- package/dist/esm/utils/colspan.js +1 -1
- package/dist/esm/utils/handle-paste.js +25 -2
- package/dist/esm/utils/normalize-selection.js +2 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -38,7 +38,7 @@ function assertColspan(attrs) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// TODO: replace "addColSpan" from table plugin with this function
|
|
41
|
+
// TODO: ED-26961 - replace "addColSpan" from table plugin with this function
|
|
42
42
|
function addColSpan(attrs, pos) {
|
|
43
43
|
var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
44
44
|
assertColspan(attrs);
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handlePaste = handlePaste;
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
8
10
|
var _cellSelection = require("../cell-selection");
|
|
9
11
|
var _tableMap2 = require("../table-map");
|
|
10
12
|
var _selectionCell = require("../utils/selection-cell");
|
|
@@ -15,11 +17,32 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
15
17
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
18
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
19
|
function handlePaste(view, event, slice) {
|
|
20
|
+
var _slice$content$firstC;
|
|
18
21
|
if (!(0, _tables.isInTable)(view.state)) {
|
|
19
22
|
return false;
|
|
20
23
|
}
|
|
21
|
-
var
|
|
24
|
+
var schema = view.state.schema;
|
|
25
|
+
var isNestingAllowed = (0, _experiments.editorExperiment)('nested-tables-in-tables', true);
|
|
26
|
+
/**
|
|
27
|
+
* TODO: There can be multiple variations.
|
|
28
|
+
* 1. The last cell is selected with content outside of the table
|
|
29
|
+
* 2. The first cell is selected with content outside of the table
|
|
30
|
+
*/
|
|
31
|
+
var isPartialTablePaste = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === schema.nodes.table && slice.openStart !== 0 && slice.openEnd !== 0;
|
|
22
32
|
var sel = view.state.selection;
|
|
33
|
+
if (isNestingAllowed && !isPartialTablePaste) {
|
|
34
|
+
var cellRes = (0, _utils.findParentNode)(function (node) {
|
|
35
|
+
return node.type === schema.nodes.tableCell || node.type === schema.nodes.tableHeader;
|
|
36
|
+
})(sel);
|
|
37
|
+
if (cellRes) {
|
|
38
|
+
var _cellRes$node$content;
|
|
39
|
+
var canInsertNestedTable = (_cellRes$node$content = cellRes.node.contentMatchAt(0).matchType(schema.nodes.table)) === null || _cellRes$node$content === void 0 ? void 0 : _cellRes$node$content.validEnd;
|
|
40
|
+
if (canInsertNestedTable) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
var cells = (0, _copyPaste.pastedCells)(slice);
|
|
23
46
|
if (sel instanceof _cellSelection.CellSelection) {
|
|
24
47
|
if (!cells) {
|
|
25
48
|
cells = {
|
|
@@ -80,7 +103,7 @@ var clearColumnWidthOfCells = function clearColumnWidthOfCells(cells, rect, tabl
|
|
|
80
103
|
}
|
|
81
104
|
for (var _i = 0, _overlappingCells = overlappingCells; _i < _overlappingCells.length; _i++) {
|
|
82
105
|
var cell = _overlappingCells[_i];
|
|
83
|
-
// TODO: ED-13910 unblock Prosemirror bump
|
|
106
|
+
// TODO: ED-13910 - unblock Prosemirror bump
|
|
84
107
|
// @ts-ignore
|
|
85
108
|
cell.attrs.colwidth = null;
|
|
86
109
|
}
|
|
@@ -18,9 +18,7 @@ function normalizeSelection(state, transaction, allowTableNodeSelection) {
|
|
|
18
18
|
if (sel instanceof _state.NodeSelection) {
|
|
19
19
|
role = sel.node.type.spec.tableRole;
|
|
20
20
|
}
|
|
21
|
-
var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true
|
|
22
|
-
exposure: true
|
|
23
|
-
});
|
|
21
|
+
var isMultiSelect = (0, _experiments.editorExperiment)('platform_editor_element_drag_and_drop_multiselect', true);
|
|
24
22
|
if (sel instanceof _state.NodeSelection && role) {
|
|
25
23
|
if (role === 'cell' || role === 'header_cell') {
|
|
26
24
|
normalize = _cellSelection.CellSelection.create(doc, sel.from);
|
|
@@ -35,7 +33,7 @@ function normalizeSelection(state, transaction, allowTableNodeSelection) {
|
|
|
35
33
|
}
|
|
36
34
|
} else if (sel instanceof _state.TextSelection && isCellBoundarySelection(sel)) {
|
|
37
35
|
normalize = _state.TextSelection.create(doc, sel.from);
|
|
38
|
-
} else if (sel instanceof _state.TextSelection && isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel)) {
|
|
36
|
+
} else if (sel instanceof _state.TextSelection && (isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel))) {
|
|
39
37
|
normalize = _state.TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
40
38
|
}
|
|
41
39
|
if (normalize) {
|
|
@@ -24,7 +24,7 @@ export function assertColspan(attrs) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// TODO: replace "addColSpan" from table plugin with this function
|
|
27
|
+
// TODO: ED-26961 - replace "addColSpan" from table plugin with this function
|
|
28
28
|
export function addColSpan(attrs, pos, n = 1) {
|
|
29
29
|
assertColspan(attrs);
|
|
30
30
|
const result = {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
4
|
import { CellSelection } from '../cell-selection';
|
|
3
5
|
import { TableMap } from '../table-map';
|
|
4
6
|
import { selectionCell } from '../utils/selection-cell';
|
|
@@ -6,11 +8,32 @@ import { tableNodeTypes } from '../utils/table-node-types';
|
|
|
6
8
|
import { isInTable } from '../utils/tables';
|
|
7
9
|
import { clipCells, fitSlice, insertCells, pastedCells } from './copy-paste';
|
|
8
10
|
export function handlePaste(view, event, slice) {
|
|
11
|
+
var _slice$content$firstC;
|
|
9
12
|
if (!isInTable(view.state)) {
|
|
10
13
|
return false;
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
const {
|
|
16
|
+
schema
|
|
17
|
+
} = view.state;
|
|
18
|
+
const isNestingAllowed = editorExperiment('nested-tables-in-tables', true);
|
|
19
|
+
/**
|
|
20
|
+
* TODO: There can be multiple variations.
|
|
21
|
+
* 1. The last cell is selected with content outside of the table
|
|
22
|
+
* 2. The first cell is selected with content outside of the table
|
|
23
|
+
*/
|
|
24
|
+
const isPartialTablePaste = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === schema.nodes.table && slice.openStart !== 0 && slice.openEnd !== 0;
|
|
13
25
|
const sel = view.state.selection;
|
|
26
|
+
if (isNestingAllowed && !isPartialTablePaste) {
|
|
27
|
+
const cellRes = findParentNode(node => node.type === schema.nodes.tableCell || node.type === schema.nodes.tableHeader)(sel);
|
|
28
|
+
if (cellRes) {
|
|
29
|
+
var _cellRes$node$content;
|
|
30
|
+
const canInsertNestedTable = (_cellRes$node$content = cellRes.node.contentMatchAt(0).matchType(schema.nodes.table)) === null || _cellRes$node$content === void 0 ? void 0 : _cellRes$node$content.validEnd;
|
|
31
|
+
if (canInsertNestedTable) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let cells = pastedCells(slice);
|
|
14
37
|
if (sel instanceof CellSelection) {
|
|
15
38
|
if (!cells) {
|
|
16
39
|
cells = {
|
|
@@ -61,7 +84,7 @@ const clearColumnWidthOfCells = (cells, rect, table) => {
|
|
|
61
84
|
}
|
|
62
85
|
}
|
|
63
86
|
for (const cell of overlappingCells) {
|
|
64
|
-
// TODO: ED-13910 unblock Prosemirror bump
|
|
87
|
+
// TODO: ED-13910 - unblock Prosemirror bump
|
|
65
88
|
// @ts-ignore
|
|
66
89
|
cell.attrs.colwidth = null;
|
|
67
90
|
}
|
|
@@ -13,9 +13,7 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
13
13
|
if (sel instanceof NodeSelection) {
|
|
14
14
|
role = sel.node.type.spec.tableRole;
|
|
15
15
|
}
|
|
16
|
-
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
17
|
-
exposure: true
|
|
18
|
-
});
|
|
16
|
+
const isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
19
17
|
if (sel instanceof NodeSelection && role) {
|
|
20
18
|
if (role === 'cell' || role === 'header_cell') {
|
|
21
19
|
normalize = CellSelection.create(doc, sel.from);
|
|
@@ -30,7 +28,7 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
30
28
|
}
|
|
31
29
|
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
|
|
32
30
|
normalize = TextSelection.create(doc, sel.from);
|
|
33
|
-
} else if (sel instanceof TextSelection && isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel)) {
|
|
31
|
+
} else if (sel instanceof TextSelection && (isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel))) {
|
|
34
32
|
normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
35
33
|
}
|
|
36
34
|
if (normalize) {
|
|
@@ -29,7 +29,7 @@ export function assertColspan(attrs) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// TODO: replace "addColSpan" from table plugin with this function
|
|
32
|
+
// TODO: ED-26961 - replace "addColSpan" from table plugin with this function
|
|
33
33
|
export function addColSpan(attrs, pos) {
|
|
34
34
|
var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
35
35
|
assertColspan(attrs);
|
|
@@ -2,6 +2,8 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
2
2
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
3
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
4
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
7
|
import { CellSelection } from '../cell-selection';
|
|
6
8
|
import { TableMap } from '../table-map';
|
|
7
9
|
import { selectionCell } from '../utils/selection-cell';
|
|
@@ -9,11 +11,32 @@ import { tableNodeTypes } from '../utils/table-node-types';
|
|
|
9
11
|
import { isInTable } from '../utils/tables';
|
|
10
12
|
import { clipCells, fitSlice, insertCells, pastedCells } from './copy-paste';
|
|
11
13
|
export function handlePaste(view, event, slice) {
|
|
14
|
+
var _slice$content$firstC;
|
|
12
15
|
if (!isInTable(view.state)) {
|
|
13
16
|
return false;
|
|
14
17
|
}
|
|
15
|
-
var
|
|
18
|
+
var schema = view.state.schema;
|
|
19
|
+
var isNestingAllowed = editorExperiment('nested-tables-in-tables', true);
|
|
20
|
+
/**
|
|
21
|
+
* TODO: There can be multiple variations.
|
|
22
|
+
* 1. The last cell is selected with content outside of the table
|
|
23
|
+
* 2. The first cell is selected with content outside of the table
|
|
24
|
+
*/
|
|
25
|
+
var isPartialTablePaste = slice.content.childCount === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === schema.nodes.table && slice.openStart !== 0 && slice.openEnd !== 0;
|
|
16
26
|
var sel = view.state.selection;
|
|
27
|
+
if (isNestingAllowed && !isPartialTablePaste) {
|
|
28
|
+
var cellRes = findParentNode(function (node) {
|
|
29
|
+
return node.type === schema.nodes.tableCell || node.type === schema.nodes.tableHeader;
|
|
30
|
+
})(sel);
|
|
31
|
+
if (cellRes) {
|
|
32
|
+
var _cellRes$node$content;
|
|
33
|
+
var canInsertNestedTable = (_cellRes$node$content = cellRes.node.contentMatchAt(0).matchType(schema.nodes.table)) === null || _cellRes$node$content === void 0 ? void 0 : _cellRes$node$content.validEnd;
|
|
34
|
+
if (canInsertNestedTable) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
var cells = pastedCells(slice);
|
|
17
40
|
if (sel instanceof CellSelection) {
|
|
18
41
|
if (!cells) {
|
|
19
42
|
cells = {
|
|
@@ -74,7 +97,7 @@ var clearColumnWidthOfCells = function clearColumnWidthOfCells(cells, rect, tabl
|
|
|
74
97
|
}
|
|
75
98
|
for (var _i = 0, _overlappingCells = overlappingCells; _i < _overlappingCells.length; _i++) {
|
|
76
99
|
var cell = _overlappingCells[_i];
|
|
77
|
-
// TODO: ED-13910 unblock Prosemirror bump
|
|
100
|
+
// TODO: ED-13910 - unblock Prosemirror bump
|
|
78
101
|
// @ts-ignore
|
|
79
102
|
cell.attrs.colwidth = null;
|
|
80
103
|
}
|
|
@@ -12,9 +12,7 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
12
12
|
if (sel instanceof NodeSelection) {
|
|
13
13
|
role = sel.node.type.spec.tableRole;
|
|
14
14
|
}
|
|
15
|
-
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true
|
|
16
|
-
exposure: true
|
|
17
|
-
});
|
|
15
|
+
var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true);
|
|
18
16
|
if (sel instanceof NodeSelection && role) {
|
|
19
17
|
if (role === 'cell' || role === 'header_cell') {
|
|
20
18
|
normalize = CellSelection.create(doc, sel.from);
|
|
@@ -29,7 +27,7 @@ export function normalizeSelection(state, transaction, allowTableNodeSelection)
|
|
|
29
27
|
}
|
|
30
28
|
} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {
|
|
31
29
|
normalize = TextSelection.create(doc, sel.from);
|
|
32
|
-
} else if (sel instanceof TextSelection && isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel)) {
|
|
30
|
+
} else if (sel instanceof TextSelection && (isMultiSelect ? isTextSelectionAcrossSameTableCells(sel) : isTextSelectionAcrossCells(sel))) {
|
|
33
31
|
normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());
|
|
34
32
|
}
|
|
35
33
|
if (normalize) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-tables",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.2",
|
|
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.0.0",
|
|
31
31
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
32
|
+
"@atlaskit/tmp-editor-statsig": "^4.0.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0"
|
|
34
34
|
},
|
|
35
35
|
"techstack": {
|