@atlaskit/editor-plugin-table 2.8.5 → 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.
Files changed (85) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +6 -6
  4. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +1 -1
  5. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +3 -1
  6. package/dist/cjs/plugins/table/pm-plugins/keymap.js +10 -13
  7. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
  8. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +13 -2
  9. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
  10. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +21 -8
  11. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +3 -6
  12. package/dist/cjs/plugins/table/ui/common-styles.js +12 -4
  13. package/dist/cjs/plugins/table/ui/consts.js +3 -1
  14. package/dist/cjs/plugins/table/ui/ui-styles.js +16 -7
  15. package/dist/cjs/version.json +1 -1
  16. package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
  17. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +6 -6
  18. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +1 -1
  19. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -1
  20. package/dist/es2019/plugins/table/pm-plugins/keymap.js +11 -11
  21. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
  22. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +9 -1
  23. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
  24. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +18 -7
  25. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +3 -3
  26. package/dist/es2019/plugins/table/ui/common-styles.js +27 -9
  27. package/dist/es2019/plugins/table/ui/consts.js +1 -0
  28. package/dist/es2019/plugins/table/ui/ui-styles.js +51 -4
  29. package/dist/es2019/version.json +1 -1
  30. package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +2 -1
  31. package/dist/esm/plugins/table/nodeviews/TableComponent.js +6 -6
  32. package/dist/esm/plugins/table/nodeviews/TableContainer.js +1 -1
  33. package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -1
  34. package/dist/esm/plugins/table/pm-plugins/keymap.js +11 -11
  35. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +4 -1
  36. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +11 -1
  37. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -6
  38. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +22 -9
  39. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +3 -3
  40. package/dist/esm/plugins/table/ui/common-styles.js +12 -4
  41. package/dist/esm/plugins/table/ui/consts.js +1 -0
  42. package/dist/esm/plugins/table/ui/ui-styles.js +17 -8
  43. package/dist/esm/version.json +1 -1
  44. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +5 -4
  45. package/dist/types/plugins/table/pm-plugins/keymap.d.ts +2 -2
  46. package/dist/types/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
  47. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
  48. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
  49. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
  50. package/dist/types/plugins/table/types.d.ts +8 -8
  51. package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +3 -2
  52. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  53. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -1
  54. package/dist/types/plugins/table/utils/decoration.d.ts +6 -4
  55. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +5 -4
  56. package/dist/types-ts4.5/plugins/table/pm-plugins/keymap.d.ts +2 -2
  57. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +1 -1
  58. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +8 -1
  59. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +5 -5
  60. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +5 -5
  61. package/dist/types-ts4.5/plugins/table/types.d.ts +8 -8
  62. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +3 -2
  63. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  64. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -1
  65. package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +6 -4
  66. package/package.json +2 -2
  67. package/report.api.md +1 -1
  68. package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +157 -61
  69. package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +5 -1
  70. package/src/plugins/table/nodeviews/TableComponent.tsx +16 -15
  71. package/src/plugins/table/nodeviews/TableContainer.tsx +1 -1
  72. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
  73. package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -1
  74. package/src/plugins/table/pm-plugins/keymap.ts +36 -27
  75. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +18 -9
  76. package/src/plugins/table/pm-plugins/table-resizing/utils/colgroup.ts +17 -8
  77. package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +9 -13
  78. package/src/plugins/table/pm-plugins/table-resizing/utils/resize-state.ts +34 -17
  79. package/src/plugins/table/types.ts +8 -8
  80. package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +11 -5
  81. package/src/plugins/table/ui/common-styles.ts +28 -9
  82. package/src/plugins/table/ui/consts.ts +1 -0
  83. package/src/plugins/table/ui/ui-styles.ts +59 -4
  84. package/src/plugins/table/utils/decoration.ts +8 -11
  85. package/tmp/api-report-tmp.d.ts +1 -1
@@ -2,10 +2,11 @@ import React from 'react';
2
2
  import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
3
3
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
4
  import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
6
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
7
- import { RowStickyState, StickyPluginState } from '../pm-plugins/sticky-headers';
8
- import { PluginInjectionAPI, ShadowEvent } from '../types';
5
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
6
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { RowStickyState, StickyPluginState } from '../pm-plugins/sticky-headers';
8
+ import type { PluginInjectionAPI } from '../types';
9
+ import { ShadowEvent } from '../types';
9
10
  import type { TableOptions } from './types';
10
11
  export interface ComponentProps {
11
12
  view: EditorView;
@@ -1,5 +1,5 @@
1
- import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
4
  export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null): SafePlugin;
5
5
  export default keymapPlugin;
@@ -1,4 +1,4 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
3
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  export declare const handleMouseDown: (view: EditorView, event: MouseEvent, localResizeHandlePos: number, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, editorAnalyticsAPI?: EditorAnalyticsAPI) => boolean;
@@ -1,7 +1,14 @@
1
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
2
  type Col = Array<string | {
3
3
  [name: string]: string;
4
4
  }>;
5
+ /**
6
+ * This ensures the combined width of the columns (and tbody) of table is always smaller or equal
7
+ * than the table and table wrapper elements. This is necessary as there is no longer
8
+ * padding on the .pm-table-wrapper, so all elements need to be the same width to avoid
9
+ * overflow.
10
+ */
11
+ export declare const getColWidthFix: (colwidth: number, tableColumnCount: number) => number;
5
12
  export declare const generateColgroup: (table: PmNode) => Col[];
6
13
  export declare const insertColgroupFromNode: (tableRef: HTMLTableElement, table: PmNode) => HTMLCollection;
7
14
  export declare const hasTableBeenResized: (table: PmNode) => boolean;
@@ -1,9 +1,9 @@
1
- import { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
2
2
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
- import { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
4
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import { TableOptions } from '../../../nodeviews/types';
3
+ import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
4
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { TableOptions } from '../../../nodeviews/types';
7
7
  export declare function getLayoutSize(tableLayout: TableLayout, containerWidth: number | undefined, options: TableOptions): number;
8
8
  export declare function getDefaultLayoutMaxWidth(containerWidth?: number): number;
9
9
  export declare function pointsAtCell($pos: ResolvedPos): false | PMNode | null;
@@ -1,9 +1,9 @@
1
- import { TableLayout } from '@atlaskit/adf-schema';
1
+ import type { TableLayout } from '@atlaskit/adf-schema';
2
2
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
5
- import { Rect } from '@atlaskit/editor-tables/table-map';
6
- import { ResizeState, ResizeStateWithAnalytics } from './types';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
5
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
6
+ import type { ResizeState, ResizeStateWithAnalytics } from './types';
7
7
  export declare const getResizeState: ({ minWidth, maxSize, table, tableRef, start, domAtPos, }: {
8
8
  minWidth: number;
9
9
  maxSize: number;
@@ -1,12 +1,12 @@
1
- import { IntlShape } from 'react-intl-next';
2
- import { TableLayout } from '@atlaskit/adf-schema';
3
- import { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
4
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { TableLayout } from '@atlaskit/adf-schema';
3
+ import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
4
+ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
8
- import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
- import { Rect } from '@atlaskit/editor-tables/table-map';
6
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
8
+ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
+ import type { Rect } from '@atlaskit/editor-tables/table-map';
10
10
  import type tablePlugin from './index';
11
11
  export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
12
12
  export type RowInsertPosition = 'TOP' | 'BOTTOM';
@@ -1,5 +1,6 @@
1
- import React, { SyntheticEvent } from 'react';
2
- import { WrappedComponentProps } from 'react-intl-next';
1
+ import type { SyntheticEvent } from 'react';
2
+ import React from 'react';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
3
4
  export interface ButtonProps {
4
5
  type: 'row' | 'column';
5
6
  tableRef: HTMLElement;
@@ -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 { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { Cell, CellColumnPositioning, TableDecorations } from '../types';
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.8.5",
3
+ "version": "2.9.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": "^28.1.0",
31
- "@atlaskit/editor-common": "^74.45.0",
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
- it('based on colwidth cell attributes', () => {
20
- const result = generateColgroup(
21
- getTable([
22
- {
23
- colwidth: [10],
24
- colspan: 1,
25
- },
26
- {
27
- colwidth: [20],
28
- colspan: 1,
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
- expect(result).toEqual([
34
- ['col', { style: 'width: 10px;' }],
35
- ['col', { style: 'width: 20px;' }],
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
- it('when colwidth is not an array', () => {
40
- const result = generateColgroup(
41
- getTable([
42
- {
43
- colwidth: 10,
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
- expect(result).toEqual([
58
- ['col', {}],
59
- ['col', {}],
60
- ['col', {}],
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
- it('when colwidth has falsy values', () => {
65
- const result = generateColgroup(
66
- getTable([
67
- {
68
- colwidth: [0],
69
- colspan: 1,
70
- },
71
- {
72
- colwidth: [null],
73
- colspan: 1,
74
- },
75
- {
76
- colwidth: [undefined],
77
- colspan: 1,
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: `0px ${tableInsertColumnButtonSize / 2}px 0px 0px`,
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 React, { CSSProperties } from 'react';
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
- TableCssClassName as ClassName,
38
- PluginInjectionAPI,
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: '-2px',
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
- return minColumnWidth;
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 = ({
@@ -4,7 +4,6 @@ import { TableCssClassName as ClassName } from '../types';
4
4
 
5
5
  export const updateShadowListForStickyStyles = (
6
6
  heightStyle: string,
7
-
8
7
  shadows: HTMLCollection,
9
8
  ) => {
10
9
  Array.from(shadows).forEach((shadow) => {