@atlaskit/editor-plugin-table 7.25.14 → 7.25.15

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.25.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [`be687d5675114`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/be687d5675114) -
8
+ [ux] Fixes a bug where scaled table viewed on a narrow screen loses scaling.
9
+ - Updated dependencies
10
+
3
11
  ## 7.25.14
4
12
 
5
13
  ### Patch Changes
@@ -548,7 +548,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
548
548
  // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
549
549
  !!((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled) && !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor);
550
550
  if (force || !isResizing && shouldUpdateColgroup) {
551
- var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7, _this$props$options8, _this$props$options9;
551
+ var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7;
552
552
  var resizeState = (0, _utils4.getResizeState)({
553
553
  minWidth: _utils4.COLUMN_MIN_WIDTH,
554
554
  maxSize: tableRenderWidth,
@@ -571,14 +571,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
571
571
  shouldScaleOnColgroupUpdate = true;
572
572
  }
573
573
  var scalePercent = 1;
574
- if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
575
- scalePercent = (0, _misc.getTableScalingPercent)(tableNode, this.table, shouldUseIncreasedScalingPercent);
576
- } else {
577
- scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode, this.table);
578
- }
579
-
580
- // Request animation frame required for Firefox
581
574
  requestAnimationFrame(function () {
575
+ var _this2$props$options, _this2$props$options2;
576
+ // Scaling percent has to be calculated inside requestAnimationFrame, otherwise
577
+ // renderWidth calculated as `tableRef?.parentElement?.clientWidth`
578
+ // inside of getTableScalingPercent returns 0.
579
+ if (!((_this2$props$options = _this2.props.options) !== null && _this2$props$options !== void 0 && _this2$props$options.isCommentEditor) || (_this2$props$options2 = _this2.props.options) !== null && _this2$props$options2 !== void 0 && _this2$props$options2.isCommentEditor && tableNode.attrs.width) {
580
+ scalePercent = (0, _misc.getTableScalingPercent)(tableNode, _this2.table, shouldUseIncreasedScalingPercent);
581
+ } else {
582
+ scalePercent = (0, _misc.getScalingPercentForTableWithoutWidth)(tableNode, _this2.table);
583
+ }
584
+
585
+ // Request animation frame required for Firefox
582
586
  (0, _utils4.updateColgroup)(resizeState, _this2.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
583
587
  });
584
588
  }
@@ -590,8 +594,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
590
594
  }, {
591
595
  key: "componentDidUpdate",
592
596
  value: function componentDidUpdate(_, prevState) {
593
- var _this$props$options10,
594
- _this$props$options11,
597
+ var _this$props$options8,
598
+ _this$props$options9,
595
599
  _this$wrapper,
596
600
  _this3 = this;
597
601
  var _this$props11 = this.props,
@@ -620,7 +624,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
620
624
  shouldHandleColgroupUpdates = true;
621
625
  }
622
626
  var isTableScalingWithFixedColumnWidthsOptionEnabled = !!isTableScalingEnabled && tableWithFixedColumnWidthsOption;
623
- var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor);
627
+ var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor);
624
628
  if (isTableScalingWithFixedColumnWidthsOptionEnabled && getNode().attrs.displayMode !== 'fixed') {
625
629
  shouldScale = true;
626
630
  shouldHandleColgroupUpdates = true;
@@ -631,7 +635,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
631
635
  if (isInDanger && !table) {
632
636
  (0, _commands.clearHoverSelection)()(view.state, view.dispatch);
633
637
  }
634
- if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
638
+ if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
635
639
  this.removeInlineTableWidth();
636
640
  }
637
641
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
@@ -718,7 +722,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
718
722
  key: "render",
719
723
  value: function render() {
720
724
  var _this4 = this,
721
- _this$props$options12,
725
+ _this$props$options10,
722
726
  _classnames;
723
727
  var _this$props12 = this.props,
724
728
  view = _this$props12.view,
@@ -837,7 +841,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
837
841
  stickyScrollbar = _getEditorFeatureFlag8.stickyScrollbar,
838
842
  _getEditorFeatureFlag9 = _getEditorFeatureFlag8.tableWithFixedColumnWidthsOption,
839
843
  tableWithFixedColumnWidthsOption = _getEditorFeatureFlag9 === void 0 ? false : _getEditorFeatureFlag9;
840
- var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$options12 = this.props.options) !== null && _this$props$options12 !== void 0 && _this$props$options12.isCommentEditor));
844
+ var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && (0, _platformFeatureFlags.fg)('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
841
845
  return /*#__PURE__*/_react.default.createElement(_TableContainer.TableContainer
842
846
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
843
847
  , {
@@ -529,7 +529,7 @@ class TableComponent extends React.Component {
529
529
  // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
530
530
  !!((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled) && !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor);
531
531
  if (force || !isResizing && shouldUpdateColgroup) {
532
- var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7, _this$props$options8, _this$props$options9;
532
+ var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7;
533
533
  const resizeState = getResizeState({
534
534
  minWidth: COLUMN_MIN_WIDTH,
535
535
  maxSize: tableRenderWidth,
@@ -552,14 +552,18 @@ class TableComponent extends React.Component {
552
552
  shouldScaleOnColgroupUpdate = true;
553
553
  }
554
554
  let scalePercent = 1;
555
- if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
556
- scalePercent = getTableScalingPercent(tableNode, this.table, shouldUseIncreasedScalingPercent);
557
- } else {
558
- scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table);
559
- }
560
-
561
- // Request animation frame required for Firefox
562
555
  requestAnimationFrame(() => {
556
+ var _this$props$options8, _this$props$options9;
557
+ // Scaling percent has to be calculated inside requestAnimationFrame, otherwise
558
+ // renderWidth calculated as `tableRef?.parentElement?.clientWidth`
559
+ // inside of getTableScalingPercent returns 0.
560
+ if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
561
+ scalePercent = getTableScalingPercent(tableNode, this.table, shouldUseIncreasedScalingPercent);
562
+ } else {
563
+ scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table);
564
+ }
565
+
566
+ // Request animation frame required for Firefox
563
567
  updateColgroup(resizeState, this.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
564
568
  });
565
569
  }
@@ -82,7 +82,7 @@ export const getTableScalingPercent = (table, tableRef, shouldUseIncreasedScalin
82
82
  var _tableRef$parentEleme;
83
83
  const maxScalingPercent = shouldUseIncreasedScalingPercent ? MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION : MAX_SCALING_PERCENT;
84
84
  const tableWidth = getTableContainerElementWidth(table);
85
- let renderWidth = (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || tableWidth;
85
+ const renderWidth = (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || tableWidth;
86
86
  // minus 1 here to avoid any 1px scroll in Firefox
87
87
  let scalePercent = (renderWidth - 1) / tableWidth;
88
88
  scalePercent = Math.max(scalePercent, 1 - maxScalingPercent);
@@ -541,7 +541,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
541
541
  // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
542
542
  !!((_this$props$options2 = this.props.options) !== null && _this$props$options2 !== void 0 && _this$props$options2.isTableScalingEnabled) && !!((_this$props$options3 = this.props.options) !== null && _this$props$options3 !== void 0 && _this$props$options3.isCommentEditor);
543
543
  if (force || !isResizing && shouldUpdateColgroup) {
544
- var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7, _this$props$options8, _this$props$options9;
544
+ var _this$props$options4, _this$props$options5, _this$props$options6, _this$props$options7;
545
545
  var resizeState = getResizeState({
546
546
  minWidth: COLUMN_MIN_WIDTH,
547
547
  maxSize: tableRenderWidth,
@@ -564,14 +564,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
564
564
  shouldScaleOnColgroupUpdate = true;
565
565
  }
566
566
  var scalePercent = 1;
567
- if (!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor) || (_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && tableNode.attrs.width) {
568
- scalePercent = getTableScalingPercent(tableNode, this.table, shouldUseIncreasedScalingPercent);
569
- } else {
570
- scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table);
571
- }
572
-
573
- // Request animation frame required for Firefox
574
567
  requestAnimationFrame(function () {
568
+ var _this2$props$options, _this2$props$options2;
569
+ // Scaling percent has to be calculated inside requestAnimationFrame, otherwise
570
+ // renderWidth calculated as `tableRef?.parentElement?.clientWidth`
571
+ // inside of getTableScalingPercent returns 0.
572
+ if (!((_this2$props$options = _this2.props.options) !== null && _this2$props$options !== void 0 && _this2$props$options.isCommentEditor) || (_this2$props$options2 = _this2.props.options) !== null && _this2$props$options2 !== void 0 && _this2$props$options2.isCommentEditor && tableNode.attrs.width) {
573
+ scalePercent = getTableScalingPercent(tableNode, _this2.table, shouldUseIncreasedScalingPercent);
574
+ } else {
575
+ scalePercent = getScalingPercentForTableWithoutWidth(tableNode, _this2.table);
576
+ }
577
+
578
+ // Request animation frame required for Firefox
575
579
  updateColgroup(resizeState, _this2.table, tableNode, shouldScaleOnColgroupUpdate, scalePercent);
576
580
  });
577
581
  }
@@ -583,8 +587,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
583
587
  }, {
584
588
  key: "componentDidUpdate",
585
589
  value: function componentDidUpdate(_, prevState) {
586
- var _this$props$options10,
587
- _this$props$options11,
590
+ var _this$props$options8,
591
+ _this$props$options9,
588
592
  _this$wrapper,
589
593
  _this3 = this;
590
594
  var _this$props11 = this.props,
@@ -613,7 +617,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
613
617
  shouldHandleColgroupUpdates = true;
614
618
  }
615
619
  var isTableScalingWithFixedColumnWidthsOptionEnabled = !!isTableScalingEnabled && tableWithFixedColumnWidthsOption;
616
- var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor);
620
+ var shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && fg('platform.editor.table.use-increased-scaling-percent') || !!isTableScalingEnabled && !!((_this$props$options8 = this.props.options) !== null && _this$props$options8 !== void 0 && _this$props$options8.isCommentEditor);
617
621
  if (isTableScalingWithFixedColumnWidthsOptionEnabled && getNode().attrs.displayMode !== 'fixed') {
618
622
  shouldScale = true;
619
623
  shouldHandleColgroupUpdates = true;
@@ -624,7 +628,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
624
628
  if (isInDanger && !table) {
625
629
  clearHoverSelection()(view.state, view.dispatch);
626
630
  }
627
- if ((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
631
+ if ((_this$props$options9 = this.props.options) !== null && _this$props$options9 !== void 0 && _this$props$options9.isCommentEditor && options !== null && options !== void 0 && options.isTableResizingEnabled) {
628
632
  this.removeInlineTableWidth();
629
633
  }
630
634
  if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
@@ -711,7 +715,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
711
715
  key: "render",
712
716
  value: function render() {
713
717
  var _this4 = this,
714
- _this$props$options12,
718
+ _this$props$options10,
715
719
  _classnames;
716
720
  var _this$props12 = this.props,
717
721
  view = _this$props12.view,
@@ -830,7 +834,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
830
834
  stickyScrollbar = _getEditorFeatureFlag8.stickyScrollbar,
831
835
  _getEditorFeatureFlag9 = _getEditorFeatureFlag8.tableWithFixedColumnWidthsOption,
832
836
  tableWithFixedColumnWidthsOption = _getEditorFeatureFlag9 === void 0 ? false : _getEditorFeatureFlag9;
833
- var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && fg('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$options12 = this.props.options) !== null && _this$props$options12 !== void 0 && _this$props$options12.isCommentEditor));
837
+ var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption && fg('platform.editor.table.use-increased-scaling-percent') || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
834
838
  return /*#__PURE__*/React.createElement(TableContainer
835
839
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
836
840
  , {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.25.14",
3
+ "version": "7.25.15",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/adf-schema": "^40.9.0",
32
32
  "@atlaskit/button": "^20.1.0",
33
33
  "@atlaskit/custom-steps": "^0.7.0",
34
- "@atlaskit/editor-common": "^88.3.0",
34
+ "@atlaskit/editor-common": "^88.4.0",
35
35
  "@atlaskit/editor-palette": "1.6.0",
36
36
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
@@ -483,21 +483,24 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
483
483
  }
484
484
 
485
485
  let scalePercent = 1;
486
- if (
487
- !this.props.options?.isCommentEditor ||
488
- (this.props.options?.isCommentEditor && tableNode.attrs.width)
489
- ) {
490
- scalePercent = getTableScalingPercent(
491
- tableNode,
492
- this.table!,
493
- shouldUseIncreasedScalingPercent,
494
- );
495
- } else {
496
- scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table!);
497
- }
498
-
499
- // Request animation frame required for Firefox
500
486
  requestAnimationFrame(() => {
487
+ // Scaling percent has to be calculated inside requestAnimationFrame, otherwise
488
+ // renderWidth calculated as `tableRef?.parentElement?.clientWidth`
489
+ // inside of getTableScalingPercent returns 0.
490
+ if (
491
+ !this.props.options?.isCommentEditor ||
492
+ (this.props.options?.isCommentEditor && tableNode.attrs.width)
493
+ ) {
494
+ scalePercent = getTableScalingPercent(
495
+ tableNode,
496
+ this.table!,
497
+ shouldUseIncreasedScalingPercent,
498
+ );
499
+ } else {
500
+ scalePercent = getScalingPercentForTableWithoutWidth(tableNode, this.table!);
501
+ }
502
+
503
+ // Request animation frame required for Firefox
501
504
  updateColgroup(
502
505
  resizeState,
503
506
  this.table!,
@@ -135,7 +135,7 @@ export const getTableScalingPercent = (
135
135
  : MAX_SCALING_PERCENT;
136
136
 
137
137
  const tableWidth = getTableContainerElementWidth(table);
138
- let renderWidth = tableRef?.parentElement?.clientWidth || tableWidth;
138
+ const renderWidth = tableRef?.parentElement?.clientWidth || tableWidth;
139
139
  // minus 1 here to avoid any 1px scroll in Firefox
140
140
  let scalePercent = (renderWidth - 1) / tableWidth;
141
141
  scalePercent = Math.max(scalePercent, 1 - maxScalingPercent);