@atlaskit/editor-plugin-table 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +7 -3
  3. package/dist/cjs/plugins/table/nodeviews/TableContainer.js +23 -19
  4. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +2 -1
  5. package/dist/cjs/plugins/table/nodeviews/table.js +5 -1
  6. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +7 -3
  9. package/dist/es2019/plugins/table/nodeviews/TableContainer.js +22 -18
  10. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +3 -2
  11. package/dist/es2019/plugins/table/nodeviews/table.js +5 -1
  12. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/esm/plugins/table/nodeviews/TableComponent.js +7 -3
  15. package/dist/esm/plugins/table/nodeviews/TableContainer.js +23 -19
  16. package/dist/esm/plugins/table/nodeviews/TableResizer.js +3 -2
  17. package/dist/esm/plugins/table/nodeviews/table.js +5 -1
  18. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +8 -1
  19. package/dist/esm/version.json +1 -1
  20. package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  21. package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  22. package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -3
  23. package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +2 -1
  24. package/package.json +4 -6
  25. package/src/plugins/table/nodeviews/TableComponent.tsx +10 -4
  26. package/src/plugins/table/nodeviews/TableContainer.tsx +28 -19
  27. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -2
  28. package/src/plugins/table/nodeviews/table.tsx +6 -0
  29. package/src/plugins/table/pm-plugins/table-resizing/utils/scale-table.ts +10 -1
  30. package/tmp/api-report-tmp.d.ts +0 -104
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`802453ec412`](https://bitbucket.org/atlassian/atlassian-frontend/commits/802453ec412) - [ux] update how table respond to external width changes under `platform.editor.custom-table-width` feature flag
8
+ - Updated dependencies
9
+
3
10
  ## 2.0.0
4
11
 
5
12
  ### Major Changes
@@ -284,7 +284,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
284
284
  * We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
285
285
  * Instead we use the resize event to only trigger updates when necessary.
286
286
  */
287
- window.addEventListener('resize', this.handleWindowResizeDebounced);
287
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width')) {
288
+ window.addEventListener('resize', this.handleWindowResizeDebounced);
289
+ }
288
290
  this.handleTableResizingDebounced();
289
291
  }
290
292
  var currentStickyState = _stickyHeaders.pluginKey.getState(this.props.view.state);
@@ -303,8 +305,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
303
305
  this.scaleTableDebounced.cancel();
304
306
  this.handleTableResizingDebounced.cancel();
305
307
  this.handleAutoSizeDebounced.cancel();
306
- this.handleWindowResizeDebounced.cancel();
307
- if (this.props.allowColumnResizing) {
308
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width')) {
309
+ this.handleWindowResizeDebounced.cancel();
310
+ }
311
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') && this.props.allowColumnResizing) {
308
312
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
309
313
  }
310
314
  if (this.overflowShadowsObserver) {
@@ -11,6 +11,7 @@ var _nodeWidth = require("@atlaskit/editor-common/node-width");
11
11
  var _styles = require("@atlaskit/editor-common/styles");
12
12
  var _types = require("../types");
13
13
  var _TableResizer = require("./TableResizer");
14
+ var _utils = require("../pm-plugins/table-resizing/utils");
14
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
17
  var getMarginLeft = function getMarginLeft(_ref) {
@@ -26,17 +27,13 @@ var getMarginLeft = function getMarginLeft(_ref) {
26
27
  return marginLeft;
27
28
  };
28
29
  var InnerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
29
- var marginLeft = _ref2.marginLeft,
30
- className = _ref2.className,
31
- width = _ref2.width,
30
+ var className = _ref2.className,
31
+ style = _ref2.style,
32
32
  node = _ref2.node,
33
33
  children = _ref2.children;
34
34
  return /*#__PURE__*/_react.default.createElement("div", {
35
35
  ref: ref,
36
- style: {
37
- width: width,
38
- marginLeft: marginLeft
39
- },
36
+ style: style,
40
37
  className: className,
41
38
  "data-number-column": node.attrs.isNumberColumnEnabled,
42
39
  "data-layout": node.attrs.layout,
@@ -49,6 +46,7 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
49
46
  className = _ref3.className,
50
47
  node = _ref3.node,
51
48
  lineLength = _ref3.lineLength,
49
+ containerWidth = _ref3.containerWidth,
52
50
  editorView = _ref3.editorView,
53
51
  getPos = _ref3.getPos,
54
52
  tableRef = _ref3.tableRef;
@@ -58,19 +56,24 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
58
56
  if (!containerRef.current || !innerContainerRef.current) {
59
57
  return;
60
58
  }
61
- innerContainerRef.current.style.width = "".concat(width, "px");
62
59
  var marginLeft = getMarginLeft({
63
60
  lineLength: lineLength,
64
61
  tableWidth: width
65
62
  });
66
- containerRef.current.style.width = "".concat(width, "px");
67
- containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
63
+ if (marginLeft) {
64
+ containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
65
+ }
68
66
  }, [lineLength]);
69
- var width = (0, _nodeWidth.getTableContainerWidth)(node);
67
+ var tableWidth = (0, _nodeWidth.getTableContainerWidth)(node);
68
+
69
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
70
+ var responsiveContainerWidth = containerWidth - 76;
71
+ var width = Math.min(tableWidth, responsiveContainerWidth);
70
72
  var marginLeft = getMarginLeft({
71
73
  lineLength: lineLength,
72
74
  tableWidth: width
73
75
  });
76
+ var maxResizerWidth = Math.min(responsiveContainerWidth, _utils.TABLE_MAX_WIDTH);
74
77
  return /*#__PURE__*/_react.default.createElement("div", {
75
78
  style: {
76
79
  marginLeft: marginLeft,
@@ -80,6 +83,7 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
80
83
  ref: containerRef
81
84
  }, /*#__PURE__*/_react.default.createElement(_TableResizer.TableResizer, {
82
85
  width: width,
86
+ maxWidth: maxResizerWidth,
83
87
  updateWidth: updateWidth,
84
88
  editorView: editorView,
85
89
  getPos: getPos,
@@ -88,9 +92,7 @@ var ResizableTableContainer = function ResizableTableContainer(_ref3) {
88
92
  }, /*#__PURE__*/_react.default.createElement(InnerContainer, {
89
93
  ref: innerContainerRef,
90
94
  className: className,
91
- node: node,
92
- width: width,
93
- marginLeft: 0
95
+ node: node
94
96
  }, children)));
95
97
  };
96
98
  exports.ResizableTableContainer = ResizableTableContainer;
@@ -121,11 +123,13 @@ var TableContainer = function TableContainer(_ref4) {
121
123
  return /*#__PURE__*/_react.default.createElement(InnerContainer, {
122
124
  node: node,
123
125
  className: className,
124
- width: tableWidth,
125
- marginLeft: getMarginLeft({
126
- lineLength: lineLength,
127
- tableWidth: tableWidth
128
- })
126
+ style: {
127
+ width: tableWidth,
128
+ marginLeft: getMarginLeft({
129
+ lineLength: lineLength,
130
+ tableWidth: tableWidth
131
+ })
132
+ }
129
133
  }, children);
130
134
  };
131
135
  exports.TableContainer = TableContainer;
@@ -18,6 +18,7 @@ var handles = {
18
18
  var TableResizer = function TableResizer(_ref) {
19
19
  var children = _ref.children,
20
20
  width = _ref.width,
21
+ maxWidth = _ref.maxWidth,
21
22
  updateWidth = _ref.updateWidth,
22
23
  editorView = _ref.editorView,
23
24
  getPos = _ref.getPos,
@@ -70,7 +71,7 @@ var TableResizer = function TableResizer(_ref) {
70
71
  },
71
72
  resizeRatio: 2,
72
73
  minWidth: minColumnWidth,
73
- maxWidth: _utils.TABLE_MAX_WIDTH
74
+ maxWidth: maxWidth
74
75
  }, children);
75
76
  };
76
77
  exports.TableResizer = TableResizer;
@@ -26,15 +26,19 @@ var _tableResizing = require("../pm-plugins/table-resizing");
26
26
  var _utils = require("../pm-plugins/table-resizing/utils");
27
27
  var _tableMap = require("@atlaskit/editor-tables/table-map");
28
28
  var _TableComponent = _interopRequireDefault(require("./TableComponent"));
29
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
30
+ var _nodeWidth = require("@atlaskit/editor-common/node-width");
29
31
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
30
32
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
33
  var tableAttributes = function tableAttributes(node) {
34
+ var style = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? "width: ".concat((0, _nodeWidth.getTableContainerWidth)(node), "px") : undefined;
32
35
  return {
33
36
  'data-number-column': node.attrs.isNumberColumnEnabled,
34
37
  'data-layout': node.attrs.layout,
35
38
  'data-autosize': node.attrs.__autoSize,
36
39
  'data-table-local-id': node.attrs.localId || '',
37
- 'data-table-width': node.attrs.width
40
+ 'data-table-width': node.attrs.width,
41
+ style: style
38
42
  };
39
43
  };
40
44
  var toDOM = function toDOM(node, props) {
@@ -10,6 +10,7 @@ exports.scaleWithParent = void 0;
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _styles = require("@atlaskit/editor-common/styles");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _utils = require("../../../utils");
14
15
  var _misc = require("../utils/misc");
15
16
  var _resizeLogic = require("../utils/resize-logic");
@@ -112,7 +113,13 @@ var previewScaleTable = function previewScaleTable(tableRef, options, domAtPos)
112
113
  var node = options.node,
113
114
  start = options.start,
114
115
  parentWidth = options.parentWidth;
115
- if (!tableRef || !(0, _colgroup.hasTableBeenResized)(node)) {
116
+ if (!tableRef) {
117
+ return;
118
+ }
119
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') && parentWidth) {
120
+ tableRef.style.width = "".concat(parentWidth, "px");
121
+ }
122
+ if (!(0, _colgroup.hasTableBeenResized)(node)) {
116
123
  return;
117
124
  }
118
125
  var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -281,7 +281,9 @@ class TableComponent extends React.Component {
281
281
  * We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
282
282
  * Instead we use the resize event to only trigger updates when necessary.
283
283
  */
284
- window.addEventListener('resize', this.handleWindowResizeDebounced);
284
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
285
+ window.addEventListener('resize', this.handleWindowResizeDebounced);
286
+ }
285
287
  this.handleTableResizingDebounced();
286
288
  }
287
289
  const currentStickyState = stickyHeadersPluginKey.getState(this.props.view.state);
@@ -298,8 +300,10 @@ class TableComponent extends React.Component {
298
300
  this.scaleTableDebounced.cancel();
299
301
  this.handleTableResizingDebounced.cancel();
300
302
  this.handleAutoSizeDebounced.cancel();
301
- this.handleWindowResizeDebounced.cancel();
302
- if (this.props.allowColumnResizing) {
303
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
304
+ this.handleWindowResizeDebounced.cancel();
305
+ }
306
+ if (!getBooleanFF('platform.editor.custom-table-width') && this.props.allowColumnResizing) {
303
307
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
304
308
  }
305
309
  if (this.overflowShadowsObserver) {
@@ -4,6 +4,7 @@ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
5
5
  import { TableCssClassName as ClassName } from '../types';
6
6
  import { TableResizer } from './TableResizer';
7
+ import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
7
8
  const getMarginLeft = ({
8
9
  lineLength,
9
10
  tableWidth
@@ -18,18 +19,14 @@ const getMarginLeft = ({
18
19
  return marginLeft;
19
20
  };
20
21
  export const InnerContainer = /*#__PURE__*/forwardRef(({
21
- marginLeft,
22
22
  className,
23
- width,
23
+ style,
24
24
  node,
25
25
  children
26
26
  }, ref) => {
27
27
  return /*#__PURE__*/React.createElement("div", {
28
28
  ref: ref,
29
- style: {
30
- width,
31
- marginLeft
32
- },
29
+ style: style,
33
30
  className: className,
34
31
  "data-number-column": node.attrs.isNumberColumnEnabled,
35
32
  "data-layout": node.attrs.layout,
@@ -41,6 +38,7 @@ export const ResizableTableContainer = ({
41
38
  className,
42
39
  node,
43
40
  lineLength,
41
+ containerWidth,
44
42
  editorView,
45
43
  getPos,
46
44
  tableRef
@@ -51,19 +49,24 @@ export const ResizableTableContainer = ({
51
49
  if (!containerRef.current || !innerContainerRef.current) {
52
50
  return;
53
51
  }
54
- innerContainerRef.current.style.width = `${width}px`;
55
52
  const marginLeft = getMarginLeft({
56
53
  lineLength,
57
54
  tableWidth: width
58
55
  });
59
- containerRef.current.style.width = `${width}px`;
60
- containerRef.current.style.marginLeft = `${marginLeft}px`;
56
+ if (marginLeft) {
57
+ containerRef.current.style.marginLeft = `${marginLeft}px`;
58
+ }
61
59
  }, [lineLength]);
62
- const width = getTableContainerWidth(node);
60
+ const tableWidth = getTableContainerWidth(node);
61
+
62
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
63
+ const responsiveContainerWidth = containerWidth - 76;
64
+ const width = Math.min(tableWidth, responsiveContainerWidth);
63
65
  const marginLeft = getMarginLeft({
64
66
  lineLength,
65
67
  tableWidth: width
66
68
  });
69
+ const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
67
70
  return /*#__PURE__*/React.createElement("div", {
68
71
  style: {
69
72
  marginLeft,
@@ -73,6 +76,7 @@ export const ResizableTableContainer = ({
73
76
  ref: containerRef
74
77
  }, /*#__PURE__*/React.createElement(TableResizer, {
75
78
  width: width,
79
+ maxWidth: maxResizerWidth,
76
80
  updateWidth: updateWidth,
77
81
  editorView: editorView,
78
82
  getPos: getPos,
@@ -81,9 +85,7 @@ export const ResizableTableContainer = ({
81
85
  }, /*#__PURE__*/React.createElement(InnerContainer, {
82
86
  ref: innerContainerRef,
83
87
  className: className,
84
- node: node,
85
- width: width,
86
- marginLeft: 0
88
+ node: node
87
89
  }, children)));
88
90
  };
89
91
  export const TableContainer = ({
@@ -115,10 +117,12 @@ export const TableContainer = ({
115
117
  return /*#__PURE__*/React.createElement(InnerContainer, {
116
118
  node: node,
117
119
  className: className,
118
- width: tableWidth,
119
- marginLeft: getMarginLeft({
120
- lineLength: lineLength,
121
- tableWidth
122
- })
120
+ style: {
121
+ width: tableWidth,
122
+ marginLeft: getMarginLeft({
123
+ lineLength: lineLength,
124
+ tableWidth
125
+ })
126
+ }
123
127
  }, children);
124
128
  };
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import rafSchd from 'raf-schd';
3
3
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
4
- import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
4
+ import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH } from '../pm-plugins/table-resizing/utils';
5
5
  const handles = {
6
6
  right: true
7
7
  };
8
8
  export const TableResizer = ({
9
9
  children,
10
10
  width,
11
+ maxWidth,
11
12
  updateWidth,
12
13
  editorView,
13
14
  getPos,
@@ -62,6 +63,6 @@ export const TableResizer = ({
62
63
  },
63
64
  resizeRatio: 2,
64
65
  minWidth: minColumnWidth,
65
- maxWidth: TABLE_MAX_WIDTH
66
+ maxWidth: maxWidth
66
67
  }, children);
67
68
  };
@@ -10,13 +10,17 @@ import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizin
10
10
  import { generateColgroup } from '../pm-plugins/table-resizing/utils';
11
11
  import { TableMap } from '@atlaskit/editor-tables/table-map';
12
12
  import TableComponent from './TableComponent';
13
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
+ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
13
15
  const tableAttributes = node => {
16
+ const style = getBooleanFF('platform.editor.custom-table-width') ? `width: ${getTableContainerWidth(node)}px` : undefined;
14
17
  return {
15
18
  'data-number-column': node.attrs.isNumberColumnEnabled,
16
19
  'data-layout': node.attrs.layout,
17
20
  'data-autosize': node.attrs.__autoSize,
18
21
  'data-table-local-id': node.attrs.localId || '',
19
- 'data-table-width': node.attrs.width
22
+ 'data-table-width': node.attrs.width,
23
+ style
20
24
  };
21
25
  };
22
26
  const toDOM = (node, props) => {
@@ -1,5 +1,6 @@
1
1
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
2
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
4
  import { getTableWidth } from '../../../utils';
4
5
  import { getLayoutSize } from '../utils/misc';
5
6
  import { reduceSpace } from '../utils/resize-logic';
@@ -106,7 +107,13 @@ export const previewScaleTable = (tableRef, options, domAtPos) => {
106
107
  start,
107
108
  parentWidth
108
109
  } = options;
109
- if (!tableRef || !hasTableBeenResized(node)) {
110
+ if (!tableRef) {
111
+ return;
112
+ }
113
+ if (getBooleanFF('platform.editor.custom-table-width') && parentWidth) {
114
+ tableRef.style.width = `${parentWidth}px`;
115
+ }
116
+ if (!hasTableBeenResized(node)) {
110
117
  return;
111
118
  }
112
119
  const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -278,7 +278,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
278
278
  * We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
279
279
  * Instead we use the resize event to only trigger updates when necessary.
280
280
  */
281
- window.addEventListener('resize', this.handleWindowResizeDebounced);
281
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
282
+ window.addEventListener('resize', this.handleWindowResizeDebounced);
283
+ }
282
284
  this.handleTableResizingDebounced();
283
285
  }
284
286
  var currentStickyState = stickyHeadersPluginKey.getState(this.props.view.state);
@@ -297,8 +299,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
297
299
  this.scaleTableDebounced.cancel();
298
300
  this.handleTableResizingDebounced.cancel();
299
301
  this.handleAutoSizeDebounced.cancel();
300
- this.handleWindowResizeDebounced.cancel();
301
- if (this.props.allowColumnResizing) {
302
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
303
+ this.handleWindowResizeDebounced.cancel();
304
+ }
305
+ if (!getBooleanFF('platform.editor.custom-table-width') && this.props.allowColumnResizing) {
302
306
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
303
307
  }
304
308
  if (this.overflowShadowsObserver) {
@@ -4,6 +4,7 @@ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
5
5
  import { TableCssClassName as ClassName } from '../types';
6
6
  import { TableResizer } from './TableResizer';
7
+ import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
7
8
  var getMarginLeft = function getMarginLeft(_ref) {
8
9
  var lineLength = _ref.lineLength,
9
10
  tableWidth = _ref.tableWidth;
@@ -17,17 +18,13 @@ var getMarginLeft = function getMarginLeft(_ref) {
17
18
  return marginLeft;
18
19
  };
19
20
  export var InnerContainer = /*#__PURE__*/forwardRef(function (_ref2, ref) {
20
- var marginLeft = _ref2.marginLeft,
21
- className = _ref2.className,
22
- width = _ref2.width,
21
+ var className = _ref2.className,
22
+ style = _ref2.style,
23
23
  node = _ref2.node,
24
24
  children = _ref2.children;
25
25
  return /*#__PURE__*/React.createElement("div", {
26
26
  ref: ref,
27
- style: {
28
- width: width,
29
- marginLeft: marginLeft
30
- },
27
+ style: style,
31
28
  className: className,
32
29
  "data-number-column": node.attrs.isNumberColumnEnabled,
33
30
  "data-layout": node.attrs.layout,
@@ -39,6 +36,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
39
36
  className = _ref3.className,
40
37
  node = _ref3.node,
41
38
  lineLength = _ref3.lineLength,
39
+ containerWidth = _ref3.containerWidth,
42
40
  editorView = _ref3.editorView,
43
41
  getPos = _ref3.getPos,
44
42
  tableRef = _ref3.tableRef;
@@ -48,19 +46,24 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
48
46
  if (!containerRef.current || !innerContainerRef.current) {
49
47
  return;
50
48
  }
51
- innerContainerRef.current.style.width = "".concat(width, "px");
52
49
  var marginLeft = getMarginLeft({
53
50
  lineLength: lineLength,
54
51
  tableWidth: width
55
52
  });
56
- containerRef.current.style.width = "".concat(width, "px");
57
- containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
53
+ if (marginLeft) {
54
+ containerRef.current.style.marginLeft = "".concat(marginLeft, "px");
55
+ }
58
56
  }, [lineLength]);
59
- var width = getTableContainerWidth(node);
57
+ var tableWidth = getTableContainerWidth(node);
58
+
59
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
60
+ var responsiveContainerWidth = containerWidth - 76;
61
+ var width = Math.min(tableWidth, responsiveContainerWidth);
60
62
  var marginLeft = getMarginLeft({
61
63
  lineLength: lineLength,
62
64
  tableWidth: width
63
65
  });
66
+ var maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
64
67
  return /*#__PURE__*/React.createElement("div", {
65
68
  style: {
66
69
  marginLeft: marginLeft,
@@ -70,6 +73,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
70
73
  ref: containerRef
71
74
  }, /*#__PURE__*/React.createElement(TableResizer, {
72
75
  width: width,
76
+ maxWidth: maxResizerWidth,
73
77
  updateWidth: updateWidth,
74
78
  editorView: editorView,
75
79
  getPos: getPos,
@@ -78,9 +82,7 @@ export var ResizableTableContainer = function ResizableTableContainer(_ref3) {
78
82
  }, /*#__PURE__*/React.createElement(InnerContainer, {
79
83
  ref: innerContainerRef,
80
84
  className: className,
81
- node: node,
82
- width: width,
83
- marginLeft: 0
85
+ node: node
84
86
  }, children)));
85
87
  };
86
88
  export var TableContainer = function TableContainer(_ref4) {
@@ -110,10 +112,12 @@ export var TableContainer = function TableContainer(_ref4) {
110
112
  return /*#__PURE__*/React.createElement(InnerContainer, {
111
113
  node: node,
112
114
  className: className,
113
- width: tableWidth,
114
- marginLeft: getMarginLeft({
115
- lineLength: lineLength,
116
- tableWidth: tableWidth
117
- })
115
+ style: {
116
+ width: tableWidth,
117
+ marginLeft: getMarginLeft({
118
+ lineLength: lineLength,
119
+ tableWidth: tableWidth
120
+ })
121
+ }
118
122
  }, children);
119
123
  };
@@ -4,13 +4,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  import React from 'react';
5
5
  import rafSchd from 'raf-schd';
6
6
  import { ResizerNext } from '@atlaskit/editor-common/resizer';
7
- import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
7
+ import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH } from '../pm-plugins/table-resizing/utils';
8
8
  var handles = {
9
9
  right: true
10
10
  };
11
11
  export var TableResizer = function TableResizer(_ref) {
12
12
  var children = _ref.children,
13
13
  width = _ref.width,
14
+ maxWidth = _ref.maxWidth,
14
15
  updateWidth = _ref.updateWidth,
15
16
  editorView = _ref.editorView,
16
17
  getPos = _ref.getPos,
@@ -63,6 +64,6 @@ export var TableResizer = function TableResizer(_ref) {
63
64
  },
64
65
  resizeRatio: 2,
65
66
  minWidth: minColumnWidth,
66
- maxWidth: TABLE_MAX_WIDTH
67
+ maxWidth: maxWidth
67
68
  }, children);
68
69
  };
@@ -21,13 +21,17 @@ import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizin
21
21
  import { generateColgroup } from '../pm-plugins/table-resizing/utils';
22
22
  import { TableMap } from '@atlaskit/editor-tables/table-map';
23
23
  import TableComponent from './TableComponent';
24
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
+ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
24
26
  var tableAttributes = function tableAttributes(node) {
27
+ var style = getBooleanFF('platform.editor.custom-table-width') ? "width: ".concat(getTableContainerWidth(node), "px") : undefined;
25
28
  return {
26
29
  'data-number-column': node.attrs.isNumberColumnEnabled,
27
30
  'data-layout': node.attrs.layout,
28
31
  'data-autosize': node.attrs.__autoSize,
29
32
  'data-table-local-id': node.attrs.localId || '',
30
- 'data-table-width': node.attrs.width
33
+ 'data-table-width': node.attrs.width,
34
+ style: style
31
35
  };
32
36
  };
33
37
  var toDOM = function toDOM(node, props) {
@@ -3,6 +3,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
5
5
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
7
  import { getTableWidth } from '../../../utils';
7
8
  import { getLayoutSize } from '../utils/misc';
8
9
  import { reduceSpace } from '../utils/resize-logic';
@@ -101,7 +102,13 @@ export var previewScaleTable = function previewScaleTable(tableRef, options, dom
101
102
  var node = options.node,
102
103
  start = options.start,
103
104
  parentWidth = options.parentWidth;
104
- if (!tableRef || !hasTableBeenResized(node)) {
105
+ if (!tableRef) {
106
+ return;
107
+ }
108
+ if (getBooleanFF('platform.editor.custom-table-width') && parentWidth) {
109
+ tableRef.style.width = "".concat(parentWidth, "px");
110
+ }
111
+ if (!hasTableBeenResized(node)) {
105
112
  return;
106
113
  }
107
114
  var resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos) : scale(tableRef, options, domAtPos);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -4,8 +4,10 @@ import { EditorView } from 'prosemirror-view';
4
4
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  type InnerContainerProps = {
6
6
  className: string;
7
- marginLeft: number | undefined;
8
- width: number | 'inherit';
7
+ style?: {
8
+ width: number | 'inherit';
9
+ marginLeft: number | undefined;
10
+ };
9
11
  node: PMNode;
10
12
  };
11
13
  export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContainerProps & {
@@ -20,7 +22,7 @@ type ResizableTableContainerProps = {
20
22
  getPos: () => number | undefined;
21
23
  tableRef: HTMLTableElement;
22
24
  };
23
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
25
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
24
26
  type TableContainerProps = {
25
27
  node: PMNode;
26
28
  className: string;
@@ -3,11 +3,12 @@ import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
4
  interface TableResizerProps {
5
5
  width: number;
6
+ maxWidth: number;
6
7
  updateWidth: (width: number) => void;
7
8
  editorView: EditorView;
8
9
  getPos: () => number | undefined;
9
10
  node: PMNode;
10
11
  tableRef: HTMLTableElement;
11
12
  }
12
- export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
14
  export {};
@@ -4,8 +4,10 @@ import { EditorView } from 'prosemirror-view';
4
4
  import { EditorContainerWidth } from '@atlaskit/editor-common/types';
5
5
  type InnerContainerProps = {
6
6
  className: string;
7
- marginLeft: number | undefined;
8
- width: number | 'inherit';
7
+ style?: {
8
+ width: number | 'inherit';
9
+ marginLeft: number | undefined;
10
+ };
9
11
  node: PMNode;
10
12
  };
11
13
  export declare const InnerContainer: React.ForwardRefExoticComponent<InnerContainerProps & {
@@ -20,7 +22,7 @@ type ResizableTableContainerProps = {
20
22
  getPos: () => number | undefined;
21
23
  tableRef: HTMLTableElement;
22
24
  };
23
- export declare const ResizableTableContainer: ({ children, className, node, lineLength, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
25
+ export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
24
26
  type TableContainerProps = {
25
27
  node: PMNode;
26
28
  className: string;
@@ -3,11 +3,12 @@ import { EditorView } from 'prosemirror-view';
3
3
  import { Node as PMNode } from 'prosemirror-model';
4
4
  interface TableResizerProps {
5
5
  width: number;
6
+ maxWidth: number;
6
7
  updateWidth: (width: number) => void;
7
8
  editorView: EditorView;
8
9
  getPos: () => number | undefined;
9
10
  node: PMNode;
10
11
  tableRef: HTMLTableElement;
11
12
  }
12
- export declare const TableResizer: ({ children, width, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
+ export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
13
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^26.1.0",
31
- "@atlaskit/editor-common": "^74.15.0",
31
+ "@atlaskit/editor-common": "^74.18.0",
32
32
  "@atlaskit/editor-palette": "1.5.1",
33
33
  "@atlaskit/editor-plugin-analytics": "^0.0.5",
34
34
  "@atlaskit/editor-plugin-content-insertion": "^0.0.5",
@@ -60,15 +60,13 @@
60
60
  "react-intl-next": "npm:react-intl@^5.18.1"
61
61
  },
62
62
  "devDependencies": {
63
- "@af/editor-libra": "*",
64
63
  "@atlaskit/analytics-next": "^9.1.0",
65
- "@atlaskit/editor-core": "^185.9.0",
64
+ "@atlaskit/editor-core": "^185.11.0",
66
65
  "@atlaskit/editor-plugin-decorations": "^0.1.0",
67
66
  "@atlaskit/editor-plugin-feature-flags": "^0.1.0",
68
67
  "@atlaskit/editor-plugin-grid": "^0.1.0",
69
68
  "@atlaskit/editor-plugin-width": "^0.1.0",
70
- "@atlaskit/editor-test-helpers": "^18.9.0",
71
- "@atlaskit/media-integration-test-helpers": "^3.0.0",
69
+ "@atlaskit/editor-test-helpers": "^18.10.0",
72
70
  "@atlaskit/visual-regression": "*",
73
71
  "@atlaskit/webdriver-runner": "*",
74
72
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -48,7 +48,6 @@ import {
48
48
  import type { TableOptions } from './types';
49
49
  import { updateOverflowShadows } from './update-overflow-shadows';
50
50
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
51
-
52
51
  import memoizeOne from 'memoize-one';
53
52
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
54
53
  import { TableContainer } from './TableContainer';
@@ -151,7 +150,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
151
150
  * We no longer use `containerWidth` as a variable to determine an update for table resizing (avoids unnecessary updates).
152
151
  * Instead we use the resize event to only trigger updates when necessary.
153
152
  */
154
- window.addEventListener('resize', this.handleWindowResizeDebounced);
153
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
154
+ window.addEventListener('resize', this.handleWindowResizeDebounced);
155
+ }
155
156
  this.handleTableResizingDebounced();
156
157
  }
157
158
 
@@ -175,9 +176,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
175
176
  this.scaleTableDebounced.cancel();
176
177
  this.handleTableResizingDebounced.cancel();
177
178
  this.handleAutoSizeDebounced.cancel();
178
- this.handleWindowResizeDebounced.cancel();
179
+ if (!getBooleanFF('platform.editor.custom-table-width')) {
180
+ this.handleWindowResizeDebounced.cancel();
181
+ }
179
182
 
180
- if (this.props.allowColumnResizing) {
183
+ if (
184
+ !getBooleanFF('platform.editor.custom-table-width') &&
185
+ this.props.allowColumnResizing
186
+ ) {
181
187
  window.removeEventListener('resize', this.handleWindowResizeDebounced);
182
188
  }
183
189
 
@@ -14,6 +14,7 @@ import { calcTableWidth } from '@atlaskit/editor-common/styles';
14
14
 
15
15
  import { TableCssClassName as ClassName } from '../types';
16
16
  import { TableResizer } from './TableResizer';
17
+ import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
17
18
 
18
19
  interface GetMarginLeftOpts {
19
20
  lineLength: number;
@@ -35,22 +36,21 @@ const getMarginLeft = ({ lineLength, tableWidth }: GetMarginLeftOpts) => {
35
36
 
36
37
  type InnerContainerProps = {
37
38
  className: string;
38
- marginLeft: number | undefined;
39
- width: number | 'inherit';
39
+ style?: {
40
+ width: number | 'inherit';
41
+ marginLeft: number | undefined;
42
+ };
40
43
  node: PMNode;
41
44
  };
42
45
 
43
46
  export const InnerContainer = forwardRef<
44
47
  HTMLDivElement,
45
48
  PropsWithChildren<InnerContainerProps>
46
- >(({ marginLeft, className, width, node, children }, ref) => {
49
+ >(({ className, style, node, children }, ref) => {
47
50
  return (
48
51
  <div
49
52
  ref={ref}
50
- style={{
51
- width,
52
- marginLeft,
53
- }}
53
+ style={style}
54
54
  className={className}
55
55
  data-number-column={node.attrs.isNumberColumnEnabled}
56
56
  data-layout={node.attrs.layout}
@@ -76,6 +76,7 @@ export const ResizableTableContainer = ({
76
76
  className,
77
77
  node,
78
78
  lineLength,
79
+ containerWidth,
79
80
  editorView,
80
81
  getPos,
81
82
  tableRef,
@@ -89,25 +90,32 @@ export const ResizableTableContainer = ({
89
90
  return;
90
91
  }
91
92
 
92
- innerContainerRef.current.style.width = `${width}px`;
93
-
94
93
  const marginLeft = getMarginLeft({
95
94
  lineLength,
96
95
  tableWidth: width,
97
96
  });
98
97
 
99
- containerRef.current.style.width = `${width}px`;
100
- containerRef.current.style.marginLeft = `${marginLeft}px`;
98
+ if (marginLeft) {
99
+ containerRef.current.style.marginLeft = `${marginLeft}px`;
100
+ }
101
101
  },
102
102
  [lineLength],
103
103
  );
104
104
 
105
- const width = getTableContainerWidth(node);
105
+ const tableWidth = getTableContainerWidth(node);
106
+
107
+ // 76 is currently an accepted padding value considering the spacing for resizer handle
108
+ const responsiveContainerWidth = containerWidth - 76;
109
+
110
+ const width = Math.min(tableWidth, responsiveContainerWidth);
111
+
106
112
  const marginLeft = getMarginLeft({
107
113
  lineLength,
108
114
  tableWidth: width,
109
115
  });
110
116
 
117
+ const maxResizerWidth = Math.min(responsiveContainerWidth, TABLE_MAX_WIDTH);
118
+
111
119
  return (
112
120
  <div
113
121
  style={{ marginLeft, width }}
@@ -116,6 +124,7 @@ export const ResizableTableContainer = ({
116
124
  >
117
125
  <TableResizer
118
126
  width={width}
127
+ maxWidth={maxResizerWidth}
119
128
  updateWidth={updateWidth}
120
129
  editorView={editorView}
121
130
  getPos={getPos}
@@ -126,8 +135,6 @@ export const ResizableTableContainer = ({
126
135
  ref={innerContainerRef}
127
136
  className={className}
128
137
  node={node}
129
- width={width}
130
- marginLeft={0}
131
138
  >
132
139
  {children}
133
140
  </InnerContainer>
@@ -188,11 +195,13 @@ export const TableContainer = ({
188
195
  <InnerContainer
189
196
  node={node}
190
197
  className={className}
191
- width={tableWidth}
192
- marginLeft={getMarginLeft({
193
- lineLength: lineLength!,
194
- tableWidth,
195
- })}
198
+ style={{
199
+ width: tableWidth,
200
+ marginLeft: getMarginLeft({
201
+ lineLength: lineLength!,
202
+ tableWidth,
203
+ }),
204
+ }}
196
205
  >
197
206
  {children}
198
207
  </InnerContainer>
@@ -10,11 +10,11 @@ import {
10
10
  previewScaleTable,
11
11
  getColgroupChildrenLength,
12
12
  COLUMN_MIN_WIDTH,
13
- TABLE_MAX_WIDTH,
14
13
  } from '../pm-plugins/table-resizing/utils';
15
14
 
16
15
  interface TableResizerProps {
17
16
  width: number;
17
+ maxWidth: number;
18
18
  updateWidth: (width: number) => void;
19
19
  editorView: EditorView;
20
20
  getPos: () => number | undefined;
@@ -27,6 +27,7 @@ const handles = { right: true };
27
27
  export const TableResizer = ({
28
28
  children,
29
29
  width,
30
+ maxWidth,
30
31
  updateWidth,
31
32
  editorView,
32
33
  getPos,
@@ -99,7 +100,7 @@ export const TableResizer = ({
99
100
  }}
100
101
  resizeRatio={2}
101
102
  minWidth={minColumnWidth}
102
- maxWidth={TABLE_MAX_WIDTH}
103
+ maxWidth={maxWidth}
103
104
  >
104
105
  {children}
105
106
  </ResizerNext>
@@ -29,16 +29,22 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
29
29
  import TableComponent from './TableComponent';
30
30
  import { Props, TableOptions } from './types';
31
31
  import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
32
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
33
+ import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
32
34
 
33
35
  type ForwardRef = (node: HTMLElement | null) => void;
34
36
 
35
37
  const tableAttributes = (node: PmNode) => {
38
+ const style = getBooleanFF('platform.editor.custom-table-width')
39
+ ? `width: ${getTableContainerWidth(node)}px`
40
+ : undefined;
36
41
  return {
37
42
  'data-number-column': node.attrs.isNumberColumnEnabled,
38
43
  'data-layout': node.attrs.layout,
39
44
  'data-autosize': node.attrs.__autoSize,
40
45
  'data-table-local-id': node.attrs.localId || '',
41
46
  'data-table-width': node.attrs.width,
47
+ style,
42
48
  };
43
49
  };
44
50
 
@@ -5,6 +5,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
5
5
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
6
6
 
7
7
  import type { DomAtPos } from 'prosemirror-utils';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
 
9
10
  import { getTableWidth } from '../../../utils';
10
11
  import { getLayoutSize } from '../utils/misc';
@@ -152,7 +153,15 @@ export const previewScaleTable = (
152
153
  ) => {
153
154
  const { node, start, parentWidth } = options;
154
155
 
155
- if (!tableRef || !hasTableBeenResized(node)) {
156
+ if (!tableRef) {
157
+ return;
158
+ }
159
+
160
+ if (getBooleanFF('platform.editor.custom-table-width') && parentWidth) {
161
+ tableRef.style.width = `${parentWidth}px`;
162
+ }
163
+
164
+ if (!hasTableBeenResized(node)) {
156
165
  return;
157
166
  }
158
167
 
@@ -1,104 +0,0 @@
1
- ## API Report File for "@atlaskit/editor-plugin-table"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
8
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
- import type { Command } from '@atlaskit/editor-common/types';
10
- import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
11
- import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
12
- import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
13
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
14
- import { TableLayout } from '@atlaskit/adf-schema';
15
- import type { widthPlugin } from '@atlaskit/editor-plugin-width';
16
-
17
- // @public (undocumented)
18
- type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
19
-
20
- // @public (undocumented)
21
- type PermittedLayoutsDescriptor = 'all' | TableLayout[];
22
-
23
- // @public (undocumented)
24
- interface PluginConfig {
25
- // (undocumented)
26
- advanced?: boolean;
27
- // (undocumented)
28
- allowAddColumnWithCustomStep?: boolean;
29
- // (undocumented)
30
- allowBackgroundColor?: boolean;
31
- // (undocumented)
32
- allowCellOptionsInFloatingToolbar?: boolean;
33
- // (undocumented)
34
- allowCollapse?: boolean;
35
- // (undocumented)
36
- allowColumnResizing?: boolean;
37
- // (undocumented)
38
- allowColumnSorting?: boolean;
39
- // (undocumented)
40
- allowControls?: boolean;
41
- // (undocumented)
42
- allowDistributeColumns?: boolean;
43
- // (undocumented)
44
- allowHeaderColumn?: boolean;
45
- // (undocumented)
46
- allowHeaderRow?: boolean;
47
- // (undocumented)
48
- allowMergeCells?: boolean;
49
- // (undocumented)
50
- allowNumberColumn?: boolean;
51
- // (undocumented)
52
- initialRenderOptimization?: boolean;
53
- // (undocumented)
54
- isHeaderRowRequired?: boolean;
55
- // (undocumented)
56
- mouseMoveOptimization?: boolean;
57
- // (undocumented)
58
- permittedLayouts?: PermittedLayoutsDescriptor;
59
- // (undocumented)
60
- stickyHeaders?: boolean;
61
- // (undocumented)
62
- stickyHeadersOptimization?: boolean;
63
- // (undocumented)
64
- tableCellOptimization?: boolean;
65
- // (undocumented)
66
- tableOverflowShadowsOptimization?: boolean;
67
- // (undocumented)
68
- tableRenderOptimization?: boolean;
69
- }
70
-
71
- // @public (undocumented)
72
- interface TablePluginOptions {
73
- // (undocumented)
74
- allowContextualMenu?: boolean;
75
- // (undocumented)
76
- breakoutEnabled?: boolean;
77
- // (undocumented)
78
- editorSelectionAPI?: EditorSelectionAPI;
79
- // (undocumented)
80
- fullWidthEnabled?: boolean;
81
- // (undocumented)
82
- getEditorFeatureFlags?: GetEditorFeatureFlags;
83
- // (undocumented)
84
- tableOptions: PluginConfig;
85
- // (undocumented)
86
- wasFullWidthEnabled?: boolean;
87
- }
88
-
89
- // @public (undocumented)
90
- export const tablesPlugin: NextEditorPlugin<'table', {
91
- pluginConfiguration: TablePluginOptions | undefined;
92
- actions: {
93
- insertTable: InsertTableAction;
94
- };
95
- dependencies: [
96
- typeof analyticsPlugin,
97
- typeof contentInsertionPlugin,
98
- typeof widthPlugin
99
- ];
100
- }>;
101
-
102
- // (No @packageDocumentation comment for this package)
103
-
104
- ```