@atlaskit/editor-tables 2.1.5 → 2.1.6
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/dist/cjs/utils/analytics-helpers.js +63 -0
- package/dist/cjs/utils/replace-table.js +31 -0
- package/dist/cjs/utils.js +23 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/utils/analytics-helpers.js +51 -0
- package/dist/es2019/utils/replace-table.js +18 -0
- package/dist/es2019/utils.js +3 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/utils/analytics-helpers.js +51 -0
- package/dist/esm/utils/replace-table.js +18 -0
- package/dist/esm/utils.js +3 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/utils/analytics-helpers.d.ts +15 -0
- package/dist/types/utils/replace-table.d.ts +3 -0
- package/dist/types/utils.d.ts +2 -0
- package/package.json +2 -2
- package/tsconfig.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-tables
|
|
2
2
|
|
|
3
|
+
## 2.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`95f007063cf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/95f007063cf) - Decoupling paste plugin and table plugin, copied `replaceSelectedTable` and `getSelectedTableInfo` utils to editor-tables utils package and analytics dependency shifted to paste plugin.
|
|
8
|
+
|
|
3
9
|
## 2.1.5
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSelectedCellInfo = getSelectedCellInfo;
|
|
7
|
+
exports.getSelectedTableInfo = getSelectedTableInfo;
|
|
8
|
+
|
|
9
|
+
var _tableMap = require("../table-map");
|
|
10
|
+
|
|
11
|
+
var _find = require("./find");
|
|
12
|
+
|
|
13
|
+
var _getSelectionRect = require("./get-selection-rect");
|
|
14
|
+
|
|
15
|
+
function getSelectedTableInfo(selection) {
|
|
16
|
+
var map;
|
|
17
|
+
var totalRowCount = 0;
|
|
18
|
+
var totalColumnCount = 0;
|
|
19
|
+
var table = (0, _find.findTable)(selection);
|
|
20
|
+
|
|
21
|
+
if (table) {
|
|
22
|
+
map = _tableMap.TableMap.get(table.node);
|
|
23
|
+
totalRowCount = map.height;
|
|
24
|
+
totalColumnCount = map.width;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
table: table,
|
|
29
|
+
map: map,
|
|
30
|
+
totalRowCount: totalRowCount,
|
|
31
|
+
totalColumnCount: totalColumnCount
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getSelectedCellInfo(selection) {
|
|
36
|
+
var horizontalCells = 1;
|
|
37
|
+
var verticalCells = 1;
|
|
38
|
+
var totalCells = 1;
|
|
39
|
+
|
|
40
|
+
var _getSelectedTableInfo = getSelectedTableInfo(selection),
|
|
41
|
+
table = _getSelectedTableInfo.table,
|
|
42
|
+
map = _getSelectedTableInfo.map,
|
|
43
|
+
totalRowCount = _getSelectedTableInfo.totalRowCount,
|
|
44
|
+
totalColumnCount = _getSelectedTableInfo.totalColumnCount;
|
|
45
|
+
|
|
46
|
+
if (table && map) {
|
|
47
|
+
var rect = (0, _getSelectionRect.getSelectionRect)(selection);
|
|
48
|
+
|
|
49
|
+
if (rect) {
|
|
50
|
+
totalCells = map.cellsInRect(rect).length;
|
|
51
|
+
horizontalCells = rect.right - rect.left;
|
|
52
|
+
verticalCells = rect.bottom - rect.top;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
totalRowCount: totalRowCount,
|
|
58
|
+
totalColumnCount: totalColumnCount,
|
|
59
|
+
horizontalCells: horizontalCells,
|
|
60
|
+
verticalCells: verticalCells,
|
|
61
|
+
totalCells: totalCells
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.replaceSelectedTable = void 0;
|
|
7
|
+
|
|
8
|
+
var _prosemirrorModel = require("prosemirror-model");
|
|
9
|
+
|
|
10
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
11
|
+
|
|
12
|
+
var _find = require("./find");
|
|
13
|
+
|
|
14
|
+
var _isSelected = require("./is-selected");
|
|
15
|
+
|
|
16
|
+
var replaceSelectedTable = function replaceSelectedTable(state, content) {
|
|
17
|
+
if ((0, _isSelected.isTableSelected)(state.selection)) {
|
|
18
|
+
var table = (0, _find.findTable)(state.selection);
|
|
19
|
+
|
|
20
|
+
if (table) {
|
|
21
|
+
var slice = typeof content === 'string' ? new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(state.schema.text(content)), 0, 0) : content;
|
|
22
|
+
var tr = state.tr.replace(table.pos, table.pos + table.node.nodeSize, slice);
|
|
23
|
+
tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, table.pos + slice.size + 1));
|
|
24
|
+
return tr;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return state.tr;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.replaceSelectedTable = replaceSelectedTable;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -159,6 +159,18 @@ Object.defineProperty(exports, "getCellsInTable", {
|
|
|
159
159
|
return _getCellsInTable.getCellsInTable;
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
|
+
Object.defineProperty(exports, "getSelectedCellInfo", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function get() {
|
|
165
|
+
return _analyticsHelpers.getSelectedCellInfo;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "getSelectedTableInfo", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function get() {
|
|
171
|
+
return _analyticsHelpers.getSelectedTableInfo;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
162
174
|
Object.defineProperty(exports, "getSelectionRangeInColumn", {
|
|
163
175
|
enumerable: true,
|
|
164
176
|
get: function get() {
|
|
@@ -309,6 +321,12 @@ Object.defineProperty(exports, "removeTable", {
|
|
|
309
321
|
return _removeTable.removeTable;
|
|
310
322
|
}
|
|
311
323
|
});
|
|
324
|
+
Object.defineProperty(exports, "replaceSelectedTable", {
|
|
325
|
+
enumerable: true,
|
|
326
|
+
get: function get() {
|
|
327
|
+
return _replaceTable.replaceSelectedTable;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
312
330
|
Object.defineProperty(exports, "selectColumn", {
|
|
313
331
|
enumerable: true,
|
|
314
332
|
get: function get() {
|
|
@@ -448,4 +466,8 @@ var _toggleHeader = require("./utils/toggle-header");
|
|
|
448
466
|
|
|
449
467
|
var _reorderUtils = require("./utils/reorder-utils");
|
|
450
468
|
|
|
451
|
-
var _handlePaste = require("./utils/handle-paste");
|
|
469
|
+
var _handlePaste = require("./utils/handle-paste");
|
|
470
|
+
|
|
471
|
+
var _replaceTable = require("./utils/replace-table");
|
|
472
|
+
|
|
473
|
+
var _analyticsHelpers = require("./utils/analytics-helpers");
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TableMap } from '../table-map';
|
|
2
|
+
import { findTable } from './find';
|
|
3
|
+
import { getSelectionRect } from './get-selection-rect';
|
|
4
|
+
export function getSelectedTableInfo(selection) {
|
|
5
|
+
let map;
|
|
6
|
+
let totalRowCount = 0;
|
|
7
|
+
let totalColumnCount = 0;
|
|
8
|
+
const table = findTable(selection);
|
|
9
|
+
|
|
10
|
+
if (table) {
|
|
11
|
+
map = TableMap.get(table.node);
|
|
12
|
+
totalRowCount = map.height;
|
|
13
|
+
totalColumnCount = map.width;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
table,
|
|
18
|
+
map,
|
|
19
|
+
totalRowCount,
|
|
20
|
+
totalColumnCount
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function getSelectedCellInfo(selection) {
|
|
24
|
+
let horizontalCells = 1;
|
|
25
|
+
let verticalCells = 1;
|
|
26
|
+
let totalCells = 1;
|
|
27
|
+
const {
|
|
28
|
+
table,
|
|
29
|
+
map,
|
|
30
|
+
totalRowCount,
|
|
31
|
+
totalColumnCount
|
|
32
|
+
} = getSelectedTableInfo(selection);
|
|
33
|
+
|
|
34
|
+
if (table && map) {
|
|
35
|
+
const rect = getSelectionRect(selection);
|
|
36
|
+
|
|
37
|
+
if (rect) {
|
|
38
|
+
totalCells = map.cellsInRect(rect).length;
|
|
39
|
+
horizontalCells = rect.right - rect.left;
|
|
40
|
+
verticalCells = rect.bottom - rect.top;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
totalRowCount,
|
|
46
|
+
totalColumnCount,
|
|
47
|
+
horizontalCells,
|
|
48
|
+
verticalCells,
|
|
49
|
+
totalCells
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fragment, Slice } from 'prosemirror-model';
|
|
2
|
+
import { TextSelection } from 'prosemirror-state';
|
|
3
|
+
import { findTable } from './find';
|
|
4
|
+
import { isTableSelected } from './is-selected';
|
|
5
|
+
export const replaceSelectedTable = (state, content) => {
|
|
6
|
+
if (isTableSelected(state.selection)) {
|
|
7
|
+
const table = findTable(state.selection);
|
|
8
|
+
|
|
9
|
+
if (table) {
|
|
10
|
+
const slice = typeof content === 'string' ? new Slice(Fragment.from(state.schema.text(content)), 0, 0) : content;
|
|
11
|
+
let tr = state.tr.replace(table.pos, table.pos + table.node.nodeSize, slice);
|
|
12
|
+
tr.setSelection(TextSelection.create(tr.doc, table.pos + slice.size + 1));
|
|
13
|
+
return tr;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return state.tr;
|
|
18
|
+
};
|
package/dist/es2019/utils.js
CHANGED
|
@@ -37,4 +37,6 @@ export { tableNodeTypes } from './utils/table-node-types';
|
|
|
37
37
|
export { isInTable, inSameTable } from './utils/tables';
|
|
38
38
|
export { toggleHeader } from './utils/toggle-header';
|
|
39
39
|
export { convertArrayOfRowsToTableNode, convertTableNodeToArrayOfRows } from './utils/reorder-utils';
|
|
40
|
-
export { handlePaste } from './utils/handle-paste';
|
|
40
|
+
export { handlePaste } from './utils/handle-paste';
|
|
41
|
+
export { replaceSelectedTable } from './utils/replace-table';
|
|
42
|
+
export { getSelectedTableInfo, getSelectedCellInfo } from './utils/analytics-helpers';
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TableMap } from '../table-map';
|
|
2
|
+
import { findTable } from './find';
|
|
3
|
+
import { getSelectionRect } from './get-selection-rect';
|
|
4
|
+
export function getSelectedTableInfo(selection) {
|
|
5
|
+
var map;
|
|
6
|
+
var totalRowCount = 0;
|
|
7
|
+
var totalColumnCount = 0;
|
|
8
|
+
var table = findTable(selection);
|
|
9
|
+
|
|
10
|
+
if (table) {
|
|
11
|
+
map = TableMap.get(table.node);
|
|
12
|
+
totalRowCount = map.height;
|
|
13
|
+
totalColumnCount = map.width;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
table: table,
|
|
18
|
+
map: map,
|
|
19
|
+
totalRowCount: totalRowCount,
|
|
20
|
+
totalColumnCount: totalColumnCount
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function getSelectedCellInfo(selection) {
|
|
24
|
+
var horizontalCells = 1;
|
|
25
|
+
var verticalCells = 1;
|
|
26
|
+
var totalCells = 1;
|
|
27
|
+
|
|
28
|
+
var _getSelectedTableInfo = getSelectedTableInfo(selection),
|
|
29
|
+
table = _getSelectedTableInfo.table,
|
|
30
|
+
map = _getSelectedTableInfo.map,
|
|
31
|
+
totalRowCount = _getSelectedTableInfo.totalRowCount,
|
|
32
|
+
totalColumnCount = _getSelectedTableInfo.totalColumnCount;
|
|
33
|
+
|
|
34
|
+
if (table && map) {
|
|
35
|
+
var rect = getSelectionRect(selection);
|
|
36
|
+
|
|
37
|
+
if (rect) {
|
|
38
|
+
totalCells = map.cellsInRect(rect).length;
|
|
39
|
+
horizontalCells = rect.right - rect.left;
|
|
40
|
+
verticalCells = rect.bottom - rect.top;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
totalRowCount: totalRowCount,
|
|
46
|
+
totalColumnCount: totalColumnCount,
|
|
47
|
+
horizontalCells: horizontalCells,
|
|
48
|
+
verticalCells: verticalCells,
|
|
49
|
+
totalCells: totalCells
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Fragment, Slice } from 'prosemirror-model';
|
|
2
|
+
import { TextSelection } from 'prosemirror-state';
|
|
3
|
+
import { findTable } from './find';
|
|
4
|
+
import { isTableSelected } from './is-selected';
|
|
5
|
+
export var replaceSelectedTable = function replaceSelectedTable(state, content) {
|
|
6
|
+
if (isTableSelected(state.selection)) {
|
|
7
|
+
var table = findTable(state.selection);
|
|
8
|
+
|
|
9
|
+
if (table) {
|
|
10
|
+
var slice = typeof content === 'string' ? new Slice(Fragment.from(state.schema.text(content)), 0, 0) : content;
|
|
11
|
+
var tr = state.tr.replace(table.pos, table.pos + table.node.nodeSize, slice);
|
|
12
|
+
tr.setSelection(TextSelection.create(tr.doc, table.pos + slice.size + 1));
|
|
13
|
+
return tr;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return state.tr;
|
|
18
|
+
};
|
package/dist/esm/utils.js
CHANGED
|
@@ -37,4 +37,6 @@ export { tableNodeTypes } from './utils/table-node-types';
|
|
|
37
37
|
export { isInTable, inSameTable } from './utils/tables';
|
|
38
38
|
export { toggleHeader } from './utils/toggle-header';
|
|
39
39
|
export { convertArrayOfRowsToTableNode, convertTableNodeToArrayOfRows } from './utils/reorder-utils';
|
|
40
|
-
export { handlePaste } from './utils/handle-paste';
|
|
40
|
+
export { handlePaste } from './utils/handle-paste';
|
|
41
|
+
export { replaceSelectedTable } from './utils/replace-table';
|
|
42
|
+
export { getSelectedTableInfo, getSelectedCellInfo } from './utils/analytics-helpers';
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Selection } from 'prosemirror-state';
|
|
2
|
+
import { TableMap } from '../table-map';
|
|
3
|
+
export declare function getSelectedTableInfo(selection: Selection): {
|
|
4
|
+
table: import("prosemirror-utils").ContentNodeWithPos | undefined;
|
|
5
|
+
map: TableMap | undefined;
|
|
6
|
+
totalRowCount: number;
|
|
7
|
+
totalColumnCount: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function getSelectedCellInfo(selection: Selection): {
|
|
10
|
+
totalRowCount: number;
|
|
11
|
+
totalColumnCount: number;
|
|
12
|
+
horizontalCells: number;
|
|
13
|
+
verticalCells: number;
|
|
14
|
+
totalCells: number;
|
|
15
|
+
};
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -39,3 +39,5 @@ export { isInTable, inSameTable } from './utils/tables';
|
|
|
39
39
|
export { toggleHeader } from './utils/toggle-header';
|
|
40
40
|
export { convertArrayOfRowsToTableNode, convertTableNodeToArrayOfRows, } from './utils/reorder-utils';
|
|
41
41
|
export { handlePaste } from './utils/handle-paste';
|
|
42
|
+
export { replaceSelectedTable } from './utils/replace-table';
|
|
43
|
+
export { getSelectedTableInfo, getSelectedCellInfo, } from './utils/analytics-helpers';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-tables",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
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
|
"prosemirror-view": "1.23.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^
|
|
32
|
+
"@atlaskit/adf-schema": "^24.0.0",
|
|
33
33
|
"@atlaskit/editor-test-helpers": "^17.1.0",
|
|
34
34
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1"
|
|
35
35
|
},
|