@atlaskit/editor-plugin-table 1.7.3 → 2.0.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/plugins/table/index.js +11 -16
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +7 -3
  4. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +23 -19
  5. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +2 -1
  6. package/dist/cjs/plugins/table/nodeviews/table.js +5 -1
  7. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/es2019/plugins/table/index.js +11 -16
  10. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +7 -3
  11. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +22 -18
  12. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -2
  13. package/dist/es2019/plugins/table/nodeviews/table.js +5 -1
  14. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  15. package/dist/es2019/version.json +1 -1
  16. package/dist/esm/plugins/table/index.js +11 -16
  17. package/dist/esm/plugins/table/nodeviews/TableComponent.js +7 -3
  18. package/dist/esm/plugins/table/nodeviews/TableContainer.js +23 -19
  19. package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -2
  20. package/dist/esm/plugins/table/nodeviews/table.js +5 -1
  21. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  22. package/dist/esm/version.json +1 -1
  23. package/dist/types/plugins/table/index.d.ts +0 -2
  24. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  25. package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  26. package/dist/types-ts4.5/plugins/table/index.d.ts +0 -2
  27. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  28. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  29. package/package.json +5 -7
  30. package/report.api.md +0 -3
  31. package/src/__tests__/unit/analytics.ts +20 -10
  32. package/src/__tests__/unit/keymap.ts +14 -21
  33. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +12 -7
  34. package/src/plugins/table/index.tsx +12 -25
  35. package/src/plugins/table/nodeviews/TableComponent.tsx +10 -4
  36. package/src/plugins/table/nodeviews/TableContainer.tsx +28 -19
  37. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
  38. package/src/plugins/table/nodeviews/table.tsx +6 -0
  39. package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +10 -1
  40. package/tmp/api-report-tmp.d.ts +0 -107
@@ -8,7 +8,6 @@ import {
8
8
  } from '@atlaskit/editor-tables/utils';
9
9
  import { PluginKey } from 'prosemirror-state';
10
10
 
11
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
12
11
  import {
13
12
  createProsemirrorEditorFactory,
14
13
  LightEditorPlugin,
@@ -29,10 +28,6 @@ import {
29
28
  import { pmNodeBuilder } from '@atlaskit/editor-test-helpers/schema-element-builder';
30
29
  import defaultSchema from '@atlaskit/editor-test-helpers/schema';
31
30
  import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
32
- import {
33
- CreateUIAnalyticsEvent,
34
- UIAnalyticsEvent,
35
- } from '@atlaskit/analytics-next';
36
31
  import { uuid } from '@atlaskit/adf-schema';
37
32
  import { uuid as tablesUuid } from '@atlaskit/editor-tables';
38
33
 
@@ -42,8 +37,7 @@ import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
42
37
  import tasksDecisionsPlugin from '@atlaskit/editor-core/src/plugins/tasks-and-decisions';
43
38
  import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
44
39
  import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
45
- import deprecatedAnalyticsPlugin from '@atlaskit/editor-core/src/plugins/analytics';
46
- import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
40
+ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
47
41
  import listPlugin from '@atlaskit/editor-core/src/plugins/list';
48
42
  import blockTypePlugin from '@atlaskit/editor-core/src/plugins/block-type';
49
43
  import codeBlockPlugin from '@atlaskit/editor-core/src/plugins/code-block';
@@ -67,6 +61,16 @@ import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
67
61
 
68
62
  const TABLE_LOCAL_ID = 'test-table-local-id';
69
63
 
64
+ // We don't need to test if the analytics implementation works (tested elsewhere)
65
+ // We just want to know if the action is called.
66
+ const mockAttachPayload = jest.fn();
67
+ const analyticsPluginFake = () => ({
68
+ name: 'analytics',
69
+ actions: {
70
+ attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
71
+ },
72
+ });
73
+
70
74
  describe('table keymap', () => {
71
75
  beforeAll(() => {
72
76
  uuid.setStatic(TABLE_LOCAL_ID);
@@ -78,27 +82,16 @@ describe('table keymap', () => {
78
82
  tablesUuid.setStatic(false);
79
83
  });
80
84
 
81
- let editorAnalyticsAPIFake: EditorAnalyticsAPI = {
82
- attachAnalyticsEvent: jest.fn().mockReturnValue(jest.fn()),
83
- };
84
- const createAnalyticsEvent: CreateUIAnalyticsEvent = jest.fn(
85
- () => ({ fire() {} } as UIAnalyticsEvent),
86
- );
87
-
88
85
  const createEditor = createProsemirrorEditorFactory();
89
86
  const preset = new Preset<LightEditorPlugin>()
90
87
  .add([featureFlagsPlugin, {}])
91
- .add([analyticsPlugin, { createAnalyticsEvent }])
92
- .add([deprecatedAnalyticsPlugin, { createAnalyticsEvent }])
88
+ .add([analyticsPluginFake as unknown as typeof analyticsPlugin, {}])
93
89
  .add(contentInsertionPlugin)
94
90
  .add(decorationsPlugin)
95
91
  .add(widthPlugin)
96
92
  .add(gridPlugin)
97
93
  .add(selectionPlugin)
98
- .add([
99
- tablePlugin,
100
- { tableOptions: {}, editorAnalyticsAPI: editorAnalyticsAPIFake },
101
- ])
94
+ .add([tablePlugin, { tableOptions: {} }])
102
95
  .add(expandPlugin)
103
96
  .add(tasksDecisionsPlugin)
104
97
  .add(panelPlugin)
@@ -604,7 +597,7 @@ describe('table keymap', () => {
604
597
  });
605
598
 
606
599
  it('should dispatch analytics event', () => {
607
- expect(editorAnalyticsAPIFake.attachAnalyticsEvent).toBeCalledWith({
600
+ expect(mockAttachPayload).toBeCalledWith({
608
601
  action: 'inserted',
609
602
  actionSubject: 'document',
610
603
  actionSubjectId: 'table',
@@ -25,7 +25,6 @@ import { TextSelection, NodeSelection, EditorState } from 'prosemirror-state';
25
25
  import { EditorView } from 'prosemirror-view';
26
26
  import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
27
27
  import { widthPlugin } from '@atlaskit/editor-plugin-width';
28
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
29
28
  import {
30
29
  akEditorFullPageMaxWidth,
31
30
  akEditorDefaultLayoutWidth,
@@ -35,10 +34,17 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
35
34
  import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
36
35
  import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
37
36
 
37
+ // We don't need to test if the analytics implementation works (tested elsewhere)
38
+ // We just want to know if the action is called.
39
+ const mockAttachPayload = jest.fn();
40
+ const analyticsPluginFake = () => ({
41
+ name: 'analytics',
42
+ actions: {
43
+ attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
44
+ },
45
+ });
46
+
38
47
  describe('table-resizing/event-handlers', () => {
39
- const editorAnalyticsAPIFake: EditorAnalyticsAPI = {
40
- attachAnalyticsEvent: jest.fn().mockReturnValue(() => jest.fn()),
41
- };
42
48
  let editor: any;
43
49
  beforeEach(() => {
44
50
  const createEditor = createProsemirrorEditorFactory();
@@ -48,7 +54,7 @@ describe('table-resizing/event-handlers', () => {
48
54
  attachTo: document.body,
49
55
  preset: new Preset<LightEditorPlugin>()
50
56
  .add([featureFlagsPlugin, {}])
51
- .add([analyticsPlugin, {}])
57
+ .add([analyticsPluginFake as unknown as typeof analyticsPlugin, {}])
52
58
  .add(contentInsertionPlugin)
53
59
  .add(decorationsPlugin)
54
60
  .add(widthPlugin)
@@ -56,7 +62,6 @@ describe('table-resizing/event-handlers', () => {
56
62
  tablePlugin,
57
63
  {
58
64
  tableOptions: { allowColumnResizing: true },
59
- editorAnalyticsAPI: editorAnalyticsAPIFake,
60
65
  },
61
66
  ])
62
67
  .add(panelPlugin),
@@ -72,7 +77,7 @@ describe('table-resizing/event-handlers', () => {
72
77
 
73
78
  resizeColumn(view, 12, 150, 250);
74
79
 
75
- expect(editorAnalyticsAPIFake.attachAnalyticsEvent).toHaveBeenCalledWith(
80
+ expect(mockAttachPayload).toHaveBeenCalledWith(
76
81
  expect.objectContaining({
77
82
  action: TABLE_ACTION.ATTEMPTED_TABLE_WIDTH_CHANGE,
78
83
  actionSubject: ACTION_SUBJECT.TABLE,
@@ -32,7 +32,6 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
32
32
 
33
33
  import { IconTable } from '@atlaskit/editor-common/icons';
34
34
 
35
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
36
35
  import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
37
36
 
38
37
  import { pluginConfig } from './create-plugin-config';
@@ -80,7 +79,6 @@ interface TablePluginOptions {
80
79
  // TODO these two need to be rethought
81
80
  fullWidthEnabled?: boolean;
82
81
  wasFullWidthEnabled?: boolean;
83
- editorAnalyticsAPI?: EditorAnalyticsAPI;
84
82
  editorSelectionAPI?: EditorSelectionAPI;
85
83
  getEditorFeatureFlags?: GetEditorFeatureFlags;
86
84
  }
@@ -110,6 +108,7 @@ const tablesPlugin: NextEditorPlugin<
110
108
  };
111
109
  return api?.dependencies.width.sharedState.currentState() ?? defaultState;
112
110
  };
111
+ const editorAnalyticsAPI = api?.dependencies.analytics?.actions;
113
112
 
114
113
  return {
115
114
  name: 'table',
@@ -165,13 +164,8 @@ const tablesPlugin: NextEditorPlugin<
165
164
  wasFullWidthEnabled,
166
165
  breakoutEnabled,
167
166
  tableOptions,
168
- editorAnalyticsAPI,
169
167
  getEditorFeatureFlags,
170
- } =
171
- options ||
172
- ({
173
- editorAnalyticsAPI: api?.dependencies.analytics?.actions,
174
- } as TablePluginOptions);
168
+ } = options || ({} as TablePluginOptions);
175
169
  return createPlugin(
176
170
  dispatchAnalyticsEvent,
177
171
  dispatch,
@@ -191,12 +185,8 @@ const tablesPlugin: NextEditorPlugin<
191
185
  {
192
186
  name: 'tablePMColResizing',
193
187
  plugin: ({ dispatch }) => {
194
- const {
195
- fullWidthEnabled,
196
- tableOptions,
197
- editorAnalyticsAPI,
198
- getEditorFeatureFlags,
199
- } = options || ({} as TablePluginOptions);
188
+ const { fullWidthEnabled, tableOptions, getEditorFeatureFlags } =
189
+ options || ({} as TablePluginOptions);
200
190
  const { allowColumnResizing } = pluginConfig(tableOptions);
201
191
  return allowColumnResizing
202
192
  ? createFlexiResizingPlugin(
@@ -217,10 +207,7 @@ const tablesPlugin: NextEditorPlugin<
217
207
  {
218
208
  name: 'tableKeymap',
219
209
  plugin: () =>
220
- keymapPlugin(
221
- defaultGetEditorContainerWidth,
222
- options?.editorAnalyticsAPI,
223
- ),
210
+ keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI),
224
211
  },
225
212
  {
226
213
  name: 'tableSelectionKeymap',
@@ -239,7 +226,7 @@ const tablesPlugin: NextEditorPlugin<
239
226
  tr: Transaction;
240
227
  reason: string;
241
228
  }) => {
242
- options?.editorAnalyticsAPI?.attachAnalyticsEvent({
229
+ editorAnalyticsAPI?.attachAnalyticsEvent({
243
230
  action: TABLE_ACTION.FIXED,
244
231
  actionSubject: ACTION_SUBJECT.TABLE,
245
232
  actionSubjectId: null,
@@ -374,7 +361,7 @@ const tablesPlugin: NextEditorPlugin<
374
361
  !!resizingPluginState && !!resizingPluginState.dragging
375
362
  }
376
363
  stickyHeader={stickyHeader}
377
- editorAnalyticsAPI={options?.editorAnalyticsAPI}
364
+ editorAnalyticsAPI={editorAnalyticsAPI}
378
365
  />
379
366
  ) : null;
380
367
 
@@ -415,7 +402,7 @@ const tablesPlugin: NextEditorPlugin<
415
402
  scrollableElement={popupsScrollableElement}
416
403
  hasStickyHeaders={stickyHeader && stickyHeader.sticky}
417
404
  dispatchAnalyticsEvent={dispatchAnalyticsEvent}
418
- editorAnalyticsAPI={options?.editorAnalyticsAPI}
405
+ editorAnalyticsAPI={editorAnalyticsAPI}
419
406
  getEditorContainerWidth={defaultGetEditorContainerWidth}
420
407
  />
421
408
  )}
@@ -426,7 +413,7 @@ const tablesPlugin: NextEditorPlugin<
426
413
  targetCellPosition={targetCellPosition}
427
414
  isOpen={Boolean(isContextualMenuOpen)}
428
415
  pluginConfig={pluginConfig}
429
- editorAnalyticsAPI={options?.editorAnalyticsAPI}
416
+ editorAnalyticsAPI={editorAnalyticsAPI}
430
417
  getEditorContainerWidth={defaultGetEditorContainerWidth}
431
418
  getEditorFeatureFlags={
432
419
  options?.getEditorFeatureFlags ||
@@ -445,7 +432,7 @@ const tablesPlugin: NextEditorPlugin<
445
432
  isNumberColumnEnabled={
446
433
  tableNode && tableNode.attrs.isNumberColumnEnabled
447
434
  }
448
- editorAnalyticsAPI={options?.editorAnalyticsAPI}
435
+ editorAnalyticsAPI={editorAnalyticsAPI}
449
436
  />
450
437
  )}
451
438
  {LayoutContent}
@@ -473,7 +460,7 @@ const tablesPlugin: NextEditorPlugin<
473
460
  schema: state.schema,
474
461
  }),
475
462
  );
476
- options?.editorAnalyticsAPI?.attachAnalyticsEvent({
463
+ editorAnalyticsAPI?.attachAnalyticsEvent({
477
464
  action: ACTION.INSERTED,
478
465
  actionSubject: ACTION_SUBJECT.DOCUMENT,
479
466
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
@@ -486,7 +473,7 @@ const tablesPlugin: NextEditorPlugin<
486
473
  ],
487
474
  floatingToolbar: getToolbarConfig(
488
475
  defaultGetEditorContainerWidth,
489
- options?.editorAnalyticsAPI,
476
+ editorAnalyticsAPI,
490
477
  options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
491
478
  () => editorViewRef.current,
492
479
  )(pluginConfig(options?.tableOptions)),
@@ -48,7 +48,6 @@ import {
48
48
  import type { TableOptions } from './types';
49
49
  import { updateOverflowShadows } from './update-overflow-shadows';
50
50
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
51
-
52
51
  import memoizeOne from 'memoize-one';
53
52
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
54
53
  import { TableContainer } from './TableContainer';
@@ -151,7 +150,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
151
150
  * We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
152
151
  * Instead we use the resize event to only trigger updates when necessary.
153
152
  */
154
- window.addEventListener('resize', this.handleWindowResizeDebounced);
153
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
154
+ window.addEventListener('resize', this.handleWindowResizeDebounced);
155
+ }
155
156
  this.handleTableResizingDebounced();
156
157
  }
157
158
 
@@ -175,9 +176,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
175
176
  this.scaleTableDebounced.cancel();
176
177
  this.handleTableResizingDebounced.cancel();
177
178
  this.handleAutoSizeDebounced.cancel();
178
- this.handleWindowResizeDebounced.cancel();
179
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
180
+ this.handleWindowResizeDebounced.cancel();
181
+ }
179
182
 
180
- if (this.props.allowColumnResizing) {
183
+ if (
184
+ !getBooleanFF('platform.editor.custom-table-width') &&
185
+ this.props.allowColumnResizing
186
+ ) {
181
187
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
182
188
  }
183
189
 
@@ -14,6 +14,7 @@ import { calcTableWidth } from '@atlaskit/editor-common/styles';
14
14
 
15
15
  import { TableCssClassName as ClassName } from '../types';
16
16
  import { TableResizer } from './TableResizer';
17
+ import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
17
18
 
18
19
  interface GetMarginLeftOpts {
19
20
  lineLength: number;
@@ -35,22 +36,21 @@ const getMarginLeft = ({ lineLength, tableWidth }: GetMarginLeftOpts) => {
35
36
 
36
37
  type InnerContainerProps = {
37
38
  className: string;
38
- marginLeft: number | undefined;
39
- width: number | 'inherit';
39
+ style?: {
40
+ width: number | 'inherit';
41
+ marginLeft: number | undefined;
42
+ };
40
43
  node: PMNode;
41
44
  };
42
45
 
43
46
  export const InnerContainer = forwardRef<
44
47
  HTMLDivElement,
45
48
  PropsWithChildren<InnerContainerProps>
46
- >(({ marginLeft, className, width, node, children }, ref) => {
49
+ >(({ className, style, node, children }, ref) => {
47
50
  return (
48
51
  <div
49
52
  ref={ref}
50
- style={{
51
- width,
52
- marginLeft,
53
- }}
53
+ style={style}
54
54
  className={className}
55
55
  data-number-column={node.attrs.isNumberColumnEnabled}
56
56
  data-layout={node.attrs.layout}
@@ -76,6 +76,7 @@ export const ResizableTableContainer = ({
76
76
  className,
77
77
  node,
78
78
  lineLength,
79
+ containerWidth,
79
80
  editorView,
80
81
  getPos,
81
82
  tableRef,
@@ -89,25 +90,32 @@ export const ResizableTableContainer = ({
89
90
  return;
90
91
  }
91
92
 
92
- innerContainerRef.current.style.width = `${width}px`;
93
-
94
93
  const marginLeft = getMarginLeft({
95
94
  lineLength,
96
95
  tableWidth: width,
97
96
  });
98
97
 
99
- containerRef.current.style.width = `${width}px`;
100
- containerRef.current.style.marginLeft = `${marginLeft}px`;
98
+ if (marginLeft) {
99
+ containerRef.current.style.marginLeft = `${marginLeft}px`;
100
+ }
101
101
  },
102
102
  [lineLength],
103
103
  );
104
104
 
105
- const width = getTableContainerWidth(node);
105
+ const tableWidth = getTableContainerWidth(node);
106
+
107
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
108
+ const responsiveContainerWidth = containerWidth - 76;
109
+
110
+ const width = Math.min(tableWidth, responsiveContainerWidth);
111
+
106
112
  const marginLeft = getMarginLeft({
107
113
  lineLength,
108
114
  tableWidth: width,
109
115
  });
110
116
 
117
+ const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
118
+
111
119
  return (
112
120
  <div
113
121
  style={{ marginLeft, width }}
@@ -116,6 +124,7 @@ export const ResizableTableContainer = ({
116
124
  >
117
125
  <TableResizer
118
126
  width={width}
127
+ maxWidth={maxResizerWidth}
119
128
  updateWidth={updateWidth}
120
129
  editorView={editorView}
121
130
  getPos={getPos}
@@ -126,8 +135,6 @@ export const ResizableTableContainer = ({
126
135
  ref={innerContainerRef}
127
136
  className={className}
128
137
  node={node}
129
- width={width}
130
- marginLeft={0}
131
138
  >
132
139
  {children}
133
140
  </InnerContainer>
@@ -188,11 +195,13 @@ export const TableContainer = ({
188
195
  <InnerContainer
189
196
  node={node}
190
197
  className={className}
191
- width={tableWidth}
192
- marginLeft={getMarginLeft({
193
- lineLength: lineLength!,
194
- tableWidth,
195
- })}
198
+ style={{
199
+ width: tableWidth,
200
+ marginLeft: getMarginLeft({
201
+ lineLength: lineLength!,
202
+ tableWidth,
203
+ }),
204
+ }}
196
205
  >
197
206
  {children}
198
207
  </InnerContainer>
@@ -10,11 +10,11 @@ import {
10
10
  previewScaleTable,
11
11
  getColgroupChildrenLength,
12
12
  COLUMN_MIN_WIDTH,
13
- TABLE_MAX_WIDTH,
14
13
  } from '../pm-plugins/table-resizing/utils';
15
14
 
16
15
  interface TableResizerProps {
17
16
  width: number;
17
+ maxWidth: number;
18
18
  updateWidth: (width: number) => void;
19
19
  editorView: EditorView;
20
20
  getPos: () => number | undefined;
@@ -27,6 +27,7 @@ const handles = { right: true };
27
27
  export const TableResizer = ({
28
28
  children,
29
29
  width,
30
+ maxWidth,
30
31
  updateWidth,
31
32
  editorView,
32
33
  getPos,
@@ -99,7 +100,7 @@ export const TableResizer = ({
99
100
  }}
100
101
  resizeRatio={2}
101
102
  minWidth={minColumnWidth}
102
- maxWidth={TABLE_MAX_WIDTH}
103
+ maxWidth={maxWidth}
103
104
  >
104
105
  {children}
105
106
  </ResizerNext>
@@ -29,16 +29,22 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
29
29
  import TableComponent from './TableComponent';
30
30
  import { Props, TableOptions } from './types';
31
31
  import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
32
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
33
+ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
32
34
 
33
35
  type ForwardRef = (node: HTMLElement | null) => void;
34
36
 
35
37
  const tableAttributes = (node: PmNode) => {
38
+ const style = getBooleanFF('platform.editor.custom-table-width')
39
+ ? `width: ${getTableContainerWidth(node)}px`
40
+ : undefined;
36
41
  return {
37
42
  'data-number-column': node.attrs.isNumberColumnEnabled,
38
43
  'data-layout': node.attrs.layout,
39
44
  'data-autosize': node.attrs.__autoSize,
40
45
  'data-table-local-id': node.attrs.localId || '',
41
46
  'data-table-width': node.attrs.width,
47
+ style,
42
48
  };
43
49
  };
44
50
 
@@ -5,6 +5,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
5
5
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
6
6
 
7
7
  import type { DomAtPos } from 'prosemirror-utils';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
 
9
10
  import { getTableWidth } from '../../../utils';
10
11
  import { getLayoutSize } from '../utils/misc';
@@ -152,7 +153,15 @@ export const previewScaleTable = (
152
153
  ) => {
153
154
  const { node, start, parentWidth } = options;
154
155
 
155
- if (!tableRef || !hasTableBeenResized(node)) {
156
+ if (!tableRef) {
157
+ return;
158
+ }
159
+
160
+ if (getBooleanFF('platform.editor.custom-table-width') && parentWidth) {
161
+ tableRef.style.width = `${parentWidth}px`;
162
+ }
163
+
164
+ if (!hasTableBeenResized(node)) {
156
165
  return;
157
166
  }
158
167
 
@@ -1,107 +0,0 @@
1
- ## API Report File for "@atlaskit/editor-plugin-table"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
8
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
- import type { Command } from '@atlaskit/editor-common/types';
10
- import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
11
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
12
- import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
13
- import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
14
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
15
- import { TableLayout } from '@atlaskit/adf-schema';
16
- import type { widthPlugin } from '@atlaskit/editor-plugin-width';
17
-
18
- // @public (undocumented)
19
- type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
20
-
21
- // @public (undocumented)
22
- type PermittedLayoutsDescriptor = 'all' | TableLayout[];
23
-
24
- // @public (undocumented)
25
- interface PluginConfig {
26
- // (undocumented)
27
- advanced?: boolean;
28
- // (undocumented)
29
- allowAddColumnWithCustomStep?: boolean;
30
- // (undocumented)
31
- allowBackgroundColor?: boolean;
32
- // (undocumented)
33
- allowCellOptionsInFloatingToolbar?: boolean;
34
- // (undocumented)
35
- allowCollapse?: boolean;
36
- // (undocumented)
37
- allowColumnResizing?: boolean;
38
- // (undocumented)
39
- allowColumnSorting?: boolean;
40
- // (undocumented)
41
- allowControls?: boolean;
42
- // (undocumented)
43
- allowDistributeColumns?: boolean;
44
- // (undocumented)
45
- allowHeaderColumn?: boolean;
46
- // (undocumented)
47
- allowHeaderRow?: boolean;
48
- // (undocumented)
49
- allowMergeCells?: boolean;
50
- // (undocumented)
51
- allowNumberColumn?: boolean;
52
- // (undocumented)
53
- initialRenderOptimization?: boolean;
54
- // (undocumented)
55
- isHeaderRowRequired?: boolean;
56
- // (undocumented)
57
- mouseMoveOptimization?: boolean;
58
- // (undocumented)
59
- permittedLayouts?: PermittedLayoutsDescriptor;
60
- // (undocumented)
61
- stickyHeaders?: boolean;
62
- // (undocumented)
63
- stickyHeadersOptimization?: boolean;
64
- // (undocumented)
65
- tableCellOptimization?: boolean;
66
- // (undocumented)
67
- tableOverflowShadowsOptimization?: boolean;
68
- // (undocumented)
69
- tableRenderOptimization?: boolean;
70
- }
71
-
72
- // @public (undocumented)
73
- interface TablePluginOptions {
74
- // (undocumented)
75
- allowContextualMenu?: boolean;
76
- // (undocumented)
77
- breakoutEnabled?: boolean;
78
- // (undocumented)
79
- editorAnalyticsAPI?: EditorAnalyticsAPI;
80
- // (undocumented)
81
- editorSelectionAPI?: EditorSelectionAPI;
82
- // (undocumented)
83
- fullWidthEnabled?: boolean;
84
- // (undocumented)
85
- getEditorFeatureFlags?: GetEditorFeatureFlags;
86
- // (undocumented)
87
- tableOptions: PluginConfig;
88
- // (undocumented)
89
- wasFullWidthEnabled?: boolean;
90
- }
91
-
92
- // @public (undocumented)
93
- export const tablesPlugin: NextEditorPlugin<'table', {
94
- pluginConfiguration: TablePluginOptions | undefined;
95
- actions: {
96
- insertTable: InsertTableAction;
97
- };
98
- dependencies: [
99
- typeof analyticsPlugin,
100
- typeof contentInsertionPlugin,
101
- typeof widthPlugin
102
- ];
103
- }>;
104
-
105
- // (No @packageDocumentation comment for this package)
106
-
107
- ```