@atlaskit/editor-plugin-table 1.6.9 → 1.7.0
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 +10 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +48 -21
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +44 -19
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +48 -21
- package/dist/esm/version.json +1 -1
- package/package.json +4 -4
- package/src/plugins/table/nodeviews/TableComponent.tsx +6 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +46 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`cb69e6847ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb69e6847ec) - [ux] The table colgroup will always set the width to the min width when the custom-table-width flag is enabled
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 1.6.9
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -32,6 +32,7 @@ var _updateOverflowShadows = require("./update-overflow-shadows");
|
|
|
32
32
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
33
33
|
var _OverflowShadowsObserver = require("./OverflowShadowsObserver");
|
|
34
34
|
var _TableContainer = require("./TableContainer");
|
|
35
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
35
36
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
36
37
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty3.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
37
38
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -135,7 +136,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
135
136
|
// Usually happens on window resize.
|
|
136
137
|
layoutSize !== _this.layoutSize || noOfColumnsChanged) {
|
|
137
138
|
// If column has been inserted/deleted avoid multi dispatch
|
|
138
|
-
if (!hasNumberedColumnChanged && !noOfColumnsChanged) {
|
|
139
|
+
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') && !hasNumberedColumnChanged && !noOfColumnsChanged) {
|
|
139
140
|
_this.scaleTable({
|
|
140
141
|
parentWidth: parentWidth,
|
|
141
142
|
layoutChanged: layoutChanged
|
|
@@ -10,29 +10,56 @@ var _prosemirrorModel = require("prosemirror-model");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
12
12
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var generateColgroup = function generateColgroup(table) {
|
|
14
15
|
var cols = [];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width')) {
|
|
17
|
+
table.content.firstChild.content.forEach(function (cell) {
|
|
18
|
+
var colspan = cell.attrs.colspan || 1;
|
|
19
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
20
|
+
// We slice here to guard against our colwidth array having more entries
|
|
21
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
22
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
23
|
+
cols.push(['col', {
|
|
24
|
+
style: "width: ".concat(width ? Math.max(width, _styles.tableCellMinWidth) : _styles.tableCellMinWidth, "px;")
|
|
25
|
+
}]);
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
// When we have merged cells on the first row (firstChild),
|
|
29
|
+
// We want to ensure we're creating the appropriate amount of
|
|
30
|
+
// cols the table still has.
|
|
31
|
+
cols.push.apply(cols, (0, _toConsumableArray2.default)(Array.from({
|
|
32
|
+
length: colspan
|
|
33
|
+
}, function (_) {
|
|
34
|
+
return ['col', {
|
|
35
|
+
style: "width: ".concat(_styles.tableCellMinWidth, "px;")
|
|
36
|
+
}];
|
|
37
|
+
})));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
table.content.firstChild.content.forEach(function (cell) {
|
|
42
|
+
var colspan = cell.attrs.colspan || 1;
|
|
43
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
44
|
+
// We slice here to guard against our colwidth array having more entries
|
|
45
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
46
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
47
|
+
cols.push(['col', width ? {
|
|
48
|
+
style: "width: ".concat(width, "px;")
|
|
49
|
+
} : {}]);
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
// When we have merged cells on the first row (firstChild),
|
|
53
|
+
// We want to ensure we're creating the appropriate amount of
|
|
54
|
+
// cols the table still has.
|
|
55
|
+
cols.push.apply(cols, (0, _toConsumableArray2.default)(Array.from({
|
|
56
|
+
length: colspan
|
|
57
|
+
}, function (_) {
|
|
58
|
+
return ['col', {}];
|
|
59
|
+
})));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
36
63
|
return cols;
|
|
37
64
|
};
|
|
38
65
|
exports.generateColgroup = generateColgroup;
|
package/dist/cjs/version.json
CHANGED
|
@@ -20,6 +20,7 @@ import { updateOverflowShadows } from './update-overflow-shadows';
|
|
|
20
20
|
import memoizeOne from 'memoize-one';
|
|
21
21
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
22
22
|
import { TableContainer } from './TableContainer';
|
|
23
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
23
24
|
const isIE11 = browser.ie_version === 11;
|
|
24
25
|
const NOOP = () => undefined;
|
|
25
26
|
class TableComponent extends React.Component {
|
|
@@ -121,7 +122,7 @@ class TableComponent extends React.Component {
|
|
|
121
122
|
// Usually happens on window resize.
|
|
122
123
|
layoutSize !== this.layoutSize || noOfColumnsChanged) {
|
|
123
124
|
// If column has been inserted/deleted avoid multi dispatch
|
|
124
|
-
if (!hasNumberedColumnChanged && !noOfColumnsChanged) {
|
|
125
|
+
if (!getBooleanFF('platform.editor.custom-table-width') && !hasNumberedColumnChanged && !noOfColumnsChanged) {
|
|
125
126
|
this.scaleTable({
|
|
126
127
|
parentWidth,
|
|
127
128
|
layoutChanged
|
|
@@ -2,27 +2,52 @@ import { DOMSerializer } from 'prosemirror-model';
|
|
|
2
2
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
export const generateColgroup = table => {
|
|
6
7
|
const cols = [];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
9
|
+
table.content.firstChild.content.forEach(cell => {
|
|
10
|
+
const colspan = cell.attrs.colspan || 1;
|
|
11
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
12
|
+
// We slice here to guard against our colwidth array having more entries
|
|
13
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
14
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(width => {
|
|
15
|
+
cols.push(['col', {
|
|
16
|
+
style: `width: ${width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth}px;`
|
|
17
|
+
}]);
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
// When we have merged cells on the first row (firstChild),
|
|
21
|
+
// We want to ensure we're creating the appropriate amount of
|
|
22
|
+
// cols the table still has.
|
|
23
|
+
cols.push(...Array.from({
|
|
24
|
+
length: colspan
|
|
25
|
+
}, _ => ['col', {
|
|
26
|
+
style: `width: ${tableCellMinWidth}px;`
|
|
27
|
+
}]));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
table.content.firstChild.content.forEach(cell => {
|
|
32
|
+
const colspan = cell.attrs.colspan || 1;
|
|
33
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
34
|
+
// We slice here to guard against our colwidth array having more entries
|
|
35
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
36
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(width => {
|
|
37
|
+
cols.push(['col', width ? {
|
|
38
|
+
style: `width: ${width}px;`
|
|
39
|
+
} : {}]);
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
// When we have merged cells on the first row (firstChild),
|
|
43
|
+
// We want to ensure we're creating the appropriate amount of
|
|
44
|
+
// cols the table still has.
|
|
45
|
+
cols.push(...Array.from({
|
|
46
|
+
length: colspan
|
|
47
|
+
}, _ => ['col', {}]));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
26
51
|
return cols;
|
|
27
52
|
};
|
|
28
53
|
export const insertColgroupFromNode = (tableRef, table) => {
|
package/dist/es2019/version.json
CHANGED
|
@@ -30,6 +30,7 @@ import { updateOverflowShadows } from './update-overflow-shadows';
|
|
|
30
30
|
import memoizeOne from 'memoize-one';
|
|
31
31
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
32
32
|
import { TableContainer } from './TableContainer';
|
|
33
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
33
34
|
var isIE11 = browser.ie_version === 11;
|
|
34
35
|
var NOOP = function NOOP() {
|
|
35
36
|
return undefined;
|
|
@@ -129,7 +130,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
129
130
|
// Usually happens on window resize.
|
|
130
131
|
layoutSize !== _this.layoutSize || noOfColumnsChanged) {
|
|
131
132
|
// If column has been inserted/deleted avoid multi dispatch
|
|
132
|
-
if (!hasNumberedColumnChanged && !noOfColumnsChanged) {
|
|
133
|
+
if (!getBooleanFF('platform.editor.custom-table-width') && !hasNumberedColumnChanged && !noOfColumnsChanged) {
|
|
133
134
|
_this.scaleTable({
|
|
134
135
|
parentWidth: parentWidth,
|
|
135
136
|
layoutChanged: layoutChanged
|
|
@@ -3,29 +3,56 @@ import { DOMSerializer } from 'prosemirror-model';
|
|
|
3
3
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
5
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
export var generateColgroup = function generateColgroup(table) {
|
|
7
8
|
var cols = [];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
10
|
+
table.content.firstChild.content.forEach(function (cell) {
|
|
11
|
+
var colspan = cell.attrs.colspan || 1;
|
|
12
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
13
|
+
// We slice here to guard against our colwidth array having more entries
|
|
14
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
15
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
16
|
+
cols.push(['col', {
|
|
17
|
+
style: "width: ".concat(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, "px;")
|
|
18
|
+
}]);
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
// When we have merged cells on the first row (firstChild),
|
|
22
|
+
// We want to ensure we're creating the appropriate amount of
|
|
23
|
+
// cols the table still has.
|
|
24
|
+
cols.push.apply(cols, _toConsumableArray(Array.from({
|
|
25
|
+
length: colspan
|
|
26
|
+
}, function (_) {
|
|
27
|
+
return ['col', {
|
|
28
|
+
style: "width: ".concat(tableCellMinWidth, "px;")
|
|
29
|
+
}];
|
|
30
|
+
})));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
table.content.firstChild.content.forEach(function (cell) {
|
|
35
|
+
var colspan = cell.attrs.colspan || 1;
|
|
36
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
37
|
+
// We slice here to guard against our colwidth array having more entries
|
|
38
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
39
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
40
|
+
cols.push(['col', width ? {
|
|
41
|
+
style: "width: ".concat(width, "px;")
|
|
42
|
+
} : {}]);
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
// When we have merged cells on the first row (firstChild),
|
|
46
|
+
// We want to ensure we're creating the appropriate amount of
|
|
47
|
+
// cols the table still has.
|
|
48
|
+
cols.push.apply(cols, _toConsumableArray(Array.from({
|
|
49
|
+
length: colspan
|
|
50
|
+
}, function (_) {
|
|
51
|
+
return ['col', {}];
|
|
52
|
+
})));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
29
56
|
return cols;
|
|
30
57
|
};
|
|
31
58
|
export var insertColgroupFromNode = function insertColgroupFromNode(tableRef, table) {
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^25.10.0",
|
|
31
|
-
"@atlaskit/editor-common": "^74.
|
|
31
|
+
"@atlaskit/editor-common": "^74.12.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.0.3",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.0.3",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@atlaskit/icon": "^21.12.0",
|
|
38
38
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
39
39
|
"@atlaskit/theme": "^12.5.0",
|
|
40
|
-
"@atlaskit/tokens": "^1.
|
|
40
|
+
"@atlaskit/tokens": "^1.11.0",
|
|
41
41
|
"@atlaskit/tooltip": "^17.8.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"@emotion/react": "^11.7.1",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@af/editor-libra": "*",
|
|
66
66
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
67
67
|
"@atlaskit/button": "^16.8.0",
|
|
68
|
-
"@atlaskit/editor-core": "^185.
|
|
68
|
+
"@atlaskit/editor-core": "^185.6.0",
|
|
69
69
|
"@atlaskit/editor-plugin-decorations": "^0.1.0",
|
|
70
70
|
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
71
71
|
"@atlaskit/editor-plugin-grid": "^0.1.0",
|
|
@@ -52,6 +52,7 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
|
52
52
|
import memoizeOne from 'memoize-one';
|
|
53
53
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
54
54
|
import { TableContainer } from './TableContainer';
|
|
55
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
55
56
|
|
|
56
57
|
const isIE11 = browser.ie_version === 11;
|
|
57
58
|
const NOOP = () => undefined;
|
|
@@ -550,7 +551,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
550
551
|
noOfColumnsChanged
|
|
551
552
|
) {
|
|
552
553
|
// If column has been inserted/deleted avoid multi dispatch
|
|
553
|
-
if (
|
|
554
|
+
if (
|
|
555
|
+
!getBooleanFF('platform.editor.custom-table-width') &&
|
|
556
|
+
!hasNumberedColumnChanged &&
|
|
557
|
+
!noOfColumnsChanged
|
|
558
|
+
) {
|
|
554
559
|
this.scaleTable({ parentWidth, layoutChanged });
|
|
555
560
|
}
|
|
556
561
|
this.updateParentWidth(parentWidth);
|
|
@@ -2,27 +2,58 @@ 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
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
|
|
6
7
|
type Col = Array<string | { [name: string]: string }>;
|
|
7
8
|
|
|
8
9
|
export const generateColgroup = (table: PmNode): Col[] => {
|
|
9
10
|
const cols: Col[] = [];
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
13
|
+
table.content.firstChild!.content.forEach((cell) => {
|
|
14
|
+
const colspan = cell.attrs.colspan || 1;
|
|
15
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
16
|
+
// We slice here to guard against our colwidth array having more entries
|
|
17
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
18
|
+
cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
|
|
19
|
+
cols.push([
|
|
20
|
+
'col',
|
|
21
|
+
{
|
|
22
|
+
style: `width: ${
|
|
23
|
+
width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth
|
|
24
|
+
}px;`,
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
// When we have merged cells on the first row (firstChild),
|
|
30
|
+
// We want to ensure we're creating the appropriate amount of
|
|
31
|
+
// cols the table still has.
|
|
32
|
+
cols.push(
|
|
33
|
+
...Array.from({ length: colspan }, (_) => [
|
|
34
|
+
'col',
|
|
35
|
+
{ style: `width: ${tableCellMinWidth}px;` },
|
|
36
|
+
]),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
table.content.firstChild!.content.forEach((cell) => {
|
|
42
|
+
const colspan = cell.attrs.colspan || 1;
|
|
43
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
44
|
+
// We slice here to guard against our colwidth array having more entries
|
|
45
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
46
|
+
cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
|
|
47
|
+
cols.push(['col', width ? { style: `width: ${width}px;` } : {}]);
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
// When we have merged cells on the first row (firstChild),
|
|
51
|
+
// We want to ensure we're creating the appropriate amount of
|
|
52
|
+
// cols the table still has.
|
|
53
|
+
cols.push(...Array.from({ length: colspan }, (_) => ['col', {}]));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
26
57
|
|
|
27
58
|
return cols;
|
|
28
59
|
};
|