@atlaskit/editor-plugin-table 2.8.6 → 2.9.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 +15 -0
- package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +6 -6
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +3 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +13 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +21 -8
- package/dist/cjs/plugins/table/ui/common-styles.js +12 -4
- package/dist/cjs/plugins/table/ui/consts.js +3 -1
- package/dist/cjs/plugins/table/ui/ui-styles.js +16 -7
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +6 -6
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +9 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +18 -7
- package/dist/es2019/plugins/table/ui/common-styles.js +27 -9
- package/dist/es2019/plugins/table/ui/consts.js +1 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +51 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +6 -6
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +11 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +22 -9
- package/dist/esm/plugins/table/ui/common-styles.js +12 -4
- package/dist/esm/plugins/table/ui/consts.js +1 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +17 -8
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +5 -4
- package/dist/types/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
- package/dist/types/plugins/table/types.d.ts +8 -8
- package/dist/types/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -1
- package/dist/types/plugins/table/utils/decoration.d.ts +6 -4
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +5 -4
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
- package/dist/types-ts4.5/plugins/table/types.d.ts +8 -8
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +6 -4
- package/package.json +2 -2
- package/report.api.md +1 -1
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +157 -61
- package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +5 -1
- package/src/plugins/table/nodeviews/TableComponent.tsx +16 -15
- package/src/plugins/table/nodeviews/TableContainer.tsx +1 -1
- package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -1
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +18 -9
- package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +17 -8
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +9 -13
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-state.ts +34 -17
- package/src/plugins/table/types.ts +8 -8
- package/src/plugins/table/ui/common-styles.ts +28 -9
- package/src/plugins/table/ui/consts.ts +1 -0
- package/src/plugins/table/ui/ui-styles.ts +59 -4
- package/src/plugins/table/utils/decoration.ts +8 -11
- package/tmp/api-report-tmp.d.ts +1 -1
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
tr,
|
|
7
7
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
8
8
|
import defaultSchema from '@atlaskit/editor-test-helpers/schema';
|
|
9
|
+
import { ffTest } from '@atlassian/feature-flags-test-utils';
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
generateColgroup,
|
|
@@ -15,74 +16,169 @@ import { isMinCellWidthTable } from '../../../../plugins/table/pm-plugins/table-
|
|
|
15
16
|
|
|
16
17
|
describe('table-resizing/colgroup', () => {
|
|
17
18
|
describe('#generateColgroup', () => {
|
|
18
|
-
describe('creates col with correct widths
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
describe('creates col with correct widths', () => {
|
|
20
|
+
describe('based on colwidth cell attributes', () => {
|
|
21
|
+
ffTest(
|
|
22
|
+
'platform.editor.custom-table-width',
|
|
23
|
+
() => {
|
|
24
|
+
const result = generateColgroup(
|
|
25
|
+
getTable([
|
|
26
|
+
{
|
|
27
|
+
colwidth: [10],
|
|
28
|
+
colspan: 1,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
colwidth: [20],
|
|
32
|
+
colspan: 1,
|
|
33
|
+
},
|
|
34
|
+
]),
|
|
35
|
+
);
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
expect(result).toEqual([
|
|
38
|
+
['col', { style: 'width: 47.5px;' }],
|
|
39
|
+
['col', { style: 'width: 47.5px;' }],
|
|
40
|
+
]);
|
|
41
|
+
},
|
|
42
|
+
() => {
|
|
43
|
+
const result = generateColgroup(
|
|
44
|
+
getTable([
|
|
45
|
+
{
|
|
46
|
+
colwidth: [10],
|
|
47
|
+
colspan: 1,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
colwidth: [20],
|
|
51
|
+
colspan: 1,
|
|
52
|
+
},
|
|
53
|
+
]),
|
|
54
|
+
);
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
colspan: 1,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
colwidth: null,
|
|
48
|
-
colspan: 1,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
colwidth: undefined,
|
|
52
|
-
colspan: 1,
|
|
53
|
-
},
|
|
54
|
-
]),
|
|
56
|
+
expect(result).toEqual([
|
|
57
|
+
['col', { style: 'width: 10px;' }],
|
|
58
|
+
['col', { style: 'width: 20px;' }],
|
|
59
|
+
]);
|
|
60
|
+
},
|
|
55
61
|
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('when colwidth is not an array', () => {
|
|
65
|
+
ffTest(
|
|
66
|
+
'platform.editor.custom-table-width',
|
|
67
|
+
() => {
|
|
68
|
+
const result = generateColgroup(
|
|
69
|
+
getTable([
|
|
70
|
+
{
|
|
71
|
+
colwidth: 10,
|
|
72
|
+
colspan: 1,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
colwidth: null,
|
|
76
|
+
colspan: 1,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
colwidth: undefined,
|
|
80
|
+
colspan: 1,
|
|
81
|
+
},
|
|
82
|
+
]),
|
|
83
|
+
);
|
|
56
84
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
85
|
+
expect(result).toEqual([
|
|
86
|
+
['col', { style: 'width: 48px;' }],
|
|
87
|
+
['col', { style: 'width: 48px;' }],
|
|
88
|
+
['col', { style: 'width: 48px;' }],
|
|
89
|
+
]);
|
|
90
|
+
},
|
|
91
|
+
() => {
|
|
92
|
+
const result = generateColgroup(
|
|
93
|
+
getTable([
|
|
94
|
+
{
|
|
95
|
+
colwidth: 10,
|
|
96
|
+
colspan: 1,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
colwidth: null,
|
|
100
|
+
colspan: 1,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
colwidth: undefined,
|
|
104
|
+
colspan: 1,
|
|
105
|
+
},
|
|
106
|
+
]),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(result).toEqual([
|
|
110
|
+
['col', {}],
|
|
111
|
+
['col', {}],
|
|
112
|
+
['col', {}],
|
|
113
|
+
]);
|
|
114
|
+
},
|
|
115
|
+
);
|
|
62
116
|
});
|
|
63
117
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
118
|
+
describe('when colwidth has falsy values', () => {
|
|
119
|
+
ffTest(
|
|
120
|
+
'platform.editor.custom-table-width',
|
|
121
|
+
() => {
|
|
122
|
+
const result = generateColgroup(
|
|
123
|
+
getTable([
|
|
124
|
+
{
|
|
125
|
+
colwidth: [0],
|
|
126
|
+
colspan: 1,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
colwidth: [null],
|
|
130
|
+
colspan: 1,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
colwidth: [undefined],
|
|
134
|
+
colspan: 1,
|
|
135
|
+
},
|
|
136
|
+
]),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(result).toEqual(
|
|
140
|
+
expect.arrayContaining([
|
|
141
|
+
// (.666*) -> match unknown number of 6's
|
|
142
|
+
// (.?) -> match rounding errors e.g. 47.6666664px
|
|
143
|
+
[
|
|
144
|
+
'col',
|
|
145
|
+
{ style: expect.stringMatching(/^width: 47.666*.?px/) },
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
'col',
|
|
149
|
+
{ style: expect.stringMatching(/^width: 47.666*.?px/) },
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
'col',
|
|
153
|
+
{ style: expect.stringMatching(/^width: 47.666*.?px/) },
|
|
154
|
+
],
|
|
155
|
+
]),
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
() => {
|
|
159
|
+
const result = generateColgroup(
|
|
160
|
+
getTable([
|
|
161
|
+
{
|
|
162
|
+
colwidth: [0],
|
|
163
|
+
colspan: 1,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
colwidth: [null],
|
|
167
|
+
colspan: 1,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
colwidth: [undefined],
|
|
171
|
+
colspan: 1,
|
|
172
|
+
},
|
|
173
|
+
]),
|
|
174
|
+
);
|
|
175
|
+
expect(result).toEqual([
|
|
176
|
+
['col', {}],
|
|
177
|
+
['col', {}],
|
|
178
|
+
['col', {}],
|
|
179
|
+
]);
|
|
180
|
+
},
|
|
80
181
|
);
|
|
81
|
-
expect(result).toEqual([
|
|
82
|
-
['col', {}],
|
|
83
|
-
['col', {}],
|
|
84
|
-
['col', {}],
|
|
85
|
-
]);
|
|
86
182
|
});
|
|
87
183
|
|
|
88
184
|
function getTable(cellAttributes: { [key: string]: any }[]) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
|
|
1
3
|
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
2
4
|
import { tableInsertColumnButtonSize } from '../ui/consts';
|
|
3
5
|
|
|
@@ -63,7 +65,9 @@ export class OverflowShadowsObserver {
|
|
|
63
65
|
{
|
|
64
66
|
threshold: [0, 1],
|
|
65
67
|
root: this.wrapper,
|
|
66
|
-
rootMargin:
|
|
68
|
+
rootMargin: getBooleanFF('platform.editor.custom-table-width')
|
|
69
|
+
? '0px'
|
|
70
|
+
: `0px ${tableInsertColumnButtonSize / 2}px 0px 0px`,
|
|
67
71
|
},
|
|
68
72
|
);
|
|
69
73
|
return;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
|
|
3
4
|
import classnames from 'classnames';
|
|
4
5
|
import memoizeOne from 'memoize-one';
|
|
@@ -13,18 +14,21 @@ import type {
|
|
|
13
14
|
GetEditorFeatureFlags,
|
|
14
15
|
} from '@atlaskit/editor-common/types';
|
|
15
16
|
import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
|
|
16
|
-
import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
17
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
17
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
18
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
18
19
|
import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
|
|
19
20
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
21
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
20
22
|
|
|
21
23
|
import { autoSizeTable, clearHoverSelection } from '../commands';
|
|
22
24
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
25
|
+
import type {
|
|
26
|
+
RowStickyState,
|
|
27
|
+
StickyPluginState,
|
|
28
|
+
} from '../pm-plugins/sticky-headers';
|
|
23
29
|
import {
|
|
24
30
|
findStickyHeaderForTable,
|
|
25
|
-
RowStickyState,
|
|
26
31
|
pluginKey as stickyHeadersPluginKey,
|
|
27
|
-
StickyPluginState,
|
|
28
32
|
} from '../pm-plugins/sticky-headers';
|
|
29
33
|
import {
|
|
30
34
|
getLayoutSize,
|
|
@@ -33,11 +37,9 @@ import {
|
|
|
33
37
|
} from '../pm-plugins/table-resizing/utils';
|
|
34
38
|
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
35
39
|
import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
ShadowEvent,
|
|
40
|
-
} from '../types';
|
|
40
|
+
import type { PluginInjectionAPI } from '../types';
|
|
41
|
+
import { TableCssClassName as ClassName, ShadowEvent } from '../types';
|
|
42
|
+
import { tableOverflowShadowWidth } from '../ui/consts';
|
|
41
43
|
import TableFloatingControls from '../ui/TableFloatingControls';
|
|
42
44
|
import {
|
|
43
45
|
containsHeaderRow,
|
|
@@ -456,7 +458,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
456
458
|
<div
|
|
457
459
|
style={{
|
|
458
460
|
position: 'absolute',
|
|
459
|
-
right: '-
|
|
461
|
+
right: getBooleanFF('platform.editor.custom-table-width')
|
|
462
|
+
? `${tableOverflowShadowWidth}px`
|
|
463
|
+
: '-2px',
|
|
460
464
|
}}
|
|
461
465
|
>
|
|
462
466
|
<div
|
|
@@ -566,7 +570,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
566
570
|
this.scaleTable({
|
|
567
571
|
parentWidth,
|
|
568
572
|
layoutChanged,
|
|
569
|
-
isTableResizingEnabled: options?.isTableResizingEnabled,
|
|
570
573
|
});
|
|
571
574
|
}
|
|
572
575
|
|
|
@@ -574,9 +577,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
574
577
|
if (options?.isTableResizingEnabled && hasNumberedColumnChanged) {
|
|
575
578
|
if (!hasTableBeenResized(prevNode)) {
|
|
576
579
|
this.scaleTable({
|
|
577
|
-
parentWidth,
|
|
580
|
+
parentWidth: node.attrs.width,
|
|
578
581
|
layoutChanged,
|
|
579
|
-
isTableResizingEnabled: options?.isTableResizingEnabled,
|
|
580
582
|
});
|
|
581
583
|
}
|
|
582
584
|
}
|
|
@@ -592,7 +594,6 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
592
594
|
private scaleTable = (scaleOptions: {
|
|
593
595
|
layoutChanged: boolean;
|
|
594
596
|
parentWidth?: number;
|
|
595
|
-
isTableResizingEnabled?: boolean;
|
|
596
597
|
}) => {
|
|
597
598
|
const { view, getNode, getPos, containerWidth, options } = this.props;
|
|
598
599
|
const node = getNode();
|
|
@@ -208,7 +208,7 @@ export const TableContainer = ({
|
|
|
208
208
|
<InnerContainer
|
|
209
209
|
node={node}
|
|
210
210
|
className={classNames(className, {
|
|
211
|
-
'less-padding': editorWidth < akEditorMobileBreakoutPoint,
|
|
211
|
+
'less-padding': editorWidth < akEditorMobileBreakoutPoint && !isNested,
|
|
212
212
|
})}
|
|
213
213
|
style={{
|
|
214
214
|
width: tableWidth,
|
|
@@ -82,8 +82,9 @@ const getResizerMinWidth = (node: PMNode) => {
|
|
|
82
82
|
currentColumnCount <= 3
|
|
83
83
|
? currentColumnCount * COLUMN_MIN_WIDTH
|
|
84
84
|
: 3 * COLUMN_MIN_WIDTH;
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
86
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
87
|
+
return minColumnWidth + 1;
|
|
87
88
|
};
|
|
88
89
|
|
|
89
90
|
export const TableResizer = ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
|
|
1
|
+
import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import {
|
|
3
3
|
ACTION_SUBJECT,
|
|
4
4
|
EVENT_TYPE,
|
|
@@ -11,10 +11,11 @@ import type {
|
|
|
11
11
|
GetEditorContainerWidth,
|
|
12
12
|
GetEditorFeatureFlags,
|
|
13
13
|
} from '@atlaskit/editor-common/types';
|
|
14
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
14
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
15
15
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
16
16
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
17
17
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
18
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
|
|
19
20
|
import { updateColumnWidths } from '../../transforms';
|
|
20
21
|
import { getSelectedColumnIndexes, updateResizeHandles } from '../../utils';
|
|
@@ -65,13 +66,21 @@ export const handleMouseDown = (
|
|
|
65
66
|
const containerWidth = getEditorContainerWidth();
|
|
66
67
|
const parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
67
68
|
|
|
68
|
-
let maxSize =
|
|
69
|
-
parentWidth ||
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
let maxSize = getBooleanFF('platform.editor.custom-table-width')
|
|
70
|
+
? parentWidth ||
|
|
71
|
+
// its safe to reference table width from node as this will not have changed
|
|
72
|
+
originalTable.attrs.width ||
|
|
73
|
+
getLayoutSize(
|
|
74
|
+
dom.getAttribute('data-layout') as TableLayout,
|
|
75
|
+
containerWidth.width,
|
|
76
|
+
{},
|
|
77
|
+
)
|
|
78
|
+
: parentWidth ||
|
|
79
|
+
getLayoutSize(
|
|
80
|
+
dom.getAttribute('data-layout') as TableLayout,
|
|
81
|
+
containerWidth.width,
|
|
82
|
+
{},
|
|
83
|
+
);
|
|
75
84
|
|
|
76
85
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
77
86
|
maxSize -= akEditorTableNumberColumnWidth;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
Node as PmNode,
|
|
6
|
-
} from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
7
5
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
7
|
|
|
10
8
|
type Col = Array<string | { [name: string]: string }>;
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
12
|
+
* than the table and table wrapper elements. This is necessary as there is no longer
|
|
13
|
+
* padding on the .pm-table-wrapper, so all elements need to be the same width to avoid
|
|
14
|
+
* overflow.
|
|
15
|
+
*/
|
|
16
|
+
export const getColWidthFix = (colwidth: number, tableColumnCount: number) =>
|
|
17
|
+
colwidth - 1 / tableColumnCount;
|
|
18
|
+
|
|
19
|
+
export const generateColgroup = (table: PmNode) => {
|
|
13
20
|
const cols: Col[] = [];
|
|
14
21
|
|
|
15
22
|
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
23
|
+
const map = TableMap.get(table);
|
|
16
24
|
table.content.firstChild!.content.forEach((cell) => {
|
|
17
25
|
const colspan = cell.attrs.colspan || 1;
|
|
18
26
|
if (Array.isArray(cell.attrs.colwidth)) {
|
|
@@ -22,9 +30,10 @@ export const generateColgroup = (table: PmNode): Col[] => {
|
|
|
22
30
|
cols.push([
|
|
23
31
|
'col',
|
|
24
32
|
{
|
|
25
|
-
style: `width: ${
|
|
26
|
-
width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth
|
|
27
|
-
|
|
33
|
+
style: `width: ${getColWidthFix(
|
|
34
|
+
width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth,
|
|
35
|
+
map.width,
|
|
36
|
+
)}px;`,
|
|
28
37
|
},
|
|
29
38
|
]);
|
|
30
39
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
|
|
1
|
+
import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import {
|
|
3
3
|
getParentNodeWidth,
|
|
4
4
|
layoutToWidth,
|
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
mapBreakpointToLayoutMaxWidth,
|
|
11
11
|
} from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { containsClassName } from '@atlaskit/editor-common/utils';
|
|
13
|
-
import {
|
|
13
|
+
import type {
|
|
14
14
|
NodeSpec,
|
|
15
15
|
Node as PMNode,
|
|
16
16
|
ResolvedPos,
|
|
17
17
|
} from '@atlaskit/editor-prosemirror/model';
|
|
18
|
-
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
19
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
18
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
19
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
20
20
|
import {
|
|
21
21
|
akEditorFullWidthLayoutWidth,
|
|
22
22
|
akEditorGutterPadding,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from '@atlaskit/editor-shared-styles';
|
|
25
25
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
26
26
|
|
|
27
|
-
import { TableOptions } from '../../../nodeviews/types';
|
|
27
|
+
import type { TableOptions } from '../../../nodeviews/types';
|
|
28
28
|
|
|
29
29
|
// Translates named layouts in number values.
|
|
30
30
|
export function getLayoutSize(
|
|
@@ -120,15 +120,11 @@ export const getTableMaxWidth = ({
|
|
|
120
120
|
const containerWidth = getEditorContainerWidth();
|
|
121
121
|
const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
|
|
122
122
|
|
|
123
|
-
let maxWidth
|
|
124
|
-
|
|
125
|
-
maxWidth =
|
|
126
|
-
parentWidth ||
|
|
123
|
+
let maxWidth = getBooleanFF('platform.editor.custom-table-width')
|
|
124
|
+
? parentWidth ||
|
|
127
125
|
table.attrs.width ||
|
|
128
|
-
getLayoutSize(layout, containerWidth.width, {})
|
|
129
|
-
|
|
130
|
-
maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
131
|
-
}
|
|
126
|
+
getLayoutSize(layout, containerWidth.width, {})
|
|
127
|
+
: parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
132
128
|
|
|
133
129
|
if (table.attrs.isNumberColumnEnabled) {
|
|
134
130
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { TableLayout } from '@atlaskit/adf-schema';
|
|
1
|
+
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import {
|
|
3
3
|
tableCellMinWidth,
|
|
4
4
|
tableNewColumnMinWidth,
|
|
5
5
|
} from '@atlaskit/editor-common/styles';
|
|
6
6
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
7
7
|
import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
9
|
-
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
8
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
9
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
|
|
12
13
|
import { getSelectedTableInfo } from '../../../utils';
|
|
13
14
|
|
|
14
|
-
import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from './
|
|
16
|
+
getColWidthFix,
|
|
17
|
+
hasTableBeenResized,
|
|
18
|
+
insertColgroupFromNode,
|
|
19
|
+
} from './colgroup';
|
|
20
|
+
import type { ColumnState } from './column-state';
|
|
21
|
+
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
20
22
|
import { syncStickyRowToTable } from './dom';
|
|
21
23
|
import { getTableMaxWidth } from './misc';
|
|
22
|
-
import { ResizeState, ResizeStateWithAnalytics } from './types';
|
|
24
|
+
import type { ResizeState, ResizeStateWithAnalytics } from './types';
|
|
23
25
|
|
|
24
26
|
export const getResizeState = ({
|
|
25
27
|
minWidth,
|
|
@@ -83,13 +85,28 @@ export const updateColgroup = (
|
|
|
83
85
|
tableRef: HTMLElement,
|
|
84
86
|
): void => {
|
|
85
87
|
const cols = tableRef.querySelectorAll('col');
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
|
|
89
|
+
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
90
|
+
const columnsCount = cols.length;
|
|
91
|
+
state.cols
|
|
92
|
+
.filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
93
|
+
.forEach((column, i) => {
|
|
94
|
+
if (cols[i]) {
|
|
95
|
+
cols[i].style.width = `${getColWidthFix(
|
|
96
|
+
column.width,
|
|
97
|
+
columnsCount,
|
|
98
|
+
)}px`;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
state.cols
|
|
103
|
+
.filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
104
|
+
.forEach((column, i) => {
|
|
105
|
+
if (cols[i]) {
|
|
106
|
+
cols[i].style.width = `${column.width}px`;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
93
110
|
|
|
94
111
|
// colgroup has updated, reflect new widths in sticky header
|
|
95
112
|
syncStickyRowToTable(tableRef);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl-next';
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
|
|
3
|
+
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
3
4
|
import {
|
|
4
5
|
tableCellSelector,
|
|
5
6
|
tableHeaderSelector,
|
|
6
|
-
TableLayout,
|
|
7
7
|
tablePrefixSelector,
|
|
8
8
|
} from '@atlaskit/adf-schema';
|
|
9
|
-
import { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
|
|
10
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
9
|
+
import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
|
|
10
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
11
|
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
12
12
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
13
|
-
import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
14
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
15
|
-
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
16
|
-
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
13
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
14
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
15
|
+
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
16
|
+
import type { Rect } from '@atlaskit/editor-tables/table-map';
|
|
17
17
|
|
|
18
18
|
import type tablePlugin from './index';
|
|
19
19
|
|