@atlaskit/editor-plugin-table 2.8.6 → 2.9.1
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 +21 -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 +10 -1
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +22 -5
- 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/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 +10 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +22 -5
- 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/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 +10 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +22 -5
- 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/types/plugins/table/nodeviews/TableComponent.d.ts +5 -4
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +6 -5
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +2 -1
- 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/nodeviews/TableContainer.d.ts +6 -5
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +2 -1
- 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 +18 -12
- package/src/plugins/table/nodeviews/TableResizer.tsx +36 -5
- 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
- package/dist/cjs/version.json +0 -5
- package/dist/es2019/version.json +0 -5
- package/dist/esm/version.json +0 -5
|
@@ -42,6 +42,7 @@ export declare const contextualMenuDropdownWidth = 180;
|
|
|
42
42
|
export declare const stickyRowZIndex: number;
|
|
43
43
|
export declare const stickyRowOffsetTop = 8;
|
|
44
44
|
export declare const stickyHeaderBorderBottomWidth = 1;
|
|
45
|
+
export declare const tableOverflowShadowWidth = 8;
|
|
45
46
|
export declare const TABLE_SNAP_GAP = 9;
|
|
46
47
|
export declare const TABLE_HIGHLIGHT_GAP = 10;
|
|
47
48
|
export declare const TABLE_HIGHLIGHT_TOLERANCE = 2;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeProps } from '@atlaskit/theme/types';
|
|
1
|
+
import type { ThemeProps } from '@atlaskit/theme/types';
|
|
2
2
|
export declare const InsertMarker: (props: ThemeProps, cssString?: string) => import("@emotion/react").SerializedStyles;
|
|
3
3
|
export declare const HeaderButton: (props: ThemeProps, cssString?: string) => import("@emotion/react").SerializedStyles;
|
|
4
4
|
export declare const HeaderButtonHover: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import { ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { Cell, CellColumnPositioning } from '../types';
|
|
6
|
+
import { TableDecorations } from '../types';
|
|
5
7
|
export declare const findColumnControlSelectedDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
6
8
|
export declare const findControlsHoverDecoration: (decorationSet: DecorationSet) => Decoration[];
|
|
7
9
|
export declare const createCellHoverDecoration: (cells: Cell[]) => Decoration[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.1",
|
|
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": "^28.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^74.
|
|
31
|
+
"@atlaskit/editor-common": "^74.46.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.0.8",
|
package/report.api.md
CHANGED
|
@@ -23,7 +23,7 @@ import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
|
23
23
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
24
24
|
import type { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
25
25
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
26
|
-
import { TableLayout } from '@atlaskit/adf-schema';
|
|
26
|
+
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
27
27
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
28
28
|
|
|
29
29
|
// @public (undocumented)
|
|
@@ -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();
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
PropsWithChildren,
|
|
4
|
-
useCallback,
|
|
5
|
-
useRef,
|
|
6
|
-
} from 'react';
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import React, { forwardRef, useCallback, useRef } from 'react';
|
|
7
3
|
|
|
8
4
|
import classNames from 'classnames';
|
|
9
5
|
|
|
10
|
-
import { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
11
7
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
12
8
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
13
9
|
import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
14
|
-
import { EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
15
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
16
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
10
|
+
import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
11
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
12
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
17
13
|
import { akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
18
14
|
|
|
19
15
|
import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
20
|
-
import {
|
|
16
|
+
import type { PluginInjectionAPI } from '../types';
|
|
17
|
+
import { TableCssClassName as ClassName } from '../types';
|
|
21
18
|
|
|
22
19
|
import { TableResizer } from './TableResizer';
|
|
23
20
|
|
|
@@ -94,6 +91,14 @@ export const ResizableTableContainer = ({
|
|
|
94
91
|
|
|
95
92
|
const marginLeft = getMarginLeft(lineLength, width);
|
|
96
93
|
|
|
94
|
+
// make sure during resizing
|
|
95
|
+
// the pm-table-resizer-container width is the same as its child div resizer-item
|
|
96
|
+
// otherwise when resize table from wider to narrower , pm-table-resizer-container stays wider
|
|
97
|
+
// and cause the fabric-editor-popup-scroll-parent to overflow
|
|
98
|
+
if (containerRef.current.style.width !== `${width}px`) {
|
|
99
|
+
containerRef.current.style.width = `${width}px`;
|
|
100
|
+
}
|
|
101
|
+
|
|
97
102
|
if (marginLeftRef.current !== marginLeft) {
|
|
98
103
|
marginLeftRef.current = marginLeft;
|
|
99
104
|
|
|
@@ -141,6 +146,7 @@ export const ResizableTableContainer = ({
|
|
|
141
146
|
<TableResizer
|
|
142
147
|
width={width}
|
|
143
148
|
maxWidth={maxResizerWidth}
|
|
149
|
+
containerWidth={containerWidth}
|
|
144
150
|
updateWidth={updateWidth}
|
|
145
151
|
editorView={editorView}
|
|
146
152
|
getPos={getPos}
|
|
@@ -208,7 +214,7 @@ export const TableContainer = ({
|
|
|
208
214
|
<InnerContainer
|
|
209
215
|
node={node}
|
|
210
216
|
className={classNames(className, {
|
|
211
|
-
'less-padding': editorWidth < akEditorMobileBreakoutPoint,
|
|
217
|
+
'less-padding': editorWidth < akEditorMobileBreakoutPoint && !isNested,
|
|
212
218
|
})}
|
|
213
219
|
style={{
|
|
214
220
|
width: tableWidth,
|
|
@@ -40,6 +40,7 @@ import { defaultSnappingWidths, findClosestSnap } from '../utils/snapping';
|
|
|
40
40
|
interface TableResizerProps {
|
|
41
41
|
width: number;
|
|
42
42
|
maxWidth: number;
|
|
43
|
+
containerWidth: number;
|
|
43
44
|
updateWidth: (width: number) => void;
|
|
44
45
|
editorView: EditorView;
|
|
45
46
|
getPos: () => number | undefined;
|
|
@@ -82,14 +83,36 @@ const getResizerMinWidth = (node: PMNode) => {
|
|
|
82
83
|
currentColumnCount <= 3
|
|
83
84
|
? currentColumnCount * COLUMN_MIN_WIDTH
|
|
84
85
|
: 3 * COLUMN_MIN_WIDTH;
|
|
86
|
+
// add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
|
|
87
|
+
// the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
|
|
88
|
+
return minColumnWidth + 1;
|
|
89
|
+
};
|
|
85
90
|
|
|
86
|
-
|
|
91
|
+
/**
|
|
92
|
+
* When guidelines are outside the viewport, filter them out, do not show
|
|
93
|
+
* So the guideline container won't make the fabric-editor-popup-scroll-parent overflow
|
|
94
|
+
* @param guidelines
|
|
95
|
+
* @param containerWidth editorWidth
|
|
96
|
+
*/
|
|
97
|
+
const getVisibleGuidelines = (
|
|
98
|
+
guidelines: GuidelineConfig[],
|
|
99
|
+
containerWidth: number,
|
|
100
|
+
) => {
|
|
101
|
+
return guidelines.filter((guideline) => {
|
|
102
|
+
return (
|
|
103
|
+
guideline.position &&
|
|
104
|
+
guideline.position.x !== undefined &&
|
|
105
|
+
typeof guideline.position.x === 'number' &&
|
|
106
|
+
Math.abs(guideline.position.x * 2) < containerWidth
|
|
107
|
+
);
|
|
108
|
+
});
|
|
87
109
|
};
|
|
88
110
|
|
|
89
111
|
export const TableResizer = ({
|
|
90
112
|
children,
|
|
91
113
|
width,
|
|
92
114
|
maxWidth,
|
|
115
|
+
containerWidth,
|
|
93
116
|
updateWidth,
|
|
94
117
|
editorView,
|
|
95
118
|
getPos,
|
|
@@ -110,17 +133,21 @@ export const TableResizer = ({
|
|
|
110
133
|
({ gap, keys }: { gap: number; keys: string[] }) => {
|
|
111
134
|
if (gap !== currentGap.current) {
|
|
112
135
|
currentGap.current = gap;
|
|
136
|
+
const visibleGuidelines = getVisibleGuidelines(
|
|
137
|
+
defaultGuidelines,
|
|
138
|
+
containerWidth,
|
|
139
|
+
);
|
|
113
140
|
displayGuideline(
|
|
114
141
|
getGuidelinesWithHighlights(
|
|
115
142
|
gap,
|
|
116
143
|
TABLE_SNAP_GAP,
|
|
117
144
|
keys,
|
|
118
|
-
|
|
145
|
+
visibleGuidelines,
|
|
119
146
|
),
|
|
120
147
|
);
|
|
121
148
|
}
|
|
122
149
|
},
|
|
123
|
-
[displayGuideline],
|
|
150
|
+
[displayGuideline, containerWidth],
|
|
124
151
|
);
|
|
125
152
|
|
|
126
153
|
const guidelineSnaps = useMemo(
|
|
@@ -143,8 +170,12 @@ export const TableResizer = ({
|
|
|
143
170
|
|
|
144
171
|
dispatch(tr.setMeta(tableWidthPluginKey, { resizing: true }));
|
|
145
172
|
|
|
146
|
-
|
|
147
|
-
|
|
173
|
+
const visibleGuidelines = getVisibleGuidelines(
|
|
174
|
+
defaultGuidelines,
|
|
175
|
+
containerWidth,
|
|
176
|
+
);
|
|
177
|
+
setSnappingEnabled(displayGuideline(visibleGuidelines));
|
|
178
|
+
}, [displayGuideline, containerWidth, editorView, startMeasure]);
|
|
148
179
|
|
|
149
180
|
const handleResize = useCallback(
|
|
150
181
|
(originalState, delta) => {
|
|
@@ -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
|
});
|