@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
@@ -55,7 +55,6 @@ export default class TableView extends ReactNodeView {
55
55
  });
56
56
  _defineProperty(this, "hasHoveredRows", false);
57
57
  this.getPos = props.getPos;
58
- this.tableRenderOptimization = props.tableRenderOptimization;
59
58
  this.eventDispatcher = props.eventDispatcher;
60
59
  }
61
60
  getContentDOM() {
@@ -148,34 +147,31 @@ export default class TableView extends ReactNodeView {
148
147
  });
149
148
  }
150
149
  viewShouldUpdate(nextNode) {
151
- if (this.tableRenderOptimization) {
152
- const {
153
- hoveredRows
154
- } = getPluginState(this.view.state);
155
- const hoveredRowsChanged = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length) !== this.hasHoveredRows;
156
- if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
157
- this.hasHoveredRows = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length);
158
- return true;
159
- }
160
- const node = this.getNode();
161
- if (typeof node.attrs !== typeof nextNode.attrs) {
162
- return true;
163
- }
164
- const attrKeys = Object.keys(node.attrs);
165
- const nextAttrKeys = Object.keys(nextNode.attrs);
166
- if (attrKeys.length !== nextAttrKeys.length) {
167
- return true;
168
- }
169
- const tableMap = TableMap.get(node);
170
- const nextTableMap = TableMap.get(nextNode);
171
- if (tableMap.width !== nextTableMap.width) {
172
- return true;
173
- }
174
- return attrKeys.some(key => {
175
- return node.attrs[key] !== nextNode.attrs[key];
176
- });
150
+ const {
151
+ hoveredRows
152
+ } = getPluginState(this.view.state);
153
+ const hoveredRowsChanged = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length) !== this.hasHoveredRows;
154
+ if (nextNode.attrs.isNumberColumnEnabled && hoveredRowsChanged) {
155
+ this.hasHoveredRows = !!(hoveredRows !== null && hoveredRows !== void 0 && hoveredRows.length);
156
+ return true;
177
157
  }
178
- return super.viewShouldUpdate(nextNode);
158
+ const node = this.getNode();
159
+ if (typeof node.attrs !== typeof nextNode.attrs) {
160
+ return true;
161
+ }
162
+ const attrKeys = Object.keys(node.attrs);
163
+ const nextAttrKeys = Object.keys(nextNode.attrs);
164
+ if (attrKeys.length !== nextAttrKeys.length) {
165
+ return true;
166
+ }
167
+ const tableMap = TableMap.get(node);
168
+ const nextTableMap = TableMap.get(nextNode);
169
+ if (tableMap.width !== nextTableMap.width) {
170
+ return true;
171
+ }
172
+ return attrKeys.some(key => {
173
+ return node.attrs[key] !== nextNode.attrs[key];
174
+ });
179
175
  }
180
176
  ignoreMutation(mutation) {
181
177
  const {
@@ -213,9 +209,6 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
213
209
  const {
214
210
  allowColumnResizing
215
211
  } = getPluginConfig(pluginConfig);
216
- const {
217
- tableRenderOptimization
218
- } = getEditorFeatureFlags();
219
212
  const hasIntlContext = true;
220
213
  return new TableView({
221
214
  node,
@@ -225,7 +218,6 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
225
218
  eventDispatcher,
226
219
  getPos: getPos,
227
220
  options,
228
- tableRenderOptimization,
229
221
  getEditorContainerWidth,
230
222
  getEditorFeatureFlags,
231
223
  hasIntlContext,
@@ -4,7 +4,7 @@ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
4
4
  const DEFAULT_COL_SPAN = 1;
5
5
  const DEFAULT_ROW_SPAN = 1;
6
6
  export default class TableCellNodeView {
7
- constructor(node, view, getPos, getEditorFeatureFlags, observer) {
7
+ constructor(node, view, getPos, observer) {
8
8
  this.view = view;
9
9
  this.node = node;
10
10
  const {
@@ -14,12 +14,8 @@ export default class TableCellNodeView {
14
14
  this.getPos = getPos;
15
15
  this.dom = dom;
16
16
  this.contentDOM = contentDOM;
17
- const {
18
- mouseMoveOptimization
19
- } = getEditorFeatureFlags();
20
- if (mouseMoveOptimization && observer) {
17
+ if (observer) {
21
18
  this.contentDOM.id = uuid();
22
- this.mouseMoveOptimization = mouseMoveOptimization;
23
19
  this.observer = observer;
24
20
  observer.observe(this.contentDOM);
25
21
  }
@@ -64,7 +60,7 @@ export default class TableCellNodeView {
64
60
  return didUpdate;
65
61
  }
66
62
  destroy() {
67
- if (this.mouseMoveOptimization && this.observer) {
63
+ if (this.observer) {
68
64
  this.observer.unobserve(this.contentDOM);
69
65
  }
70
66
  }
@@ -7,39 +7,4 @@ export const updateShadowListForStickyStyles = (heightStyle, shadows) => {
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 const updateOverflowShadows = getEditorFeatureFlags => (wrapper, table, rightShadows, leftShadows) => {
17
- var _getEditorFeatureFlag;
18
- if (((_getEditorFeatureFlag = getEditorFeatureFlags()) === null || _getEditorFeatureFlag === void 0 ? void 0 : _getEditorFeatureFlag.tableOverflowShadowsOptimization) === true) {
19
- return false;
20
- }
21
- // Right shadow
22
- if (table && wrapper) {
23
- const stickyRow = wrapper.querySelector('tr.sticky');
24
- const stickyCell = stickyRow && stickyRow.firstElementChild;
25
- if (rightShadows) {
26
- const diff = table.offsetWidth - wrapper.offsetWidth;
27
- for (let i = 0; i < rightShadows.length; i++) {
28
- const rightShadow = rightShadows[i];
29
- rightShadow.style.display = diff > 0 && diff > wrapper.scrollLeft ? 'block' : 'none';
30
- if (rightShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
31
- rightShadow.style.height = `${stickyCell.clientHeight + 1}px`;
32
- }
33
- }
34
- }
35
- if (leftShadows) {
36
- for (let i = 0; i < leftShadows.length; i++) {
37
- const leftShadow = leftShadows[i];
38
- leftShadow.style.display = wrapper.scrollLeft > 0 ? 'block' : 'none';
39
- if (leftShadow.classList.contains(ClassName.TABLE_STICKY_SHADOW) && stickyCell) {
40
- leftShadow.style.height = `${stickyCell.clientHeight + 1}px`;
41
- }
42
- }
43
- }
44
- }
45
10
  };
@@ -47,8 +47,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
47
47
  });
48
48
  }) : undefined;
49
49
  const tableCellNodeview = {
50
- tableCell: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer),
51
- tableHeader: (node, view, getPos) => new TableCellNodeView(node, view, getPos, getEditorFeatureFlags, observer)
50
+ tableCell: (node, view, getPos) => new TableCellNodeView(node, view, getPos, observer),
51
+ tableHeader: (node, view, getPos) => new TableCellNodeView(node, view, getPos, observer)
52
52
  };
53
53
 
54
54
  // Used to prevent invalid table cell spans being reported more than once per editor/document
@@ -225,7 +225,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
225
225
  return false;
226
226
  },
227
227
  nodeViews: {
228
- //temporary flag to test tableCell optimisation
229
228
  ...tableCellNodeview,
230
229
  table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, {
231
230
  isBreakoutEnabled,
@@ -241,7 +240,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
241
240
  mouseover: whenTableInFocus(handleMouseOver),
242
241
  mouseleave: whenTableInFocus(handleMouseLeave),
243
242
  mouseout: whenTableInFocus(handleMouseOut),
244
- mousemove: whenTableInFocus(handleMouseMove(getEditorFeatureFlags), elementContentRects),
243
+ mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
245
244
  click: whenTableInFocus(handleClick)
246
245
  },
247
246
  handleTripleClick
@@ -35,12 +35,11 @@ export class TableRowNodeView {
35
35
  get tree() {
36
36
  return getTree(this.dom);
37
37
  }
38
- constructor(node, view, getPos, eventDispatcher, getEditorFeatureFlags) {
38
+ constructor(node, view, getPos, eventDispatcher) {
39
39
  // this is the sticky header table row
40
40
  _defineProperty(this, "colControlsOffset", 0);
41
41
  _defineProperty(this, "focused", false);
42
42
  _defineProperty(this, "topPosEditorElement", 0);
43
- _defineProperty(this, "stickyHeadersOptimization", false);
44
43
  _defineProperty(this, "sentinels", {});
45
44
  /* external events */
46
45
  _defineProperty(this, "listening", false);
@@ -56,64 +55,9 @@ export class TableRowNodeView {
56
55
  this.headerRowMouseScrollEnd();
57
56
  }
58
57
  }, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
59
- _defineProperty(this, "onScroll", () => {
60
- if (!this.tree) {
61
- return;
62
- }
63
- this.latestDomTop = getTop(this.tree.wrapper);
64
-
65
- // kick off rAF loop again if it hasn't already happened
66
- if (!this.nextFrame) {
67
- this.loop();
68
- }
69
- });
70
- _defineProperty(this, "loop", () => {
71
- this.nextFrame = window.requestAnimationFrame(() => {
72
- if (this.previousDomTop === this.latestDomTop && this.previousPadding === this.padding) {
73
- this.nextFrame = undefined;
74
- return;
75
- }
76
-
77
- // can't store these since React might re-render at any time
78
- const tree = this.tree;
79
- if (!tree) {
80
- this.nextFrame = undefined;
81
- return;
82
- }
83
- this.paint(tree);
84
-
85
- // run again on next frame
86
- this.previousPadding = this.padding;
87
- this.previousDomTop = this.latestDomTop;
88
- this.loop();
89
- });
90
- });
91
- _defineProperty(this, "paint", tree => {
92
- const {
93
- table,
94
- wrapper
95
- } = tree;
96
-
97
- // If the previous refresh is less than 10ms then don't do anything.
98
- // The jumpiness happen under that time and this is to avoid it.
99
- const timelapse = Math.abs(performance.now() - this.lastTimePainted);
100
- if (timelapse < 10) {
101
- return;
102
- }
103
- if (this.shouldHeaderStick(tree)) {
104
- this.makeHeaderRowSticky(tree);
105
- } else {
106
- this.makeRowHeaderNotSticky(table);
107
- }
108
-
109
- // ensure scroll positions are locked
110
- this.dom.scrollLeft = wrapper.scrollLeft;
111
- this.lastTimePainted = performance.now();
112
- });
113
58
  /* receive external events */
114
59
  _defineProperty(this, "onTablePluginState", state => {
115
60
  const tableRef = state.tableRef;
116
- let focusChanged = false;
117
61
  const tree = this.tree;
118
62
  if (!tree) {
119
63
  return;
@@ -133,9 +77,6 @@ export class TableRowNodeView {
133
77
  if (isCurrentTableSelected && !state.isHeaderRowEnabled && this.tree) {
134
78
  this.makeRowHeaderNotSticky(this.tree.table);
135
79
  }
136
- if (isCurrentTableSelected !== this.focused) {
137
- focusChanged = true;
138
- }
139
80
  this.focused = isCurrentTableSelected;
140
81
  const {
141
82
  wrapper
@@ -159,10 +100,6 @@ export class TableRowNodeView {
159
100
 
160
101
  // run after table style changes have been committed
161
102
  setTimeout(() => {
162
- // if focus changed while header is sticky - still repaint the positions will shift
163
- if (!this.stickyHeadersOptimization || focusChanged && this.isSticky) {
164
- this.paint(tree);
165
- }
166
103
  syncStickyRowToTable(tree.table);
167
104
  }, 0);
168
105
  });
@@ -290,11 +227,6 @@ export class TableRowNodeView {
290
227
  this.eventDispatcher = eventDispatcher;
291
228
  this.dom = document.createElement('tr');
292
229
  this.contentDOM = this.dom;
293
- const featureFlags = getEditorFeatureFlags();
294
- const {
295
- stickyHeadersOptimization
296
- } = featureFlags;
297
- this.stickyHeadersOptimization = !!stickyHeadersOptimization;
298
230
  this.lastTimePainted = 0;
299
231
  this.isHeaderRow = supportedHeaderRow(node);
300
232
  this.isSticky = false;
@@ -306,11 +238,7 @@ export class TableRowNodeView {
306
238
  subscribe() {
307
239
  this.editorScrollableElement = findOverflowScrollParent(this.view.dom) || window;
308
240
  if (this.editorScrollableElement) {
309
- if (this.stickyHeadersOptimization) {
310
- this.initObservers();
311
- } else {
312
- this.editorScrollableElement.addEventListener('scroll', this.onScroll);
313
- }
241
+ this.initObservers();
314
242
  this.topPosEditorElement = getTop(this.editorScrollableElement);
315
243
  }
316
244
  this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
@@ -336,9 +264,6 @@ export class TableRowNodeView {
336
264
  if (this.resizeObserver) {
337
265
  this.resizeObserver.disconnect();
338
266
  }
339
- if (this.editorScrollableElement && !this.stickyHeadersOptimization) {
340
- this.editorScrollableElement.removeEventListener('scroll', this.onScroll);
341
- }
342
267
  this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
343
268
  this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
344
269
  this.listening = false;
@@ -9,7 +9,7 @@ export const createPlugin = (dispatch, eventDispatcher, initialState = () => [],
9
9
  props: {
10
10
  nodeViews: {
11
11
  tableRow: (node, view, getPos) => {
12
- return new TableRowNodeView(node, view, getPos, eventDispatcher, getEditorFeatureFlags);
12
+ return new TableRowNodeView(node, view, getPos, eventDispatcher);
13
13
  }
14
14
  }
15
15
  }
@@ -149,7 +149,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
149
149
  const map = TableMap.get(table);
150
150
  const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
151
151
  resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
152
- updateControls(getEditorFeatureFlags)(state);
152
+ updateControls()(state);
153
153
  updateResizeHandles(dom);
154
154
  }
155
155
  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 const updateControls = getEditorFeatureFlags => state => {
7
+ export const updateControls = () => state => {
9
8
  const {
10
9
  tableRef
11
10
  } = getMainPluginState(state);
@@ -35,9 +34,6 @@ export const updateControls = getEditorFeatureFlags => state => {
35
34
  }
36
35
  }
37
36
  }
38
- const rightShadows = wrapper.parentElement.querySelectorAll(`.${ClassName.TABLE_RIGHT_SHADOW}`);
39
- const leftShadows = wrapper.parentElement.querySelectorAll(`.${ClassName.TABLE_LEFT_SHADOW}`);
40
- updateOverflowShadows(getEditorFeatureFlags)(wrapper, tableRef, rightShadows, leftShadows);
41
37
  };
42
38
  export const isClickNear = (event, click) => {
43
39
  const dx = click.x - event.clientX,
@@ -45,10 +45,7 @@ export default class TableFloatingControls extends Component {
45
45
  let {
46
46
  tableRef
47
47
  } = this.props;
48
- const {
49
- tableRenderOptimization
50
- } = this.props.getEditorFeatureFlags();
51
- if (tableRenderOptimization && tableRef && !this.resizeObserver && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
48
+ if (tableRef && !this.resizeObserver && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
52
49
  this.resizeObserver = new ResizeObserver(entries => {
53
50
  for (let entry of entries) {
54
51
  const tableHeight = entry.contentRect.height;
@@ -76,11 +73,8 @@ export default class TableFloatingControls extends Component {
76
73
  headerRowHeight,
77
74
  stickyHeader
78
75
  } = this.props;
79
- const {
80
- tableRenderOptimization
81
- } = this.props.getEditorFeatureFlags();
82
- const tableHeight = tableRenderOptimization ? (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.tableHeight : this.props.tableHeight;
83
- const nextTableHeight = tableRenderOptimization ? nextState === null || nextState === void 0 ? void 0 : nextState.tableHeight : nextProps.tableHeight;
76
+ const tableHeight = (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.tableHeight;
77
+ const nextTableHeight = nextState === null || nextState === void 0 ? void 0 : nextState.tableHeight;
84
78
  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;
85
79
  }
86
80
  componentWillUnmount() {
@@ -117,7 +117,7 @@ const tableWrapperStyles = () => {
117
117
 
118
118
  // TODO: https://product-fabric.atlassian.net/browse/DSP-4139
119
119
  export const tableStyles = props => {
120
- var _props$featureFlags, _props$featureFlags2;
120
+ var _props$featureFlags;
121
121
  return css`
122
122
  .${ClassName.LAYOUT_BUTTON} button {
123
123
  background: ${`var(--ds-background-neutral, ${N20A})`};
@@ -342,7 +342,7 @@ export const tableStyles = props => {
342
342
  ${"var(--ds-surface, white)"};
343
343
  }
344
344
 
345
- ${(_props$featureFlags = props.featureFlags) !== null && _props$featureFlags !== void 0 && _props$featureFlags.stickyHeadersOptimization ? sentinelStyles : ''}
345
+ ${sentinelStyles}
346
346
  ${OverflowShadow(props)}
347
347
 
348
348
  .${ClassName.TABLE_STICKY} .${ClassName.TABLE_STICKY_SHADOW} {
@@ -703,7 +703,7 @@ export const tableStyles = props => {
703
703
  styles that handle this generally (in editor-common) so we can
704
704
  throw away the older table-specific styles here.
705
705
  */
706
- ${props !== null && props !== void 0 && (_props$featureFlags2 = props.featureFlags) !== null && _props$featureFlags2 !== void 0 && _props$featureFlags2.restartNumberedLists ? `` : listLargeNumericMarkersOldStyles}
706
+ ${props !== null && props !== void 0 && (_props$featureFlags = props.featureFlags) !== null && _props$featureFlags !== void 0 && _props$featureFlags.restartNumberedLists ? `` : listLargeNumericMarkersOldStyles}
707
707
 
708
708
  ${shadowSentinelStyles}
709
709
  `;
@@ -68,22 +68,15 @@ export const isTableContainerOrWrapper = node => containsClassName(node, ClassNa
68
68
  * the same is valid to the right side.
69
69
  */
70
70
 
71
- export const getMousePositionHorizontalRelativeByElement = (mouseEvent, mouseMoveOptimization, elementContentRects, gapInPixels) => {
71
+ export const getMousePositionHorizontalRelativeByElement = (mouseEvent, elementContentRects, gapInPixels) => {
72
72
  const element = mouseEvent.target;
73
73
  if (element instanceof HTMLElement) {
74
+ var _closestCell$id, _elementContentRects$, _elementContentRects$2;
74
75
  let width, x;
75
76
  const closestCell = element.closest(SELECTOR_TABLE_LEAFS);
76
- if (mouseMoveOptimization) {
77
- var _closestCell$id, _elementContentRects$, _elementContentRects$2;
78
- const id = (_closestCell$id = closestCell === null || closestCell === void 0 ? void 0 : closestCell.id) !== null && _closestCell$id !== void 0 ? _closestCell$id : '';
79
- width = (_elementContentRects$ = elementContentRects === null || elementContentRects === void 0 ? void 0 : (_elementContentRects$2 = elementContentRects[id]) === null || _elementContentRects$2 === void 0 ? void 0 : _elementContentRects$2.width) !== null && _elementContentRects$ !== void 0 ? _elementContentRects$ : 0;
80
- x = mouseEvent.offsetX;
81
- } else {
82
- const elementRect = element.getBoundingClientRect();
83
- width = elementRect.width;
84
- const left = elementRect.left;
85
- x = mouseEvent.clientX - left;
86
- }
77
+ const id = (_closestCell$id = closestCell === null || closestCell === void 0 ? void 0 : closestCell.id) !== null && _closestCell$id !== void 0 ? _closestCell$id : '';
78
+ width = (_elementContentRects$ = elementContentRects === null || elementContentRects === void 0 ? void 0 : (_elementContentRects$2 = elementContentRects[id]) === null || _elementContentRects$2 === void 0 ? void 0 : _elementContentRects$2.width) !== null && _elementContentRects$ !== void 0 ? _elementContentRects$ : 0;
79
+ x = mouseEvent.offsetX;
87
80
  if (width <= 0) {
88
81
  return null;
89
82
  }
@@ -174,67 +174,63 @@ export var handleMouseLeave = function handleMouseLeave(view, event) {
174
174
  }
175
175
  return false;
176
176
  };
177
- export var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
178
- return function (view, event, elementContentRects) {
179
- if (!(event.target instanceof HTMLElement)) {
180
- return false;
181
- }
182
- var element = event.target;
183
- if (isColumnControlsDecorations(element)) {
184
- var state = view.state,
185
- dispatch = view.dispatch;
186
- var _getPluginState3 = getPluginState(state),
187
- insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
188
- var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
189
- _getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
190
- startIndex = _getColumnOrRowIndex10[0],
191
- endIndex = _getColumnOrRowIndex10[1];
192
- var positionColumn = getMousePositionHorizontalRelativeByElement(event, false, elementContentRects) === 'right' ? endIndex : startIndex;
193
- if (positionColumn !== insertColumnButtonIndex) {
194
- return showInsertColumnButton(positionColumn)(state, dispatch);
195
- }
177
+ export var handleMouseMove = function handleMouseMove(view, event, elementContentRects) {
178
+ if (!(event.target instanceof HTMLElement)) {
179
+ return false;
180
+ }
181
+ var element = event.target;
182
+ if (isColumnControlsDecorations(element)) {
183
+ var state = view.state,
184
+ dispatch = view.dispatch;
185
+ var _getPluginState3 = getPluginState(state),
186
+ insertColumnButtonIndex = _getPluginState3.insertColumnButtonIndex;
187
+ var _getColumnOrRowIndex9 = getColumnOrRowIndex(element),
188
+ _getColumnOrRowIndex10 = _slicedToArray(_getColumnOrRowIndex9, 2),
189
+ startIndex = _getColumnOrRowIndex10[0],
190
+ endIndex = _getColumnOrRowIndex10[1];
191
+ var positionColumn = getMousePositionHorizontalRelativeByElement(event, elementContentRects) === 'right' ? endIndex : startIndex;
192
+ if (positionColumn !== insertColumnButtonIndex) {
193
+ return showInsertColumnButton(positionColumn)(state, dispatch);
196
194
  }
197
- if (isRowControlsButton(element)) {
198
- var _state3 = view.state,
199
- _dispatch4 = view.dispatch;
200
- var _getPluginState4 = getPluginState(_state3),
201
- insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
202
- var _getColumnOrRowIndex11 = getColumnOrRowIndex(element),
203
- _getColumnOrRowIndex12 = _slicedToArray(_getColumnOrRowIndex11, 2),
204
- _startIndex3 = _getColumnOrRowIndex12[0],
205
- _endIndex2 = _getColumnOrRowIndex12[1];
206
- var positionRow = getMousePositionVerticalRelativeByElement(event) === 'bottom' ? _endIndex2 : _startIndex3;
207
- if (positionRow !== insertRowButtonIndex) {
208
- return showInsertRowButton(positionRow)(_state3, _dispatch4);
209
- }
195
+ }
196
+ if (isRowControlsButton(element)) {
197
+ var _state3 = view.state,
198
+ _dispatch4 = view.dispatch;
199
+ var _getPluginState4 = getPluginState(_state3),
200
+ insertRowButtonIndex = _getPluginState4.insertRowButtonIndex;
201
+ var _getColumnOrRowIndex11 = getColumnOrRowIndex(element),
202
+ _getColumnOrRowIndex12 = _slicedToArray(_getColumnOrRowIndex11, 2),
203
+ _startIndex3 = _getColumnOrRowIndex12[0],
204
+ _endIndex2 = _getColumnOrRowIndex12[1];
205
+ var positionRow = getMousePositionVerticalRelativeByElement(event) === 'bottom' ? _endIndex2 : _startIndex3;
206
+ if (positionRow !== insertRowButtonIndex) {
207
+ return showInsertRowButton(positionRow)(_state3, _dispatch4);
210
208
  }
211
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
212
- mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
213
- if (!isResizeHandleDecoration(element) && isCell(element)) {
214
- var _positionColumn = getMousePositionHorizontalRelativeByElement(event, mouseMoveOptimization, elementContentRects, RESIZE_HANDLE_AREA_DECORATION_GAP);
215
- if (_positionColumn !== null) {
216
- var _state4 = view.state,
217
- _dispatch5 = view.dispatch;
218
- var _getPluginState5 = getPluginState(_state4),
219
- resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
220
- resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
221
- var tableCell = closestElement(element, 'td, th');
222
- var cellStartPosition = view.posAtDOM(tableCell, 0);
223
- var rect = findCellRectClosestToPos(_state4.doc.resolve(cellStartPosition));
224
- if (rect) {
225
- var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
226
- var rowIndexTarget = rect.top;
227
- if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
228
- target: element,
229
- columnEndIndexTarget: columnEndIndexTarget
230
- })) {
231
- return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget)(_state4, _dispatch5);
232
- }
209
+ }
210
+ if (!isResizeHandleDecoration(element) && isCell(element)) {
211
+ var _positionColumn = getMousePositionHorizontalRelativeByElement(event, elementContentRects, RESIZE_HANDLE_AREA_DECORATION_GAP);
212
+ if (_positionColumn !== null) {
213
+ var _state4 = view.state,
214
+ _dispatch5 = view.dispatch;
215
+ var _getPluginState5 = getPluginState(_state4),
216
+ resizeHandleColumnIndex = _getPluginState5.resizeHandleColumnIndex,
217
+ resizeHandleRowIndex = _getPluginState5.resizeHandleRowIndex;
218
+ var tableCell = closestElement(element, 'td, th');
219
+ var cellStartPosition = view.posAtDOM(tableCell, 0);
220
+ var rect = findCellRectClosestToPos(_state4.doc.resolve(cellStartPosition));
221
+ if (rect) {
222
+ var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
223
+ var rowIndexTarget = rect.top;
224
+ if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
225
+ target: element,
226
+ columnEndIndexTarget: columnEndIndexTarget
227
+ })) {
228
+ return addResizeHandleDecorations(rowIndexTarget, columnEndIndexTarget)(_state4, _dispatch5);
233
229
  }
234
230
  }
235
231
  }
236
- return false;
237
- };
232
+ }
233
+ return false;
238
234
  };
239
235
  export function handleTripleClick(view, pos) {
240
236
  var state = view.state,