@atlaskit/editor-plugin-table 1.6.3 → 1.6.5
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 +13 -0
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +5 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +8 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/consts.js +10 -0
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/index.js +20 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +6 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +6 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/consts.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/index.js +3 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +6 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +6 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/consts.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/index.js +3 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +2 -1
- package/package.json +5 -5
- package/src/__tests__/unit/commands.ts +2 -0
- package/src/__tests__/unit/event-handlers.ts +2 -0
- package/src/__tests__/unit/index.ts +2 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +48 -2
- package/src/__tests__/visual-regression/sticky-header.ts +2 -1
- package/src/plugins/table/nodeviews/TableResizer.tsx +11 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +6 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/consts.ts +2 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/index.ts +2 -0
- package/src/__tests__/playwright/__fixtures__/base-adfs.ts +0 -1486
- package/src/__tests__/playwright/extensions.spec.ts +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 1.6.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`dcb378acc03`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dcb378acc03) - [ux] ED-17625: add restriction of resizing table
|
|
8
|
+
|
|
9
|
+
## 1.6.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`5e01082b600`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5e01082b600) - Extracting SelectionBasedNodeView to editor-common.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 1.6.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -23,6 +23,8 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
23
23
|
getPos = _ref.getPos,
|
|
24
24
|
node = _ref.node,
|
|
25
25
|
tableRef = _ref.tableRef;
|
|
26
|
+
var currentColumnCount = (0, _utils.getColgroupChildrenLength)(node);
|
|
27
|
+
var minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * _utils.COLUMN_MIN_WIDTH : 3 * _utils.COLUMN_MIN_WIDTH;
|
|
26
28
|
return /*#__PURE__*/_react.default.createElement(_resizer.ResizerNext, {
|
|
27
29
|
enable: handles,
|
|
28
30
|
width: width,
|
|
@@ -59,7 +61,9 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
59
61
|
updateWidth(newWidth);
|
|
60
62
|
return newWidth;
|
|
61
63
|
},
|
|
62
|
-
resizeRatio: 2
|
|
64
|
+
resizeRatio: 2,
|
|
65
|
+
minWidth: minColumnWidth,
|
|
66
|
+
maxWidth: _utils.TABLE_MAX_WIDTH
|
|
63
67
|
}, children);
|
|
64
68
|
};
|
|
65
69
|
exports.TableResizer = TableResizer;
|
|
@@ -4,11 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.isMinCellWidthTable = exports.insertColgroupFromNode = exports.hasTableBeenResized = exports.generateColgroup = void 0;
|
|
7
|
+
exports.isMinCellWidthTable = exports.insertColgroupFromNode = exports.hasTableBeenResized = exports.getColgroupChildrenLength = exports.generateColgroup = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _prosemirrorModel = require("prosemirror-model");
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
|
+
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
12
13
|
var generateColgroup = function generateColgroup(table) {
|
|
13
14
|
var cols = [];
|
|
14
15
|
table.content.firstChild.content.forEach(function (cell) {
|
|
@@ -69,4 +70,9 @@ exports.isMinCellWidthTable = isMinCellWidthTable;
|
|
|
69
70
|
function renderColgroupFromNode(table) {
|
|
70
71
|
var rendered = _prosemirrorModel.DOMSerializer.renderSpec(document, ['colgroup', {}].concat((0, _toConsumableArray2.default)(generateColgroup(table))));
|
|
71
72
|
return rendered.dom;
|
|
72
|
-
}
|
|
73
|
+
}
|
|
74
|
+
var getColgroupChildrenLength = function getColgroupChildrenLength(table) {
|
|
75
|
+
var map = _tableMap.TableMap.get(table);
|
|
76
|
+
return map.width;
|
|
77
|
+
};
|
|
78
|
+
exports.getColgroupChildrenLength = getColgroupChildrenLength;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TABLE_MAX_WIDTH = exports.COLUMN_MIN_WIDTH = void 0;
|
|
7
|
+
var COLUMN_MIN_WIDTH = 48;
|
|
8
|
+
exports.COLUMN_MIN_WIDTH = COLUMN_MIN_WIDTH;
|
|
9
|
+
var TABLE_MAX_WIDTH = 1800;
|
|
10
|
+
exports.TABLE_MAX_WIDTH = TABLE_MAX_WIDTH;
|
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "COLUMN_MIN_WIDTH", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _consts.COLUMN_MIN_WIDTH;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "TABLE_MAX_WIDTH", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _consts.TABLE_MAX_WIDTH;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
6
18
|
Object.defineProperty(exports, "addContainerLeftRightPadding", {
|
|
7
19
|
enumerable: true,
|
|
8
20
|
get: function get() {
|
|
@@ -69,6 +81,12 @@ Object.defineProperty(exports, "getCellsRefsInColumn", {
|
|
|
69
81
|
return _columnState.getCellsRefsInColumn;
|
|
70
82
|
}
|
|
71
83
|
});
|
|
84
|
+
Object.defineProperty(exports, "getColgroupChildrenLength", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _colgroup.getColgroupChildrenLength;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
72
90
|
Object.defineProperty(exports, "getColumnStateFromDOM", {
|
|
73
91
|
enumerable: true,
|
|
74
92
|
get: function get() {
|
|
@@ -203,4 +221,5 @@ var _resizeState = require("./resize-state");
|
|
|
203
221
|
var _misc = require("./misc");
|
|
204
222
|
var _dom = require("./dom");
|
|
205
223
|
var _scaleTable = require("./scale-table");
|
|
206
|
-
var _resizeColumn = require("./resize-column");
|
|
224
|
+
var _resizeColumn = require("./resize-column");
|
|
225
|
+
var _consts = require("./consts");
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import rafSchd from 'raf-schd';
|
|
3
3
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
4
|
-
import { scaleTable, previewScaleTable } from '../pm-plugins/table-resizing/utils';
|
|
4
|
+
import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
5
5
|
const handles = {
|
|
6
6
|
right: true
|
|
7
7
|
};
|
|
@@ -14,6 +14,8 @@ export const TableResizer = ({
|
|
|
14
14
|
node,
|
|
15
15
|
tableRef
|
|
16
16
|
}) => {
|
|
17
|
+
const currentColumnCount = getColgroupChildrenLength(node);
|
|
18
|
+
const minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * COLUMN_MIN_WIDTH : 3 * COLUMN_MIN_WIDTH;
|
|
17
19
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
18
20
|
enable: handles,
|
|
19
21
|
width: width,
|
|
@@ -51,6 +53,8 @@ export const TableResizer = ({
|
|
|
51
53
|
updateWidth(newWidth);
|
|
52
54
|
return newWidth;
|
|
53
55
|
},
|
|
54
|
-
resizeRatio: 2
|
|
56
|
+
resizeRatio: 2,
|
|
57
|
+
minWidth: minColumnWidth,
|
|
58
|
+
maxWidth: TABLE_MAX_WIDTH
|
|
55
59
|
}, children);
|
|
56
60
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DOMSerializer } from 'prosemirror-model';
|
|
2
2
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
5
|
export const generateColgroup = table => {
|
|
5
6
|
const cols = [];
|
|
6
7
|
table.content.firstChild.content.forEach(cell => {
|
|
@@ -53,4 +54,8 @@ export const isMinCellWidthTable = table => {
|
|
|
53
54
|
function renderColgroupFromNode(table) {
|
|
54
55
|
const rendered = DOMSerializer.renderSpec(document, ['colgroup', {}, ...generateColgroup(table)]);
|
|
55
56
|
return rendered.dom;
|
|
56
|
-
}
|
|
57
|
+
}
|
|
58
|
+
export const getColgroupChildrenLength = table => {
|
|
59
|
+
const map = TableMap.get(table);
|
|
60
|
+
return map.width;
|
|
61
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding } from './column-state';
|
|
4
4
|
export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
|
|
@@ -6,4 +6,5 @@ export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bu
|
|
|
6
6
|
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround } from './misc';
|
|
7
7
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
8
8
|
export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
|
|
9
|
-
export { resizeColumn } from './resize-column';
|
|
9
|
+
export { resizeColumn } from './resize-column';
|
|
10
|
+
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from './consts';
|
package/dist/es2019/version.json
CHANGED
|
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import rafSchd from 'raf-schd';
|
|
6
6
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
7
|
-
import { scaleTable, previewScaleTable } from '../pm-plugins/table-resizing/utils';
|
|
7
|
+
import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
8
8
|
var handles = {
|
|
9
9
|
right: true
|
|
10
10
|
};
|
|
@@ -16,6 +16,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
16
16
|
getPos = _ref.getPos,
|
|
17
17
|
node = _ref.node,
|
|
18
18
|
tableRef = _ref.tableRef;
|
|
19
|
+
var currentColumnCount = getColgroupChildrenLength(node);
|
|
20
|
+
var minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * COLUMN_MIN_WIDTH : 3 * COLUMN_MIN_WIDTH;
|
|
19
21
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
20
22
|
enable: handles,
|
|
21
23
|
width: width,
|
|
@@ -52,6 +54,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
52
54
|
updateWidth(newWidth);
|
|
53
55
|
return newWidth;
|
|
54
56
|
},
|
|
55
|
-
resizeRatio: 2
|
|
57
|
+
resizeRatio: 2,
|
|
58
|
+
minWidth: minColumnWidth,
|
|
59
|
+
maxWidth: TABLE_MAX_WIDTH
|
|
56
60
|
}, children);
|
|
57
61
|
};
|
|
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import { DOMSerializer } from 'prosemirror-model';
|
|
3
3
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
6
|
export var generateColgroup = function generateColgroup(table) {
|
|
6
7
|
var cols = [];
|
|
7
8
|
table.content.firstChild.content.forEach(function (cell) {
|
|
@@ -58,4 +59,8 @@ export var isMinCellWidthTable = function isMinCellWidthTable(table) {
|
|
|
58
59
|
function renderColgroupFromNode(table) {
|
|
59
60
|
var rendered = DOMSerializer.renderSpec(document, ['colgroup', {}].concat(_toConsumableArray(generateColgroup(table))));
|
|
60
61
|
return rendered.dom;
|
|
61
|
-
}
|
|
62
|
+
}
|
|
63
|
+
export var getColgroupChildrenLength = function getColgroupChildrenLength(table) {
|
|
64
|
+
var map = TableMap.get(table);
|
|
65
|
+
return map.width;
|
|
66
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding } from './column-state';
|
|
4
4
|
export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
|
|
@@ -6,4 +6,5 @@ export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bu
|
|
|
6
6
|
export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround } from './misc';
|
|
7
7
|
export { updateControls, isClickNear, getResizeCellPos } from './dom';
|
|
8
8
|
export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
|
|
9
|
-
export { resizeColumn } from './resize-column';
|
|
9
|
+
export { resizeColumn } from './resize-column';
|
|
10
|
+
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from './consts';
|
package/dist/esm/version.json
CHANGED
|
@@ -12,4 +12,5 @@ export declare const hasTableBeenResized: (table: PmNode) => boolean;
|
|
|
12
12
|
* @returns true if all column width is equal to tableCellMinWidth or null, false otherwise
|
|
13
13
|
*/
|
|
14
14
|
export declare const isMinCellWidthTable: (table: PmNode) => boolean;
|
|
15
|
+
export declare const getColgroupChildrenLength: (table: PmNode) => number;
|
|
15
16
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding, } from './column-state';
|
|
4
4
|
export type { ColumnState } from './column-state';
|
|
@@ -10,3 +10,4 @@ export { scale, scaleWithParent, scaleTable, previewScaleTable, } from './scale-
|
|
|
10
10
|
export type { ScaleOptions } from './scale-table';
|
|
11
11
|
export type { ResizeState, ResizeStateWithAnalytics } from './types';
|
|
12
12
|
export { resizeColumn } from './resize-column';
|
|
13
|
+
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from './consts';
|
|
@@ -12,4 +12,5 @@ export declare const hasTableBeenResized: (table: PmNode) => boolean;
|
|
|
12
12
|
* @returns true if all column width is equal to tableCellMinWidth or null, false otherwise
|
|
13
13
|
*/
|
|
14
14
|
export declare const isMinCellWidthTable: (table: PmNode) => boolean;
|
|
15
|
+
export declare const getColgroupChildrenLength: (table: PmNode) => number;
|
|
15
16
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding, } from './column-state';
|
|
4
4
|
export type { ColumnState } from './column-state';
|
|
@@ -10,3 +10,4 @@ export { scale, scaleWithParent, scaleTable, previewScaleTable, } from './scale-
|
|
|
10
10
|
export type { ScaleOptions } from './scale-table';
|
|
11
11
|
export type { ResizeState, ResizeStateWithAnalytics } from './types';
|
|
12
12
|
export { resizeColumn } from './resize-column';
|
|
13
|
+
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from './consts';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@atlaskit/adf-schema": "^25.9.0",
|
|
30
|
-
"@atlaskit/editor-common": "^74.
|
|
30
|
+
"@atlaskit/editor-common": "^74.8.0",
|
|
31
31
|
"@atlaskit/editor-palette": "1.5.0",
|
|
32
32
|
"@atlaskit/editor-plugin-analytics": "^0.0.2",
|
|
33
33
|
"@atlaskit/editor-plugin-content-insertion": "^0.0.2",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/icon": "^21.12.0",
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
38
38
|
"@atlaskit/theme": "^12.5.0",
|
|
39
|
-
"@atlaskit/tokens": "^1.
|
|
39
|
+
"@atlaskit/tokens": "^1.8.0",
|
|
40
40
|
"@atlaskit/tooltip": "^17.8.0",
|
|
41
41
|
"@babel/runtime": "^7.0.0",
|
|
42
42
|
"@emotion/react": "^11.7.1",
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@af/editor-libra": "*",
|
|
65
65
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
66
|
-
"@atlaskit/button": "^16.
|
|
66
|
+
"@atlaskit/button": "^16.8.0",
|
|
67
67
|
"@atlaskit/editor-core": "^185.2.0",
|
|
68
68
|
"@atlaskit/editor-plugin-decorations": "^0.1.0",
|
|
69
69
|
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
70
70
|
"@atlaskit/editor-plugin-grid": "^0.1.0",
|
|
71
71
|
"@atlaskit/editor-plugin-width": "^0.1.0",
|
|
72
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
72
|
+
"@atlaskit/editor-test-helpers": "^18.7.0",
|
|
73
73
|
"@atlaskit/link-provider": "^1.6.0",
|
|
74
74
|
"@atlaskit/logo": "^13.14.0",
|
|
75
75
|
"@atlaskit/media-integration-test-helpers": "^3.0.0",
|
|
@@ -55,6 +55,7 @@ import { handleCut } from '../../plugins/table/event-handlers';
|
|
|
55
55
|
import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
|
|
56
56
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
57
57
|
import tablePlugin from '../../plugins/table';
|
|
58
|
+
import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
|
|
58
59
|
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
59
60
|
import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
|
|
60
61
|
import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
|
|
@@ -87,6 +88,7 @@ describe('table plugin: actions', () => {
|
|
|
87
88
|
attachTo: document.body,
|
|
88
89
|
preset: new Preset<LightEditorPlugin>()
|
|
89
90
|
.add([featureFlagsPlugin, {}])
|
|
91
|
+
.add(editorDisabledPlugin)
|
|
90
92
|
.add([analyticsPlugin, {}])
|
|
91
93
|
.add(contentInsertionPlugin)
|
|
92
94
|
.add(decorationsPlugin)
|
|
@@ -36,6 +36,7 @@ import { TableCssClassName as ClassName } from '../../plugins/table/types';
|
|
|
36
36
|
import tablePlugin from '../../plugins/table-plugin';
|
|
37
37
|
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
38
38
|
import floatingToolbarPlugin from '@atlaskit/editor-core/src/plugins/floating-toolbar';
|
|
39
|
+
import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
|
|
39
40
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
40
41
|
import { gridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
41
42
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
@@ -167,6 +168,7 @@ describe('table event handlers', () => {
|
|
|
167
168
|
attachTo: document.body,
|
|
168
169
|
preset: new Preset<LightEditorPlugin>()
|
|
169
170
|
.add([featureFlagsPlugin, {}])
|
|
171
|
+
.add(editorDisabledPlugin)
|
|
170
172
|
.add([analyticsPlugin, {}])
|
|
171
173
|
.add(contentInsertionPlugin)
|
|
172
174
|
.add(decorationsPlugin)
|
|
@@ -56,6 +56,7 @@ import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatt
|
|
|
56
56
|
import deprecatedAnalyticsPlugin from '@atlaskit/editor-core/src/plugins/analytics';
|
|
57
57
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
58
58
|
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
59
|
+
import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
|
|
59
60
|
import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
|
|
60
61
|
import floatingToolbarPlugin from '@atlaskit/editor-core/src/plugins/floating-toolbar';
|
|
61
62
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -101,6 +102,7 @@ describe('table plugin', () => {
|
|
|
101
102
|
.add([featureFlagsPlugin, {}])
|
|
102
103
|
.add([analyticsPlugin, {}])
|
|
103
104
|
.add([deprecatedAnalyticsPlugin, {}])
|
|
105
|
+
.add(editorDisabledPlugin)
|
|
104
106
|
.add(contentInsertionPlugin)
|
|
105
107
|
.add(decorationsPlugin)
|
|
106
108
|
.add(widthPlugin)
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
p,
|
|
3
|
+
table,
|
|
4
|
+
tr,
|
|
5
|
+
td,
|
|
6
|
+
th,
|
|
7
|
+
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
2
8
|
import defaultSchema from '@atlaskit/editor-test-helpers/schema';
|
|
3
9
|
import { isMinCellWidthTable } from '../../../../plugins/table/pm-plugins/table-resizing/utils/colgroup';
|
|
4
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
generateColgroup,
|
|
12
|
+
getColgroupChildrenLength,
|
|
13
|
+
} from '../../../../plugins/table/pm-plugins/table-resizing/utils';
|
|
5
14
|
|
|
6
15
|
describe('table-resizing/colgroup', () => {
|
|
7
16
|
describe('#generateColgroup', () => {
|
|
@@ -121,4 +130,41 @@ describe('table-resizing/colgroup', () => {
|
|
|
121
130
|
}
|
|
122
131
|
});
|
|
123
132
|
});
|
|
133
|
+
|
|
134
|
+
describe('#getColgroupChildrenLength', () => {
|
|
135
|
+
it('returns 1 when table only have 1 column', () => {
|
|
136
|
+
expect(
|
|
137
|
+
getColgroupChildrenLength(table()(tr(td()(p(''))))(defaultSchema)),
|
|
138
|
+
).toBe(1);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('returns 3 when table have 3 column', () => {
|
|
142
|
+
expect(
|
|
143
|
+
getColgroupChildrenLength(
|
|
144
|
+
table()(tr(td()(p('')), td()(p('')), td()(p(''))))(defaultSchema),
|
|
145
|
+
),
|
|
146
|
+
).toBe(3);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('returns 5 when table have 5 column', () => {
|
|
150
|
+
expect(
|
|
151
|
+
getColgroupChildrenLength(
|
|
152
|
+
table()(
|
|
153
|
+
tr(td()(p('')), td()(p('')), td()(p('')), td()(p('')), td()(p(''))),
|
|
154
|
+
)(defaultSchema),
|
|
155
|
+
),
|
|
156
|
+
).toBe(5);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('returns correct number when table have merged header column', () => {
|
|
160
|
+
expect(
|
|
161
|
+
getColgroupChildrenLength(
|
|
162
|
+
table()(
|
|
163
|
+
tr(th({ colspan: 2 })(p('')), th()(p(''))),
|
|
164
|
+
tr(td()(p('')), td()(p('')), td()(p(''))),
|
|
165
|
+
)(defaultSchema),
|
|
166
|
+
),
|
|
167
|
+
).toBe(3);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
124
170
|
});
|
|
@@ -38,7 +38,8 @@ describe('Snapshot Test: Table', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
describe('sticky header', () => {
|
|
41
|
-
|
|
41
|
+
// FIXME: This test was automatically skipped due to failure on 21/06/2023: https://product-fabric.atlassian.net/browse/ED-18903
|
|
42
|
+
it.skip('should align with table cell when active', async () => {
|
|
42
43
|
await initEditor(page, stickyHeaderWithHorizontalScroll);
|
|
43
44
|
|
|
44
45
|
await clickFirstCell(page, true);
|
|
@@ -8,6 +8,9 @@ import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
|
8
8
|
import {
|
|
9
9
|
scaleTable,
|
|
10
10
|
previewScaleTable,
|
|
11
|
+
getColgroupChildrenLength,
|
|
12
|
+
COLUMN_MIN_WIDTH,
|
|
13
|
+
TABLE_MAX_WIDTH,
|
|
11
14
|
} from '../pm-plugins/table-resizing/utils';
|
|
12
15
|
|
|
13
16
|
interface TableResizerProps {
|
|
@@ -30,6 +33,12 @@ export const TableResizer = ({
|
|
|
30
33
|
node,
|
|
31
34
|
tableRef,
|
|
32
35
|
}: PropsWithChildren<TableResizerProps>) => {
|
|
36
|
+
const currentColumnCount = getColgroupChildrenLength(node);
|
|
37
|
+
const minColumnWidth =
|
|
38
|
+
currentColumnCount <= 3
|
|
39
|
+
? currentColumnCount * COLUMN_MIN_WIDTH
|
|
40
|
+
: 3 * COLUMN_MIN_WIDTH;
|
|
41
|
+
|
|
33
42
|
return (
|
|
34
43
|
<ResizerNext
|
|
35
44
|
enable={handles}
|
|
@@ -81,6 +90,8 @@ export const TableResizer = ({
|
|
|
81
90
|
return newWidth;
|
|
82
91
|
}}
|
|
83
92
|
resizeRatio={2}
|
|
93
|
+
minWidth={minColumnWidth}
|
|
94
|
+
maxWidth={TABLE_MAX_WIDTH}
|
|
84
95
|
>
|
|
85
96
|
{children}
|
|
86
97
|
</ResizerNext>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DOMSerializer, Node as PmNode } from 'prosemirror-model';
|
|
2
2
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
|
+
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
5
|
|
|
5
6
|
type Col = Array<string | { [name: string]: string }>;
|
|
6
7
|
|
|
@@ -74,3 +75,8 @@ function renderColgroupFromNode(table: PmNode): HTMLElement {
|
|
|
74
75
|
|
|
75
76
|
return rendered.dom as HTMLElement;
|
|
76
77
|
}
|
|
78
|
+
|
|
79
|
+
export const getColgroupChildrenLength = (table: PmNode): number => {
|
|
80
|
+
const map = TableMap.get(table);
|
|
81
|
+
return map.width;
|
|
82
|
+
};
|
|
@@ -2,6 +2,7 @@ export {
|
|
|
2
2
|
generateColgroup,
|
|
3
3
|
insertColgroupFromNode,
|
|
4
4
|
hasTableBeenResized,
|
|
5
|
+
getColgroupChildrenLength,
|
|
5
6
|
} from './colgroup';
|
|
6
7
|
export { contentWidth } from './content-width';
|
|
7
8
|
export {
|
|
@@ -39,3 +40,4 @@ export {
|
|
|
39
40
|
export type { ScaleOptions } from './scale-table';
|
|
40
41
|
export type { ResizeState, ResizeStateWithAnalytics } from './types';
|
|
41
42
|
export { resizeColumn } from './resize-column';
|
|
43
|
+
export { COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from './consts';
|