@atlaskit/editor-plugin-table 7.27.2 → 7.28.0

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +5 -1
  3. package/dist/cjs/nodeviews/TableRow.js +6 -1
  4. package/dist/cjs/toDOM.js +29 -6
  5. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +3 -1
  6. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +4 -2
  7. package/dist/cjs/ui/TableFloatingColumnControls/index.js +2 -1
  8. package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +2 -1
  9. package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +2 -1
  10. package/dist/es2019/nodeviews/TableComponent.js +4 -2
  11. package/dist/es2019/nodeviews/TableRow.js +6 -1
  12. package/dist/es2019/toDOM.js +28 -4
  13. package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +3 -1
  14. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +4 -2
  15. package/dist/es2019/ui/TableFloatingColumnControls/index.js +2 -1
  16. package/dist/es2019/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +2 -1
  17. package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +2 -1
  18. package/dist/esm/nodeviews/TableComponent.js +5 -1
  19. package/dist/esm/nodeviews/TableRow.js +6 -1
  20. package/dist/esm/toDOM.js +29 -6
  21. package/dist/esm/ui/FloatingContextualButton/FixedButton.js +3 -1
  22. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +4 -2
  23. package/dist/esm/ui/TableFloatingColumnControls/index.js +2 -1
  24. package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +2 -1
  25. package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +2 -1
  26. package/package.json +4 -1
  27. package/src/nodeviews/TableComponent.tsx +7 -4
  28. package/src/nodeviews/TableRow.ts +6 -1
  29. package/src/toDOM.ts +35 -7
  30. package/src/ui/FloatingContextualButton/FixedButton.tsx +4 -1
  31. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +3 -1
  32. package/src/ui/TableFloatingColumnControls/index.tsx +4 -1
  33. package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +8 -1
  34. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +8 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 7.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#144162](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/144162)
8
+ [`2b2233eed311a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2b2233eed311a) -
9
+ ED-24858: fixes layout shifts for tables under SSR
10
+
3
11
  ## 7.27.2
4
12
 
5
13
  ### Patch Changes
@@ -721,6 +721,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
721
721
  key: "render",
722
722
  value: function render() {
723
723
  var _this4 = this,
724
+ _this$state$stickyHea2,
725
+ _this$state$stickyHea3,
724
726
  _this$props$options10,
725
727
  _classnames;
726
728
  var _this$props12 = this.props,
@@ -835,7 +837,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
835
837
  tablePos = undefined;
836
838
  }
837
839
  var isNested = (0, _utils5.isTableNested)(view.state, tablePos);
838
- var topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
840
+ var topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
841
+ var topOffset = (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? 0 : (_this$state$stickyHea2 = (_this$state$stickyHea3 = this.state.stickyHeader) === null || _this$state$stickyHea3 === void 0 ? void 0 : _this$state$stickyHea3.top) !== null && _this$state$stickyHea2 !== void 0 ? _this$state$stickyHea2 : 0;
842
+ var topStickyShadowPosition = this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
839
843
  var _getEditorFeatureFlag8 = getEditorFeatureFlags(),
840
844
  stickyScrollbar = _getEditorFeatureFlag8.stickyScrollbar,
841
845
  _getEditorFeatureFlag9 = _getEditorFeatureFlag8.tableWithFixedColumnWidthsOption,
@@ -15,6 +15,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
15
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
16
16
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
17
17
  var _ui = require("@atlaskit/editor-common/ui");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  var _pluginFactory = require("../pm-plugins/plugin-factory");
19
20
  var _pluginKey = require("../pm-plugins/plugin-key");
20
21
  var _commands = require("../pm-plugins/sticky-headers/commands");
@@ -496,7 +497,11 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
496
497
  _this6.refireIntersectionObservers();
497
498
  }, fastScrollThresholdMs);
498
499
  }
499
- this.dom.style.top = "".concat(domTop, "px");
500
+ if ((0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css')) {
501
+ this.dom.style.top = "0px";
502
+ } else {
503
+ this.dom.style.top = "".concat(domTop, "px");
504
+ }
500
505
  (0, _dom.updateStickyMargins)(table);
501
506
  this.dom.scrollLeft = wrapper.scrollLeft;
502
507
  this.emitOn(domTop, this.colControlsOffset);
package/dist/cjs/toDOM.js CHANGED
@@ -10,10 +10,13 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
12
12
  var _adfSchema = require("@atlaskit/adf-schema");
13
+ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
13
14
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
16
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
17
  var _tableContainerStyles = require("./nodeviews/table-container-styles");
16
18
  var _colgroup = require("./pm-plugins/table-resizing/utils/colgroup");
19
+ var _consts = require("./pm-plugins/table-resizing/utils/consts");
17
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
22
  var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
@@ -22,21 +25,23 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
22
25
  }
23
26
  return _objectSpread(_objectSpread({}, _adfSchema.table), {}, {
24
27
  toDOM: function toDOM(node) {
25
- var editorWidthFromGetter = Math.min(config.getEditorContainerWidth().width - (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2, node.attrs.width);
28
+ var gutterPadding = (0, _editorSharedStyles.akEditorGutterPaddingDynamic)() * 2;
29
+ var editorWidthFromGetter = (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? undefined : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
26
30
  var alignmentStyle = Object.entries((0, _tableContainerStyles.getAlignmentStyle)(node.attrs.layout)).map(function (_ref) {
27
31
  var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
28
32
  k = _ref2[0],
29
33
  v = _ref2[1];
30
34
  return "".concat((0, _kebabCase.default)(k), ": ").concat((0, _kebabCase.default)(v));
31
35
  }).join(';');
32
- var attrs = {
36
+ var attrs = _objectSpread({
33
37
  'data-number-column': node.attrs.isNumberColumnEnabled,
34
38
  'data-layout': node.attrs.layout,
35
39
  'data-autosize': node.attrs.__autoSize,
36
40
  'data-table-local-id': node.attrs.localId,
37
- 'data-table-width': node.attrs.width,
41
+ 'data-table-width': node.attrs.width
42
+ }, (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? {} : {
38
43
  style: "width: ".concat(node.attrs.width, "px;")
39
- };
44
+ });
40
45
  var colgroup = '';
41
46
  if (config.allowColumnResizing) {
42
47
  colgroup = ['colgroup', {}].concat((0, _toConsumableArray2.default)((0, _colgroup.generateColgroup)(node)));
@@ -77,10 +82,28 @@ var tableNodeSpecWithFixedToDOM = exports.tableNodeSpecWithFixedToDOM = function
77
82
  style: alignmentStyle
78
83
  }, ['div', {
79
84
  class: 'pm-table-resizer-container',
80
- style: "width: ".concat(node.attrs.width, "px")
85
+ style: (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? "width: min(calc(100cqw - ".concat(gutterPadding, "px), ").concat(node.attrs.width, "px);") : "width: ".concat(node.attrs.width, "px")
81
86
  }, ['div', {
82
87
  class: 'resizer-item display-handle',
83
- style: "position: relative; user-select: auto; height: auto; min-width: 145px; box-sizing: border-box; max-width: ".concat(editorWidthFromGetter, "px; width: ").concat(editorWidthFromGetter, "px;")
88
+ style: (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? (0, _lazyNodeView.convertToInlineCss)({
89
+ position: 'relative',
90
+ userSelect: 'auto',
91
+ boxSizing: 'border-box',
92
+ '--ak-editor-table-gutter-padding': "".concat(gutterPadding, "px"),
93
+ '--ak-editor-table-max-width': "".concat(_consts.TABLE_MAX_WIDTH, "px"),
94
+ '--ak-editor-table-min-width': "145px",
95
+ minWidth: 'var(--ak-editor-table-min-width)',
96
+ maxWidth: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))",
97
+ width: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(node.attrs.width, ")")
98
+ }) : (0, _lazyNodeView.convertToInlineCss)({
99
+ position: 'relative',
100
+ userSelect: 'auto',
101
+ boxSizing: 'border-box',
102
+ height: 'auto',
103
+ minWidth: '145px',
104
+ maxWidth: "".concat(editorWidthFromGetter, "px"),
105
+ width: "".concat(editorWidthFromGetter, "px;")
106
+ })
84
107
  }, ['span', {
85
108
  class: 'resizer-hover-zone'
86
109
  }, tableContainerDiv]]]];
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
11
11
  var _reactDom = require("react-dom");
12
12
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _types = require("../../types");
14
15
  var _commonStyles = require("../common-styles");
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -89,6 +90,7 @@ var FixedButton = exports.FixedButton = function FixedButton(_ref2) {
89
90
  }
90
91
  }, [fixedButtonRef, observerTargetRef, tableWrapper, targetCellPosition, targetCellRef, isContextualMenuOpen]);
91
92
  var targetCellRect = targetCellRef.getBoundingClientRect();
93
+ var fixedButtonTop = (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? 0 : stickyHeader.top;
92
94
 
93
95
  // Using a portal here to ensure wrapperRef has the tableWrapper as an
94
96
  // ancestor. This is required to make the Intersection Observer work.
@@ -119,7 +121,7 @@ var FixedButton = exports.FixedButton = function FixedButton(_ref2) {
119
121
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
120
122
  position: 'fixed',
121
123
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
122
- top: stickyHeader.top + stickyHeader.padding + offset * 2,
124
+ top: fixedButtonTop + stickyHeader.padding + offset * 2,
123
125
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
124
126
  zIndex: _editorSharedStyles.akEditorTableCellOnStickyHeaderZIndex,
125
127
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -11,6 +11,7 @@ var _styles = require("@atlaskit/editor-common/styles");
11
11
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
12
12
  var _editorTables = require("@atlaskit/editor-tables");
13
13
  var _utils = require("@atlaskit/editor-tables/utils");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _commands = require("../../../commands");
15
16
  var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
16
17
  var _types = require("../../../types");
@@ -31,7 +32,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
31
32
  return [];
32
33
  };
33
34
  var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
34
- var _colWidths$map$join, _rowHeights$;
35
+ var _colWidths$map$join;
35
36
  var editorView = _ref.editorView,
36
37
  tableActive = _ref.tableActive,
37
38
  tableRef = _ref.tableRef,
@@ -64,7 +65,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
64
65
  var selectedColIndexes = getSelectedColumns((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection) || editorView.state.selection);
65
66
  var firstRow = tableRef.querySelector('tr');
66
67
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
67
- var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
68
+ var rowControlStickyTop = (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? 45 : rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0];
69
+ var marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop !== null && rowControlStickyTop !== void 0 ? rowControlStickyTop : 0 : 0;
68
70
  var handleClick = (0, _react.useCallback)(function (event) {
69
71
  var state = editorView.state,
70
72
  dispatch = editorView.dispatch;
@@ -74,8 +74,9 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
74
74
  var colWidths = (0, _utils.getColumnsWidths)(editorView);
75
75
  if (stickyTop) {
76
76
  var _rowHeights$, _containerRef$current;
77
+ var columnControlTopOffsetFromParent = '-12px';
77
78
  var headerRowHeight = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
78
- containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 || _containerRef$current.style.setProperty('top', "".concat(stickyTop - headerRowHeight + 33, "px") // 33px is padding and margin applied on tr.sticky
79
+ containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 || _containerRef$current.style.setProperty('top', (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? columnControlTopOffsetFromParent : "".concat(stickyTop - headerRowHeight + 33, "px") // 33px is padding and margin applied on tr.sticky
79
80
  );
80
81
  } else {
81
82
  var _containerRef$current2;
@@ -19,6 +19,7 @@ var _reactIntlNext = require("react-intl-next");
19
19
  var _messages = require("@atlaskit/editor-common/messages");
20
20
  var _tableMap = require("@atlaskit/editor-tables/table-map");
21
21
  var _utils = require("@atlaskit/editor-tables/utils");
22
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
23
  var _commands = require("../../../commands");
23
24
  var _types = require("../../../types");
24
25
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -88,7 +89,7 @@ var CornerControlComponent = /*#__PURE__*/function (_Component) {
88
89
  }),
89
90
  style: {
90
91
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
91
- top: this.props.stickyTop !== undefined ? "".concat(this.props.stickyTop, "px") : undefined
92
+ top: (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? this.props.stickyTop !== undefined ? "0px" : undefined : this.props.stickyTop !== undefined ? "".concat(this.props.stickyTop, "px") : undefined
92
93
  },
93
94
  contentEditable: false
94
95
  }, /*#__PURE__*/_react.default.createElement("button", {
@@ -16,6 +16,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
16
16
  var _react = _interopRequireWildcard(require("react"));
17
17
  var _reactIntlNext = require("react-intl-next");
18
18
  var _messages = require("@atlaskit/editor-common/messages");
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
20
  var _commands = require("../../../commands");
20
21
  var _types = require("../../../types");
21
22
  var _utils = require("../../../utils");
@@ -89,7 +90,7 @@ var RowControlsComponent = /*#__PURE__*/function (_Component) {
89
90
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
90
91
  marginTop: "".concat(marginTop, "px"),
91
92
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
92
- top: thisRowSticky ? "".concat(_this2.props.stickyTop + 3, "px") : undefined,
93
+ top: (0, _platformFeatureFlags.fg)('platform_editor_breakout_use_css') ? thisRowSticky ? "3px" : undefined : thisRowSticky ? "".concat(_this2.props.stickyTop + 3, "px") : undefined,
93
94
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
94
95
  paddingTop: thisRowSticky ? "".concat(_consts.tableControlsSpacing, "px") : undefined
95
96
  }
@@ -701,7 +701,7 @@ class TableComponent extends React.Component {
701
701
  }
702
702
  }
703
703
  render() {
704
- var _this$props$options12;
704
+ var _this$state$stickyHea2, _this$state$stickyHea3, _this$props$options12;
705
705
  const {
706
706
  view,
707
707
  getNode,
@@ -815,7 +815,9 @@ class TableComponent extends React.Component {
815
815
  tablePos = undefined;
816
816
  }
817
817
  const isNested = isTableNested(view.state, tablePos);
818
- const topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
818
+ const topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
819
+ const topOffset = fg('platform_editor_breakout_use_css') ? 0 : (_this$state$stickyHea2 = (_this$state$stickyHea3 = this.state.stickyHeader) === null || _this$state$stickyHea3 === void 0 ? void 0 : _this$state$stickyHea3.top) !== null && _this$state$stickyHea2 !== void 0 ? _this$state$stickyHea2 : 0;
820
+ let topStickyShadowPosition = this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
819
821
  const {
820
822
  stickyScrollbar,
821
823
  tableWithFixedColumnWidthsOption = false
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import debounce from 'lodash/debounce';
3
3
  import throttle from 'lodash/throttle';
4
4
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { getPluginState } from '../pm-plugins/plugin-factory';
6
7
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
7
8
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
@@ -456,7 +457,11 @@ export default class TableRow extends TableNodeView {
456
457
  this.refireIntersectionObservers();
457
458
  }, fastScrollThresholdMs);
458
459
  }
459
- this.dom.style.top = `${domTop}px`;
460
+ if (fg('platform_editor_breakout_use_css')) {
461
+ this.dom.style.top = `0px`;
462
+ } else {
463
+ this.dom.style.top = `${domTop}px`;
464
+ }
460
465
  updateTableMargin(table);
461
466
  this.dom.scrollLeft = wrapper.scrollLeft;
462
467
  this.emitOn(domTop, this.colControlsOffset);
@@ -1,9 +1,12 @@
1
1
  import kebabCase from 'lodash/kebabCase';
2
2
  import { table } from '@atlaskit/adf-schema';
3
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
4
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
4
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
7
  import { getAlignmentStyle } from './nodeviews/table-container-styles';
6
8
  import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
9
+ import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
7
10
  export const tableNodeSpecWithFixedToDOM = config => {
8
11
  if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
9
12
  return table;
@@ -11,7 +14,8 @@ export const tableNodeSpecWithFixedToDOM = config => {
11
14
  return {
12
15
  ...table,
13
16
  toDOM: node => {
14
- const editorWidthFromGetter = Math.min(config.getEditorContainerWidth().width - akEditorGutterPaddingDynamic() * 2, node.attrs.width);
17
+ const gutterPadding = akEditorGutterPaddingDynamic() * 2;
18
+ const editorWidthFromGetter = fg('platform_editor_breakout_use_css') ? undefined : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
15
19
  const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`).join(';');
16
20
  const attrs = {
17
21
  'data-number-column': node.attrs.isNumberColumnEnabled,
@@ -19,7 +23,9 @@ export const tableNodeSpecWithFixedToDOM = config => {
19
23
  'data-autosize': node.attrs.__autoSize,
20
24
  'data-table-local-id': node.attrs.localId,
21
25
  'data-table-width': node.attrs.width,
22
- style: `width: ${node.attrs.width}px;`
26
+ ...(fg('platform_editor_breakout_use_css') ? {} : {
27
+ style: `width: ${node.attrs.width}px;`
28
+ })
23
29
  };
24
30
  let colgroup = '';
25
31
  if (config.allowColumnResizing) {
@@ -61,10 +67,28 @@ export const tableNodeSpecWithFixedToDOM = config => {
61
67
  style: alignmentStyle
62
68
  }, ['div', {
63
69
  class: 'pm-table-resizer-container',
64
- style: `width: ${node.attrs.width}px`
70
+ style: fg('platform_editor_breakout_use_css') ? `width: min(calc(100cqw - ${gutterPadding}px), ${node.attrs.width}px);` : `width: ${node.attrs.width}px`
65
71
  }, ['div', {
66
72
  class: 'resizer-item display-handle',
67
- style: `position: relative; user-select: auto; height: auto; min-width: 145px; box-sizing: border-box; max-width: ${editorWidthFromGetter}px; width: ${editorWidthFromGetter}px;`
73
+ style: fg('platform_editor_breakout_use_css') ? convertToInlineCss({
74
+ position: 'relative',
75
+ userSelect: 'auto',
76
+ boxSizing: 'border-box',
77
+ '--ak-editor-table-gutter-padding': `${gutterPadding}px`,
78
+ '--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
79
+ '--ak-editor-table-min-width': `145px`,
80
+ minWidth: 'var(--ak-editor-table-min-width)',
81
+ maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
82
+ width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${node.attrs.width})`
83
+ }) : convertToInlineCss({
84
+ position: 'relative',
85
+ userSelect: 'auto',
86
+ boxSizing: 'border-box',
87
+ height: 'auto',
88
+ minWidth: '145px',
89
+ maxWidth: `${editorWidthFromGetter}px`,
90
+ width: `${editorWidthFromGetter}px;`
91
+ })
68
92
  }, ['span', {
69
93
  class: 'resizer-hover-zone'
70
94
  }, tableContainerDiv]]]];
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
2
  import rafSchedule from 'raf-schd';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { TableCssClassName as ClassName } from '../../types';
6
7
  import { insertColumnButtonOffset } from '../common-styles';
7
8
  const BUTTON_WIDTH = 20;
@@ -81,6 +82,7 @@ export const FixedButton = ({
81
82
  }
82
83
  }, [fixedButtonRef, observerTargetRef, tableWrapper, targetCellPosition, targetCellRef, isContextualMenuOpen]);
83
84
  const targetCellRect = targetCellRef.getBoundingClientRect();
85
+ const fixedButtonTop = fg('platform_editor_breakout_use_css') ? 0 : stickyHeader.top;
84
86
 
85
87
  // Using a portal here to ensure wrapperRef has the tableWrapper as an
86
88
  // ancestor. This is required to make the Intersection Observer work.
@@ -111,7 +113,7 @@ export const FixedButton = ({
111
113
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
112
114
  position: 'fixed',
113
115
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
114
- top: stickyHeader.top + stickyHeader.padding + offset * 2,
116
+ top: fixedButtonTop + stickyHeader.padding + offset * 2,
115
117
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
116
118
  zIndex: akEditorTableCellOnStickyHeaderZIndex,
117
119
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -6,6 +6,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
7
  import { CellSelection } from '@atlaskit/editor-tables';
8
8
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../commands';
10
11
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
11
12
  import { TableCssClassName as ClassName } from '../../../types';
@@ -39,7 +40,7 @@ export const ColumnControls = ({
39
40
  getScrollOffset,
40
41
  api
41
42
  }) => {
42
- var _colWidths$map$join, _rowHeights$;
43
+ var _colWidths$map$join;
43
44
  const columnControlsRef = useRef(null);
44
45
  const {
45
46
  selectionState
@@ -54,7 +55,8 @@ export const ColumnControls = ({
54
55
  const selectedColIndexes = getSelectedColumns((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection) || editorView.state.selection);
55
56
  const firstRow = tableRef.querySelector('tr');
56
57
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
57
- const marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
58
+ const rowControlStickyTop = fg('platform_editor_breakout_use_css') ? 45 : rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0];
59
+ const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop !== null && rowControlStickyTop !== void 0 ? rowControlStickyTop : 0 : 0;
58
60
  const handleClick = useCallback(event => {
59
61
  const {
60
62
  state,
@@ -63,8 +63,9 @@ const TableFloatingColumnControls = ({
63
63
  const colWidths = getColumnsWidths(editorView);
64
64
  if (stickyTop) {
65
65
  var _rowHeights$, _containerRef$current;
66
+ const columnControlTopOffsetFromParent = '-12px';
66
67
  const headerRowHeight = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
67
- containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.style.setProperty('top', `${stickyTop - headerRowHeight + 33}px` // 33px is padding and margin applied on tr.sticky
68
+ containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.style.setProperty('top', fg('platform_editor_breakout_use_css') ? columnControlTopOffsetFromParent : `${stickyTop - headerRowHeight + 33}px` // 33px is padding and margin applied on tr.sticky
68
69
  );
69
70
  } else {
70
71
  var _containerRef$current2;
@@ -5,6 +5,7 @@ import { injectIntl } from 'react-intl-next';
5
5
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
7
7
  import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { clearHoverSelection, hoverTable } from '../../../commands';
9
10
  import { TableCssClassName as ClassName } from '../../../types';
10
11
  class CornerControlComponent extends Component {
@@ -69,7 +70,7 @@ class CornerControlComponent extends Component {
69
70
  }),
70
71
  style: {
71
72
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
72
- top: this.props.stickyTop !== undefined ? `${this.props.stickyTop}px` : undefined
73
+ top: fg('platform_editor_breakout_use_css') ? this.props.stickyTop !== undefined ? `0px` : undefined : this.props.stickyTop !== undefined ? `${this.props.stickyTop}px` : undefined
73
74
  },
74
75
  contentEditable: false
75
76
  }, /*#__PURE__*/React.createElement("button", {
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { Component } from 'react';
3
3
  import { injectIntl } from 'react-intl-next';
4
4
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { clearHoverSelection } from '../../../commands';
6
7
  import { TableCssClassName as ClassName } from '../../../types';
7
8
  import { getRowClassNames, getRowHeights, getRowsParams } from '../../../utils';
@@ -67,7 +68,7 @@ class RowControlsComponent extends Component {
67
68
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
68
69
  marginTop: `${marginTop}px`,
69
70
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
70
- top: thisRowSticky ? `${this.props.stickyTop + 3}px` : undefined,
71
+ top: fg('platform_editor_breakout_use_css') ? thisRowSticky ? `3px` : undefined : thisRowSticky ? `${this.props.stickyTop + 3}px` : undefined,
71
72
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
72
73
  paddingTop: thisRowSticky ? `${tableControlsSpacing}px` : undefined
73
74
  }
@@ -714,6 +714,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
714
714
  key: "render",
715
715
  value: function render() {
716
716
  var _this4 = this,
717
+ _this$state$stickyHea2,
718
+ _this$state$stickyHea3,
717
719
  _this$props$options10,
718
720
  _classnames;
719
721
  var _this$props12 = this.props,
@@ -828,7 +830,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
828
830
  tablePos = undefined;
829
831
  }
830
832
  var isNested = isTableNested(view.state, tablePos);
831
- var topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
833
+ var topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
834
+ var topOffset = fg('platform_editor_breakout_use_css') ? 0 : (_this$state$stickyHea2 = (_this$state$stickyHea3 = this.state.stickyHeader) === null || _this$state$stickyHea3 === void 0 ? void 0 : _this$state$stickyHea3.top) !== null && _this$state$stickyHea2 !== void 0 ? _this$state$stickyHea2 : 0;
835
+ var topStickyShadowPosition = this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
832
836
  var _getEditorFeatureFlag8 = getEditorFeatureFlags(),
833
837
  stickyScrollbar = _getEditorFeatureFlag8.stickyScrollbar,
834
838
  _getEditorFeatureFlag9 = _getEditorFeatureFlag8.tableWithFixedColumnWidthsOption,
@@ -10,6 +10,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
10
10
  import debounce from 'lodash/debounce';
11
11
  import throttle from 'lodash/throttle';
12
12
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { getPluginState } from '../pm-plugins/plugin-factory';
14
15
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
15
16
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
@@ -489,7 +490,11 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
489
490
  _this6.refireIntersectionObservers();
490
491
  }, fastScrollThresholdMs);
491
492
  }
492
- this.dom.style.top = "".concat(domTop, "px");
493
+ if (fg('platform_editor_breakout_use_css')) {
494
+ this.dom.style.top = "0px";
495
+ } else {
496
+ this.dom.style.top = "".concat(domTop, "px");
497
+ }
493
498
  updateTableMargin(table);
494
499
  this.dom.scrollLeft = wrapper.scrollLeft;
495
500
  this.emitOn(domTop, this.colControlsOffset);
package/dist/esm/toDOM.js CHANGED
@@ -5,31 +5,36 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import kebabCase from 'lodash/kebabCase';
7
7
  import { table } from '@atlaskit/adf-schema';
8
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
8
9
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
9
11
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
12
  import { getAlignmentStyle } from './nodeviews/table-container-styles';
11
13
  import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
14
+ import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
12
15
  export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(config) {
13
16
  if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
14
17
  return table;
15
18
  }
16
19
  return _objectSpread(_objectSpread({}, table), {}, {
17
20
  toDOM: function toDOM(node) {
18
- var editorWidthFromGetter = Math.min(config.getEditorContainerWidth().width - akEditorGutterPaddingDynamic() * 2, node.attrs.width);
21
+ var gutterPadding = akEditorGutterPaddingDynamic() * 2;
22
+ var editorWidthFromGetter = fg('platform_editor_breakout_use_css') ? undefined : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
19
23
  var alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout)).map(function (_ref) {
20
24
  var _ref2 = _slicedToArray(_ref, 2),
21
25
  k = _ref2[0],
22
26
  v = _ref2[1];
23
27
  return "".concat(kebabCase(k), ": ").concat(kebabCase(v));
24
28
  }).join(';');
25
- var attrs = {
29
+ var attrs = _objectSpread({
26
30
  'data-number-column': node.attrs.isNumberColumnEnabled,
27
31
  'data-layout': node.attrs.layout,
28
32
  'data-autosize': node.attrs.__autoSize,
29
33
  'data-table-local-id': node.attrs.localId,
30
- 'data-table-width': node.attrs.width,
34
+ 'data-table-width': node.attrs.width
35
+ }, fg('platform_editor_breakout_use_css') ? {} : {
31
36
  style: "width: ".concat(node.attrs.width, "px;")
32
- };
37
+ });
33
38
  var colgroup = '';
34
39
  if (config.allowColumnResizing) {
35
40
  colgroup = ['colgroup', {}].concat(_toConsumableArray(generateColgroup(node)));
@@ -70,10 +75,28 @@ export var tableNodeSpecWithFixedToDOM = function tableNodeSpecWithFixedToDOM(co
70
75
  style: alignmentStyle
71
76
  }, ['div', {
72
77
  class: 'pm-table-resizer-container',
73
- style: "width: ".concat(node.attrs.width, "px")
78
+ style: fg('platform_editor_breakout_use_css') ? "width: min(calc(100cqw - ".concat(gutterPadding, "px), ").concat(node.attrs.width, "px);") : "width: ".concat(node.attrs.width, "px")
74
79
  }, ['div', {
75
80
  class: 'resizer-item display-handle',
76
- style: "position: relative; user-select: auto; height: auto; min-width: 145px; box-sizing: border-box; max-width: ".concat(editorWidthFromGetter, "px; width: ").concat(editorWidthFromGetter, "px;")
81
+ style: fg('platform_editor_breakout_use_css') ? convertToInlineCss({
82
+ position: 'relative',
83
+ userSelect: 'auto',
84
+ boxSizing: 'border-box',
85
+ '--ak-editor-table-gutter-padding': "".concat(gutterPadding, "px"),
86
+ '--ak-editor-table-max-width': "".concat(TABLE_MAX_WIDTH, "px"),
87
+ '--ak-editor-table-min-width': "145px",
88
+ minWidth: 'var(--ak-editor-table-min-width)',
89
+ maxWidth: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))",
90
+ width: "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(node.attrs.width, ")")
91
+ }) : convertToInlineCss({
92
+ position: 'relative',
93
+ userSelect: 'auto',
94
+ boxSizing: 'border-box',
95
+ height: 'auto',
96
+ minWidth: '145px',
97
+ maxWidth: "".concat(editorWidthFromGetter, "px"),
98
+ width: "".concat(editorWidthFromGetter, "px;")
99
+ })
77
100
  }, ['span', {
78
101
  class: 'resizer-hover-zone'
79
102
  }, tableContainerDiv]]]];
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
2
  import rafSchedule from 'raf-schd';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { TableCssClassName as ClassName } from '../../types';
6
7
  import { insertColumnButtonOffset } from '../common-styles';
7
8
  var BUTTON_WIDTH = 20;
@@ -79,6 +80,7 @@ export var FixedButton = function FixedButton(_ref2) {
79
80
  }
80
81
  }, [fixedButtonRef, observerTargetRef, tableWrapper, targetCellPosition, targetCellRef, isContextualMenuOpen]);
81
82
  var targetCellRect = targetCellRef.getBoundingClientRect();
83
+ var fixedButtonTop = fg('platform_editor_breakout_use_css') ? 0 : stickyHeader.top;
82
84
 
83
85
  // Using a portal here to ensure wrapperRef has the tableWrapper as an
84
86
  // ancestor. This is required to make the Intersection Observer work.
@@ -109,7 +111,7 @@ export var FixedButton = function FixedButton(_ref2) {
109
111
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
110
112
  position: 'fixed',
111
113
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
112
- top: stickyHeader.top + stickyHeader.padding + offset * 2,
114
+ top: fixedButtonTop + stickyHeader.padding + offset * 2,
113
115
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
114
116
  zIndex: akEditorTableCellOnStickyHeaderZIndex,
115
117
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -6,6 +6,7 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
6
6
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
7
7
  import { CellSelection } from '@atlaskit/editor-tables';
8
8
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn, selectColumns } from '../../../commands';
10
11
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
11
12
  import { TableCssClassName as ClassName } from '../../../types';
@@ -22,7 +23,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
22
23
  return [];
23
24
  };
24
25
  export var ColumnControls = function ColumnControls(_ref) {
25
- var _colWidths$map$join, _rowHeights$;
26
+ var _colWidths$map$join;
26
27
  var editorView = _ref.editorView,
27
28
  tableActive = _ref.tableActive,
28
29
  tableRef = _ref.tableRef,
@@ -55,7 +56,8 @@ export var ColumnControls = function ColumnControls(_ref) {
55
56
  var selectedColIndexes = getSelectedColumns((selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection) || editorView.state.selection);
56
57
  var firstRow = tableRef.querySelector('tr');
57
58
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
58
- var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
59
+ var rowControlStickyTop = fg('platform_editor_breakout_use_css') ? 45 : rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0];
60
+ var marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop !== null && rowControlStickyTop !== void 0 ? rowControlStickyTop : 0 : 0;
59
61
  var handleClick = useCallback(function (event) {
60
62
  var state = editorView.state,
61
63
  dispatch = editorView.dispatch;
@@ -64,8 +64,9 @@ var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
64
64
  var colWidths = getColumnsWidths(editorView);
65
65
  if (stickyTop) {
66
66
  var _rowHeights$, _containerRef$current;
67
+ var columnControlTopOffsetFromParent = '-12px';
67
68
  var headerRowHeight = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
68
- containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 || _containerRef$current.style.setProperty('top', "".concat(stickyTop - headerRowHeight + 33, "px") // 33px is padding and margin applied on tr.sticky
69
+ containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 || _containerRef$current.style.setProperty('top', fg('platform_editor_breakout_use_css') ? columnControlTopOffsetFromParent : "".concat(stickyTop - headerRowHeight + 33, "px") // 33px is padding and margin applied on tr.sticky
69
70
  );
70
71
  } else {
71
72
  var _containerRef$current2;
@@ -13,6 +13,7 @@ import { injectIntl } from 'react-intl-next';
13
13
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
14
14
  import { TableMap } from '@atlaskit/editor-tables/table-map';
15
15
  import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
16
17
  import { clearHoverSelection, hoverTable } from '../../../commands';
17
18
  import { TableCssClassName as ClassName } from '../../../types';
18
19
  var CornerControlComponent = /*#__PURE__*/function (_Component) {
@@ -78,7 +79,7 @@ var CornerControlComponent = /*#__PURE__*/function (_Component) {
78
79
  }),
79
80
  style: {
80
81
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
81
- top: this.props.stickyTop !== undefined ? "".concat(this.props.stickyTop, "px") : undefined
82
+ top: fg('platform_editor_breakout_use_css') ? this.props.stickyTop !== undefined ? "0px" : undefined : this.props.stickyTop !== undefined ? "".concat(this.props.stickyTop, "px") : undefined
82
83
  },
83
84
  contentEditable: false
84
85
  }, /*#__PURE__*/React.createElement("button", {
@@ -10,6 +10,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
10
10
  import React, { Component } from 'react';
11
11
  import { injectIntl } from 'react-intl-next';
12
12
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { clearHoverSelection } from '../../../commands';
14
15
  import { TableCssClassName as ClassName } from '../../../types';
15
16
  import { getRowClassNames, getRowHeights, getRowsParams } from '../../../utils';
@@ -79,7 +80,7 @@ var RowControlsComponent = /*#__PURE__*/function (_Component) {
79
80
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
80
81
  marginTop: "".concat(marginTop, "px"),
81
82
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
82
- top: thisRowSticky ? "".concat(_this2.props.stickyTop + 3, "px") : undefined,
83
+ top: fg('platform_editor_breakout_use_css') ? thisRowSticky ? "3px" : undefined : thisRowSticky ? "".concat(_this2.props.stickyTop + 3, "px") : undefined,
83
84
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
84
85
  paddingTop: thisRowSticky ? "".concat(tableControlsSpacing, "px") : undefined
85
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.27.2",
3
+ "version": "7.28.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -117,6 +117,9 @@
117
117
  },
118
118
  "platform_editor_announce_cell_options_hotkeys": {
119
119
  "type": "boolean"
120
+ },
121
+ "platform_editor_breakout_use_css": {
122
+ "type": "boolean"
120
123
  }
121
124
  }
122
125
  }
@@ -838,10 +838,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
838
838
 
839
839
  const isNested = isTableNested(view.state, tablePos);
840
840
 
841
- const topStickyShadowPosition = isDragAndDropEnabled
842
- ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2
843
- : this.state.stickyHeader &&
844
- this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
841
+ const topShadowPadding = isDragAndDropEnabled ? 0 : shadowPadding;
842
+ const topOffset = fg('platform_editor_breakout_use_css')
843
+ ? 0
844
+ : this.state.stickyHeader?.top ?? 0;
845
+
846
+ let topStickyShadowPosition =
847
+ this.state.stickyHeader && topOffset + this.state.stickyHeader.padding + topShadowPadding + 2;
845
848
 
846
849
  const { stickyScrollbar, tableWithFixedColumnWidthsOption = false } = getEditorFeatureFlags();
847
850
 
@@ -5,6 +5,7 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
6
6
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
7
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
 
9
10
  import { getPluginState } from '../pm-plugins/plugin-factory';
10
11
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
@@ -557,7 +558,11 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
557
558
  }, fastScrollThresholdMs);
558
559
  }
559
560
 
560
- this.dom.style.top = `${domTop}px`;
561
+ if (fg('platform_editor_breakout_use_css')) {
562
+ this.dom.style.top = `0px`;
563
+ } else {
564
+ this.dom.style.top = `${domTop}px`;
565
+ }
561
566
  updateTableMargin(table);
562
567
  this.dom.scrollLeft = wrapper.scrollLeft;
563
568
 
package/src/toDOM.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import kebabCase from 'lodash/kebabCase';
2
2
 
3
3
  import { table } from '@atlaskit/adf-schema';
4
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
4
5
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/src/types';
5
6
  import type { DOMOutputSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
7
  import { akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
7
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
 
9
11
  import { getAlignmentStyle } from './nodeviews/table-container-styles';
10
12
  import { generateColgroup } from './pm-plugins/table-resizing/utils/colgroup';
13
+ import { TABLE_MAX_WIDTH } from './pm-plugins/table-resizing/utils/consts';
11
14
 
12
15
  type Config = {
13
16
  allowColumnResizing: boolean;
@@ -22,10 +25,11 @@ export const tableNodeSpecWithFixedToDOM = (config: Config): typeof table => {
22
25
  return {
23
26
  ...table,
24
27
  toDOM: (node: PMNode): DOMOutputSpec => {
25
- const editorWidthFromGetter = Math.min(
26
- config.getEditorContainerWidth().width - akEditorGutterPaddingDynamic() * 2,
27
- node.attrs.width,
28
- );
28
+ const gutterPadding = akEditorGutterPaddingDynamic() * 2;
29
+ const editorWidthFromGetter = fg('platform_editor_breakout_use_css')
30
+ ? undefined
31
+ : Math.min(config.getEditorContainerWidth().width - gutterPadding, node.attrs.width);
32
+
29
33
  const alignmentStyle = Object.entries(getAlignmentStyle(node.attrs.layout))
30
34
  .map(([k, v]) => `${kebabCase(k)}: ${kebabCase(v)}`)
31
35
  .join(';');
@@ -36,7 +40,9 @@ export const tableNodeSpecWithFixedToDOM = (config: Config): typeof table => {
36
40
  'data-autosize': node.attrs.__autoSize,
37
41
  'data-table-local-id': node.attrs.localId,
38
42
  'data-table-width': node.attrs.width,
39
- style: `width: ${node.attrs.width}px;`,
43
+ ...(fg('platform_editor_breakout_use_css')
44
+ ? {}
45
+ : { style: `width: ${node.attrs.width}px;` }),
40
46
  };
41
47
 
42
48
  let colgroup: DOMOutputSpec = '';
@@ -124,13 +130,35 @@ export const tableNodeSpecWithFixedToDOM = (config: Config): typeof table => {
124
130
  'div',
125
131
  {
126
132
  class: 'pm-table-resizer-container',
127
- style: `width: ${node.attrs.width}px`,
133
+ style: fg('platform_editor_breakout_use_css')
134
+ ? `width: min(calc(100cqw - ${gutterPadding}px), ${node.attrs.width}px);`
135
+ : `width: ${node.attrs.width}px`,
128
136
  },
129
137
  [
130
138
  'div',
131
139
  {
132
140
  class: 'resizer-item display-handle',
133
- style: `position: relative; user-select: auto; height: auto; min-width: 145px; box-sizing: border-box; max-width: ${editorWidthFromGetter}px; width: ${editorWidthFromGetter}px;`,
141
+ style: fg('platform_editor_breakout_use_css')
142
+ ? convertToInlineCss({
143
+ position: 'relative',
144
+ userSelect: 'auto',
145
+ boxSizing: 'border-box',
146
+ '--ak-editor-table-gutter-padding': `${gutterPadding}px`,
147
+ '--ak-editor-table-max-width': `${TABLE_MAX_WIDTH}px`,
148
+ '--ak-editor-table-min-width': `145px`,
149
+ minWidth: 'var(--ak-editor-table-min-width)',
150
+ maxWidth: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))`,
151
+ width: `min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ${node.attrs.width})`,
152
+ })
153
+ : convertToInlineCss({
154
+ position: 'relative',
155
+ userSelect: 'auto',
156
+ boxSizing: 'border-box',
157
+ height: 'auto',
158
+ minWidth: '145px',
159
+ maxWidth: `${editorWidthFromGetter}px`,
160
+ width: `${editorWidthFromGetter}px;`,
161
+ }),
134
162
  },
135
163
  [
136
164
  'span',
@@ -4,6 +4,7 @@ import rafSchedule from 'raf-schd';
4
4
  import { createPortal } from 'react-dom';
5
5
 
6
6
  import { akEditorTableCellOnStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { token } from '@atlaskit/tokens';
8
9
 
9
10
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
@@ -131,6 +132,8 @@ export const FixedButton = ({
131
132
 
132
133
  const targetCellRect = targetCellRef.getBoundingClientRect();
133
134
 
135
+ const fixedButtonTop = fg('platform_editor_breakout_use_css') ? 0 : stickyHeader.top;
136
+
134
137
  // Using a portal here to ensure wrapperRef has the tableWrapper as an
135
138
  // ancestor. This is required to make the Intersection Observer work.
136
139
  return createPortal(
@@ -159,7 +162,7 @@ export const FixedButton = ({
159
162
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
160
163
  position: 'fixed',
161
164
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
162
- top: stickyHeader.top + stickyHeader.padding + offset * 2,
165
+ top: fixedButtonTop + stickyHeader.padding + offset * 2,
163
166
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
164
167
  zIndex: akEditorTableCellOnStickyHeaderZIndex,
165
168
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
@@ -10,6 +10,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
11
11
  import { CellSelection } from '@atlaskit/editor-tables';
12
12
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
 
14
15
  import {
15
16
  clearHoverSelection,
@@ -95,7 +96,8 @@ export const ColumnControls = ({
95
96
  const firstRow = tableRef.querySelector('tr');
96
97
  const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
97
98
 
98
- const marginTop = hasHeaderRow && stickyTop !== undefined ? rowHeights?.[0] ?? 0 : 0;
99
+ const rowControlStickyTop = fg('platform_editor_breakout_use_css') ? 45 : rowHeights?.[0];
100
+ const marginTop = hasHeaderRow && stickyTop !== undefined ? rowControlStickyTop ?? 0 : 0;
99
101
 
100
102
  const handleClick = useCallback(
101
103
  (event: MouseEvent) => {
@@ -98,10 +98,13 @@ const TableFloatingColumnControls = ({
98
98
  const colWidths = getColumnsWidths(editorView);
99
99
 
100
100
  if (stickyTop) {
101
+ const columnControlTopOffsetFromParent = '-12px';
101
102
  const headerRowHeight = hasHeaderRow && stickyTop !== undefined ? rowHeights?.[0] ?? 0 : 0;
102
103
  containerRef?.current?.style.setProperty(
103
104
  'top',
104
- `${stickyTop! - headerRowHeight + 33}px`, // 33px is padding and margin applied on tr.sticky
105
+ fg('platform_editor_breakout_use_css')
106
+ ? columnControlTopOffsetFromParent
107
+ : `${stickyTop! - headerRowHeight + 33}px`, // 33px is padding and margin applied on tr.sticky
105
108
  );
106
109
  } else {
107
110
  containerRef?.current?.style.removeProperty('top');
@@ -7,6 +7,7 @@ import { injectIntl } from 'react-intl-next';
7
7
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
8
8
  import { TableMap } from '@atlaskit/editor-tables/table-map';
9
9
  import { findTable, isTableSelected, selectTable } from '@atlaskit/editor-tables/utils';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
 
11
12
  import { clearHoverSelection, hoverTable } from '../../../commands';
12
13
  import { TableCssClassName as ClassName } from '../../../types';
@@ -36,7 +37,13 @@ class CornerControlComponent extends Component<CornerControlProps & WrappedCompo
36
37
  })}
37
38
  style={{
38
39
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
39
- top: this.props.stickyTop !== undefined ? `${this.props.stickyTop}px` : undefined,
40
+ top: fg('platform_editor_breakout_use_css')
41
+ ? this.props.stickyTop !== undefined
42
+ ? `0px`
43
+ : undefined
44
+ : this.props.stickyTop !== undefined
45
+ ? `${this.props.stickyTop}px`
46
+ : undefined,
40
47
  }}
41
48
  contentEditable={false}
42
49
  >
@@ -6,6 +6,7 @@ import { injectIntl } from 'react-intl-next';
6
6
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
7
7
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
8
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
 
10
11
  import { clearHoverSelection } from '../../../commands';
11
12
  import { TableCssClassName as ClassName } from '../../../types';
@@ -78,7 +79,13 @@ class RowControlsComponent extends Component<Props & WrappedComponentProps> {
78
79
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
79
80
  marginTop: `${marginTop}px`,
80
81
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
81
- top: thisRowSticky ? `${this.props.stickyTop! + 3}px` : undefined,
82
+ top: fg('platform_editor_breakout_use_css')
83
+ ? thisRowSticky
84
+ ? `3px`
85
+ : undefined
86
+ : thisRowSticky
87
+ ? `${this.props.stickyTop! + 3}px`
88
+ : undefined,
82
89
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
83
90
  paddingTop: thisRowSticky ? `${tableControlsSpacing}px` : undefined,
84
91
  }}