@atlaskit/editor-plugin-table 7.28.6 → 7.28.8
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 +14 -0
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +9 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/index.js +6 -0
- package/dist/cjs/toDOM.js +3 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +8 -0
- package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/es2019/toDOM.js +4 -3
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +8 -0
- package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
- package/dist/esm/toDOM.js +4 -3
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
- package/package.json +6 -6
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +9 -0
- package/src/pm-plugins/table-resizing/utils/index.ts +1 -0
- package/src/toDOM.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.28.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#150410](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/150410)
|
|
8
|
+
[`aabd4874bd3a0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/aabd4874bd3a0) -
|
|
9
|
+
set correct min-width value in table lazy load view
|
|
10
|
+
|
|
11
|
+
## 7.28.7
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 7.28.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -4,12 +4,13 @@ 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.hasTableColumnBeenResized = exports.hasTableBeenResized = exports.getColgroupChildrenLength = exports.getColWidthFix = exports.generateColgroup = void 0;
|
|
7
|
+
exports.isMinCellWidthTable = exports.insertColgroupFromNode = exports.hasTableColumnBeenResized = exports.hasTableBeenResized = exports.getResizerMinWidth = exports.getColgroupChildrenLength = exports.getColWidthFix = exports.generateColgroup = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
12
12
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
+
var _consts = require("./consts");
|
|
13
14
|
var _misc = require("./misc");
|
|
14
15
|
/**
|
|
15
16
|
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
@@ -109,4 +110,11 @@ function renderColgroupFromNode(table, maybeTableRef, shouldUseIncreasedScalingP
|
|
|
109
110
|
var getColgroupChildrenLength = exports.getColgroupChildrenLength = function getColgroupChildrenLength(table) {
|
|
110
111
|
var map = _tableMap.TableMap.get(table);
|
|
111
112
|
return map.width;
|
|
113
|
+
};
|
|
114
|
+
var getResizerMinWidth = exports.getResizerMinWidth = function getResizerMinWidth(node) {
|
|
115
|
+
var currentColumnCount = getColgroupChildrenLength(node);
|
|
116
|
+
var minColumnWidth = Math.min(3, currentColumnCount) * _consts.COLUMN_MIN_WIDTH;
|
|
117
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
118
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
119
|
+
return minColumnWidth + 1;
|
|
112
120
|
};
|
|
@@ -81,6 +81,12 @@ Object.defineProperty(exports, "getResizeState", {
|
|
|
81
81
|
return _resizeState.getResizeState;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
+
Object.defineProperty(exports, "getResizerMinWidth", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _colgroup.getResizerMinWidth;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
84
90
|
Object.defineProperty(exports, "getTableContainerElementWidth", {
|
|
85
91
|
enumerable: true,
|
|
86
92
|
get: function get() {
|
package/dist/cjs/toDOM.js
CHANGED
|
@@ -33,6 +33,7 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
33
33
|
v = _ref2[1];
|
|
34
34
|
return "".concat((0, _kebabCase.default)(k), ": ").concat((0, _kebabCase.default)(v));
|
|
35
35
|
}).join(';');
|
|
36
|
+
var tableMinWidth = (0, _colgroup.getResizerMinWidth)(node);
|
|
36
37
|
var attrs = _objectSpread({
|
|
37
38
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
38
39
|
'data-layout': node.attrs.layout,
|
|
@@ -91,7 +92,7 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
91
92
|
boxSizing: 'border-box',
|
|
92
93
|
'--ak-editor-table-gutter-padding': "".concat(gutterPadding, "px"),
|
|
93
94
|
'--ak-editor-table-max-width': "".concat(_consts.TABLE_MAX_WIDTH, "px"),
|
|
94
|
-
'--ak-editor-table-min-width': "
|
|
95
|
+
'--ak-editor-table-min-width': "".concat(tableMinWidth, "px"),
|
|
95
96
|
minWidth: 'var(--ak-editor-table-min-width)',
|
|
96
97
|
maxWidth: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))",
|
|
97
98
|
width: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(node.attrs.width, ")")
|
|
@@ -100,7 +101,7 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
|
|
|
100
101
|
userSelect: 'auto',
|
|
101
102
|
boxSizing: 'border-box',
|
|
102
103
|
height: 'auto',
|
|
103
|
-
minWidth:
|
|
104
|
+
minWidth: "".concat(tableMinWidth, "px"),
|
|
104
105
|
maxWidth: "".concat(editorWidthFromGetter, "px"),
|
|
105
106
|
width: "".concat(editorWidthFromGetter, "px;")
|
|
106
107
|
})
|
|
@@ -2,6 +2,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
2
2
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
|
+
import { COLUMN_MIN_WIDTH } from './consts';
|
|
5
6
|
import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './misc';
|
|
6
7
|
/**
|
|
7
8
|
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
@@ -91,4 +92,11 @@ function renderColgroupFromNode(table, maybeTableRef, shouldUseIncreasedScalingP
|
|
|
91
92
|
export const getColgroupChildrenLength = table => {
|
|
92
93
|
const map = TableMap.get(table);
|
|
93
94
|
return map.width;
|
|
95
|
+
};
|
|
96
|
+
export const getResizerMinWidth = node => {
|
|
97
|
+
const currentColumnCount = getColgroupChildrenLength(node);
|
|
98
|
+
const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
|
|
99
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
100
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
101
|
+
return minColumnWidth + 1;
|
|
94
102
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, getResizerMinWidth } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getCellsRefsInColumn, calculateColumnWidth } from './column-state';
|
|
4
4
|
export { getResizeState, updateColgroup, evenAllColumnsWidths } from './resize-state';
|
package/dist/es2019/toDOM.js
CHANGED
|
@@ -5,7 +5,7 @@ import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
7
|
import { getAlignmentStyle } from './nodeviews/table-container-styles';
|
|
8
|
-
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
8
|
+
import { generateColgroup, getResizerMinWidth } from './pm-plugins/table-resizing/utils/colgroup';
|
|
9
9
|
import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
|
|
10
10
|
export const tableNodeSpecWithFixedToDOM = config => {
|
|
11
11
|
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
@@ -17,6 +17,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
17
17
|
const gutterPadding = akEditorGutterPaddingDynamic() * 2;
|
|
18
18
|
const editorWidthFromGetter = fg('platform_editor_breakout_use_css') ? undefined : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
|
|
19
19
|
const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`).join(';');
|
|
20
|
+
const tableMinWidth = getResizerMinWidth(node);
|
|
20
21
|
const attrs = {
|
|
21
22
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
22
23
|
'data-layout': node.attrs.layout,
|
|
@@ -76,7 +77,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
76
77
|
boxSizing: 'border-box',
|
|
77
78
|
'--ak-editor-table-gutter-padding': `${gutterPadding}px`,
|
|
78
79
|
'--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
|
|
79
|
-
'--ak-editor-table-min-width':
|
|
80
|
+
'--ak-editor-table-min-width': `${tableMinWidth}px`,
|
|
80
81
|
minWidth: 'var(--ak-editor-table-min-width)',
|
|
81
82
|
maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
|
|
82
83
|
width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${node.attrs.width})`
|
|
@@ -85,7 +86,7 @@ export const tableNodeSpecWithFixedToDOM = config => {
|
|
|
85
86
|
userSelect: 'auto',
|
|
86
87
|
boxSizing: 'border-box',
|
|
87
88
|
height: 'auto',
|
|
88
|
-
minWidth:
|
|
89
|
+
minWidth: `${tableMinWidth}px`,
|
|
89
90
|
maxWidth: `${editorWidthFromGetter}px`,
|
|
90
91
|
width: `${editorWidthFromGetter}px;`
|
|
91
92
|
})
|
|
@@ -3,6 +3,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
3
3
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
|
+
import { COLUMN_MIN_WIDTH } from './consts';
|
|
6
7
|
import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './misc';
|
|
7
8
|
/**
|
|
8
9
|
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
@@ -102,4 +103,11 @@ function renderColgroupFromNode(table, maybeTableRef, shouldUseIncreasedScalingP
|
|
|
102
103
|
export var getColgroupChildrenLength = function getColgroupChildrenLength(table) {
|
|
103
104
|
var map = TableMap.get(table);
|
|
104
105
|
return map.width;
|
|
106
|
+
};
|
|
107
|
+
export var getResizerMinWidth = function getResizerMinWidth(node) {
|
|
108
|
+
var currentColumnCount = getColgroupChildrenLength(node);
|
|
109
|
+
var minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
|
|
110
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
111
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
112
|
+
return minColumnWidth + 1;
|
|
105
113
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, getResizerMinWidth } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getCellsRefsInColumn, calculateColumnWidth } from './column-state';
|
|
4
4
|
export { getResizeState, updateColgroup, evenAllColumnsWidths } from './resize-state';
|
package/dist/esm/toDOM.js
CHANGED
|
@@ -10,7 +10,7 @@ import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
|
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
12
|
import { getAlignmentStyle } from './nodeviews/table-container-styles';
|
|
13
|
-
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
13
|
+
import { generateColgroup, getResizerMinWidth } from './pm-plugins/table-resizing/utils/colgroup';
|
|
14
14
|
import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
|
|
15
15
|
export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
|
|
16
16
|
if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
|
|
@@ -26,6 +26,7 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
|
|
|
26
26
|
v = _ref2[1];
|
|
27
27
|
return "".concat(kebabCase(k), ": ").concat(kebabCase(v));
|
|
28
28
|
}).join(';');
|
|
29
|
+
var tableMinWidth = getResizerMinWidth(node);
|
|
29
30
|
var attrs = _objectSpread({
|
|
30
31
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
31
32
|
'data-layout': node.attrs.layout,
|
|
@@ -84,7 +85,7 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
|
|
|
84
85
|
boxSizing: 'border-box',
|
|
85
86
|
'--ak-editor-table-gutter-padding': "".concat(gutterPadding, "px"),
|
|
86
87
|
'--ak-editor-table-max-width': "".concat(TABLE_MAX_WIDTH, "px"),
|
|
87
|
-
'--ak-editor-table-min-width': "
|
|
88
|
+
'--ak-editor-table-min-width': "".concat(tableMinWidth, "px"),
|
|
88
89
|
minWidth: 'var(--ak-editor-table-min-width)',
|
|
89
90
|
maxWidth: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))",
|
|
90
91
|
width: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(node.attrs.width, ")")
|
|
@@ -93,7 +94,7 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
|
|
|
93
94
|
userSelect: 'auto',
|
|
94
95
|
boxSizing: 'border-box',
|
|
95
96
|
height: 'auto',
|
|
96
|
-
minWidth:
|
|
97
|
+
minWidth: "".concat(tableMinWidth, "px"),
|
|
97
98
|
maxWidth: "".concat(editorWidthFromGetter, "px"),
|
|
98
99
|
width: "".concat(editorWidthFromGetter, "px;")
|
|
99
100
|
})
|
|
@@ -21,4 +21,5 @@ export declare const hasTableColumnBeenResized: (table: PmNode) => boolean;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const isMinCellWidthTable: (table: PmNode) => boolean;
|
|
23
23
|
export declare const getColgroupChildrenLength: (table: PmNode) => number;
|
|
24
|
+
export declare const getResizerMinWidth: (node: PmNode) => number;
|
|
24
25
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, getResizerMinWidth, } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getCellsRefsInColumn, calculateColumnWidth } from './column-state';
|
|
4
4
|
export { getResizeState, updateColgroup, evenAllColumnsWidths } from './resize-state';
|
|
@@ -21,4 +21,5 @@ export declare const hasTableColumnBeenResized: (table: PmNode) => boolean;
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const isMinCellWidthTable: (table: PmNode) => boolean;
|
|
23
23
|
export declare const getColgroupChildrenLength: (table: PmNode) => number;
|
|
24
|
+
export declare const getResizerMinWidth: (node: PmNode) => number;
|
|
24
25
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, } from './colgroup';
|
|
1
|
+
export { generateColgroup, insertColgroupFromNode, hasTableBeenResized, getColgroupChildrenLength, getResizerMinWidth, } from './colgroup';
|
|
2
2
|
export { contentWidth } from './content-width';
|
|
3
3
|
export { getCellsRefsInColumn, calculateColumnWidth } from './column-state';
|
|
4
4
|
export { getResizeState, updateColgroup, evenAllColumnsWidths } from './resize-state';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "7.28.
|
|
3
|
+
"version": "7.28.8",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"@atlaskit/adf-schema": "^40.9.0",
|
|
31
31
|
"@atlaskit/button": "^20.2.0",
|
|
32
32
|
"@atlaskit/custom-steps": "^0.7.0",
|
|
33
|
-
"@atlaskit/editor-common": "^
|
|
33
|
+
"@atlaskit/editor-common": "^93.1.0",
|
|
34
34
|
"@atlaskit/editor-palette": "1.6.1",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
37
|
-
"@atlaskit/editor-plugin-batch-attribute-updates": "1.0.
|
|
37
|
+
"@atlaskit/editor-plugin-batch-attribute-updates": "1.0.8",
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^1.8.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-guideline": "^1.2.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^3.0.0",
|
|
45
45
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
46
|
-
"@atlaskit/icon": "^22.
|
|
46
|
+
"@atlaskit/icon": "^22.22.0",
|
|
47
47
|
"@atlaskit/menu": "^2.12.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
49
49
|
"@atlaskit/pragmatic-drag-and-drop": "^1.3.0",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
|
|
52
52
|
"@atlaskit/primitives": "^12.2.0",
|
|
53
53
|
"@atlaskit/theme": "^13.0.0",
|
|
54
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
54
|
+
"@atlaskit/tmp-editor-statsig": "^2.3.0",
|
|
55
55
|
"@atlaskit/toggle": "^13.4.0",
|
|
56
56
|
"@atlaskit/tokens": "^2.0.0",
|
|
57
|
-
"@atlaskit/tooltip": "^18.
|
|
57
|
+
"@atlaskit/tooltip": "^18.8.0",
|
|
58
58
|
"@babel/runtime": "^7.0.0",
|
|
59
59
|
"@emotion/react": "^11.7.1",
|
|
60
60
|
"classnames": "^2.2.5",
|
|
@@ -4,6 +4,7 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
6
|
|
|
7
|
+
import { COLUMN_MIN_WIDTH } from './consts';
|
|
7
8
|
import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './misc';
|
|
8
9
|
|
|
9
10
|
type Col = Array<string | { [name: string]: string }>;
|
|
@@ -152,3 +153,11 @@ export const getColgroupChildrenLength = (table: PmNode): number => {
|
|
|
152
153
|
const map = TableMap.get(table);
|
|
153
154
|
return map.width;
|
|
154
155
|
};
|
|
156
|
+
|
|
157
|
+
export const getResizerMinWidth = (node: PmNode) => {
|
|
158
|
+
const currentColumnCount = getColgroupChildrenLength(node);
|
|
159
|
+
const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
|
|
160
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
161
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
162
|
+
return minColumnWidth + 1;
|
|
163
|
+
};
|
package/src/toDOM.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
9
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
10
|
|
|
11
11
|
import { getAlignmentStyle } from './nodeviews/table-container-styles';
|
|
12
|
-
import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
|
|
12
|
+
import { generateColgroup, getResizerMinWidth } from './pm-plugins/table-resizing/utils/colgroup';
|
|
13
13
|
import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
|
|
14
14
|
|
|
15
15
|
type Config = {
|
|
@@ -34,6 +34,8 @@ export const tableNodeSpecWithFixedToDOM = (config: Config): typeof table => {
|
|
|
34
34
|
.map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`)
|
|
35
35
|
.join(';');
|
|
36
36
|
|
|
37
|
+
const tableMinWidth = getResizerMinWidth(node);
|
|
38
|
+
|
|
37
39
|
const attrs = {
|
|
38
40
|
'data-number-column': node.attrs.isNumberColumnEnabled,
|
|
39
41
|
'data-layout': node.attrs.layout,
|
|
@@ -145,7 +147,7 @@ export const tableNodeSpecWithFixedToDOM = (config: Config): typeof table => {
|
|
|
145
147
|
boxSizing: 'border-box',
|
|
146
148
|
'--ak-editor-table-gutter-padding': `${gutterPadding}px`,
|
|
147
149
|
'--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
|
|
148
|
-
'--ak-editor-table-min-width':
|
|
150
|
+
'--ak-editor-table-min-width': `${tableMinWidth}px`,
|
|
149
151
|
minWidth: 'var(--ak-editor-table-min-width)',
|
|
150
152
|
maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
|
|
151
153
|
width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${node.attrs.width})`,
|
|
@@ -155,7 +157,7 @@ export const tableNodeSpecWithFixedToDOM = (config: Config): typeof table => {
|
|
|
155
157
|
userSelect: 'auto',
|
|
156
158
|
boxSizing: 'border-box',
|
|
157
159
|
height: 'auto',
|
|
158
|
-
minWidth:
|
|
160
|
+
minWidth: `${tableMinWidth}px`,
|
|
159
161
|
maxWidth: `${editorWidthFromGetter}px`,
|
|
160
162
|
width: `${editorWidthFromGetter}px;`,
|
|
161
163
|
}),
|