@atlaskit/editor-plugin-table 22.0.0 → 22.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 22.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 22.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`3394e81c10e6e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3394e81c10e6e) -
14
+ Fix table flicker on focus: defer data-initial-width-mode removal to after colgroup update.
15
+ Consolidate isTableInContentMode and hasTableBeenResized into editor-common/table.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 22.0.0
4
22
 
5
23
  ### Major Changes
@@ -21,6 +21,7 @@ var _collab = require("@atlaskit/editor-common/collab");
21
21
  var _nesting = require("@atlaskit/editor-common/nesting");
22
22
  var _nodeVisibility = require("@atlaskit/editor-common/node-visibility");
23
23
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
24
+ var _table = require("@atlaskit/editor-common/table");
24
25
  var _utils = require("@atlaskit/editor-common/utils");
25
26
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
26
27
  var _utils2 = require("@atlaskit/editor-tables/utils");
@@ -38,7 +39,8 @@ var _misc = require("../pm-plugins/table-resizing/utils/misc");
38
39
  var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
39
40
  var _scaleTable = require("../pm-plugins/table-resizing/utils/scale-table");
40
41
  var _nodes = require("../pm-plugins/utils/nodes");
41
- var _table = require("../pm-plugins/utils/table");
42
+ var _table2 = require("../pm-plugins/utils/table");
43
+ var _tableMode = require("../pm-plugins/utils/tableMode");
42
44
  var _types = require("../types");
43
45
  var _eventHandlers = require("../ui/event-handlers");
44
46
  var _TableFloatingColumnControls = _interopRequireDefault(require("../ui/TableFloatingColumnControls"));
@@ -720,7 +722,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
720
722
  var isNoOfRowsChanged = (0, _nodes.tablesHaveDifferentNoOfRows)(currentTable, previousTable);
721
723
  if (isNoOfColumnsChanged || isNoOfRowsChanged) {
722
724
  var _this$props$pluginInj;
723
- (_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify((0, _table.getAssistiveMessage)(previousTable, currentTable, this.props.intl), {
725
+ (_this$props$pluginInj = this.props.pluginInjectionApi) === null || _this$props$pluginInj === void 0 || (_this$props$pluginInj = _this$props$pluginInj.accessibilityUtils) === null || _this$props$pluginInj === void 0 || _this$props$pluginInj.actions.ariaNotify((0, _table2.getAssistiveMessage)(previousTable, currentTable, this.props.intl), {
724
726
  priority: 'important'
725
727
  });
726
728
  }
@@ -737,10 +739,24 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
737
739
  var view = this.props.view;
738
740
  var shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
739
741
  if (shouldRecreateResizeCols) {
742
+ var _this$table7, _this$props$options10, _this$props$options11;
740
743
  var start = getPos() || 0;
741
744
  var depth = view.state.doc.resolve(start).depth;
742
745
  shouldScale = depth === 0 && shouldScale;
743
746
  (0, _colgroup.insertColgroupFromNode)(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
747
+
748
+ // Deferred from setDomAttrs — remove only once colgroup is updated and table has left content mode.
749
+ if ((_this$table7 = this.table) !== null && _this$table7 !== void 0 && _this$table7.hasAttribute('data-initial-width-mode') && !(0, _table.isTableInContentMode)({
750
+ tableNode: currentTable,
751
+ isSupported: (0, _tableMode.isContentModeSupported)({
752
+ allowColumnResizing: !!allowColumnResizing,
753
+ allowTableResizing: !!allowTableResizing,
754
+ isFullPageEditor: !((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor) && !((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isChromelessEditor)
755
+ }),
756
+ isTableNested: (0, _nodes.isTableNested)(view.state, getPos())
757
+ })) {
758
+ this.table.removeAttribute('data-initial-width-mode');
759
+ }
744
760
  }
745
761
  (0, _dom.updateControls)()(view.state);
746
762
  }
@@ -768,7 +784,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
768
784
  key: "render",
769
785
  value: function render() {
770
786
  var _this5 = this,
771
- _this$props$options10;
787
+ _this$props$options12;
772
788
  var _this$props10 = this.props,
773
789
  view = _this$props10.view,
774
790
  getNode = _this$props10.getNode,
@@ -872,7 +888,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
872
888
  var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
873
889
  _getEditorFeatureFlag4 = _getEditorFeatureFlag3.tableWithFixedColumnWidthsOption,
874
890
  tableWithFixedColumnWidthsOption = _getEditorFeatureFlag4 === void 0 ? false : _getEditorFeatureFlag4;
875
- var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
891
+ var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options12 = this.props.options) !== null && _this$props$options12 !== void 0 && _this$props$options12.isCommentEditor));
876
892
  return /*#__PURE__*/_react.default.createElement(_TableContainer.TableContainer
877
893
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
878
894
  , {
@@ -16,13 +16,13 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
16
16
  var _react = _interopRequireDefault(require("react"));
17
17
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
18
18
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
19
+ var _table = require("@atlaskit/editor-common/table");
19
20
  var _model = require("@atlaskit/editor-prosemirror/model");
20
21
  var _state = require("@atlaskit/editor-prosemirror/state");
21
22
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
22
23
  var _tableMap = require("@atlaskit/editor-tables/table-map");
23
24
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
24
25
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
25
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
26
26
  var _createPluginConfig = require("../pm-plugins/create-plugin-config");
27
27
  var _pluginFactory = require("../pm-plugins/plugin-factory");
28
28
  var _tableWidth = require("../pm-plugins/table-width");
@@ -206,7 +206,9 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
206
206
  }, {
207
207
  key: "setDomAttrs",
208
208
  value: function setDomAttrs(node) {
209
- var _this3 = this,
209
+ var _this$reactComponentP6,
210
+ _this$reactComponentP7,
211
+ _this3 = this,
210
212
  _this$reactComponentP8,
211
213
  _this$getEditorFeatur2,
212
214
  _this$options3,
@@ -215,19 +217,19 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
215
217
  return; // width / attribute application to actual table will happen later when table is set
216
218
  }
217
219
  var attrs = tableAttributes(node);
218
- if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
219
- var _this$reactComponentP6, _this$reactComponentP7;
220
- if ((0, _tableMode.isTableInContentMode)({
221
- node: node,
220
+
221
+ // render table with content-mode attribute which removes all width constraints from the table
222
+ // fire exposure here
223
+ if ((0, _table.isTableInContentMode)({
224
+ tableNode: node,
225
+ isSupported: (0, _tableMode.isContentModeSupported)({
222
226
  allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
223
227
  allowTableResizing: !!this.reactComponentProps.allowTableResizing,
224
- isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor),
225
- isTableNested: (0, _nodes.isTableNested)(this.view.state, this.getPos())
226
- }) && (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
227
- attrs['data-initial-width-mode'] = 'content';
228
- } else {
229
- this.table.removeAttribute('data-initial-width-mode');
230
- }
228
+ isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor)
229
+ }),
230
+ isTableNested: (0, _nodes.isTableNested)(this.view.state, this.getPos())
231
+ }) && (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
232
+ attrs['data-initial-width-mode'] = 'content';
231
233
  }
232
234
  Object.keys(attrs).forEach(function (attr) {
233
235
  // Ignored via go/ees005
@@ -12,6 +12,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
12
12
  var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
13
13
  var _adfSchema = require("@atlaskit/adf-schema");
14
14
  var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
15
+ var _table = require("@atlaskit/editor-common/table");
15
16
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
16
17
  var _colgroup = require("../pm-plugins/table-resizing/utils/colgroup");
17
18
  var _consts = require("../pm-plugins/table-resizing/utils/consts");
@@ -25,11 +26,13 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
25
26
  return _objectSpread(_objectSpread({}, tableNode), {}, {
26
27
  toDOM: function toDOM(node) {
27
28
  var isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
28
- var isInContentMode = (0, _tableMode.isTableInContentMode)({
29
- node: node,
30
- allowColumnResizing: config.allowColumnResizing,
31
- allowTableResizing: config.tableResizingEnabled,
32
- isFullPageEditor: isFullPageEditor,
29
+ var isInContentMode = (0, _table.isTableInContentMode)({
30
+ tableNode: node,
31
+ isSupported: (0, _tableMode.isContentModeSupported)({
32
+ allowColumnResizing: config.allowColumnResizing,
33
+ allowTableResizing: config.tableResizingEnabled,
34
+ isFullPageEditor: isFullPageEditor
35
+ }),
33
36
  isTableNested: config.isNested
34
37
  }) && (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true);
35
38
  var alignmentStyle = Object.entries((0, _tableContainerStyles.getAlignmentStyle)(node.attrs.layout)).map(function (_ref) {
@@ -9,6 +9,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _steps = require("@atlaskit/adf-schema/steps");
11
11
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
+ var _table = require("@atlaskit/editor-common/table");
12
13
  var _document = require("@atlaskit/editor-common/utils/document");
13
14
  var _state = require("@atlaskit/editor-prosemirror/state");
14
15
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -69,11 +70,13 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, dispat
69
70
  var tr = newState.tr;
70
71
  if (isReplaceDocumentOperation && !isCommentEditor) {
71
72
  newState.doc.forEach(function (node, offset) {
72
- if ((0, _tableMode.isTableInContentMode)({
73
- node: node,
74
- allowColumnResizing: true,
75
- allowTableResizing: true,
76
- isFullPageEditor: true,
73
+ if ((0, _table.isTableInContentMode)({
74
+ tableNode: node,
75
+ isSupported: (0, _tableMode.isContentModeSupported)({
76
+ allowColumnResizing: true,
77
+ allowTableResizing: true,
78
+ isFullPageEditor: true
79
+ }),
77
80
  isTableNested: false
78
81
  })) {
79
82
  return;
@@ -3,41 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isTableInContentMode = exports.isContentModeSupported = exports.hasTableBeenResized = exports.applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToAllTables = void 0;
6
+ exports.isContentModeSupported = exports.applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToAllTables = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _styles = require("@atlaskit/editor-common/styles");
9
+ var _table = require("@atlaskit/editor-common/table");
9
10
  var _utils = require("@atlaskit/editor-tables/utils");
10
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
11
- var _colgroup = require("../table-resizing/utils/colgroup");
12
11
  var _contentMode = require("../transforms/content-mode");
13
- var _alignment = require("./alignment");
14
- var isTableInContentMode = exports.isTableInContentMode = function isTableInContentMode(_ref) {
12
+ var isContentModeSupported = exports.isContentModeSupported = function isContentModeSupported(_ref) {
15
13
  var allowColumnResizing = _ref.allowColumnResizing,
16
14
  allowTableResizing = _ref.allowTableResizing,
17
- isFullPageEditor = _ref.isFullPageEditor,
18
- isTableNested = _ref.isTableNested,
19
- node = _ref.node;
20
- if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
21
- return false;
22
- }
23
- if (!node || isTableNested) {
24
- return false;
25
- }
26
- return isContentModeSupported({
27
- allowColumnResizing: allowColumnResizing,
28
- allowTableResizing: allowTableResizing,
29
- isFullPageEditor: isFullPageEditor
30
- }) && !hasTableBeenResized(node) && node.attrs.layout === _alignment.ALIGN_START;
31
- };
32
- var isContentModeSupported = exports.isContentModeSupported = function isContentModeSupported(_ref2) {
33
- var allowColumnResizing = _ref2.allowColumnResizing,
34
- allowTableResizing = _ref2.allowTableResizing,
35
- isFullPageEditor = _ref2.isFullPageEditor;
15
+ isFullPageEditor = _ref.isFullPageEditor;
36
16
  return allowColumnResizing && allowTableResizing && isFullPageEditor;
37
17
  };
38
- var hasTableBeenResized = exports.hasTableBeenResized = function hasTableBeenResized(node) {
39
- return node.attrs.width !== null || (0, _colgroup.hasTableColumnBeenResized)(node);
40
- };
41
18
 
42
19
  /**
43
20
  * Iterates all top-level tables in the document, and for those in content mode,
@@ -55,7 +32,7 @@ var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = func
55
32
 
56
33
  // modify only top-level tables
57
34
  doc.forEach(function (node, offset) {
58
- if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== _alignment.ALIGN_START) {
35
+ if (node.type !== table || (0, _table.hasTableBeenResized)(node) && node.attrs.layout !== 'align-start') {
59
36
  return;
60
37
  }
61
38
  var domNode = view.domAtPos(offset + 1).node;
@@ -70,10 +47,10 @@ var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = func
70
47
  measurement: (0, _contentMode.getTableMeasurement)(tableRef)
71
48
  });
72
49
  });
73
- measuredTables.forEach(function (_ref3) {
74
- var node = _ref3.node,
75
- offset = _ref3.offset,
76
- measurement = _ref3.measurement;
50
+ measuredTables.forEach(function (_ref2) {
51
+ var node = _ref2.node,
52
+ offset = _ref2.offset,
53
+ measurement = _ref2.measurement;
77
54
  tr = (0, _contentMode.applyTableMeasurement)(tr, node, measurement, offset);
78
55
  modified = true;
79
56
  });
@@ -87,8 +64,8 @@ var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = func
87
64
  attributes: {
88
65
  editorContainerWidth: (_pluginInjectionApi$w = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w2 = pluginInjectionApi.width) === null || _pluginInjectionApi$w2 === void 0 || (_pluginInjectionApi$w2 = _pluginInjectionApi$w2.sharedState.currentState()) === null || _pluginInjectionApi$w2 === void 0 ? void 0 : _pluginInjectionApi$w2.width) !== null && _pluginInjectionApi$w !== void 0 ? _pluginInjectionApi$w : 0,
89
66
  totalTablesResized: measuredTables.length,
90
- measurements: measuredTables.map(function (_ref4) {
91
- var measurement = _ref4.measurement;
67
+ measurements: measuredTables.map(function (_ref3) {
68
+ var measurement = _ref3.measurement;
92
69
  return {
93
70
  tableWidth: measurement.tableWidth,
94
71
  totalColumnCount: measurement.colWidths.length
@@ -99,6 +76,10 @@ var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = func
99
76
  view.dispatch(tr.setMeta('addToHistory', false));
100
77
  }
101
78
  };
79
+
80
+ /**
81
+ * Used to measure a selected table width with it's content being laid out natively by the browser
82
+ */
102
83
  var applyMeasuredWidthToSelectedTable = exports.applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
103
84
  var _api$analytics, _api$width$sharedStat, _api$width;
104
85
  var tableObject = (0, _utils.findTable)(view.state.selection);
@@ -8,6 +8,7 @@ import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
8
8
  import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
9
9
  import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
10
10
  import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
11
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
11
12
  import { isValidPosition } from '@atlaskit/editor-common/utils';
12
13
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
13
14
  import { isTableSelected } from '@atlaskit/editor-tables/utils';
@@ -26,6 +27,7 @@ import { getResizeState, updateColgroup } from '../pm-plugins/table-resizing/uti
26
27
  import { scaleTable } from '../pm-plugins/table-resizing/utils/scale-table';
27
28
  import { containsHeaderRow, isTableNested, isTableNestedInMoreThanOneNode, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../pm-plugins/utils/nodes';
28
29
  import { getAssistiveMessage } from '../pm-plugins/utils/table';
30
+ import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
29
31
  import { TableCssClassName as ClassName } from '../types';
30
32
  import { handleMouseOut, handleMouseOver, isTableInFocus, withCellTracking } from '../ui/event-handlers';
31
33
  import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
@@ -700,10 +702,24 @@ class TableComponent extends React.Component {
700
702
  } = this.props;
701
703
  const shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
702
704
  if (shouldRecreateResizeCols) {
705
+ var _this$table7, _this$props$options12, _this$props$options13;
703
706
  const start = getPos() || 0;
704
707
  const depth = view.state.doc.resolve(start).depth;
705
708
  shouldScale = depth === 0 && shouldScale;
706
709
  insertColgroupFromNode(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
710
+
711
+ // Deferred from setDomAttrs — remove only once colgroup is updated and table has left content mode.
712
+ if ((_this$table7 = this.table) !== null && _this$table7 !== void 0 && _this$table7.hasAttribute('data-initial-width-mode') && !isTableInContentMode({
713
+ tableNode: currentTable,
714
+ isSupported: isContentModeSupported({
715
+ allowColumnResizing: !!allowColumnResizing,
716
+ allowTableResizing: !!allowTableResizing,
717
+ isFullPageEditor: !((_this$props$options12 = this.props.options) !== null && _this$props$options12 !== void 0 && _this$props$options12.isCommentEditor) && !((_this$props$options13 = this.props.options) !== null && _this$props$options13 !== void 0 && _this$props$options13.isChromelessEditor)
718
+ }),
719
+ isTableNested: isTableNested(view.state, getPos())
720
+ })) {
721
+ this.table.removeAttribute('data-initial-width-mode');
722
+ }
707
723
  }
708
724
  updateControls()(view.state);
709
725
  }
@@ -724,7 +740,7 @@ class TableComponent extends React.Component {
724
740
  }
725
741
  }
726
742
  render() {
727
- var _this$props$options12;
743
+ var _this$props$options14;
728
744
  const {
729
745
  view,
730
746
  getNode,
@@ -829,7 +845,7 @@ class TableComponent extends React.Component {
829
845
  const {
830
846
  tableWithFixedColumnWidthsOption = false
831
847
  } = getEditorFeatureFlags();
832
- const shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options12 = this.props.options) !== null && _this$props$options12 !== void 0 && _this$props$options12.isCommentEditor));
848
+ const shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options14 = this.props.options) !== null && _this$props$options14 !== void 0 && _this$props$options14.isCommentEditor));
833
849
  return /*#__PURE__*/React.createElement(TableContainer
834
850
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
835
851
  , {
@@ -2,18 +2,18 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
5
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
5
6
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
6
7
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
7
8
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
8
9
  import { TableMap } from '@atlaskit/editor-tables/table-map';
9
10
  import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
12
12
  import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
13
13
  import { getPluginState } from '../pm-plugins/plugin-factory';
14
14
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
15
15
  import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/utils/nodes';
16
- import { isTableInContentMode } from '../pm-plugins/utils/tableMode';
16
+ import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
17
17
  import { TableComponentWithSharedState } from './TableComponentWithSharedState';
18
18
  import { tableNodeSpecWithFixedToDOM } from './toDOM';
19
19
  const tableAttributes = node => {
@@ -178,24 +178,24 @@ export default class TableView extends ReactNodeView {
178
178
  }
179
179
  }
180
180
  setDomAttrs(node) {
181
- var _this$reactComponentP8, _this$getEditorFeatur2, _this$options3, _this$options4;
181
+ var _this$reactComponentP6, _this$reactComponentP7, _this$reactComponentP8, _this$getEditorFeatur2, _this$options3, _this$options4;
182
182
  if (!this.table) {
183
183
  return; // width / attribute application to actual table will happen later when table is set
184
184
  }
185
185
  const attrs = tableAttributes(node);
186
- if (expValEqualsNoExposure('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
187
- var _this$reactComponentP6, _this$reactComponentP7;
188
- if (isTableInContentMode({
189
- node,
186
+
187
+ // render table with content-mode attribute which removes all width constraints from the table
188
+ // fire exposure here
189
+ if (isTableInContentMode({
190
+ tableNode: node,
191
+ isSupported: isContentModeSupported({
190
192
  allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
191
193
  allowTableResizing: !!this.reactComponentProps.allowTableResizing,
192
- isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor),
193
- isTableNested: isTableNested(this.view.state, this.getPos())
194
- }) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
195
- attrs['data-initial-width-mode'] = 'content';
196
- } else {
197
- this.table.removeAttribute('data-initial-width-mode');
198
- }
194
+ isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor)
195
+ }),
196
+ isTableNested: isTableNested(this.view.state, this.getPos())
197
+ }) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
198
+ attrs['data-initial-width-mode'] = 'content';
199
199
  }
200
200
  Object.keys(attrs).forEach(attr => {
201
201
  // Ignored via go/ees005
@@ -2,11 +2,12 @@ import classNames from 'classnames';
2
2
  import kebabCase from 'lodash/kebabCase';
3
3
  import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
4
4
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
5
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
5
6
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
7
  import { generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
7
8
  import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
8
9
  import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
9
- import { isTableInContentMode } from '../pm-plugins/utils/tableMode';
10
+ import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
10
11
  import { getAlignmentStyle } from './table-container-styles';
11
12
  export const tableNodeSpecWithFixedToDOM = config => {
12
13
  const tableNode = config.isNestingSupported ? tableWithNestedTable : table;
@@ -15,10 +16,12 @@ export const tableNodeSpecWithFixedToDOM = config => {
15
16
  toDOM: node => {
16
17
  const isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
17
18
  const isInContentMode = isTableInContentMode({
18
- node,
19
- allowColumnResizing: config.allowColumnResizing,
20
- allowTableResizing: config.tableResizingEnabled,
21
- isFullPageEditor,
19
+ tableNode: node,
20
+ isSupported: isContentModeSupported({
21
+ allowColumnResizing: config.allowColumnResizing,
22
+ allowTableResizing: config.tableResizingEnabled,
23
+ isFullPageEditor
24
+ }),
22
25
  isTableNested: config.isNested
23
26
  }) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true);
24
27
  const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`).join(';');
@@ -6,13 +6,14 @@
6
6
 
7
7
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
8
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
9
10
  import { isReplaceDocOperation } from '@atlaskit/editor-common/utils/document';
10
11
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
12
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorMaxWidthLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
12
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
14
  import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from './table-resizing/utils/consts';
14
15
  import { ALIGN_START } from './utils/alignment';
15
- import { isTableInContentMode } from './utils/tableMode';
16
+ import { isContentModeSupported } from './utils/tableMode';
16
17
  export const pluginKey = new PluginKey('tableWidthPlugin');
17
18
  const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, maxWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
18
19
  return new SafePlugin({
@@ -63,10 +64,12 @@ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, maxWid
63
64
  if (isReplaceDocumentOperation && !isCommentEditor) {
64
65
  newState.doc.forEach((node, offset) => {
65
66
  if (isTableInContentMode({
66
- node,
67
- allowColumnResizing: true,
68
- allowTableResizing: true,
69
- isFullPageEditor: true,
67
+ tableNode: node,
68
+ isSupported: isContentModeSupported({
69
+ allowColumnResizing: true,
70
+ allowTableResizing: true,
71
+ isFullPageEditor: true
72
+ }),
70
73
  isTableNested: false
71
74
  })) {
72
75
  return;
@@ -1,29 +1,8 @@
1
1
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
2
2
  import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
3
+ import { hasTableBeenResized } from '@atlaskit/editor-common/table';
3
4
  import { findTable } from '@atlaskit/editor-tables/utils';
4
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
- import { hasTableColumnBeenResized } from '../table-resizing/utils/colgroup';
6
5
  import { applyTableMeasurement, getTableMeasurement } from '../transforms/content-mode';
7
- import { ALIGN_START } from './alignment';
8
- export const isTableInContentMode = ({
9
- allowColumnResizing,
10
- allowTableResizing,
11
- isFullPageEditor,
12
- isTableNested,
13
- node
14
- }) => {
15
- if (!expValEqualsNoExposure('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
16
- return false;
17
- }
18
- if (!node || isTableNested) {
19
- return false;
20
- }
21
- return isContentModeSupported({
22
- allowColumnResizing,
23
- allowTableResizing,
24
- isFullPageEditor
25
- }) && !hasTableBeenResized(node) && node.attrs.layout === ALIGN_START;
26
- };
27
6
  export const isContentModeSupported = ({
28
7
  allowColumnResizing,
29
8
  allowTableResizing,
@@ -31,7 +10,6 @@ export const isContentModeSupported = ({
31
10
  }) => {
32
11
  return allowColumnResizing && allowTableResizing && isFullPageEditor;
33
12
  };
34
- export const hasTableBeenResized = node => node.attrs.width !== null || hasTableColumnBeenResized(node);
35
13
 
36
14
  /**
37
15
  * Iterates all top-level tables in the document, and for those in content mode,
@@ -54,7 +32,7 @@ export const applyMeasuredWidthToAllTables = (view, pluginInjectionApi) => {
54
32
 
55
33
  // modify only top-level tables
56
34
  doc.forEach((node, offset) => {
57
- if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== ALIGN_START) {
35
+ if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== 'align-start') {
58
36
  return;
59
37
  }
60
38
  const domNode = view.domAtPos(offset + 1).node;
@@ -98,6 +76,10 @@ export const applyMeasuredWidthToAllTables = (view, pluginInjectionApi) => {
98
76
  view.dispatch(tr.setMeta('addToHistory', false));
99
77
  }
100
78
  };
79
+
80
+ /**
81
+ * Used to measure a selected table width with it's content being laid out natively by the browser
82
+ */
101
83
  export const applyMeasuredWidthToSelectedTable = (view, api) => {
102
84
  var _api$analytics, _api$analytics$action, _api$width$sharedStat, _api$width, _api$width$sharedStat2;
103
85
  const tableObject = findTable(view.state.selection);
@@ -21,6 +21,7 @@ import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
21
21
  import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
22
22
  import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
23
23
  import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
24
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
24
25
  import { isValidPosition } from '@atlaskit/editor-common/utils';
25
26
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
26
27
  import { isTableSelected } from '@atlaskit/editor-tables/utils';
@@ -39,6 +40,7 @@ import { getResizeState, updateColgroup } from '../pm-plugins/table-resizing/uti
39
40
  import { scaleTable } from '../pm-plugins/table-resizing/utils/scale-table';
40
41
  import { containsHeaderRow, isTableNested, isTableNestedInMoreThanOneNode, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, tablesHaveDifferentNoOfRows } from '../pm-plugins/utils/nodes';
41
42
  import { getAssistiveMessage } from '../pm-plugins/utils/table';
43
+ import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
42
44
  import { TableCssClassName as ClassName } from '../types';
43
45
  import { handleMouseOut, handleMouseOver, isTableInFocus, withCellTracking } from '../ui/event-handlers';
44
46
  import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
@@ -731,10 +733,24 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
731
733
  var view = this.props.view;
732
734
  var shouldRecreateResizeCols = !allowTableResizing || !isResizing || isNoOfColumnsChanged && isResizing;
733
735
  if (shouldRecreateResizeCols) {
736
+ var _this$table7, _this$props$options10, _this$props$options11;
734
737
  var start = getPos() || 0;
735
738
  var depth = view.state.doc.resolve(start).depth;
736
739
  shouldScale = depth === 0 && shouldScale;
737
740
  insertColgroupFromNode(this.table, currentTable, shouldScale, undefined, shouldUseIncreasedScalingPercent, options === null || options === void 0 ? void 0 : options.isCommentEditor);
741
+
742
+ // Deferred from setDomAttrs — remove only once colgroup is updated and table has left content mode.
743
+ if ((_this$table7 = this.table) !== null && _this$table7 !== void 0 && _this$table7.hasAttribute('data-initial-width-mode') && !isTableInContentMode({
744
+ tableNode: currentTable,
745
+ isSupported: isContentModeSupported({
746
+ allowColumnResizing: !!allowColumnResizing,
747
+ allowTableResizing: !!allowTableResizing,
748
+ isFullPageEditor: !((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor) && !((_this$props$options11 = this.props.options) !== null && _this$props$options11 !== void 0 && _this$props$options11.isChromelessEditor)
749
+ }),
750
+ isTableNested: isTableNested(view.state, getPos())
751
+ })) {
752
+ this.table.removeAttribute('data-initial-width-mode');
753
+ }
738
754
  }
739
755
  updateControls()(view.state);
740
756
  }
@@ -762,7 +778,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
762
778
  key: "render",
763
779
  value: function render() {
764
780
  var _this5 = this,
765
- _this$props$options10;
781
+ _this$props$options12;
766
782
  var _this$props10 = this.props,
767
783
  view = _this$props10.view,
768
784
  getNode = _this$props10.getNode,
@@ -866,7 +882,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
866
882
  var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
867
883
  _getEditorFeatureFlag4 = _getEditorFeatureFlag3.tableWithFixedColumnWidthsOption,
868
884
  tableWithFixedColumnWidthsOption = _getEditorFeatureFlag4 === void 0 ? false : _getEditorFeatureFlag4;
869
- var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options10 = this.props.options) !== null && _this$props$options10 !== void 0 && _this$props$options10.isCommentEditor));
885
+ var shouldUseIncreasedScalingPercent = !!isTableScalingEnabled && (tableWithFixedColumnWidthsOption || !!((_this$props$options12 = this.props.options) !== null && _this$props$options12 !== void 0 && _this$props$options12.isCommentEditor));
870
886
  return /*#__PURE__*/React.createElement(TableContainer
871
887
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
872
888
  , {
@@ -12,18 +12,18 @@ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prot
12
12
  import React from 'react';
13
13
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
14
14
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
15
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
15
16
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
16
17
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
17
18
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
18
19
  import { TableMap } from '@atlaskit/editor-tables/table-map';
19
20
  import { fg } from '@atlaskit/platform-feature-flags';
20
21
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
22
22
  import { pluginConfig as getPluginConfig } from '../pm-plugins/create-plugin-config';
23
23
  import { getPluginState } from '../pm-plugins/plugin-factory';
24
24
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
25
25
  import { isTableNested, tablesHaveDifferentColumnWidths } from '../pm-plugins/utils/nodes';
26
- import { isTableInContentMode } from '../pm-plugins/utils/tableMode';
26
+ import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
27
27
  import { TableComponentWithSharedState } from './TableComponentWithSharedState';
28
28
  import { tableNodeSpecWithFixedToDOM } from './toDOM';
29
29
  var tableAttributes = function tableAttributes(node) {
@@ -199,7 +199,9 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
199
199
  }, {
200
200
  key: "setDomAttrs",
201
201
  value: function setDomAttrs(node) {
202
- var _this3 = this,
202
+ var _this$reactComponentP6,
203
+ _this$reactComponentP7,
204
+ _this3 = this,
203
205
  _this$reactComponentP8,
204
206
  _this$getEditorFeatur2,
205
207
  _this$options3,
@@ -208,19 +210,19 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
208
210
  return; // width / attribute application to actual table will happen later when table is set
209
211
  }
210
212
  var attrs = tableAttributes(node);
211
- if (expValEqualsNoExposure('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
212
- var _this$reactComponentP6, _this$reactComponentP7;
213
- if (isTableInContentMode({
214
- node: node,
213
+
214
+ // render table with content-mode attribute which removes all width constraints from the table
215
+ // fire exposure here
216
+ if (isTableInContentMode({
217
+ tableNode: node,
218
+ isSupported: isContentModeSupported({
215
219
  allowColumnResizing: !!this.reactComponentProps.allowColumnResizing,
216
220
  allowTableResizing: !!this.reactComponentProps.allowTableResizing,
217
- isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor),
218
- isTableNested: isTableNested(this.view.state, this.getPos())
219
- }) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
220
- attrs['data-initial-width-mode'] = 'content';
221
- } else {
222
- this.table.removeAttribute('data-initial-width-mode');
223
- }
221
+ isFullPageEditor: !((_this$reactComponentP6 = this.reactComponentProps.options) !== null && _this$reactComponentP6 !== void 0 && _this$reactComponentP6.isCommentEditor) && !((_this$reactComponentP7 = this.reactComponentProps.options) !== null && _this$reactComponentP7 !== void 0 && _this$reactComponentP7.isChromelessEditor)
222
+ }),
223
+ isTableNested: isTableNested(this.view.state, this.getPos())
224
+ }) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
225
+ attrs['data-initial-width-mode'] = 'content';
224
226
  }
225
227
  Object.keys(attrs).forEach(function (attr) {
226
228
  // Ignored via go/ees005
@@ -7,11 +7,12 @@ import classNames from 'classnames';
7
7
  import kebabCase from 'lodash/kebabCase';
8
8
  import { table, tableWithNestedTable } from '@atlaskit/adf-schema';
9
9
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
10
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
10
11
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
12
  import { generateColgroupFromNode, getResizerMinWidth } from '../pm-plugins/table-resizing/utils/colgroup';
12
13
  import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from '../pm-plugins/table-resizing/utils/consts';
13
14
  import { getTableResizerContainerMaxWidthInCSS, getTableResizerContainerForFullPageWidthInCSS, getTableResizerItemWidthInCSS } from '../pm-plugins/table-resizing/utils/misc';
14
- import { isTableInContentMode } from '../pm-plugins/utils/tableMode';
15
+ import { isContentModeSupported } from '../pm-plugins/utils/tableMode';
15
16
  import { getAlignmentStyle } from './table-container-styles';
16
17
  export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
17
18
  var tableNode = config.isNestingSupported ? tableWithNestedTable : table;
@@ -19,10 +20,12 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
19
20
  toDOM: function toDOM(node) {
20
21
  var isFullPageEditor = !config.isChromelessEditor && !config.isCommentEditor;
21
22
  var isInContentMode = isTableInContentMode({
22
- node: node,
23
- allowColumnResizing: config.allowColumnResizing,
24
- allowTableResizing: config.tableResizingEnabled,
25
- isFullPageEditor: isFullPageEditor,
23
+ tableNode: node,
24
+ isSupported: isContentModeSupported({
25
+ allowColumnResizing: config.allowColumnResizing,
26
+ allowTableResizing: config.tableResizingEnabled,
27
+ isFullPageEditor: isFullPageEditor
28
+ }),
26
29
  isTableNested: config.isNested
27
30
  }) && expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true);
28
31
  var alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(function (_ref) {
@@ -11,13 +11,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
11
11
 
12
12
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
13
13
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
14
+ import { isTableInContentMode } from '@atlaskit/editor-common/table';
14
15
  import { isReplaceDocOperation } from '@atlaskit/editor-common/utils/document';
15
16
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
16
17
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorMaxWidthLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
17
18
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
18
19
  import { TABLE_MAX_WIDTH, TABLE_FULL_WIDTH } from './table-resizing/utils/consts';
19
20
  import { ALIGN_START } from './utils/alignment';
20
- import { isTableInContentMode } from './utils/tableMode';
21
+ import { isContentModeSupported } from './utils/tableMode';
21
22
  export var pluginKey = new PluginKey('tableWidthPlugin');
22
23
  var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullWidthEnabled, maxWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled, isCommentEditor) {
23
24
  return new SafePlugin({
@@ -65,10 +66,12 @@ var createPlugin = function createPlugin(dispatch, dispatchAnalyticsEvent, fullW
65
66
  if (isReplaceDocumentOperation && !isCommentEditor) {
66
67
  newState.doc.forEach(function (node, offset) {
67
68
  if (isTableInContentMode({
68
- node: node,
69
- allowColumnResizing: true,
70
- allowTableResizing: true,
71
- isFullPageEditor: true,
69
+ tableNode: node,
70
+ isSupported: isContentModeSupported({
71
+ allowColumnResizing: true,
72
+ allowTableResizing: true,
73
+ isFullPageEditor: true
74
+ }),
72
75
  isTableNested: false
73
76
  })) {
74
77
  return;
@@ -1,37 +1,14 @@
1
1
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
2
2
  import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
3
+ import { hasTableBeenResized } from '@atlaskit/editor-common/table';
3
4
  import { findTable } from '@atlaskit/editor-tables/utils';
4
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
- import { hasTableColumnBeenResized } from '../table-resizing/utils/colgroup';
6
5
  import { applyTableMeasurement, getTableMeasurement } from '../transforms/content-mode';
7
- import { ALIGN_START } from './alignment';
8
- export var isTableInContentMode = function isTableInContentMode(_ref) {
6
+ export var isContentModeSupported = function isContentModeSupported(_ref) {
9
7
  var allowColumnResizing = _ref.allowColumnResizing,
10
8
  allowTableResizing = _ref.allowTableResizing,
11
- isFullPageEditor = _ref.isFullPageEditor,
12
- isTableNested = _ref.isTableNested,
13
- node = _ref.node;
14
- if (!expValEqualsNoExposure('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true)) {
15
- return false;
16
- }
17
- if (!node || isTableNested) {
18
- return false;
19
- }
20
- return isContentModeSupported({
21
- allowColumnResizing: allowColumnResizing,
22
- allowTableResizing: allowTableResizing,
23
- isFullPageEditor: isFullPageEditor
24
- }) && !hasTableBeenResized(node) && node.attrs.layout === ALIGN_START;
25
- };
26
- export var isContentModeSupported = function isContentModeSupported(_ref2) {
27
- var allowColumnResizing = _ref2.allowColumnResizing,
28
- allowTableResizing = _ref2.allowTableResizing,
29
- isFullPageEditor = _ref2.isFullPageEditor;
9
+ isFullPageEditor = _ref.isFullPageEditor;
30
10
  return allowColumnResizing && allowTableResizing && isFullPageEditor;
31
11
  };
32
- export var hasTableBeenResized = function hasTableBeenResized(node) {
33
- return node.attrs.width !== null || hasTableColumnBeenResized(node);
34
- };
35
12
 
36
13
  /**
37
14
  * Iterates all top-level tables in the document, and for those in content mode,
@@ -49,7 +26,7 @@ export var applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTable
49
26
 
50
27
  // modify only top-level tables
51
28
  doc.forEach(function (node, offset) {
52
- if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== ALIGN_START) {
29
+ if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== 'align-start') {
53
30
  return;
54
31
  }
55
32
  var domNode = view.domAtPos(offset + 1).node;
@@ -64,10 +41,10 @@ export var applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTable
64
41
  measurement: getTableMeasurement(tableRef)
65
42
  });
66
43
  });
67
- measuredTables.forEach(function (_ref3) {
68
- var node = _ref3.node,
69
- offset = _ref3.offset,
70
- measurement = _ref3.measurement;
44
+ measuredTables.forEach(function (_ref2) {
45
+ var node = _ref2.node,
46
+ offset = _ref2.offset,
47
+ measurement = _ref2.measurement;
71
48
  tr = applyTableMeasurement(tr, node, measurement, offset);
72
49
  modified = true;
73
50
  });
@@ -81,8 +58,8 @@ export var applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTable
81
58
  attributes: {
82
59
  editorContainerWidth: (_pluginInjectionApi$w = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w2 = pluginInjectionApi.width) === null || _pluginInjectionApi$w2 === void 0 || (_pluginInjectionApi$w2 = _pluginInjectionApi$w2.sharedState.currentState()) === null || _pluginInjectionApi$w2 === void 0 ? void 0 : _pluginInjectionApi$w2.width) !== null && _pluginInjectionApi$w !== void 0 ? _pluginInjectionApi$w : 0,
83
60
  totalTablesResized: measuredTables.length,
84
- measurements: measuredTables.map(function (_ref4) {
85
- var measurement = _ref4.measurement;
61
+ measurements: measuredTables.map(function (_ref3) {
62
+ var measurement = _ref3.measurement;
86
63
  return {
87
64
  tableWidth: measurement.tableWidth,
88
65
  totalColumnCount: measurement.colWidths.length
@@ -93,6 +70,10 @@ export var applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTable
93
70
  view.dispatch(tr.setMeta('addToHistory', false));
94
71
  }
95
72
  };
73
+
74
+ /**
75
+ * Used to measure a selected table width with it's content being laid out natively by the browser
76
+ */
96
77
  export var applyMeasuredWidthToSelectedTable = function applyMeasuredWidthToSelectedTable(view, api) {
97
78
  var _api$analytics, _api$width$sharedStat, _api$width;
98
79
  var tableObject = findTable(view.state.selection);
@@ -1,4 +1,3 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
2
  import type { PluginInjectionAPI } from '../../types';
4
3
  type ContentModePluginOptions = {
@@ -6,17 +5,15 @@ type ContentModePluginOptions = {
6
5
  allowTableResizing: boolean;
7
6
  isFullPageEditor: boolean;
8
7
  };
9
- export declare const isTableInContentMode: ({ allowColumnResizing, allowTableResizing, isFullPageEditor, isTableNested, node, }: ContentModePluginOptions & {
10
- isTableNested?: boolean;
11
- node?: PMNode;
12
- }) => boolean;
13
8
  export declare const isContentModeSupported: ({ allowColumnResizing, allowTableResizing, isFullPageEditor, }: ContentModePluginOptions) => boolean;
14
- export declare const hasTableBeenResized: (node: PMNode) => boolean;
15
9
  /**
16
10
  * Iterates all top-level tables in the document, and for those in content mode,
17
11
  * measures rendered column widths and sets colwidth + table width attributes
18
12
  * in a single batched transaction.
19
13
  */
20
14
  export declare const applyMeasuredWidthToAllTables: (view: EditorView, pluginInjectionApi?: PluginInjectionAPI) => void;
15
+ /**
16
+ * Used to measure a selected table width with it's content being laid out natively by the browser
17
+ */
21
18
  export declare const applyMeasuredWidthToSelectedTable: (view: EditorView, api?: PluginInjectionAPI) => void;
22
19
  export {};
@@ -1,4 +1,3 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
2
  import type { PluginInjectionAPI } from '../../types';
4
3
  type ContentModePluginOptions = {
@@ -6,17 +5,15 @@ type ContentModePluginOptions = {
6
5
  allowTableResizing: boolean;
7
6
  isFullPageEditor: boolean;
8
7
  };
9
- export declare const isTableInContentMode: ({ allowColumnResizing, allowTableResizing, isFullPageEditor, isTableNested, node, }: ContentModePluginOptions & {
10
- isTableNested?: boolean;
11
- node?: PMNode;
12
- }) => boolean;
13
8
  export declare const isContentModeSupported: ({ allowColumnResizing, allowTableResizing, isFullPageEditor, }: ContentModePluginOptions) => boolean;
14
- export declare const hasTableBeenResized: (node: PMNode) => boolean;
15
9
  /**
16
10
  * Iterates all top-level tables in the document, and for those in content mode,
17
11
  * measures rendered column widths and sets colwidth + table width attributes
18
12
  * in a single batched transaction.
19
13
  */
20
14
  export declare const applyMeasuredWidthToAllTables: (view: EditorView, pluginInjectionApi?: PluginInjectionAPI) => void;
15
+ /**
16
+ * Used to measure a selected table width with it's content being laid out natively by the browser
17
+ */
21
18
  export declare const applyMeasuredWidthToSelectedTable: (view: EditorView, api?: PluginInjectionAPI) => void;
22
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "22.0.0",
3
+ "version": "22.1.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/editor-plugin-batch-attribute-updates": "^10.0.0",
38
38
  "@atlaskit/editor-plugin-content-insertion": "^10.0.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^12.0.0",
40
- "@atlaskit/editor-plugin-extension": "13.0.0",
40
+ "@atlaskit/editor-plugin-extension": "13.0.1",
41
41
  "@atlaskit/editor-plugin-guideline": "^10.0.0",
42
42
  "@atlaskit/editor-plugin-interaction": "^19.0.0",
43
43
  "@atlaskit/editor-plugin-limited-mode": "^7.0.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
57
57
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
58
58
  "@atlaskit/primitives": "^19.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^62.4.0",
59
+ "@atlaskit/tmp-editor-statsig": "^63.0.0",
60
60
  "@atlaskit/toggle": "^15.6.0",
61
61
  "@atlaskit/tokens": "^13.0.0",
62
62
  "@atlaskit/tooltip": "^21.1.0",
@@ -70,7 +70,7 @@
70
70
  "uuid": "^3.1.0"
71
71
  },
72
72
  "peerDependencies": {
73
- "@atlaskit/editor-common": "^114.1.0",
73
+ "@atlaskit/editor-common": "^114.2.0",
74
74
  "react": "^18.2.0",
75
75
  "react-dom": "^18.2.0",
76
76
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"