@atlaskit/editor-plugin-table 7.21.2 → 7.21.3

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 (57) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/commands/insert.js +6 -3
  3. package/dist/cjs/nodeviews/TableComponent.js +9 -8
  4. package/dist/cjs/nodeviews/TableContainer.js +9 -6
  5. package/dist/cjs/nodeviews/lazy-node-views.js +4 -3
  6. package/dist/cjs/nodeviews/table.js +8 -3
  7. package/dist/cjs/plugin.js +16 -7
  8. package/dist/cjs/pm-plugins/keymap.js +3 -1
  9. package/dist/cjs/pm-plugins/main.js +3 -2
  10. package/dist/cjs/utils/create.js +6 -1
  11. package/dist/es2019/commands/insert.js +6 -3
  12. package/dist/es2019/nodeviews/TableComponent.js +10 -9
  13. package/dist/es2019/nodeviews/TableContainer.js +9 -6
  14. package/dist/es2019/nodeviews/lazy-node-views.js +4 -3
  15. package/dist/es2019/nodeviews/table.js +8 -3
  16. package/dist/es2019/plugin.js +14 -7
  17. package/dist/es2019/pm-plugins/keymap.js +2 -2
  18. package/dist/es2019/pm-plugins/main.js +3 -2
  19. package/dist/es2019/utils/create.js +6 -1
  20. package/dist/esm/commands/insert.js +6 -3
  21. package/dist/esm/nodeviews/TableComponent.js +10 -9
  22. package/dist/esm/nodeviews/TableContainer.js +9 -6
  23. package/dist/esm/nodeviews/lazy-node-views.js +4 -3
  24. package/dist/esm/nodeviews/table.js +8 -3
  25. package/dist/esm/plugin.js +16 -7
  26. package/dist/esm/pm-plugins/keymap.js +3 -1
  27. package/dist/esm/pm-plugins/main.js +3 -2
  28. package/dist/esm/utils/create.js +6 -1
  29. package/dist/types/commands/insert.d.ts +2 -2
  30. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  31. package/dist/types/nodeviews/lazy-node-views.d.ts +1 -0
  32. package/dist/types/nodeviews/table.d.ts +1 -1
  33. package/dist/types/nodeviews/types.d.ts +1 -0
  34. package/dist/types/plugin.d.ts +1 -0
  35. package/dist/types/pm-plugins/keymap.d.ts +1 -1
  36. package/dist/types/pm-plugins/main.d.ts +1 -1
  37. package/dist/types/utils/create.d.ts +3 -1
  38. package/dist/types-ts4.5/commands/insert.d.ts +2 -2
  39. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  40. package/dist/types-ts4.5/nodeviews/lazy-node-views.d.ts +1 -0
  41. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
  42. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  43. package/dist/types-ts4.5/plugin.d.ts +1 -0
  44. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +1 -1
  45. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  46. package/dist/types-ts4.5/utils/create.d.ts +3 -1
  47. package/package.json +1 -1
  48. package/src/commands/insert.ts +6 -0
  49. package/src/nodeviews/TableComponent.tsx +9 -8
  50. package/src/nodeviews/TableContainer.tsx +15 -3
  51. package/src/nodeviews/lazy-node-views.ts +4 -0
  52. package/src/nodeviews/table.tsx +7 -1
  53. package/src/nodeviews/types.ts +1 -0
  54. package/src/plugin.tsx +12 -1
  55. package/src/pm-plugins/keymap.ts +4 -0
  56. package/src/pm-plugins/main.ts +2 -0
  57. package/src/utils/create.ts +9 -2
@@ -32,5 +32,5 @@ export default class TableView extends ReactNodeView<Props> {
32
32
  }): boolean;
33
33
  destroy(): void;
34
34
  }
35
- export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isTableAlignmentEnabled?: boolean) => NodeView;
35
+ export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, dispatchAnalyticsEvent: DispatchAnalyticsEvent, pluginInjectionApi?: PluginInjectionAPI, isTableAlignmentEnabled?: boolean, isCommentEditor?: boolean) => NodeView;
36
36
  export {};
@@ -12,6 +12,7 @@ export type TableOptions = {
12
12
  isDragAndDropEnabled?: boolean;
13
13
  isTableScalingEnabled?: boolean;
14
14
  isTableAlignmentEnabled?: boolean;
15
+ isCommentEditor?: boolean;
15
16
  };
16
17
  export interface Props {
17
18
  node: PmNode;
@@ -21,6 +21,7 @@ export interface TablePluginOptions {
21
21
  isTableScalingEnabled?: boolean;
22
22
  isTableAlignmentEnabled?: boolean;
23
23
  isNewColumnResizingEnabled?: boolean;
24
+ isCommentEditor?: boolean;
24
25
  }
25
26
  type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
26
27
  type MediaPlugin = NextEditorPlugin<'media', {
@@ -3,5 +3,5 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  import type { PluginInjectionAPIWithA11y } from '../types';
6
- export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isFullWidthEnabled?: boolean, pluginInjectionApi?: PluginInjectionAPIWithA11y, getIntl?: () => IntlShape, isCellBackgroundDuplicated?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean): SafePlugin;
6
+ export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isFullWidthEnabled?: boolean, pluginInjectionApi?: PluginInjectionAPIWithA11y, getIntl?: () => IntlShape, isCellBackgroundDuplicated?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean, isTableResizingEnabled?: boolean): SafePlugin;
7
7
  export default keymapPlugin;
@@ -5,4 +5,4 @@ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
7
  import type { PluginConfig, PluginInjectionAPI } from '../types';
8
- export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, tableResizingEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, dragAndDropEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => SafePlugin<import("../types").TablePluginState>;
8
+ export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, tableResizingEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, dragAndDropEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean) => SafePlugin<import("../types").TablePluginState>;
@@ -1,8 +1,10 @@
1
1
  import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
- export declare const createTableWithWidth: ({ isTableScalingEnabled, isTableAlignmentEnabled, isFullWidthModeEnabled, createTableProps, }: {
2
+ export declare const createTableWithWidth: ({ isTableScalingEnabled, isTableAlignmentEnabled, isFullWidthModeEnabled, isCommentEditor, isTableResizingEnabled, createTableProps, }: {
3
3
  isTableScalingEnabled?: boolean | undefined;
4
4
  isTableAlignmentEnabled?: boolean | undefined;
5
5
  isFullWidthModeEnabled?: boolean | undefined;
6
+ isCommentEditor?: boolean | undefined;
7
+ isTableResizingEnabled?: boolean | undefined;
6
8
  createTableProps?: {
7
9
  rowsCount?: number | undefined;
8
10
  colsCount?: number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.21.2",
3
+ "version": "7.21.3",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -231,12 +231,16 @@ export const createTable =
231
231
  isTableAlignmentEnabled?: boolean,
232
232
  isFullWidthModeEnabled?: boolean,
233
233
  editorAnalyticsAPI?: EditorAnalyticsAPI | undefined | null,
234
+ isCommentEditor?: boolean,
235
+ isTableResizingEnabled?: boolean,
234
236
  ): Command =>
235
237
  (state, dispatch) => {
236
238
  const table = createTableWithWidth({
237
239
  isTableScalingEnabled,
238
240
  isTableAlignmentEnabled,
239
241
  isFullWidthModeEnabled,
242
+ isCommentEditor,
243
+ isTableResizingEnabled,
240
244
  })(state.schema);
241
245
 
242
246
  if (dispatch) {
@@ -262,6 +266,7 @@ export const insertTableWithSize =
262
266
  isTableScalingEnabled?: boolean,
263
267
  isTableAlignmentEnabled?: boolean,
264
268
  editorAnalyticsAPI?: EditorAnalyticsAPI,
269
+ isCommentEditor?: boolean,
265
270
  ) =>
266
271
  (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER): EditorCommand => {
267
272
  return ({ tr }) => {
@@ -269,6 +274,7 @@ export const insertTableWithSize =
269
274
  isTableScalingEnabled,
270
275
  isFullWidthModeEnabled,
271
276
  isTableAlignmentEnabled,
277
+ isCommentEditor,
272
278
  createTableProps: {
273
279
  rowsCount: rowsCount,
274
280
  colsCount: colsCount,
@@ -20,7 +20,7 @@ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
20
20
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
21
21
  import { akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
22
22
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
23
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
23
+ import { fg } from '@atlaskit/platform-feature-flags';
24
24
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
25
25
  import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
26
26
  import { token } from '@atlaskit/tokens';
@@ -197,7 +197,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
197
197
  isTableScalingEnabled,
198
198
  } = this.props;
199
199
 
200
- if (getBooleanFF('platform.editor.table.live-pages-sorting_4malx')) {
200
+ if (fg('platform.editor.table.live-pages-sorting_4malx')) {
201
201
  const { mode } =
202
202
  this.props.pluginInjectionApi?.editorViewMode?.sharedState.currentState() || {};
203
203
  if (mode === 'view') {
@@ -305,7 +305,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
305
305
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
306
306
  }
307
307
 
308
- if (getBooleanFF('platform.editor.table.live-pages-sorting_4malx')) {
308
+ if (fg('platform.editor.table.live-pages-sorting_4malx')) {
309
309
  this?.table?.removeEventListener('mouseenter', this.handleMouseEnter);
310
310
  }
311
311
 
@@ -388,7 +388,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
388
388
 
389
389
  const shouldUseIncreasedScalingPercent =
390
390
  (isTableScalingWithFixedColumnWidthsOptionEnabled &&
391
- getBooleanFF('platform.editor.table.use-increased-scaling-percent')) ||
391
+ fg('platform.editor.table.use-increased-scaling-percent')) ||
392
392
  false;
393
393
 
394
394
  if (force || (!isResizing && shouldUpdateColgroup)) {
@@ -448,7 +448,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
448
448
 
449
449
  const table = findTable(view.state.selection);
450
450
 
451
- if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
451
+ if (!fg('platform.editor.table.use-shared-state-hook')) {
452
452
  const pluginState = getPluginState(view.state);
453
453
  isInDanger = pluginState.isInDanger;
454
454
  }
@@ -466,7 +466,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
466
466
  isTableScalingEnabled && tableWithFixedColumnWidthsOption;
467
467
  const shouldUseIncreasedScalingPercent =
468
468
  isTableScalingWithFixedColumnWidthsOptionEnabled &&
469
- getBooleanFF('platform.editor.table.use-increased-scaling-percent');
469
+ fg('platform.editor.table.use-increased-scaling-percent');
470
470
 
471
471
  if (
472
472
  isTableScalingWithFixedColumnWidthsOptionEnabled &&
@@ -651,7 +651,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
651
651
  const { showBeforeShadow, showAfterShadow } = this.state;
652
652
  const node = getNode();
653
653
 
654
- if (!getBooleanFF('platform.editor.table.use-shared-state-hook')) {
654
+ if (!fg('platform.editor.table.use-shared-state-hook')) {
655
655
  const pluginState = getPluginState(view.state);
656
656
  isInDanger = pluginState.isInDanger;
657
657
  hoveredRows = pluginState.hoveredRows;
@@ -748,7 +748,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
748
748
  const shouldUseIncreasedScalingPercent =
749
749
  isTableScalingEnabled &&
750
750
  tableWithFixedColumnWidthsOption &&
751
- getBooleanFF('platform.editor.table.use-increased-scaling-percent');
751
+ fg('platform.editor.table.use-increased-scaling-percent');
752
752
 
753
753
  return (
754
754
  <TableContainer
@@ -774,6 +774,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
774
774
  isWholeTableInDanger={isWholeTableInDanger}
775
775
  isTableAlignmentEnabled={isTableAlignmentEnabled}
776
776
  shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
777
+ isCommentEditor={options?.isCommentEditor}
777
778
  >
778
779
  <div
779
780
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
@@ -174,6 +174,7 @@ type ResizableTableContainerProps = {
174
174
  isTableWithFixedColumnWidthsOptionEnabled?: boolean;
175
175
  isTableAlignmentEnabled?: boolean;
176
176
  shouldUseIncreasedScalingPercent?: boolean;
177
+ isCommentEditor?: boolean;
177
178
  };
178
179
 
179
180
  export const ResizableTableContainer = React.memo(
@@ -194,6 +195,7 @@ export const ResizableTableContainer = React.memo(
194
195
  isTableWithFixedColumnWidthsOptionEnabled,
195
196
  isTableAlignmentEnabled,
196
197
  shouldUseIncreasedScalingPercent,
198
+ isCommentEditor,
197
199
  }: PropsWithChildren<ResizableTableContainerProps>) => {
198
200
  const containerRef = useRef<HTMLDivElement | null>(null);
199
201
  const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
@@ -296,14 +298,21 @@ export const ResizableTableContainer = React.memo(
296
298
  // padding left = padding right = akEditorGutterPadding = 32
297
299
  responsiveContainerWidth = isTableScalingEnabled
298
300
  ? containerWidth - akEditorGutterPaddingDynamic() * 2
299
- : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
301
+ : containerWidth -
302
+ akEditorGutterPaddingDynamic() * 2 -
303
+ (isCommentEditor ? 0 : resizeHandleSpacing);
300
304
  }
301
- let width = Math.min(tableWidth, responsiveContainerWidth);
305
+ let width =
306
+ !node.attrs.width && isCommentEditor
307
+ ? responsiveContainerWidth
308
+ : Math.min(tableWidth, responsiveContainerWidth);
302
309
 
303
310
  if (!isResizing) {
304
311
  tableWidthRef.current = width;
305
312
  }
306
- const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
313
+ const maxResizerWidth = isCommentEditor
314
+ ? responsiveContainerWidth
315
+ : Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
307
316
 
308
317
  const tableResizerProps = {
309
318
  width,
@@ -391,6 +400,7 @@ type TableContainerProps = {
391
400
  isTableWithFixedColumnWidthsOptionEnabled?: boolean;
392
401
  isTableAlignmentEnabled?: boolean;
393
402
  shouldUseIncreasedScalingPercent?: boolean;
403
+ isCommentEditor?: boolean;
394
404
  };
395
405
 
396
406
  export const TableContainer = ({
@@ -411,6 +421,7 @@ export const TableContainer = ({
411
421
  isTableWithFixedColumnWidthsOptionEnabled,
412
422
  isTableAlignmentEnabled,
413
423
  shouldUseIncreasedScalingPercent,
424
+ isCommentEditor,
414
425
  }: PropsWithChildren<TableContainerProps>) => {
415
426
  if (isTableResizingEnabled && !isNested) {
416
427
  return (
@@ -431,6 +442,7 @@ export const TableContainer = ({
431
442
  isWholeTableInDanger={isWholeTableInDanger}
432
443
  isTableAlignmentEnabled={isTableAlignmentEnabled}
433
444
  shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
445
+ isCommentEditor={isCommentEditor}
434
446
  >
435
447
  {children}
436
448
  </ResizableTableContainer>
@@ -22,6 +22,7 @@ type TableViewOptions = {
22
22
  dispatchAnalyticsEvent: DispatchAnalyticsEvent;
23
23
  pluginInjectionApi?: PluginInjectionAPI;
24
24
  isTableAlignmentEnabled?: boolean;
25
+ isCommentEditor?: boolean;
25
26
  };
26
27
 
27
28
  export const lazyTableView = (options: TableViewOptions) => {
@@ -38,6 +39,7 @@ export const lazyTableView = (options: TableViewOptions) => {
38
39
  options.dispatchAnalyticsEvent,
39
40
  options.pluginInjectionApi,
40
41
  options.isTableAlignmentEnabled,
42
+ options.isCommentEditor,
41
43
  );
42
44
  };
43
45
  }
@@ -62,6 +64,7 @@ export const lazyTableView = (options: TableViewOptions) => {
62
64
  dispatchAnalyticsEvent,
63
65
  pluginInjectionApi,
64
66
  isTableAlignmentEnabled,
67
+ isCommentEditor,
65
68
  } = getNodeViewOptions();
66
69
 
67
70
  return createTableView(
@@ -75,6 +78,7 @@ export const lazyTableView = (options: TableViewOptions) => {
75
78
  dispatchAnalyticsEvent,
76
79
  pluginInjectionApi,
77
80
  isTableAlignmentEnabled,
81
+ isCommentEditor,
78
82
  );
79
83
  };
80
84
  });
@@ -43,7 +43,7 @@ const tableAttributes = (node: PmNode) => {
43
43
  'data-layout': node.attrs.layout,
44
44
  'data-autosize': node.attrs.__autoSize,
45
45
  'data-table-local-id': node.attrs.localId || '',
46
- 'data-table-width': node.attrs.width,
46
+ 'data-table-width': node.attrs.width || 'inherit',
47
47
  'data-table-display-mode': node.attrs.displayMode,
48
48
  };
49
49
  };
@@ -54,6 +54,10 @@ const getInlineWidth = (
54
54
  state: EditorState,
55
55
  pos: number | undefined,
56
56
  ): number | undefined => {
57
+ if (!node.attrs.width && options?.isCommentEditor && options?.isTableResizingEnabled) {
58
+ return;
59
+ }
60
+
57
61
  // provide a width for tables when custom table width is supported
58
62
  // this is to ensure 'responsive' tables (colgroup widths are undefined) become fixed to
59
63
  // support screen size adjustments
@@ -360,6 +364,7 @@ export const createTableView = (
360
364
  dispatchAnalyticsEvent: DispatchAnalyticsEvent,
361
365
  pluginInjectionApi?: PluginInjectionAPI,
362
366
  isTableAlignmentEnabled?: boolean,
367
+ isCommentEditor?: boolean,
363
368
  ): NodeView => {
364
369
  const {
365
370
  pluginConfig,
@@ -386,6 +391,7 @@ export const createTableView = (
386
391
  isDragAndDropEnabled,
387
392
  isTableScalingEnabled, // same as options.isTableScalingEnabled
388
393
  isTableAlignmentEnabled,
394
+ isCommentEditor,
389
395
  },
390
396
  getEditorContainerWidth,
391
397
  getEditorFeatureFlags,
@@ -14,6 +14,7 @@ export type TableOptions = {
14
14
  isDragAndDropEnabled?: boolean;
15
15
  isTableScalingEnabled?: boolean;
16
16
  isTableAlignmentEnabled?: boolean;
17
+ isCommentEditor?: boolean;
17
18
  };
18
19
 
19
20
  export interface Props {
package/src/plugin.tsx CHANGED
@@ -97,6 +97,7 @@ export interface TablePluginOptions {
97
97
  isTableScalingEnabled?: boolean;
98
98
  isTableAlignmentEnabled?: boolean;
99
99
  isNewColumnResizingEnabled?: boolean;
100
+ isCommentEditor?: boolean;
100
101
  }
101
102
 
102
103
  type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
@@ -262,6 +263,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
262
263
  isTableScalingEnabled: options?.isTableScalingEnabled,
263
264
  isTableAlignmentEnabled: options?.isTableAlignmentEnabled,
264
265
  isFullWidthModeEnabled: options?.fullWidthEnabled,
266
+ isCommentEditor: options?.isCommentEditor,
267
+ isTableResizingEnabled: options?.tableResizingEnabled,
265
268
  })(state.schema);
266
269
 
267
270
  return (
@@ -324,6 +327,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
324
327
  dragAndDropEnabled,
325
328
  isTableScalingEnabled,
326
329
  isTableAlignmentEnabled,
330
+ isCommentEditor,
327
331
  } = options || ({} as TablePluginOptions);
328
332
 
329
333
  return createPlugin(
@@ -344,6 +348,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
344
348
  isTableScalingEnabled,
345
349
  isTableAlignmentEnabled,
346
350
  shouldUseIncreasedScalingPercent,
351
+ isCommentEditor,
347
352
  );
348
353
  },
349
354
  },
@@ -386,6 +391,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
386
391
  isTableScalingEnabled = false,
387
392
  isTableAlignmentEnabled = false,
388
393
  fullWidthEnabled = false,
394
+ isCommentEditor = false,
395
+ tableResizingEnabled = false,
389
396
  } = options || ({} as TablePluginOptions);
390
397
 
391
398
  return keymapPlugin(
@@ -400,6 +407,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
400
407
  isCellBackgroundDuplicated,
401
408
  isTableFixedColumnWidthsOptionEnabled,
402
409
  shouldUseIncreasedScalingPercent,
410
+ isCommentEditor,
411
+ tableResizingEnabled,
403
412
  );
404
413
  },
405
414
  },
@@ -463,7 +472,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
463
472
  {
464
473
  name: 'tableWidth',
465
474
  plugin: ({ dispatchAnalyticsEvent, dispatch }) =>
466
- options?.tableResizingEnabled
475
+ options?.tableResizingEnabled && !options?.isCommentEditor
467
476
  ? createTableWidthPlugin(
468
477
  dispatch,
469
478
  dispatchAnalyticsEvent,
@@ -717,6 +726,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
717
726
  isTableScalingEnabled: options?.isTableScalingEnabled,
718
727
  isTableAlignmentEnabled: options?.isTableAlignmentEnabled,
719
728
  isFullWidthModeEnabled: tableState?.isFullWidthModeEnabled,
729
+ isCommentEditor: options?.isCommentEditor,
730
+ isTableResizingEnabled: options?.tableResizingEnabled,
720
731
  })(state.schema);
721
732
 
722
733
  const tr = insert(tableNode);
@@ -69,6 +69,8 @@ export function keymapPlugin(
69
69
  isCellBackgroundDuplicated = false,
70
70
  isTableFixedColumnWidthsOptionEnabled = false,
71
71
  shouldUseIncreasedScalingPercent?: boolean,
72
+ isCommentEditor?: boolean,
73
+ isTableResizingEnabled?: boolean,
72
74
  ): SafePlugin {
73
75
  const list = {};
74
76
 
@@ -91,6 +93,8 @@ export function keymapPlugin(
91
93
  isTableAlignmentEnabled,
92
94
  !!isFullWidthEnabled,
93
95
  editorAnalyticsAPI,
96
+ isCommentEditor,
97
+ isTableResizingEnabled,
94
98
  ),
95
99
  list,
96
100
  );
@@ -96,6 +96,7 @@ export const createPlugin = (
96
96
  isTableScalingEnabled?: boolean,
97
97
  isTableAlignmentEnabled?: boolean,
98
98
  shouldUseIncreasedScalingPercent?: boolean,
99
+ isCommentEditor?: boolean,
99
100
  ) => {
100
101
  const state = createPluginState(dispatch, {
101
102
  pluginConfig,
@@ -361,6 +362,7 @@ export const createPlugin = (
361
362
  dispatchAnalyticsEvent,
362
363
  pluginInjectionApi,
363
364
  isTableAlignmentEnabled,
365
+ isCommentEditor,
364
366
  }),
365
367
  tableRow: lazyTableRowView({ eventDispatcher }),
366
368
  tableCell: lazyTableCellView({ eventDispatcher }),
@@ -5,7 +5,7 @@ import { createTable } from '@atlaskit/editor-tables/utils';
5
5
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
6
6
 
7
7
  type CreateTableOverrides = {
8
- tableWidth?: TableAttributes['width'];
8
+ tableWidth?: TableAttributes['width'] | 'inherit';
9
9
  layout?: TableAttributes['layout'];
10
10
  };
11
11
 
@@ -14,11 +14,15 @@ export const createTableWithWidth =
14
14
  isTableScalingEnabled,
15
15
  isTableAlignmentEnabled,
16
16
  isFullWidthModeEnabled,
17
+ isCommentEditor,
18
+ isTableResizingEnabled,
17
19
  createTableProps,
18
20
  }: {
19
21
  isTableScalingEnabled?: boolean;
20
22
  isTableAlignmentEnabled?: boolean;
21
23
  isFullWidthModeEnabled?: boolean;
24
+ isCommentEditor?: boolean;
25
+ isTableResizingEnabled?: boolean;
22
26
  createTableProps?: {
23
27
  rowsCount?: number;
24
28
  colsCount?: number;
@@ -26,12 +30,15 @@ export const createTableWithWidth =
26
30
  }) =>
27
31
  (schema: Schema) => {
28
32
  const attrsOverrides: CreateTableOverrides = {};
29
- if (isTableScalingEnabled && isFullWidthModeEnabled) {
33
+ if (isTableScalingEnabled && isFullWidthModeEnabled && !isCommentEditor) {
30
34
  attrsOverrides.tableWidth = TABLE_MAX_WIDTH;
31
35
  }
32
36
  if (isTableAlignmentEnabled && isFullWidthModeEnabled) {
33
37
  attrsOverrides.layout = 'align-start';
34
38
  }
39
+ if (isCommentEditor && isTableResizingEnabled) {
40
+ attrsOverrides.tableWidth = 'inherit';
41
+ }
35
42
 
36
43
  return createTable({
37
44
  schema,