@atlaskit/editor-plugin-table 2.9.1 → 2.10.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 (89) hide show
  1. package/CHANGELOG.md +10 -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/table.js +23 -30
  5. package/dist/cjs/plugins/table/nodeviews/tableCell.js +3 -6
  6. package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +2 -40
  7. package/dist/cjs/plugins/table/pm-plugins/main.js +3 -3
  8. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
  9. package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
  10. package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
  11. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
  12. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +3 -7
  13. package/dist/cjs/plugins/table/ui/common-styles.js +2 -2
  14. package/dist/cjs/plugins/table/utils/dom.js +5 -12
  15. package/dist/es2019/plugins/table/event-handlers.js +3 -6
  16. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +18 -69
  17. package/dist/es2019/plugins/table/nodeviews/table.js +24 -32
  18. package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -7
  19. package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +0 -35
  20. package/dist/es2019/plugins/table/pm-plugins/main.js +3 -4
  21. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -77
  22. package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
  23. package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
  24. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
  25. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +3 -9
  26. package/dist/es2019/plugins/table/ui/common-styles.js +3 -3
  27. package/dist/es2019/plugins/table/utils/dom.js +5 -12
  28. package/dist/esm/plugins/table/event-handlers.js +52 -56
  29. package/dist/esm/plugins/table/nodeviews/TableComponent.js +19 -69
  30. package/dist/esm/plugins/table/nodeviews/table.js +23 -30
  31. package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -6
  32. package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +0 -37
  33. package/dist/esm/plugins/table/pm-plugins/main.js +3 -3
  34. package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
  35. package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
  36. package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
  37. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
  38. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +3 -7
  39. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  40. package/dist/esm/plugins/table/utils/dom.js +5 -12
  41. package/dist/types/plugins/table/event-handlers.d.ts +1 -2
  42. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +0 -2
  43. package/dist/types/plugins/table/nodeviews/table.d.ts +0 -1
  44. package/dist/types/plugins/table/nodeviews/tableCell.d.ts +2 -3
  45. package/dist/types/plugins/table/nodeviews/types.d.ts +0 -1
  46. package/dist/types/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
  47. package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
  48. package/dist/types/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
  49. package/dist/types/plugins/table/types.d.ts +2 -2
  50. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
  51. package/dist/types/plugins/table/utils/dom.d.ts +1 -1
  52. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -2
  53. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +0 -2
  54. package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +0 -1
  55. package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +2 -3
  56. package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +0 -1
  57. package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
  58. package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
  59. package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
  60. package/dist/types-ts4.5/plugins/table/types.d.ts +2 -2
  61. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
  62. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +1 -1
  63. package/package.json +2 -2
  64. package/report.api.md +2 -0
  65. package/src/__tests__/integration/horizontal-scroll-shadows.ts +6 -9
  66. package/src/__tests__/integration/resize.ts +6 -16
  67. package/src/__tests__/unit/event-handlers.ts +1 -4
  68. package/src/__tests__/unit/nodeviews/TableComponent.tsx +48 -92
  69. package/src/__tests__/unit/nodeviews/cell.ts +1 -3
  70. package/src/__tests__/unit/nodeviews/table.ts +71 -83
  71. package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +5 -9
  72. package/src/__tests__/unit/ui/RowControls.tsx +1 -0
  73. package/src/__tests__/unit/utils/dom.ts +6 -112
  74. package/src/plugins/table/event-handlers.ts +72 -79
  75. package/src/plugins/table/nodeviews/TableComponent.tsx +37 -114
  76. package/src/plugins/table/nodeviews/table.tsx +22 -30
  77. package/src/plugins/table/nodeviews/tableCell.tsx +3 -11
  78. package/src/plugins/table/nodeviews/types.ts +0 -1
  79. package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -54
  80. package/src/plugins/table/pm-plugins/main.ts +4 -22
  81. package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +1 -83
  82. package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -7
  83. package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -1
  84. package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +30 -48
  85. package/src/plugins/table/types.ts +3 -2
  86. package/src/plugins/table/ui/TableFloatingControls/index.tsx +3 -15
  87. package/src/plugins/table/ui/common-styles.ts +1 -1
  88. package/src/plugins/table/utils/dom.ts +3 -11
  89. package/tmp/api-report-tmp.d.ts +2 -0
@@ -31,11 +31,7 @@ import TableFloatingControls from '../ui/TableFloatingControls';
31
31
  import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
32
32
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
33
33
  import { TableContainer } from './TableContainer';
34
- import { updateOverflowShadows } from './update-overflow-shadows';
35
34
  var isIE11 = browser.ie_version === 11;
36
- var NOOP = function NOOP() {
37
- return undefined;
38
- };
39
35
  var TableComponent = /*#__PURE__*/function (_React$Component) {
40
36
  _inherits(TableComponent, _React$Component);
41
37
  var _super = _createSuper(TableComponent);
@@ -46,8 +42,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
46
42
  _this = _super.call(this, props);
47
43
  _defineProperty(_assertThisInitialized(_this), "state", (_defineProperty2 = {
48
44
  scroll: 0,
49
- parentWidth: undefined,
50
- isLoading: true
45
+ parentWidth: undefined
51
46
  }, _defineProperty(_defineProperty2, ShadowEvent.SHOW_BEFORE_SHADOW, false), _defineProperty(_defineProperty2, ShadowEvent.SHOW_AFTER_SHADOW, false), _defineProperty2));
52
47
  _defineProperty(_assertThisInitialized(_this), "updateShadowState", function (shadowKey, value) {
53
48
  if (_this.state[shadowKey] === value) {
@@ -66,8 +61,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
66
61
  }
67
62
  });
68
63
  _defineProperty(_assertThisInitialized(_this), "onStickyState", function (state) {
69
- var _this$props$getEditor = _this.props.getEditorFeatureFlags(),
70
- tableOverflowShadowsOptimization = _this$props$getEditor.tableOverflowShadowsOptimization;
71
64
  var pos = _this.props.getPos();
72
65
  if (!isValidPosition(pos, _this.props.view.state)) {
73
66
  return;
@@ -77,7 +70,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
77
70
  _this.setState({
78
71
  stickyHeader: stickyHeader
79
72
  });
80
- if (tableOverflowShadowsOptimization && _this.overflowShadowsObserver) {
73
+ if (_this.overflowShadowsObserver) {
81
74
  _this.overflowShadowsObserver.updateStickyShadows();
82
75
  }
83
76
  }
@@ -96,11 +89,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
96
89
  header.style.marginRight = '2px';
97
90
  }
98
91
  }
99
- var _this$props$getEditor2 = _this.props.getEditorFeatureFlags(),
100
- tableOverflowShadowsOptimization = _this$props$getEditor2.tableOverflowShadowsOptimization;
101
- if (!tableOverflowShadowsOptimization) {
102
- _this.updateShadows();
103
- }
104
92
  _this.setState(_defineProperty({}, ShadowEvent.SHOW_BEFORE_SHADOW, _this.wrapper.scrollLeft !== 0));
105
93
  });
106
94
  _defineProperty(_assertThisInitialized(_this), "handleTableResizing", function () {
@@ -245,8 +233,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
245
233
  _defineProperty(_assertThisInitialized(_this), "handleWindowResizeDebounced", rafSchedule(_this.handleWindowResize));
246
234
  var _options = props.options,
247
235
  _containerWidth = props.containerWidth,
248
- _getNode = props.getNode,
249
- getEditorFeatureFlags = props.getEditorFeatureFlags;
236
+ _getNode = props.getNode;
250
237
  _this.node = _getNode();
251
238
  _this.containerWidth = _containerWidth;
252
239
 
@@ -265,16 +252,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
265
252
  }
266
253
  });
267
254
  }
268
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
269
- initialRenderOptimization = _getEditorFeatureFlag.initialRenderOptimization;
270
- if (!initialRenderOptimization) {
271
- // @see ED-7945
272
- requestAnimationFrame(function () {
273
- _this.setState({
274
- isLoading: false
275
- });
276
- });
277
- }
278
255
  return _this;
279
256
  }
280
257
  _createClass(TableComponent, [{
@@ -331,6 +308,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
331
308
  }, {
332
309
  key: "componentDidUpdate",
333
310
  value: function componentDidUpdate() {
311
+ var _this$wrapper;
334
312
  var _this$props8 = this.props,
335
313
  view = _this$props8.view,
336
314
  getNode = _this$props8.getNode,
@@ -342,19 +320,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
342
320
  if (isInDanger && !table) {
343
321
  clearHoverSelection()(view.state, view.dispatch);
344
322
  }
345
- var _this$props$getEditor3 = this.props.getEditorFeatureFlags(),
346
- tableOverflowShadowsOptimization = _this$props$getEditor3.tableOverflowShadowsOptimization;
347
- if (!tableOverflowShadowsOptimization) {
348
- this.updateShadows();
349
- } else {
350
- var _this$wrapper;
351
- if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
352
- this.overflowShadowsObserver = new OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
353
- }
354
- if (this.overflowShadowsObserver) {
355
- var _this$state$stickyHea;
356
- this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
357
- }
323
+ if ((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement && this.table && !this.overflowShadowsObserver) {
324
+ this.overflowShadowsObserver = new OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
325
+ }
326
+ if (this.overflowShadowsObserver) {
327
+ var _this$state$stickyHea;
328
+ this.overflowShadowsObserver.observeShadowSentinels((_this$state$stickyHea = this.state.stickyHeader) === null || _this$state$stickyHea === void 0 ? void 0 : _this$state$stickyHea.sticky);
358
329
  }
359
330
  var currentTable = getNode();
360
331
  if (currentTable.attrs.__autoSize) {
@@ -370,22 +341,11 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
370
341
  if (tablesHaveDifferentColumnWidths(currentTable, previousTable) || tablesHaveDifferentNoOfColumns(currentTable, previousTable)) {
371
342
  var _view = this.props.view;
372
343
  recreateResizeColsByNode(this.table, currentTable);
373
- updateControls(this.props.getEditorFeatureFlags)(_view.state);
344
+ updateControls()(_view.state);
374
345
  }
375
346
  this.handleTableResizingDebounced();
376
347
  }
377
348
  }
378
- }, {
379
- key: "updateShadows",
380
- value: function updateShadows() {
381
- var _this$wrapper2;
382
- var parent = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.parentElement;
383
- if (this.wrapper && parent) {
384
- var rightShadows = parent.querySelectorAll(".".concat(ClassName.TABLE_RIGHT_SHADOW));
385
- var leftShadows = parent.querySelectorAll(".".concat(ClassName.TABLE_LEFT_SHADOW));
386
- updateOverflowShadows(this.props.getEditorFeatureFlags)(this.wrapper, this.table, rightShadows, leftShadows);
387
- }
388
- }
389
349
  }, {
390
350
  key: "render",
391
351
  value: function render() {
@@ -406,7 +366,6 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
406
366
  getPos = _this$props9.getPos,
407
367
  pluginInjectionApi = _this$props9.pluginInjectionApi;
408
368
  var _this$state = this.state,
409
- isLoading = _this$state.isLoading,
410
369
  showBeforeShadow = _this$state.showBeforeShadow,
411
370
  showAfterShadow = _this$state.showAfterShadow;
412
371
  var node = getNode();
@@ -414,16 +373,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
414
373
  var _getPluginState2 = getPluginState(view.state),
415
374
  isInDanger = _getPluginState2.isInDanger,
416
375
  hoveredRows = _getPluginState2.hoveredRows;
417
- var _this$props$getEditor4 = this.props.getEditorFeatureFlags(),
418
- stickyHeadersOptimization = _this$props$getEditor4.stickyHeadersOptimization,
419
- initialRenderOptimization = _this$props$getEditor4.initialRenderOptimization,
420
- tableRenderOptimization = _this$props$getEditor4.tableRenderOptimization,
421
- tableOverflowShadowsOptimization = _this$props$getEditor4.tableOverflowShadowsOptimization;
422
376
  var tableRef = this.table || undefined;
423
377
  var headerRow = tableRef ? tableRef.querySelector('tr[data-header-row]') : undefined;
424
-
425
- //dont need to change tableHeight with tableRenderOptimization because it will be observed inside floating components
426
- var tableHeight = tableRef && !tableRenderOptimization ? tableRef.offsetHeight : undefined;
427
378
  var hasHeaderRow = containsHeaderRow(node);
428
379
  var rowControls = /*#__PURE__*/React.createElement("div", {
429
380
  className: ClassName.ROW_CONTROLS_WRAPPER
@@ -442,17 +393,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
442
393
  // pass `selection` and `tableHeight` to control re-render
443
394
  ,
444
395
  selection: view.state.selection,
445
- tableHeight: tableHeight,
446
396
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
447
397
  stickyHeader: this.state.stickyHeader,
448
398
  getEditorFeatureFlags: this.props.getEditorFeatureFlags
449
399
  }));
450
- var shadowPadding = allowControls && (!isLoading || initialRenderOptimization) && tableActive ? -tableToolbarSize : tableMarginSides;
451
- var shadowStyle = tableOverflowShadowsOptimization ? memoizeOne(function (visible) {
400
+ var shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
401
+ var shadowStyle = memoizeOne(function (visible) {
452
402
  return {
453
403
  visibility: visible ? 'visible' : 'hidden'
454
404
  };
455
- }) : NOOP;
405
+ });
456
406
  var isNested = isTableNested(view.state, getPos());
457
407
  return /*#__PURE__*/React.createElement(TableContainer, {
458
408
  className: classnames(ClassName.TABLE_CONTAINER, (_classnames = {}, _defineProperty(_classnames, ClassName.WITH_CONTROLS, allowControls && tableActive), _defineProperty(_classnames, ClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), _defineProperty(_classnames, ClassName.HOVERED_DELETE_BUTTON, isInDanger), _defineProperty(_classnames, ClassName.TABLE_SELECTED, isTableSelected(view.state.selection)), _classnames)),
@@ -465,16 +415,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
465
415
  isNested: isNested,
466
416
  pluginInjectionApi: pluginInjectionApi,
467
417
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled
468
- }, stickyHeadersOptimization && /*#__PURE__*/React.createElement("div", {
418
+ }, /*#__PURE__*/React.createElement("div", {
469
419
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
470
420
  "data-testid": "sticky-sentinel-top"
471
- }), allowControls && (!isLoading || initialRenderOptimization) && rowControls, /*#__PURE__*/React.createElement("div", {
421
+ }), allowControls && rowControls, /*#__PURE__*/React.createElement("div", {
472
422
  style: shadowStyle(showBeforeShadow),
473
423
  className: ClassName.TABLE_LEFT_SHADOW
474
424
  }), this.state.stickyHeader && /*#__PURE__*/React.createElement("div", {
475
425
  className: "".concat(ClassName.TABLE_LEFT_SHADOW, " ").concat(ClassName.TABLE_STICKY_SHADOW),
476
426
  style: {
477
- visibility: tableOverflowShadowsOptimization ? showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden' : undefined,
427
+ visibility: showBeforeShadow && hasHeaderRow ? 'visible' : 'hidden',
478
428
  top: "".concat(this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2, "px")
479
429
  }
480
430
  }), /*#__PURE__*/React.createElement("div", {
@@ -501,10 +451,10 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
501
451
  }, /*#__PURE__*/React.createElement("div", {
502
452
  className: "".concat(ClassName.TABLE_RIGHT_SHADOW, " ").concat(ClassName.TABLE_STICKY_SHADOW),
503
453
  style: {
504
- visibility: tableOverflowShadowsOptimization ? showAfterShadow && hasHeaderRow ? 'visible' : 'hidden' : undefined,
454
+ visibility: showAfterShadow && hasHeaderRow ? 'visible' : 'hidden',
505
455
  top: "".concat(this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2, "px")
506
456
  }
507
- })), stickyHeadersOptimization && /*#__PURE__*/React.createElement("div", {
457
+ })), /*#__PURE__*/React.createElement("div", {
508
458
  className: ClassName.TABLE_STICKY_SENTINEL_BOTTOM,
509
459
  "data-testid": "sticky-sentinel-bottom"
510
460
  }));
@@ -70,7 +70,6 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
70
70
  });
71
71
  _defineProperty(_assertThisInitialized(_this), "hasHoveredRows", false);
72
72
  _this.getPos = props.getPos;
73
- _this.tableRenderOptimization = props.tableRenderOptimization;
74
73
  _this.eventDispatcher = props.eventDispatcher;
75
74
  return _this;
76
75
  }
@@ -171,33 +170,30 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
171
170
  }, {
172
171
  key: "viewShouldUpdate",
173
172
  value: function viewShouldUpdate(nextNode) {
174
- if (this.tableRenderOptimization) {
175
- var _getPluginState = getPluginState(this.view.state),
176
- hoveredRows = _getPluginState.hoveredRows;
177
- var hoveredRowsChanged = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length) !== this.hasHoveredRows;
178
- if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
179
- this.hasHoveredRows = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length);
180
- return true;
181
- }
182
- var _node = this.getNode();
183
- if (_typeof(_node.attrs) !== _typeof(nextNode.attrs)) {
184
- return true;
185
- }
186
- var attrKeys = Object.keys(_node.attrs);
187
- var nextAttrKeys = Object.keys(nextNode.attrs);
188
- if (attrKeys.length !== nextAttrKeys.length) {
189
- return true;
190
- }
191
- var tableMap = TableMap.get(_node);
192
- var nextTableMap = TableMap.get(nextNode);
193
- if (tableMap.width !== nextTableMap.width) {
194
- return true;
195
- }
196
- return attrKeys.some(function (key) {
197
- return _node.attrs[key] !== nextNode.attrs[key];
198
- });
173
+ var _getPluginState = getPluginState(this.view.state),
174
+ hoveredRows = _getPluginState.hoveredRows;
175
+ var hoveredRowsChanged = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length) !== this.hasHoveredRows;
176
+ if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
177
+ this.hasHoveredRows = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length);
178
+ return true;
199
179
  }
200
- return _get(_getPrototypeOf(TableView.prototype), "viewShouldUpdate", this).call(this, nextNode);
180
+ var node = this.getNode();
181
+ if (_typeof(node.attrs) !== _typeof(nextNode.attrs)) {
182
+ return true;
183
+ }
184
+ var attrKeys = Object.keys(node.attrs);
185
+ var nextAttrKeys = Object.keys(nextNode.attrs);
186
+ if (attrKeys.length !== nextAttrKeys.length) {
187
+ return true;
188
+ }
189
+ var tableMap = TableMap.get(node);
190
+ var nextTableMap = TableMap.get(nextNode);
191
+ if (tableMap.width !== nextTableMap.width) {
192
+ return true;
193
+ }
194
+ return attrKeys.some(function (key) {
195
+ return node.attrs[key] !== nextNode.attrs[key];
196
+ });
201
197
  }
202
198
  }, {
203
199
  key: "ignoreMutation",
@@ -237,8 +233,6 @@ export var createTableView = function createTableView(node, view, getPos, portal
237
233
  pluginConfig = _getPluginState2.pluginConfig;
238
234
  var _getPluginConfig = getPluginConfig(pluginConfig),
239
235
  allowColumnResizing = _getPluginConfig.allowColumnResizing;
240
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
241
- tableRenderOptimization = _getEditorFeatureFlag.tableRenderOptimization;
242
236
  var hasIntlContext = true;
243
237
  return new TableView({
244
238
  node: node,
@@ -248,7 +242,6 @@ export var createTableView = function createTableView(node, view, getPos, portal
248
242
  eventDispatcher: eventDispatcher,
249
243
  getPos: getPos,
250
244
  options: options,
251
- tableRenderOptimization: tableRenderOptimization,
252
245
  getEditorContainerWidth: getEditorContainerWidth,
253
246
  getEditorFeatureFlags: getEditorFeatureFlags,
254
247
  hasIntlContext: hasIntlContext,
@@ -7,7 +7,7 @@ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
7
7
  var DEFAULT_COL_SPAN = 1;
8
8
  var DEFAULT_ROW_SPAN = 1;
9
9
  var TableCellNodeView = /*#__PURE__*/function () {
10
- function TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer) {
10
+ function TableCellNodeView(node, view, getPos, observer) {
11
11
  _classCallCheck(this, TableCellNodeView);
12
12
  this.view = view;
13
13
  this.node = node;
@@ -17,11 +17,8 @@ var TableCellNodeView = /*#__PURE__*/function () {
17
17
  this.getPos = getPos;
18
18
  this.dom = dom;
19
19
  this.contentDOM = contentDOM;
20
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
21
- mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
22
- if (mouseMoveOptimization && observer) {
20
+ if (observer) {
23
21
  this.contentDOM.id = uuid();
24
- this.mouseMoveOptimization = mouseMoveOptimization;
25
22
  this.observer = observer;
26
23
  observer.observe(this.contentDOM);
27
24
  }
@@ -86,7 +83,7 @@ var TableCellNodeView = /*#__PURE__*/function () {
86
83
  }, {
87
84
  key: "destroy",
88
85
  value: function destroy() {
89
- if (this.mouseMoveOptimization && this.observer) {
86
+ if (this.observer) {
90
87
  this.observer.unobserve(this.contentDOM);
91
88
  }
92
89
  }
@@ -7,41 +7,4 @@ export var updateShadowListForStickyStyles = function updateShadowListForStickyS
7
7
  }
8
8
  }
9
9
  });
10
- };
11
-
12
- /**
13
- * Update overflow shadows for a given wrapper & table.
14
- * if `overflowShadowOptimization` is enabled, this will exit early.
15
- */
16
- export var updateOverflowShadows = function updateOverflowShadows(getEditorFeatureFlags) {
17
- return function (wrapper, table, rightShadows, leftShadows) {
18
- var _getEditorFeatureFlag;
19
- if (((_getEditorFeatureFlag = getEditorFeatureFlags()) === null || _getEditorFeatureFlag === void 0 ? void 0 : _getEditorFeatureFlag.tableOverflowShadowsOptimization) === true) {
20
- return false;
21
- }
22
- // Right shadow
23
- if (table && wrapper) {
24
- var stickyRow = wrapper.querySelector('tr.sticky');
25
- var stickyCell = stickyRow && stickyRow.firstElementChild;
26
- if (rightShadows) {
27
- var diff = table.offsetWidth - wrapper.offsetWidth;
28
- for (var i = 0; i < rightShadows.length; i++) {
29
- var rightShadow = rightShadows[i];
30
- rightShadow.style.display = diff > 0 && diff > wrapper.scrollLeft ? 'block' : 'none';
31
- if (rightShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
32
- rightShadow.style.height = "".concat(stickyCell.clientHeight + 1, "px");
33
- }
34
- }
35
- }
36
- if (leftShadows) {
37
- for (var _i = 0; _i < leftShadows.length; _i++) {
38
- var leftShadow = leftShadows[_i];
39
- leftShadow.style.display = wrapper.scrollLeft > 0 ? 'block' : 'none';
40
- if (leftShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
41
- leftShadow.style.height = "".concat(stickyCell.clientHeight + 1, "px");
42
- }
43
- }
44
- }
45
- }
46
- };
47
10
  };
@@ -50,10 +50,10 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
50
50
  }) : undefined;
51
51
  var tableCellNodeview = {
52
52
  tableCell: function tableCell(node, view, getPos) {
53
- return new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer);
53
+ return new TableCellNodeView(node, view, getPos, observer);
54
54
  },
55
55
  tableHeader: function tableHeader(node, view, getPos) {
56
- return new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer);
56
+ return new TableCellNodeView(node, view, getPos, observer);
57
57
  }
58
58
  };
59
59
 
@@ -242,7 +242,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
242
242
  mouseover: whenTableInFocus(handleMouseOver),
243
243
  mouseleave: whenTableInFocus(handleMouseLeave),
244
244
  mouseout: whenTableInFocus(handleMouseOut),
245
- mousemove: whenTableInFocus(handleMouseMove(getEditorFeatureFlags), elementContentRects),
245
+ mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
246
246
  click: whenTableInFocus(handleClick)
247
247
  },
248
248
  handleTripleClick: handleTripleClick
@@ -42,14 +42,13 @@ export var supportedHeaderRow = function supportedHeaderRow(node) {
42
42
  return allHeaders && !someMerged;
43
43
  };
44
44
  export var TableRowNodeView = /*#__PURE__*/function () {
45
- function TableRowNodeView(node, view, getPos, eventDispatcher, getEditorFeatureFlags) {
45
+ function TableRowNodeView(node, view, getPos, eventDispatcher) {
46
46
  var _this = this;
47
47
  _classCallCheck(this, TableRowNodeView);
48
48
  // this is the sticky header table row
49
49
  _defineProperty(this, "colControlsOffset", 0);
50
50
  _defineProperty(this, "focused", false);
51
51
  _defineProperty(this, "topPosEditorElement", 0);
52
- _defineProperty(this, "stickyHeadersOptimization", false);
53
52
  _defineProperty(this, "sentinels", {});
54
53
  /* external events */
55
54
  _defineProperty(this, "listening", false);
@@ -65,62 +64,9 @@ export var TableRowNodeView = /*#__PURE__*/function () {
65
64
  _this.headerRowMouseScrollEnd();
66
65
  }
67
66
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
68
- _defineProperty(this, "onScroll", function () {
69
- if (!_this.tree) {
70
- return;
71
- }
72
- _this.latestDomTop = getTop(_this.tree.wrapper);
73
-
74
- // kick off rAF loop again if it hasn't already happened
75
- if (!_this.nextFrame) {
76
- _this.loop();
77
- }
78
- });
79
- _defineProperty(this, "loop", function () {
80
- _this.nextFrame = window.requestAnimationFrame(function () {
81
- if (_this.previousDomTop === _this.latestDomTop && _this.previousPadding === _this.padding) {
82
- _this.nextFrame = undefined;
83
- return;
84
- }
85
-
86
- // can't store these since React might re-render at any time
87
- var tree = _this.tree;
88
- if (!tree) {
89
- _this.nextFrame = undefined;
90
- return;
91
- }
92
- _this.paint(tree);
93
-
94
- // run again on next frame
95
- _this.previousPadding = _this.padding;
96
- _this.previousDomTop = _this.latestDomTop;
97
- _this.loop();
98
- });
99
- });
100
- _defineProperty(this, "paint", function (tree) {
101
- var table = tree.table,
102
- wrapper = tree.wrapper;
103
-
104
- // If the previous refresh is less than 10ms then don't do anything.
105
- // The jumpiness happen under that time and this is to avoid it.
106
- var timelapse = Math.abs(performance.now() - _this.lastTimePainted);
107
- if (timelapse < 10) {
108
- return;
109
- }
110
- if (_this.shouldHeaderStick(tree)) {
111
- _this.makeHeaderRowSticky(tree);
112
- } else {
113
- _this.makeRowHeaderNotSticky(table);
114
- }
115
-
116
- // ensure scroll positions are locked
117
- _this.dom.scrollLeft = wrapper.scrollLeft;
118
- _this.lastTimePainted = performance.now();
119
- });
120
67
  /* receive external events */
121
68
  _defineProperty(this, "onTablePluginState", function (state) {
122
69
  var tableRef = state.tableRef;
123
- var focusChanged = false;
124
70
  var tree = _this.tree;
125
71
  if (!tree) {
126
72
  return;
@@ -140,9 +86,6 @@ export var TableRowNodeView = /*#__PURE__*/function () {
140
86
  if (isCurrentTableSelected && !state.isHeaderRowEnabled && _this.tree) {
141
87
  _this.makeRowHeaderNotSticky(_this.tree.table);
142
88
  }
143
- if (isCurrentTableSelected !== _this.focused) {
144
- focusChanged = true;
145
- }
146
89
  _this.focused = isCurrentTableSelected;
147
90
  var wrapper = tree.wrapper;
148
91
  var tableContainer = wrapper.parentElement;
@@ -164,10 +107,6 @@ export var TableRowNodeView = /*#__PURE__*/function () {
164
107
 
165
108
  // run after table style changes have been committed
166
109
  setTimeout(function () {
167
- // if focus changed while header is sticky - still repaint the positions will shift
168
- if (!_this.stickyHeadersOptimization || focusChanged && _this.isSticky) {
169
- _this.paint(tree);
170
- }
171
110
  syncStickyRowToTable(tree.table);
172
111
  }, 0);
173
112
  });
@@ -299,9 +238,6 @@ export var TableRowNodeView = /*#__PURE__*/function () {
299
238
  this.eventDispatcher = eventDispatcher;
300
239
  this.dom = document.createElement('tr');
301
240
  this.contentDOM = this.dom;
302
- var featureFlags = getEditorFeatureFlags();
303
- var stickyHeadersOptimization = featureFlags.stickyHeadersOptimization;
304
- this.stickyHeadersOptimization = !!stickyHeadersOptimization;
305
241
  this.lastTimePainted = 0;
306
242
  this.isHeaderRow = supportedHeaderRow(node);
307
243
  this.isSticky = false;
@@ -320,11 +256,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
320
256
  value: function subscribe() {
321
257
  this.editorScrollableElement = findOverflowScrollParent(this.view.dom) || window;
322
258
  if (this.editorScrollableElement) {
323
- if (this.stickyHeadersOptimization) {
324
- this.initObservers();
325
- } else {
326
- this.editorScrollableElement.addEventListener('scroll', this.onScroll);
327
- }
259
+ this.initObservers();
328
260
  this.topPosEditorElement = getTop(this.editorScrollableElement);
329
261
  }
330
262
  this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
@@ -352,9 +284,6 @@ export var TableRowNodeView = /*#__PURE__*/function () {
352
284
  if (this.resizeObserver) {
353
285
  this.resizeObserver.disconnect();
354
286
  }
355
- if (this.editorScrollableElement && !this.stickyHeadersOptimization) {
356
- this.editorScrollableElement.removeEventListener('scroll', this.onScroll);
357
- }
358
287
  this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
359
288
  this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
360
289
  this.listening = false;
@@ -13,7 +13,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
13
13
  props: {
14
14
  nodeViews: {
15
15
  tableRow: function tableRow(node, view, getPos) {
16
- return new TableRowNodeView(node, view, getPos, eventDispatcher, getEditorFeatureFlags);
16
+ return new TableRowNodeView(node, view, getPos, eventDispatcher);
17
17
  }
18
18
  }
19
19
  }
@@ -133,7 +133,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
133
133
  var map = TableMap.get(table);
134
134
  var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
135
135
  resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
136
- updateControls(getEditorFeatureFlags)(state);
136
+ updateControls()(state);
137
137
  updateResizeHandles(dom);
138
138
  }
139
139
  window.addEventListener('mouseup', finish);
@@ -1,11 +1,10 @@
1
1
  import { tableCellBorderWidth, tableMarginTop } from '@atlaskit/editor-common/styles';
2
2
  import { closestElement, containsClassName, parsePx } from '@atlaskit/editor-common/utils';
3
- import { updateOverflowShadows } from '../../../nodeviews/update-overflow-shadows';
4
3
  import { TableCssClassName as ClassName } from '../../../types';
5
4
  import { colWidthsForRow } from '../../../utils/column-controls';
6
5
  import { getRowHeights } from '../../../utils/row-controls';
7
6
  import { getPluginState as getMainPluginState } from '../../plugin-factory';
8
- export var updateControls = function updateControls(getEditorFeatureFlags) {
7
+ export var updateControls = function updateControls() {
9
8
  return function (state) {
10
9
  var _getMainPluginState = getMainPluginState(state),
11
10
  tableRef = _getMainPluginState.tableRef;
@@ -35,9 +34,6 @@ export var updateControls = function updateControls(getEditorFeatureFlags) {
35
34
  }
36
35
  }
37
36
  }
38
- var rightShadows = wrapper.parentElement.querySelectorAll(".".concat(ClassName.TABLE_RIGHT_SHADOW));
39
- var leftShadows = wrapper.parentElement.querySelectorAll(".".concat(ClassName.TABLE_LEFT_SHADOW));
40
- updateOverflowShadows(getEditorFeatureFlags)(wrapper, tableRef, rightShadows, leftShadows);
41
37
  };
42
38
  };
43
39
  export var isClickNear = function isClickNear(event, click) {
@@ -64,9 +64,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
64
64
  var _window,
65
65
  _this2 = this;
66
66
  var tableRef = this.props.tableRef;
67
- var _this$props$getEditor = this.props.getEditorFeatureFlags(),
68
- tableRenderOptimization = _this$props$getEditor.tableRenderOptimization;
69
- if (tableRenderOptimization && tableRef && !this.resizeObserver && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
67
+ if (tableRef && !this.resizeObserver && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
70
68
  this.resizeObserver = new ResizeObserver(function (entries) {
71
69
  var _iterator = _createForOfIteratorHelper(entries),
72
70
  _step;
@@ -104,10 +102,8 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
104
102
  ordering = _this$props.ordering,
105
103
  headerRowHeight = _this$props.headerRowHeight,
106
104
  stickyHeader = _this$props.stickyHeader;
107
- var _this$props$getEditor2 = this.props.getEditorFeatureFlags(),
108
- tableRenderOptimization = _this$props$getEditor2.tableRenderOptimization;
109
- var tableHeight = tableRenderOptimization ? (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.tableHeight : this.props.tableHeight;
110
- var nextTableHeight = tableRenderOptimization ? nextState === null || nextState === void 0 ? void 0 : nextState.tableHeight : nextProps.tableHeight;
105
+ var tableHeight = (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.tableHeight;
106
+ var nextTableHeight = nextState === null || nextState === void 0 ? void 0 : nextState.tableHeight;
111
107
  return ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableHeight !== nextTableHeight || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || isSelectionUpdated(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader;
112
108
  }
113
109
  }, {