@atlaskit/editor-plugin-table 7.24.1 → 7.24.2

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.24.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#124709](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124709)
8
+ [`a52d9a09ddd5c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a52d9a09ddd5c) -
9
+ [ux] When table resized to full-width in comment editor, it inherits the width of the editor.
10
+
3
11
  ## 7.24.1
4
12
 
5
13
  ### Patch Changes
@@ -471,18 +471,43 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
471
471
  clearTimeout(this.initialOverflowCaptureTimerId);
472
472
  }
473
473
  }
474
+ }, {
475
+ key: "removeInlineTableWidth",
476
+ value:
477
+ // Should be called only when table node width is reset to undefined in Comment Editor
478
+ // Maybe replaced by handleColgroupUpdates as we implement new table's support in Comment Editor.
479
+ function removeInlineTableWidth() {
480
+ var _this$props9 = this.props,
481
+ isResizing = _this$props9.isResizing,
482
+ getNode = _this$props9.getNode,
483
+ view = _this$props9.view,
484
+ getPos = _this$props9.getPos;
485
+ if (!this.table) {
486
+ return;
487
+ }
488
+ var tableNode = getNode();
489
+ var newTableWidth = tableNode.attrs.width;
490
+ var start = getPos() || 0;
491
+ var depth = view.state.doc.resolve(start).depth;
492
+ if (depth !== 0) {
493
+ return;
494
+ }
495
+ if (!isResizing && newTableWidth === null) {
496
+ this.table.style.width = '';
497
+ }
498
+ }
474
499
  }, {
475
500
  key: "handleColgroupUpdates",
476
501
  value: function handleColgroupUpdates() {
477
502
  var _this2 = this;
478
503
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
479
- var _this$props9 = this.props,
480
- getNode = _this$props9.getNode,
481
- containerWidth = _this$props9.containerWidth,
482
- isResizing = _this$props9.isResizing,
483
- view = _this$props9.view,
484
- getPos = _this$props9.getPos,
485
- getEditorFeatureFlags = _this$props9.getEditorFeatureFlags;
504
+ var _this$props10 = this.props,
505
+ getNode = _this$props10.getNode,
506
+ containerWidth = _this$props10.containerWidth,
507
+ isResizing = _this$props10.isResizing,
508
+ view = _this$props10.view,
509
+ getPos = _this$props10.getPos,
510
+ getEditorFeatureFlags = _this$props10.getEditorFeatureFlags;
486
511
  if (!this.table) {
487
512
  return;
488
513
  }
@@ -551,18 +576,19 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
551
576
  }, {
552
577
  key: "componentDidUpdate",
553
578
  value: function componentDidUpdate(_, prevState) {
554
- var _this$wrapper,
579
+ var _this$props$options3,
580
+ _this$wrapper,
555
581
  _this3 = this;
556
- var _this$props10 = this.props,
557
- view = _this$props10.view,
558
- getNode = _this$props10.getNode,
559
- isMediaFullscreen = _this$props10.isMediaFullscreen,
560
- allowColumnResizing = _this$props10.allowColumnResizing,
561
- isResizing = _this$props10.isResizing,
562
- options = _this$props10.options,
563
- isTableScalingEnabled = _this$props10.isTableScalingEnabled,
564
- getPos = _this$props10.getPos,
565
- getEditorFeatureFlags = _this$props10.getEditorFeatureFlags;
582
+ var _this$props11 = this.props,
583
+ view = _this$props11.view,
584
+ getNode = _this$props11.getNode,
585
+ isMediaFullscreen = _this$props11.isMediaFullscreen,
586
+ allowColumnResizing = _this$props11.allowColumnResizing,
587
+ isResizing = _this$props11.isResizing,
588
+ options = _this$props11.options,
589
+ isTableScalingEnabled = _this$props11.isTableScalingEnabled,
590
+ getPos = _this$props11.getPos,
591
+ getEditorFeatureFlags = _this$props11.getEditorFeatureFlags;
566
592
  var isInDanger = this.props.isInDanger;
567
593
  var table = (0, _utils2.findTable)(view.state.selection);
568
594
  if (!(0, _platformFeatureFlags.fg)('platform.editor.table.use-shared-state-hook')) {
@@ -590,6 +616,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
590
616
  if (isInDanger && !table) {
591
617
  (0, _commands.clearHoverSelection)()(view.state, view.dispatch);
592
618
  }
619
+ if ((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
620
+ this.removeInlineTableWidth();
621
+ }
593
622
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
594
623
  if (this.props.isDragAndDropEnabled) {
595
624
  // requestAnimationFrame is used here to fix a race condition issue
@@ -675,30 +704,30 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
675
704
  value: function render() {
676
705
  var _this4 = this,
677
706
  _classnames;
678
- var _this$props11 = this.props,
679
- view = _this$props11.view,
680
- getNode = _this$props11.getNode,
681
- isResizing = _this$props11.isResizing,
682
- _this$props11$allowCo = _this$props11.allowControls,
683
- allowControls = _this$props11$allowCo === void 0 ? true : _this$props11$allowCo,
684
- isHeaderRowEnabled = _this$props11.isHeaderRowEnabled,
685
- ordering = _this$props11.ordering,
686
- isHeaderColumnEnabled = _this$props11.isHeaderColumnEnabled,
687
- tableActive = _this$props11.tableActive,
688
- containerWidth = _this$props11.containerWidth,
689
- options = _this$props11.options,
690
- getPos = _this$props11.getPos,
691
- pluginInjectionApi = _this$props11.pluginInjectionApi,
692
- isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
693
- getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
694
- isTableScalingEnabled = _this$props11.isTableScalingEnabled,
695
- isTableAlignmentEnabled = _this$props11.isTableAlignmentEnabled;
696
707
  var _this$props12 = this.props,
697
- isInDanger = _this$props12.isInDanger,
698
- hoveredRows = _this$props12.hoveredRows,
699
- hoveredCell = _this$props12.hoveredCell,
700
- isTableHovered = _this$props12.isTableHovered,
701
- isWholeTableInDanger = _this$props12.isWholeTableInDanger;
708
+ view = _this$props12.view,
709
+ getNode = _this$props12.getNode,
710
+ isResizing = _this$props12.isResizing,
711
+ _this$props12$allowCo = _this$props12.allowControls,
712
+ allowControls = _this$props12$allowCo === void 0 ? true : _this$props12$allowCo,
713
+ isHeaderRowEnabled = _this$props12.isHeaderRowEnabled,
714
+ ordering = _this$props12.ordering,
715
+ isHeaderColumnEnabled = _this$props12.isHeaderColumnEnabled,
716
+ tableActive = _this$props12.tableActive,
717
+ containerWidth = _this$props12.containerWidth,
718
+ options = _this$props12.options,
719
+ getPos = _this$props12.getPos,
720
+ pluginInjectionApi = _this$props12.pluginInjectionApi,
721
+ isDragAndDropEnabled = _this$props12.isDragAndDropEnabled,
722
+ getEditorFeatureFlags = _this$props12.getEditorFeatureFlags,
723
+ isTableScalingEnabled = _this$props12.isTableScalingEnabled,
724
+ isTableAlignmentEnabled = _this$props12.isTableAlignmentEnabled;
725
+ var _this$props13 = this.props,
726
+ isInDanger = _this$props13.isInDanger,
727
+ hoveredRows = _this$props13.hoveredRows,
728
+ hoveredCell = _this$props13.hoveredCell,
729
+ isTableHovered = _this$props13.isTableHovered,
730
+ isWholeTableInDanger = _this$props13.isWholeTableInDanger;
702
731
  var _this$state3 = this.state,
703
732
  showBeforeShadow = _this$state3.showBeforeShadow,
704
733
  showAfterShadow = _this$state3.showAfterShadow;
@@ -297,7 +297,8 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
297
297
  dispatch = editorView.dispatch;
298
298
  var pos = getPos();
299
299
  var currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
300
- var tableMaxWidth = isCommentEditor ? containerWidth - _utils3.TABLE_OFFSET_IN_COMMENT_EDITOR : _utils3.TABLE_MAX_WIDTH;
300
+ var tableMaxWidth = isCommentEditor ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
301
+ : _utils3.TABLE_MAX_WIDTH;
301
302
  newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? tableMaxWidth : newWidth;
302
303
  var tr = state.tr.setMeta(_tableWidth.pluginKey, {
303
304
  resizing: false,
@@ -337,12 +338,12 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
337
338
  }
338
339
  displayGapCursor(true);
339
340
  dispatch(tr);
340
- if (delta.width < 0) {
341
+ if (delta.width < 0 && newWidth !== undefined) {
341
342
  var _pluginInjectionApi$a3;
342
343
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a3 === void 0 || _pluginInjectionApi$a3.actions.ariaNotify(formatMessage(_messages.tableMessages.tableSizeDecreaseScreenReaderInformation, {
343
344
  newWidth: newWidth
344
345
  }));
345
- } else if (delta.width > 0) {
346
+ } else if (delta.width > 0 && newWidth !== undefined) {
346
347
  var _pluginInjectionApi$a4;
347
348
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a4 === void 0 || _pluginInjectionApi$a4.actions.ariaNotify(formatMessage(_messages.tableMessages.tableSizeIncreaseScreenReaderInformation, {
348
349
  newWidth: newWidth
@@ -351,13 +352,13 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
351
352
 
352
353
  // Hide guidelines when resizing stops
353
354
  displayGuideline([]);
354
- updateWidth(newWidth);
355
+ newWidth !== undefined && updateWidth(newWidth);
355
356
  scheduleResize.cancel();
356
357
  if (onResizeStop) {
357
358
  onResizeStop();
358
359
  }
359
360
  return newWidth;
360
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, containerWidth, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
361
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
361
362
  var handleTableSizeChangeOnKeypress = (0, _react.useCallback)(function (step) {
362
363
  var newWidth = width + step;
363
364
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -455,6 +455,29 @@ class TableComponent extends React.Component {
455
455
  clearTimeout(this.initialOverflowCaptureTimerId);
456
456
  }
457
457
  }
458
+ // Should be called only when table node width is reset to undefined in Comment Editor
459
+ // Maybe replaced by handleColgroupUpdates as we implement new table's support in Comment Editor.
460
+ removeInlineTableWidth() {
461
+ const {
462
+ isResizing,
463
+ getNode,
464
+ view,
465
+ getPos
466
+ } = this.props;
467
+ if (!this.table) {
468
+ return;
469
+ }
470
+ const tableNode = getNode();
471
+ const newTableWidth = tableNode.attrs.width;
472
+ const start = getPos() || 0;
473
+ const depth = view.state.doc.resolve(start).depth;
474
+ if (depth !== 0) {
475
+ return;
476
+ }
477
+ if (!isResizing && newTableWidth === null) {
478
+ this.table.style.width = '';
479
+ }
480
+ }
458
481
  handleColgroupUpdates(force = false) {
459
482
  const {
460
483
  getNode,
@@ -532,7 +555,7 @@ class TableComponent extends React.Component {
532
555
  this.containerWidth = containerWidth;
533
556
  }
534
557
  componentDidUpdate(_, prevState) {
535
- var _this$wrapper;
558
+ var _this$props$options3, _this$wrapper;
536
559
  const {
537
560
  view,
538
561
  getNode,
@@ -574,6 +597,9 @@ class TableComponent extends React.Component {
574
597
  if (isInDanger && !table) {
575
598
  clearHoverSelection()(view.state, view.dispatch);
576
599
  }
600
+ if ((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
601
+ this.removeInlineTableWidth();
602
+ }
577
603
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
578
604
  if (this.props.isDragAndDropEnabled) {
579
605
  // requestAnimationFrame is used here to fix a race condition issue
@@ -292,7 +292,8 @@ export const TableResizer = ({
292
292
  } = editorView;
293
293
  const pos = getPos();
294
294
  const currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
295
- const tableMaxWidth = isCommentEditor ? containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR : TABLE_MAX_WIDTH;
295
+ const tableMaxWidth = isCommentEditor ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
296
+ : TABLE_MAX_WIDTH;
296
297
  newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? tableMaxWidth : newWidth;
297
298
  let tr = state.tr.setMeta(tableWidthPluginKey, {
298
299
  resizing: false,
@@ -333,12 +334,12 @@ export const TableResizer = ({
333
334
  }
334
335
  displayGapCursor(true);
335
336
  dispatch(tr);
336
- if (delta.width < 0) {
337
+ if (delta.width < 0 && newWidth !== undefined) {
337
338
  var _pluginInjectionApi$a3;
338
339
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions.ariaNotify(formatMessage(messages.tableSizeDecreaseScreenReaderInformation, {
339
340
  newWidth: newWidth
340
341
  }));
341
- } else if (delta.width > 0) {
342
+ } else if (delta.width > 0 && newWidth !== undefined) {
342
343
  var _pluginInjectionApi$a4;
343
344
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions.ariaNotify(formatMessage(messages.tableSizeIncreaseScreenReaderInformation, {
344
345
  newWidth: newWidth
@@ -347,13 +348,13 @@ export const TableResizer = ({
347
348
 
348
349
  // Hide guidelines when resizing stops
349
350
  displayGuideline([]);
350
- updateWidth(newWidth);
351
+ newWidth !== undefined && updateWidth(newWidth);
351
352
  scheduleResize.cancel();
352
353
  if (onResizeStop) {
353
354
  onResizeStop();
354
355
  }
355
356
  return newWidth;
356
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, containerWidth, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
357
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
357
358
  const handleTableSizeChangeOnKeypress = useCallback(step => {
358
359
  const newWidth = width + step;
359
360
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -464,18 +464,43 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
464
464
  clearTimeout(this.initialOverflowCaptureTimerId);
465
465
  }
466
466
  }
467
+ }, {
468
+ key: "removeInlineTableWidth",
469
+ value:
470
+ // Should be called only when table node width is reset to undefined in Comment Editor
471
+ // Maybe replaced by handleColgroupUpdates as we implement new table's support in Comment Editor.
472
+ function removeInlineTableWidth() {
473
+ var _this$props9 = this.props,
474
+ isResizing = _this$props9.isResizing,
475
+ getNode = _this$props9.getNode,
476
+ view = _this$props9.view,
477
+ getPos = _this$props9.getPos;
478
+ if (!this.table) {
479
+ return;
480
+ }
481
+ var tableNode = getNode();
482
+ var newTableWidth = tableNode.attrs.width;
483
+ var start = getPos() || 0;
484
+ var depth = view.state.doc.resolve(start).depth;
485
+ if (depth !== 0) {
486
+ return;
487
+ }
488
+ if (!isResizing && newTableWidth === null) {
489
+ this.table.style.width = '';
490
+ }
491
+ }
467
492
  }, {
468
493
  key: "handleColgroupUpdates",
469
494
  value: function handleColgroupUpdates() {
470
495
  var _this2 = this;
471
496
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
472
- var _this$props9 = this.props,
473
- getNode = _this$props9.getNode,
474
- containerWidth = _this$props9.containerWidth,
475
- isResizing = _this$props9.isResizing,
476
- view = _this$props9.view,
477
- getPos = _this$props9.getPos,
478
- getEditorFeatureFlags = _this$props9.getEditorFeatureFlags;
497
+ var _this$props10 = this.props,
498
+ getNode = _this$props10.getNode,
499
+ containerWidth = _this$props10.containerWidth,
500
+ isResizing = _this$props10.isResizing,
501
+ view = _this$props10.view,
502
+ getPos = _this$props10.getPos,
503
+ getEditorFeatureFlags = _this$props10.getEditorFeatureFlags;
479
504
  if (!this.table) {
480
505
  return;
481
506
  }
@@ -544,18 +569,19 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
544
569
  }, {
545
570
  key: "componentDidUpdate",
546
571
  value: function componentDidUpdate(_, prevState) {
547
- var _this$wrapper,
572
+ var _this$props$options3,
573
+ _this$wrapper,
548
574
  _this3 = this;
549
- var _this$props10 = this.props,
550
- view = _this$props10.view,
551
- getNode = _this$props10.getNode,
552
- isMediaFullscreen = _this$props10.isMediaFullscreen,
553
- allowColumnResizing = _this$props10.allowColumnResizing,
554
- isResizing = _this$props10.isResizing,
555
- options = _this$props10.options,
556
- isTableScalingEnabled = _this$props10.isTableScalingEnabled,
557
- getPos = _this$props10.getPos,
558
- getEditorFeatureFlags = _this$props10.getEditorFeatureFlags;
575
+ var _this$props11 = this.props,
576
+ view = _this$props11.view,
577
+ getNode = _this$props11.getNode,
578
+ isMediaFullscreen = _this$props11.isMediaFullscreen,
579
+ allowColumnResizing = _this$props11.allowColumnResizing,
580
+ isResizing = _this$props11.isResizing,
581
+ options = _this$props11.options,
582
+ isTableScalingEnabled = _this$props11.isTableScalingEnabled,
583
+ getPos = _this$props11.getPos,
584
+ getEditorFeatureFlags = _this$props11.getEditorFeatureFlags;
559
585
  var isInDanger = this.props.isInDanger;
560
586
  var table = findTable(view.state.selection);
561
587
  if (!fg('platform.editor.table.use-shared-state-hook')) {
@@ -583,6 +609,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
583
609
  if (isInDanger && !table) {
584
610
  clearHoverSelection()(view.state, view.dispatch);
585
611
  }
612
+ if ((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
613
+ this.removeInlineTableWidth();
614
+ }
586
615
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
587
616
  if (this.props.isDragAndDropEnabled) {
588
617
  // requestAnimationFrame is used here to fix a race condition issue
@@ -668,30 +697,30 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
668
697
  value: function render() {
669
698
  var _this4 = this,
670
699
  _classnames;
671
- var _this$props11 = this.props,
672
- view = _this$props11.view,
673
- getNode = _this$props11.getNode,
674
- isResizing = _this$props11.isResizing,
675
- _this$props11$allowCo = _this$props11.allowControls,
676
- allowControls = _this$props11$allowCo === void 0 ? true : _this$props11$allowCo,
677
- isHeaderRowEnabled = _this$props11.isHeaderRowEnabled,
678
- ordering = _this$props11.ordering,
679
- isHeaderColumnEnabled = _this$props11.isHeaderColumnEnabled,
680
- tableActive = _this$props11.tableActive,
681
- containerWidth = _this$props11.containerWidth,
682
- options = _this$props11.options,
683
- getPos = _this$props11.getPos,
684
- pluginInjectionApi = _this$props11.pluginInjectionApi,
685
- isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
686
- getEditorFeatureFlags = _this$props11.getEditorFeatureFlags,
687
- isTableScalingEnabled = _this$props11.isTableScalingEnabled,
688
- isTableAlignmentEnabled = _this$props11.isTableAlignmentEnabled;
689
700
  var _this$props12 = this.props,
690
- isInDanger = _this$props12.isInDanger,
691
- hoveredRows = _this$props12.hoveredRows,
692
- hoveredCell = _this$props12.hoveredCell,
693
- isTableHovered = _this$props12.isTableHovered,
694
- isWholeTableInDanger = _this$props12.isWholeTableInDanger;
701
+ view = _this$props12.view,
702
+ getNode = _this$props12.getNode,
703
+ isResizing = _this$props12.isResizing,
704
+ _this$props12$allowCo = _this$props12.allowControls,
705
+ allowControls = _this$props12$allowCo === void 0 ? true : _this$props12$allowCo,
706
+ isHeaderRowEnabled = _this$props12.isHeaderRowEnabled,
707
+ ordering = _this$props12.ordering,
708
+ isHeaderColumnEnabled = _this$props12.isHeaderColumnEnabled,
709
+ tableActive = _this$props12.tableActive,
710
+ containerWidth = _this$props12.containerWidth,
711
+ options = _this$props12.options,
712
+ getPos = _this$props12.getPos,
713
+ pluginInjectionApi = _this$props12.pluginInjectionApi,
714
+ isDragAndDropEnabled = _this$props12.isDragAndDropEnabled,
715
+ getEditorFeatureFlags = _this$props12.getEditorFeatureFlags,
716
+ isTableScalingEnabled = _this$props12.isTableScalingEnabled,
717
+ isTableAlignmentEnabled = _this$props12.isTableAlignmentEnabled;
718
+ var _this$props13 = this.props,
719
+ isInDanger = _this$props13.isInDanger,
720
+ hoveredRows = _this$props13.hoveredRows,
721
+ hoveredCell = _this$props13.hoveredCell,
722
+ isTableHovered = _this$props13.isTableHovered,
723
+ isWholeTableInDanger = _this$props13.isWholeTableInDanger;
695
724
  var _this$state3 = this.state,
696
725
  showBeforeShadow = _this$state3.showBeforeShadow,
697
726
  showAfterShadow = _this$state3.showAfterShadow;
@@ -287,7 +287,8 @@ export var TableResizer = function TableResizer(_ref) {
287
287
  dispatch = editorView.dispatch;
288
288
  var pos = getPos();
289
289
  var currentTableNodeLocalId = (_node$attrs$localId2 = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) !== null && _node$attrs$localId2 !== void 0 ? _node$attrs$localId2 : '';
290
- var tableMaxWidth = isCommentEditor ? containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR : TABLE_MAX_WIDTH;
290
+ var tableMaxWidth = isCommentEditor ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
291
+ : TABLE_MAX_WIDTH;
291
292
  newWidth = widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId] ? tableMaxWidth : newWidth;
292
293
  var tr = state.tr.setMeta(tableWidthPluginKey, {
293
294
  resizing: false,
@@ -327,12 +328,12 @@ export var TableResizer = function TableResizer(_ref) {
327
328
  }
328
329
  displayGapCursor(true);
329
330
  dispatch(tr);
330
- if (delta.width < 0) {
331
+ if (delta.width < 0 && newWidth !== undefined) {
331
332
  var _pluginInjectionApi$a3;
332
333
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a3 === void 0 || _pluginInjectionApi$a3.actions.ariaNotify(formatMessage(messages.tableSizeDecreaseScreenReaderInformation, {
333
334
  newWidth: newWidth
334
335
  }));
335
- } else if (delta.width > 0) {
336
+ } else if (delta.width > 0 && newWidth !== undefined) {
336
337
  var _pluginInjectionApi$a4;
337
338
  pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a4 === void 0 || _pluginInjectionApi$a4.actions.ariaNotify(formatMessage(messages.tableSizeIncreaseScreenReaderInformation, {
338
339
  newWidth: newWidth
@@ -341,13 +342,13 @@ export var TableResizer = function TableResizer(_ref) {
341
342
 
342
343
  // Hide guidelines when resizing stops
343
344
  displayGuideline([]);
344
- updateWidth(newWidth);
345
+ newWidth !== undefined && updateWidth(newWidth);
345
346
  scheduleResize.cancel();
346
347
  if (onResizeStop) {
347
348
  onResizeStop();
348
349
  }
349
350
  return newWidth;
350
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, containerWidth, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
351
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled, shouldUseIncreasedScalingPercent, widthToWidest, formatMessage, pluginInjectionApi, isCommentEditor]);
351
352
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
352
353
  var newWidth = width + step;
353
354
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.24.1",
3
+ "version": "7.24.2",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -343,6 +343,28 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
343
343
  this.props.view.dispatch(tr);
344
344
  };
345
345
 
346
+ // Should be called only when table node width is reset to undefined in Comment Editor
347
+ // Maybe replaced by handleColgroupUpdates as we implement new table's support in Comment Editor.
348
+ removeInlineTableWidth() {
349
+ const { isResizing, getNode, view, getPos } = this.props;
350
+ if (!this.table) {
351
+ return;
352
+ }
353
+
354
+ const tableNode = getNode();
355
+ const newTableWidth = tableNode.attrs.width;
356
+
357
+ const start = getPos() || 0;
358
+ const depth = view.state.doc.resolve(start).depth;
359
+ if (depth !== 0) {
360
+ return;
361
+ }
362
+
363
+ if (!isResizing && newTableWidth === null) {
364
+ this.table.style.width = '';
365
+ }
366
+ }
367
+
346
368
  handleColgroupUpdates(force = false) {
347
369
  const { getNode, containerWidth, isResizing, view, getPos, getEditorFeatureFlags } = this.props;
348
370
 
@@ -498,6 +520,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
498
520
  clearHoverSelection()(view.state, view.dispatch);
499
521
  }
500
522
 
523
+ if (this.props.options?.isCommentEditor && options?.isTableResizingEnabled) {
524
+ this.removeInlineTableWidth();
525
+ }
526
+
501
527
  if (this.wrapper?.parentElement && this.table && !this.overflowShadowsObserver) {
502
528
  if (this.props.isDragAndDropEnabled) {
503
529
  // requestAnimationFrame is used here to fix a race condition issue
@@ -533,6 +559,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
533
559
  { priority: 'important' },
534
560
  );
535
561
  }
562
+
536
563
  if (currentTable.attrs.__autoSize) {
537
564
  // Wait for next tick to handle auto sizing, gives the browser time to do layout calc etc.
538
565
  this.handleAutoSizeDebounced();
@@ -566,6 +593,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
566
593
 
567
594
  this.handleTableResizingDebounced();
568
595
  }
596
+
569
597
  if (isOverflowAnalyticsEnabled) {
570
598
  const newIsOverflowing =
571
599
  this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
@@ -533,13 +533,13 @@ export const TableResizer = ({
533
533
  const handleResizeStop = useCallback<HandleResize>(
534
534
  (originalState, delta) => {
535
535
  isResizing.current = false;
536
- let newWidth = originalState.width + delta.width;
536
+ let newWidth: number | undefined = originalState.width + delta.width;
537
537
  const { state, dispatch } = editorView;
538
538
  const pos = getPos();
539
539
  const currentTableNodeLocalId = node?.attrs?.localId ?? '';
540
540
 
541
541
  const tableMaxWidth = isCommentEditor
542
- ? containerWidth - TABLE_OFFSET_IN_COMMENT_EDITOR
542
+ ? undefined // Table's full-width in comment appearance inherit the width of the Editor/Renderer
543
543
  : TABLE_MAX_WIDTH;
544
544
 
545
545
  newWidth =
@@ -598,13 +598,13 @@ export const TableResizer = ({
598
598
  displayGapCursor(true);
599
599
  dispatch(tr);
600
600
 
601
- if (delta.width < 0) {
601
+ if (delta.width < 0 && newWidth !== undefined) {
602
602
  pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify(
603
603
  formatMessage(messages.tableSizeDecreaseScreenReaderInformation, {
604
604
  newWidth: newWidth,
605
605
  }),
606
606
  );
607
- } else if (delta.width > 0) {
607
+ } else if (delta.width > 0 && newWidth !== undefined) {
608
608
  pluginInjectionApi?.accessibilityUtils?.actions.ariaNotify(
609
609
  formatMessage(messages.tableSizeIncreaseScreenReaderInformation, {
610
610
  newWidth: newWidth,
@@ -614,7 +614,7 @@ export const TableResizer = ({
614
614
 
615
615
  // Hide guidelines when resizing stops
616
616
  displayGuideline([]);
617
- updateWidth(newWidth);
617
+ newWidth !== undefined && updateWidth(newWidth);
618
618
  scheduleResize.cancel();
619
619
 
620
620
  if (onResizeStop) {
@@ -632,7 +632,6 @@ export const TableResizer = ({
632
632
  tableRef,
633
633
  scheduleResize,
634
634
  displayGuideline,
635
- containerWidth,
636
635
  attachAnalyticsEvent,
637
636
  endMeasure,
638
637
  onResizeStop,