@atlaskit/editor-plugin-table 2.9.1 → 2.10.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 (93) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/plugins/table/event-handlers.js +52 -56
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +19 -69
  4. package/dist/cjs/plugins/table/nodeviews/TableResizer.js +5 -1
  5. package/dist/cjs/plugins/table/nodeviews/table.js +23 -30
  6. package/dist/cjs/plugins/table/nodeviews/tableCell.js +3 -6
  7. package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +2 -40
  8. package/dist/cjs/plugins/table/pm-plugins/main.js +3 -3
  9. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
  10. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
  11. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
  12. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
  13. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +3 -7
  14. package/dist/cjs/plugins/table/ui/common-styles.js +2 -2
  15. package/dist/cjs/plugins/table/utils/dom.js +5 -12
  16. package/dist/es2019/plugins/table/event-handlers.js +3 -6
  17. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +18 -69
  18. package/dist/es2019/plugins/table/nodeviews/TableResizer.js +6 -1
  19. package/dist/es2019/plugins/table/nodeviews/table.js +24 -32
  20. package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -7
  21. package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +0 -35
  22. package/dist/es2019/plugins/table/pm-plugins/main.js +3 -4
  23. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -77
  24. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
  25. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
  26. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
  27. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +3 -9
  28. package/dist/es2019/plugins/table/ui/common-styles.js +3 -3
  29. package/dist/es2019/plugins/table/utils/dom.js +5 -12
  30. package/dist/esm/plugins/table/event-handlers.js +52 -56
  31. package/dist/esm/plugins/table/nodeviews/TableComponent.js +19 -69
  32. package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -1
  33. package/dist/esm/plugins/table/nodeviews/table.js +23 -30
  34. package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -6
  35. package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +0 -37
  36. package/dist/esm/plugins/table/pm-plugins/main.js +3 -3
  37. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
  38. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
  39. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
  40. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
  41. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +3 -7
  42. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  43. package/dist/esm/plugins/table/utils/dom.js +5 -12
  44. package/dist/types/plugins/table/event-handlers.d.ts +1 -2
  45. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +0 -2
  46. package/dist/types/plugins/table/nodeviews/table.d.ts +0 -1
  47. package/dist/types/plugins/table/nodeviews/tableCell.d.ts +2 -3
  48. package/dist/types/plugins/table/nodeviews/types.d.ts +0 -1
  49. package/dist/types/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
  50. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
  51. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
  52. package/dist/types/plugins/table/types.d.ts +2 -2
  53. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
  54. package/dist/types/plugins/table/utils/dom.d.ts +1 -1
  55. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -2
  56. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +0 -2
  57. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +0 -1
  58. package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +2 -3
  59. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +0 -1
  60. package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
  61. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
  62. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
  63. package/dist/types-ts4.5/plugins/table/types.d.ts +2 -2
  64. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
  65. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +1 -1
  66. package/package.json +2 -2
  67. package/report.api.md +2 -0
  68. package/src/__tests__/integration/horizontal-scroll-shadows.ts +6 -9
  69. package/src/__tests__/integration/resize.ts +6 -16
  70. package/src/__tests__/unit/event-handlers.ts +1 -4
  71. package/src/__tests__/unit/nodeviews/TableComponent.tsx +48 -92
  72. package/src/__tests__/unit/nodeviews/cell.ts +1 -3
  73. package/src/__tests__/unit/nodeviews/table.ts +71 -83
  74. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +5 -9
  75. package/src/__tests__/unit/ui/RowControls.tsx +1 -0
  76. package/src/__tests__/unit/utils/dom.ts +6 -112
  77. package/src/plugins/table/event-handlers.ts +72 -79
  78. package/src/plugins/table/nodeviews/TableComponent.tsx +37 -114
  79. package/src/plugins/table/nodeviews/TableResizer.tsx +3 -0
  80. package/src/plugins/table/nodeviews/table.tsx +22 -30
  81. package/src/plugins/table/nodeviews/tableCell.tsx +3 -11
  82. package/src/plugins/table/nodeviews/types.ts +0 -1
  83. package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -54
  84. package/src/plugins/table/pm-plugins/main.ts +4 -22
  85. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +1 -83
  86. package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -7
  87. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -1
  88. package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +30 -48
  89. package/src/plugins/table/types.ts +3 -2
  90. package/src/plugins/table/ui/TableFloatingControls/index.tsx +3 -15
  91. package/src/plugins/table/ui/common-styles.ts +1 -1
  92. package/src/plugins/table/utils/dom.ts +3 -11
  93. package/tmp/api-report-tmp.d.ts +2 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 2.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`30d49e87f62`](https://bitbucket.org/atlassian/atlassian-frontend/commits/30d49e87f62) - Added danger apperance to ReszierNext component and toggled it when the delete icon in the table floating toolbar is rolled over
8
+ - Updated dependencies
9
+
10
+ ## 2.10.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`0f3026deda5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0f3026deda5) - ED-12027 cleaned up table optimisation feature flags, made optimised code run by default.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 2.9.1
4
21
 
5
22
  ### Patch Changes
@@ -190,67 +190,63 @@ var handleMouseLeave = function handleMouseLeave(view, event) {
190
190
  return false;
191
191
  };
192
192
  exports.handleMouseLeave = handleMouseLeave;
193
- var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
194
- return function (view, event, elementContentRects) {
195
- if (!(event.target instanceof HTMLElement)) {
196
- return false;
197
- }
198
- var element = event.target;
199
- if ((0, _utils3.isColumnControlsDecorations)(element)) {
200
- var state = view.state,
201
- dispatch = view.dispatch;
202
- var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
203
- insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
204
- var _getColumnOrRowIndex9 = (0, _utils3.getColumnOrRowIndex)(element),
205
- _getColumnOrRowIndex10 = (0, _slicedToArray2.default)(_getColumnOrRowIndex9, 2),
206
- startIndex = _getColumnOrRowIndex10[0],
207
- endIndex = _getColumnOrRowIndex10[1];
208
- var positionColumn = (0, _utils3.getMousePositionHorizontalRelativeByElement)(event, false, elementContentRects) === 'right' ? endIndex : startIndex;
209
- if (positionColumn !== insertColumnButtonIndex) {
210
- return (0, _commands.showInsertColumnButton)(positionColumn)(state, dispatch);
211
- }
193
+ var handleMouseMove = function handleMouseMove(view, event, elementContentRects) {
194
+ if (!(event.target instanceof HTMLElement)) {
195
+ return false;
196
+ }
197
+ var element = event.target;
198
+ if ((0, _utils3.isColumnControlsDecorations)(element)) {
199
+ var state = view.state,
200
+ dispatch = view.dispatch;
201
+ var _getPluginState3 = (0, _pluginFactory.getPluginState)(state),
202
+ insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
203
+ var _getColumnOrRowIndex9 = (0, _utils3.getColumnOrRowIndex)(element),
204
+ _getColumnOrRowIndex10 = (0, _slicedToArray2.default)(_getColumnOrRowIndex9, 2),
205
+ startIndex = _getColumnOrRowIndex10[0],
206
+ endIndex = _getColumnOrRowIndex10[1];
207
+ var positionColumn = (0, _utils3.getMousePositionHorizontalRelativeByElement)(event, elementContentRects) === 'right' ? endIndex : startIndex;
208
+ if (positionColumn !== insertColumnButtonIndex) {
209
+ return (0, _commands.showInsertColumnButton)(positionColumn)(state, dispatch);
212
210
  }
213
- if ((0, _utils3.isRowControlsButton)(element)) {
214
- var _state3 = view.state,
215
- _dispatch4 = view.dispatch;
216
- var _getPluginState4 = (0, _pluginFactory.getPluginState)(_state3),
217
- insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
218
- var _getColumnOrRowIndex11 = (0, _utils3.getColumnOrRowIndex)(element),
219
- _getColumnOrRowIndex12 = (0, _slicedToArray2.default)(_getColumnOrRowIndex11, 2),
220
- _startIndex3 = _getColumnOrRowIndex12[0],
221
- _endIndex2 = _getColumnOrRowIndex12[1];
222
- var positionRow = (0, _utils3.getMousePositionVerticalRelativeByElement)(event) === 'bottom' ? _endIndex2 : _startIndex3;
223
- if (positionRow !== insertRowButtonIndex) {
224
- return (0, _commands.showInsertRowButton)(positionRow)(_state3, _dispatch4);
225
- }
211
+ }
212
+ if ((0, _utils3.isRowControlsButton)(element)) {
213
+ var _state3 = view.state,
214
+ _dispatch4 = view.dispatch;
215
+ var _getPluginState4 = (0, _pluginFactory.getPluginState)(_state3),
216
+ insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
217
+ var _getColumnOrRowIndex11 = (0, _utils3.getColumnOrRowIndex)(element),
218
+ _getColumnOrRowIndex12 = (0, _slicedToArray2.default)(_getColumnOrRowIndex11, 2),
219
+ _startIndex3 = _getColumnOrRowIndex12[0],
220
+ _endIndex2 = _getColumnOrRowIndex12[1];
221
+ var positionRow = (0, _utils3.getMousePositionVerticalRelativeByElement)(event) === 'bottom' ? _endIndex2 : _startIndex3;
222
+ if (positionRow !== insertRowButtonIndex) {
223
+ return (0, _commands.showInsertRowButton)(positionRow)(_state3, _dispatch4);
226
224
  }
227
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
228
- mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
229
- if (!(0, _utils3.isResizeHandleDecoration)(element) && (0, _utils3.isCell)(element)) {
230
- var _positionColumn = (0, _utils3.getMousePositionHorizontalRelativeByElement)(event, mouseMoveOptimization, elementContentRects, _types.RESIZE_HANDLE_AREA_DECORATION_GAP);
231
- if (_positionColumn !== null) {
232
- var _state4 = view.state,
233
- _dispatch5 = view.dispatch;
234
- var _getPluginState5 = (0, _pluginFactory.getPluginState)(_state4),
235
- resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
236
- resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
237
- var tableCell = (0, _utils.closestElement)(element, 'td, th');
238
- var cellStartPosition = view.posAtDOM(tableCell, 0);
239
- var rect = (0, _utils2.findCellRectClosestToPos)(_state4.doc.resolve(cellStartPosition));
240
- if (rect) {
241
- var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
242
- var rowIndexTarget = rect.top;
243
- if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !(0, _utils3.hasResizeHandler)({
244
- target: element,
245
- columnEndIndexTarget: columnEndIndexTarget
246
- })) {
247
- return (0, _commands.addResizeHandleDecorations)(rowIndexTarget, columnEndIndexTarget)(_state4, _dispatch5);
248
- }
225
+ }
226
+ if (!(0, _utils3.isResizeHandleDecoration)(element) && (0, _utils3.isCell)(element)) {
227
+ var _positionColumn = (0, _utils3.getMousePositionHorizontalRelativeByElement)(event, elementContentRects, _types.RESIZE_HANDLE_AREA_DECORATION_GAP);
228
+ if (_positionColumn !== null) {
229
+ var _state4 = view.state,
230
+ _dispatch5 = view.dispatch;
231
+ var _getPluginState5 = (0, _pluginFactory.getPluginState)(_state4),
232
+ resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
233
+ resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
234
+ var tableCell = (0, _utils.closestElement)(element, 'td, th');
235
+ var cellStartPosition = view.posAtDOM(tableCell, 0);
236
+ var rect = (0, _utils2.findCellRectClosestToPos)(_state4.doc.resolve(cellStartPosition));
237
+ if (rect) {
238
+ var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
239
+ var rowIndexTarget = rect.top;
240
+ if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !(0, _utils3.hasResizeHandler)({
241
+ target: element,
242
+ columnEndIndexTarget: columnEndIndexTarget
243
+ })) {
244
+ return (0, _commands.addResizeHandleDecorations)(rowIndexTarget, columnEndIndexTarget)(_state4, _dispatch5);
249
245
  }
250
246
  }
251
247
  }
252
- return false;
253
- };
248
+ }
249
+ return false;
254
250
  };
255
251
  exports.handleMouseMove = handleMouseMove;
256
252
  function handleTripleClick(view, pos) {
@@ -34,15 +34,11 @@ var _TableFloatingControls = _interopRequireDefault(require("../ui/TableFloating
34
34
  var _utils4 = require("../utils");
35
35
  var _OverflowShadowsObserver = require("./OverflowShadowsObserver");
36
36
  var _TableContainer = require("./TableContainer");
37
- var _updateOverflowShadows = require("./update-overflow-shadows");
38
37
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
39
38
  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) { (0, _defineProperty3.default)(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; }
40
39
  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); }; }
41
40
  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; } }
42
41
  var isIE11 = _utils.browser.ie_version === 11;
43
- var NOOP = function NOOP() {
44
- return undefined;
45
- };
46
42
  var TableComponent = /*#__PURE__*/function (_React$Component) {
47
43
  (0, _inherits2.default)(TableComponent, _React$Component);
48
44
  var _super = _createSuper(TableComponent);
@@ -53,8 +49,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
53
49
  _this = _super.call(this, props);
54
50
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "state", (_defineProperty2 = {
55
51
  scroll: 0,
56
- parentWidth: undefined,
57
- isLoading: true
52
+ parentWidth: undefined
58
53
  }, (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_BEFORE_SHADOW, false), (0, _defineProperty3.default)(_defineProperty2, _types.ShadowEvent.SHOW_AFTER_SHADOW, false), _defineProperty2));
59
54
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "updateShadowState", function (shadowKey, value) {
60
55
  if (_this.state[shadowKey] === value) {
@@ -73,8 +68,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
73
68
  }
74
69
  });
75
70
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "onStickyState", function (state) {
76
- var _this$props$getEditor = _this.props.getEditorFeatureFlags(),
77
- tableOverflowShadowsOptimization = _this$props$getEditor.tableOverflowShadowsOptimization;
78
71
  var pos = _this.props.getPos();
79
72
  if (!(0, _utils.isValidPosition)(pos, _this.props.view.state)) {
80
73
  return;
@@ -84,7 +77,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
84
77
  _this.setState({
85
78
  stickyHeader: stickyHeader
86
79
  });
87
- if (tableOverflowShadowsOptimization && _this.overflowShadowsObserver) {
80
+ if (_this.overflowShadowsObserver) {
88
81
  _this.overflowShadowsObserver.updateStickyShadows();
89
82
  }
90
83
  }
@@ -103,11 +96,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
103
96
  header.style.marginRight = '2px';
104
97
  }
105
98
  }
106
- var _this$props$getEditor2 = _this.props.getEditorFeatureFlags(),
107
- tableOverflowShadowsOptimization = _this$props$getEditor2.tableOverflowShadowsOptimization;
108
- if (!tableOverflowShadowsOptimization) {
109
- _this.updateShadows();
110
- }
111
99
  _this.setState((0, _defineProperty3.default)({}, _types.ShadowEvent.SHOW_BEFORE_SHADOW, _this.wrapper.scrollLeft !== 0));
112
100
  });
113
101
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleTableResizing", function () {
@@ -252,8 +240,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
252
240
  (0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this), "handleWindowResizeDebounced", (0, _rafSchd.default)(_this.handleWindowResize));
253
241
  var _options = props.options,
254
242
  _containerWidth = props.containerWidth,
255
- _getNode = props.getNode,
256
- getEditorFeatureFlags = props.getEditorFeatureFlags;
243
+ _getNode = props.getNode;
257
244
  _this.node = _getNode();
258
245
  _this.containerWidth = _containerWidth;
259
246
 
@@ -272,16 +259,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
272
259
  }
273
260
  });
274
261
  }
275
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
276
- initialRenderOptimization = _getEditorFeatureFlag.initialRenderOptimization;
277
- if (!initialRenderOptimization) {
278
- // @see ED-7945
279
- requestAnimationFrame(function () {
280
- _this.setState({
281
- isLoading: false
282
- });
283
- });
284
- }
285
262
  return _this;
286
263
  }
287
264
  (0, _createClass2.default)(TableComponent, [{
@@ -338,6 +315,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
338
315
  }, {
339
316
  key: "componentDidUpdate",
340
317
  value: function componentDidUpdate() {
318
+ var _this$wrapper;
341
319
  var _this$props8 = this.props,
342
320
  view = _this$props8.view,
343
321
  getNode = _this$props8.getNode,
@@ -349,19 +327,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
349
327
  if (isInDanger && !table) {
350
328
  (0, _commands.clearHoverSelection)()(view.state, view.dispatch);
351
329
  }
352
- var _this$props$getEditor3 = this.props.getEditorFeatureFlags(),
353
- tableOverflowShadowsOptimization = _this$props$getEditor3.tableOverflowShadowsOptimization;
354
- if (!tableOverflowShadowsOptimization) {
355
- this.updateShadows();
356
- } else {
357
- var _this$wrapper;
358
- if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
359
- this.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
360
- }
361
- if (this.overflowShadowsObserver) {
362
- var _this$state$stickyHea;
363
- this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
364
- }
330
+ if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
331
+ this.overflowShadowsObserver = new _OverflowShadowsObserver.OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
332
+ }
333
+ if (this.overflowShadowsObserver) {
334
+ var _this$state$stickyHea;
335
+ this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
365
336
  }
366
337
  var currentTable = getNode();
367
338
  if (currentTable.attrs.__autoSize) {
@@ -377,22 +348,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
377
348
  if ((0, _utils4.tablesHaveDifferentColumnWidths)(currentTable, previousTable) || (0, _utils4.tablesHaveDifferentNoOfColumns)(currentTable, previousTable)) {
378
349
  var _view = this.props.view;
379
350
  (0, _utils3.insertColgroupFromNode)(this.table, currentTable);
380
- (0, _dom.updateControls)(this.props.getEditorFeatureFlags)(_view.state);
351
+ (0, _dom.updateControls)()(_view.state);
381
352
  }
382
353
  this.handleTableResizingDebounced();
383
354
  }
384
355
  }
385
- }, {
386
- key: "updateShadows",
387
- value: function updateShadows() {
388
- var _this$wrapper2;
389
- var parent = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.parentElement;
390
- if (this.wrapper && parent) {
391
- var rightShadows = parent.querySelectorAll(".".concat(_types.TableCssClassName.TABLE_RIGHT_SHADOW));
392
- var leftShadows = parent.querySelectorAll(".".concat(_types.TableCssClassName.TABLE_LEFT_SHADOW));
393
- (0, _updateOverflowShadows.updateOverflowShadows)(this.props.getEditorFeatureFlags)(this.wrapper, this.table, rightShadows, leftShadows);
394
- }
395
- }
396
356
  }, {
397
357
  key: "render",
398
358
  value: function render() {
@@ -413,7 +373,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
413
373
  getPos = _this$props9.getPos,
414
374
  pluginInjectionApi = _this$props9.pluginInjectionApi;
415
375
  var _this$state = this.state,
416
- isLoading = _this$state.isLoading,
417
376
  showBeforeShadow = _this$state.showBeforeShadow,
418
377
  showAfterShadow = _this$state.showAfterShadow;
419
378
  var node = getNode();
@@ -421,16 +380,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
421
380
  var _getPluginState2 = (0, _pluginFactory.getPluginState)(view.state),
422
381
  isInDanger = _getPluginState2.isInDanger,
423
382
  hoveredRows = _getPluginState2.hoveredRows;
424
- var _this$props$getEditor4 = this.props.getEditorFeatureFlags(),
425
- stickyHeadersOptimization = _this$props$getEditor4.stickyHeadersOptimization,
426
- initialRenderOptimization = _this$props$getEditor4.initialRenderOptimization,
427
- tableRenderOptimization = _this$props$getEditor4.tableRenderOptimization,
428
- tableOverflowShadowsOptimization = _this$props$getEditor4.tableOverflowShadowsOptimization;
429
383
  var tableRef = this.table || undefined;
430
384
  var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
431
-
432
- //dont need to change tableHeight with tableRenderOptimization because it will be observed inside floating components
433
- var tableHeight = tableRef && !tableRenderOptimization ? tableRef.offsetHeight : undefined;
434
385
  var hasHeaderRow = (0, _utils4.containsHeaderRow)(node);
435
386
  var rowControls = /*#__PURE__*/_react.default.createElement("div", {
436
387
  className: _types.TableCssClassName.ROW_CONTROLS_WRAPPER
@@ -449,17 +400,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
449
400
  // pass `selection` and `tableHeight` to control re-render
450
401
  ,
451
402
  selection: view.state.selection,
452
- tableHeight: tableHeight,
453
403
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
454
404
  stickyHeader: this.state.stickyHeader,
455
405
  getEditorFeatureFlags: this.props.getEditorFeatureFlags
456
406
  }));
457
- var shadowPadding = allowControls && (!isLoading || initialRenderOptimization) && tableActive ? -_editorSharedStyles.akEditorTableToolbarSize : _styles.tableMarginSides;
458
- var shadowStyle = tableOverflowShadowsOptimization ? (0, _memoizeOne.default)(function (visible) {
407
+ var shadowPadding = allowControls && tableActive ? -_editorSharedStyles.akEditorTableToolbarSize : _styles.tableMarginSides;
408
+ var shadowStyle = (0, _memoizeOne.default)(function (visible) {
459
409
  return {
460
410
  visibility: visible ? 'visible' : 'hidden'
461
411
  };
462
- }) : NOOP;
412
+ });
463
413
  var isNested = (0, _utils4.isTableNested)(view.state, getPos());
464
414
  return /*#__PURE__*/_react.default.createElement(_TableContainer.TableContainer, {
465
415
  className: (0, _classnames2.default)(_types.TableCssClassName.TABLE_CONTAINER, (_classnames = {}, (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.WITH_CONTROLS, allowControls && tableActive), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.HOVERED_DELETE_BUTTON, isInDanger), (0, _defineProperty3.default)(_classnames, _types.TableCssClassName.TABLE_SELECTED, (0, _utils2.isTableSelected)(view.state.selection)), _classnames)),
@@ -472,16 +422,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
472
422
  isNested: isNested,
473
423
  pluginInjectionApi: pluginInjectionApi,
474
424
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
475
- }, stickyHeadersOptimization && /*#__PURE__*/_react.default.createElement("div", {
425
+ }, /*#__PURE__*/_react.default.createElement("div", {
476
426
  className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP,
477
427
  "data-testid": "sticky-sentinel-top"
478
- }), allowControls && (!isLoading || initialRenderOptimization) && rowControls, /*#__PURE__*/_react.default.createElement("div", {
428
+ }), allowControls && rowControls, /*#__PURE__*/_react.default.createElement("div", {
479
429
  style: shadowStyle(showBeforeShadow),
480
430
  className: _types.TableCssClassName.TABLE_LEFT_SHADOW
481
431
  }), this.state.stickyHeader && /*#__PURE__*/_react.default.createElement("div", {
482
432
  className: "".concat(_types.TableCssClassName.TABLE_LEFT_SHADOW, " ").concat(_types.TableCssClassName.TABLE_STICKY_SHADOW),
483
433
  style: {
484
- visibility: tableOverflowShadowsOptimization ? showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden' : undefined,
434
+ visibility: showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden',
485
435
  top: "".concat(this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2, "px")
486
436
  }
487
437
  }), /*#__PURE__*/_react.default.createElement("div", {
@@ -508,10 +458,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
508
458
  }, /*#__PURE__*/_react.default.createElement("div", {
509
459
  className: "".concat(_types.TableCssClassName.TABLE_RIGHT_SHADOW, " ").concat(_types.TableCssClassName.TABLE_STICKY_SHADOW),
510
460
  style: {
511
- visibility: tableOverflowShadowsOptimization ? showAfterShadow && hasHeaderRow ? 'visible' : 'hidden' : undefined,
461
+ visibility: showAfterShadow && hasHeaderRow ? 'visible' : 'hidden',
512
462
  top: "".concat(this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2, "px")
513
463
  }
514
- })), stickyHeadersOptimization && /*#__PURE__*/_react.default.createElement("div", {
464
+ })), /*#__PURE__*/_react.default.createElement("div", {
515
465
  className: _types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM,
516
466
  "data-testid": "sticky-sentinel-bottom"
517
467
  }));
@@ -14,6 +14,7 @@ var _guideline = require("@atlaskit/editor-common/guideline");
14
14
  var _resizer = require("@atlaskit/editor-common/resizer");
15
15
  var _styles = require("@atlaskit/editor-common/styles");
16
16
  var _utils = require("@atlaskit/editor-tables/utils");
17
+ var _pluginFactory = require("../pm-plugins/plugin-factory");
17
18
  var _utils2 = require("../pm-plugins/table-resizing/utils");
18
19
  var _tableWidth = require("../pm-plugins/table-width");
19
20
  var _consts = require("../ui/consts");
@@ -86,6 +87,8 @@ var TableResizer = function TableResizer(_ref) {
86
87
  setSnappingEnabled = _useState2[1];
87
88
  var resizerMinWidth = getResizerMinWidth(node);
88
89
  var handleHeightSize = getResizerHandleHeight(tableRef);
90
+ var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
91
+ isInDanger = _getPluginState.isInDanger;
89
92
  var _useMeasureFramerate = (0, _analytics.useMeasureFramerate)(),
90
93
  startMeasure = _useMeasureFramerate.startMeasure,
91
94
  endMeasure = _useMeasureFramerate.endMeasure,
@@ -213,7 +216,8 @@ var TableResizer = function TableResizer(_ref) {
213
216
  handlePositioning: "adjacent",
214
217
  innerPadding: tableHandlePosition,
215
218
  isHandleVisible: ((_findTable = (0, _utils.findTable)((_editorView$state = editorView.state) === null || _editorView$state === void 0 ? void 0 : _editorView$state.selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) === getPos(),
216
- handleComponent: handleComponent
219
+ handleComponent: handleComponent,
220
+ appearance: isInDanger ? 'danger' : undefined
217
221
  }, children);
218
222
  };
219
223
  exports.TableResizer = TableResizer;
@@ -77,7 +77,6 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
77
77
  });
78
78
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasHoveredRows", false);
79
79
  _this.getPos = props.getPos;
80
- _this.tableRenderOptimization = props.tableRenderOptimization;
81
80
  _this.eventDispatcher = props.eventDispatcher;
82
81
  return _this;
83
82
  }
@@ -178,33 +177,30 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
178
177
  }, {
179
178
  key: "viewShouldUpdate",
180
179
  value: function viewShouldUpdate(nextNode) {
181
- if (this.tableRenderOptimization) {
182
- var _getPluginState = (0, _pluginFactory.getPluginState)(this.view.state),
183
- hoveredRows = _getPluginState.hoveredRows;
184
- var hoveredRowsChanged = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length) !== this.hasHoveredRows;
185
- if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
186
- this.hasHoveredRows = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length);
187
- return true;
188
- }
189
- var _node = this.getNode();
190
- if ((0, _typeof2.default)(_node.attrs) !== (0, _typeof2.default)(nextNode.attrs)) {
191
- return true;
192
- }
193
- var attrKeys = Object.keys(_node.attrs);
194
- var nextAttrKeys = Object.keys(nextNode.attrs);
195
- if (attrKeys.length !== nextAttrKeys.length) {
196
- return true;
197
- }
198
- var tableMap = _tableMap.TableMap.get(_node);
199
- var nextTableMap = _tableMap.TableMap.get(nextNode);
200
- if (tableMap.width !== nextTableMap.width) {
201
- return true;
202
- }
203
- return attrKeys.some(function (key) {
204
- return _node.attrs[key] !== nextNode.attrs[key];
205
- });
180
+ var _getPluginState = (0, _pluginFactory.getPluginState)(this.view.state),
181
+ hoveredRows = _getPluginState.hoveredRows;
182
+ var hoveredRowsChanged = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length) !== this.hasHoveredRows;
183
+ if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
184
+ this.hasHoveredRows = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length);
185
+ return true;
206
186
  }
207
- return (0, _get2.default)((0, _getPrototypeOf2.default)(TableView.prototype), "viewShouldUpdate", this).call(this, nextNode);
187
+ var node = this.getNode();
188
+ if ((0, _typeof2.default)(node.attrs) !== (0, _typeof2.default)(nextNode.attrs)) {
189
+ return true;
190
+ }
191
+ var attrKeys = Object.keys(node.attrs);
192
+ var nextAttrKeys = Object.keys(nextNode.attrs);
193
+ if (attrKeys.length !== nextAttrKeys.length) {
194
+ return true;
195
+ }
196
+ var tableMap = _tableMap.TableMap.get(node);
197
+ var nextTableMap = _tableMap.TableMap.get(nextNode);
198
+ if (tableMap.width !== nextTableMap.width) {
199
+ return true;
200
+ }
201
+ return attrKeys.some(function (key) {
202
+ return node.attrs[key] !== nextNode.attrs[key];
203
+ });
208
204
  }
209
205
  }, {
210
206
  key: "ignoreMutation",
@@ -244,8 +240,6 @@ var createTableView = function createTableView(node, view, getPos, portalProvide
244
240
  pluginConfig = _getPluginState2.pluginConfig;
245
241
  var _getPluginConfig = (0, _createPluginConfig.pluginConfig)(pluginConfig),
246
242
  allowColumnResizing = _getPluginConfig.allowColumnResizing;
247
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
248
- tableRenderOptimization = _getEditorFeatureFlag.tableRenderOptimization;
249
243
  var hasIntlContext = true;
250
244
  return new TableView({
251
245
  node: node,
@@ -255,7 +249,6 @@ var createTableView = function createTableView(node, view, getPos, portalProvide
255
249
  eventDispatcher: eventDispatcher,
256
250
  getPos: getPos,
257
251
  options: options,
258
- tableRenderOptimization: tableRenderOptimization,
259
252
  getEditorContainerWidth: getEditorContainerWidth,
260
253
  getEditorFeatureFlags: getEditorFeatureFlags,
261
254
  hasIntlContext: hasIntlContext,
@@ -14,7 +14,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
14
14
  var DEFAULT_COL_SPAN = 1;
15
15
  var DEFAULT_ROW_SPAN = 1;
16
16
  var TableCellNodeView = /*#__PURE__*/function () {
17
- function TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer) {
17
+ function TableCellNodeView(node, view, getPos, observer) {
18
18
  (0, _classCallCheck2.default)(this, TableCellNodeView);
19
19
  this.view = view;
20
20
  this.node = node;
@@ -24,11 +24,8 @@ var TableCellNodeView = /*#__PURE__*/function () {
24
24
  this.getPos = getPos;
25
25
  this.dom = dom;
26
26
  this.contentDOM = contentDOM;
27
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
28
- mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
29
- if (mouseMoveOptimization && observer) {
27
+ if (observer) {
30
28
  this.contentDOM.id = (0, _uuid.default)();
31
- this.mouseMoveOptimization = mouseMoveOptimization;
32
29
  this.observer = observer;
33
30
  observer.observe(this.contentDOM);
34
31
  }
@@ -93,7 +90,7 @@ var TableCellNodeView = /*#__PURE__*/function () {
93
90
  }, {
94
91
  key: "destroy",
95
92
  value: function destroy() {
96
- if (this.mouseMoveOptimization && this.observer) {
93
+ if (this.observer) {
97
94
  this.observer.unobserve(this.contentDOM);
98
95
  }
99
96
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.updateShadowListForStickyStyles = exports.updateOverflowShadows = void 0;
6
+ exports.updateShadowListForStickyStyles = void 0;
7
7
  var _types = require("../types");
8
8
  var updateShadowListForStickyStyles = function updateShadowListForStickyStyles(heightStyle, shadows) {
9
9
  Array.from(shadows).forEach(function (shadow) {
@@ -14,42 +14,4 @@ var updateShadowListForStickyStyles = function updateShadowListForStickyStyles(h
14
14
  }
15
15
  });
16
16
  };
17
-
18
- /**
19
- * Update overflow shadows for a given wrapper & table.
20
- * if `overflowShadowOptimization` is enabled, this will exit early.
21
- */
22
- exports.updateShadowListForStickyStyles = updateShadowListForStickyStyles;
23
- var updateOverflowShadows = function updateOverflowShadows(getEditorFeatureFlags) {
24
- return function (wrapper, table, rightShadows, leftShadows) {
25
- var _getEditorFeatureFlag;
26
- if (((_getEditorFeatureFlag = getEditorFeatureFlags()) === null || _getEditorFeatureFlag === void 0 ? void 0 : _getEditorFeatureFlag.tableOverflowShadowsOptimization) === true) {
27
- return false;
28
- }
29
- // Right shadow
30
- if (table && wrapper) {
31
- var stickyRow = wrapper.querySelector('tr.sticky');
32
- var stickyCell = stickyRow && stickyRow.firstElementChild;
33
- if (rightShadows) {
34
- var diff = table.offsetWidth - wrapper.offsetWidth;
35
- for (var i = 0; i < rightShadows.length; i++) {
36
- var rightShadow = rightShadows[i];
37
- rightShadow.style.display = diff > 0 && diff > wrapper.scrollLeft ? 'block' : 'none';
38
- if (rightShadow.classList.contains(_types.TableCssClassName.TABLE_STICKY_SHADOW) && stickyCell) {
39
- rightShadow.style.height = "".concat(stickyCell.clientHeight + 1, "px");
40
- }
41
- }
42
- }
43
- if (leftShadows) {
44
- for (var _i = 0; _i < leftShadows.length; _i++) {
45
- var leftShadow = leftShadows[_i];
46
- leftShadow.style.display = wrapper.scrollLeft > 0 ? 'block' : 'none';
47
- if (leftShadow.classList.contains(_types.TableCssClassName.TABLE_STICKY_SHADOW) && stickyCell) {
48
- leftShadow.style.height = "".concat(stickyCell.clientHeight + 1, "px");
49
- }
50
- }
51
- }
52
- }
53
- };
54
- };
55
- exports.updateOverflowShadows = updateOverflowShadows;
17
+ exports.updateShadowListForStickyStyles = updateShadowListForStickyStyles;
@@ -57,10 +57,10 @@ var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, porta
57
57
  }) : undefined;
58
58
  var tableCellNodeview = {
59
59
  tableCell: function tableCell(node, view, getPos) {
60
- return new _tableCell.default(node, view, getPos, getEditorFeatureFlags, observer);
60
+ return new _tableCell.default(node, view, getPos, observer);
61
61
  },
62
62
  tableHeader: function tableHeader(node, view, getPos) {
63
- return new _tableCell.default(node, view, getPos, getEditorFeatureFlags, observer);
63
+ return new _tableCell.default(node, view, getPos, observer);
64
64
  }
65
65
  };
66
66
 
@@ -249,7 +249,7 @@ var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, porta
249
249
  mouseover: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseOver),
250
250
  mouseleave: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseLeave),
251
251
  mouseout: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseOut),
252
- mousemove: (0, _eventHandlers.whenTableInFocus)((0, _eventHandlers.handleMouseMove)(getEditorFeatureFlags), elementContentRects),
252
+ mousemove: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleMouseMove, elementContentRects),
253
253
  click: (0, _eventHandlers.whenTableInFocus)(_eventHandlers.handleClick)
254
254
  },
255
255
  handleTripleClick: _eventHandlers.handleTripleClick