@atlaskit/editor-plugin-table 7.5.5 → 7.5.6

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 (69) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/event-handlers.js +25 -9
  3. package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
  4. package/dist/cjs/nodeviews/TableCell.js +5 -30
  5. package/dist/cjs/nodeviews/TableComponent.js +74 -24
  6. package/dist/cjs/nodeviews/TableContainer.js +19 -17
  7. package/dist/cjs/nodeviews/TableResizer.js +1 -1
  8. package/dist/cjs/plugin.js +2 -3
  9. package/dist/cjs/pm-plugins/main.js +3 -18
  10. package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
  11. package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
  12. package/dist/cjs/utils/column-controls.js +5 -5
  13. package/dist/cjs/utils/dom.js +13 -15
  14. package/dist/es2019/event-handlers.js +25 -9
  15. package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
  16. package/dist/es2019/nodeviews/TableCell.js +1 -24
  17. package/dist/es2019/nodeviews/TableComponent.js +63 -27
  18. package/dist/es2019/nodeviews/TableContainer.js +16 -18
  19. package/dist/es2019/nodeviews/TableResizer.js +1 -1
  20. package/dist/es2019/plugin.js +2 -3
  21. package/dist/es2019/pm-plugins/main.js +3 -18
  22. package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
  23. package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
  24. package/dist/es2019/utils/column-controls.js +6 -6
  25. package/dist/es2019/utils/dom.js +13 -15
  26. package/dist/esm/event-handlers.js +25 -9
  27. package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
  28. package/dist/esm/nodeviews/TableCell.js +5 -30
  29. package/dist/esm/nodeviews/TableComponent.js +74 -24
  30. package/dist/esm/nodeviews/TableContainer.js +20 -18
  31. package/dist/esm/nodeviews/TableResizer.js +1 -1
  32. package/dist/esm/plugin.js +2 -3
  33. package/dist/esm/pm-plugins/main.js +3 -18
  34. package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
  35. package/dist/esm/ui/TableFloatingControls/index.js +113 -224
  36. package/dist/esm/utils/column-controls.js +6 -6
  37. package/dist/esm/utils/dom.js +13 -15
  38. package/dist/types/event-handlers.d.ts +3 -4
  39. package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  40. package/dist/types/nodeviews/TableCell.d.ts +1 -5
  41. package/dist/types/nodeviews/TableComponent.d.ts +4 -0
  42. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  43. package/dist/types/types.d.ts +0 -3
  44. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
  45. package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
  46. package/dist/types/utils/dom.d.ts +10 -2
  47. package/dist/types-ts4.5/event-handlers.d.ts +3 -4
  48. package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  49. package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
  50. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +4 -0
  51. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  52. package/dist/types-ts4.5/types.d.ts +0 -3
  53. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
  54. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
  55. package/dist/types-ts4.5/utils/dom.d.ts +10 -2
  56. package/package.json +3 -4
  57. package/src/event-handlers.ts +105 -103
  58. package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
  59. package/src/nodeviews/TableCell.ts +0 -26
  60. package/src/nodeviews/TableComponent.tsx +76 -32
  61. package/src/nodeviews/TableContainer.tsx +19 -25
  62. package/src/nodeviews/TableResizer.tsx +1 -4
  63. package/src/plugin.tsx +5 -4
  64. package/src/pm-plugins/main.ts +3 -22
  65. package/src/types.ts +0 -4
  66. package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
  67. package/src/ui/TableFloatingControls/index.tsx +155 -241
  68. package/src/utils/column-controls.ts +5 -6
  69. package/src/utils/dom.ts +12 -19
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import rafSchedule from 'raf-schd';
2
3
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
4
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
4
5
  import { tableInsertColumnButtonSize } from '../ui/consts';
@@ -36,8 +37,13 @@ export class OverflowShadowsObserver {
36
37
  });
37
38
  _defineProperty(this, "observeShadowSentinels", isSticky => {
38
39
  var _this$table, _this$table2;
40
+ if (this.isSticky === isSticky) {
41
+ return;
42
+ }
39
43
  this.isSticky = !!isSticky;
40
44
 
45
+ // reset height
46
+ this.stickyRowHeight = 0;
41
47
  // update sticky shadows
42
48
  this.updateStickyShadowsHeightIfChanged();
43
49
  this.leftShadowSentinel = (_this$table = this.table) === null || _this$table === void 0 ? void 0 : _this$table.querySelector(`.${ClassName.TABLE_SHADOW_SENTINEL_LEFT}`);
@@ -54,8 +60,8 @@ export class OverflowShadowsObserver {
54
60
  * e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
55
61
  * reading it from sticky cell
56
62
  */
57
- _defineProperty(this, "updateStickyShadows", stickyRowHeight => {
58
- var _this$wrapper, _this$wrapper2, _this$wrapper2$parent, _this$wrapper3, _this$wrapper3$parent;
63
+ _defineProperty(this, "updateStickyShadows", rafSchedule(stickyRowHeight => {
64
+ var _this$wrapper;
59
65
  if (!this.isSticky) {
60
66
  return;
61
67
  }
@@ -63,14 +69,21 @@ export class OverflowShadowsObserver {
63
69
  if (!stickyCell || !((_this$wrapper = this.wrapper) !== null && _this$wrapper !== void 0 && _this$wrapper.parentElement)) {
64
70
  return;
65
71
  }
66
- const heightStyleOrCompute = `${stickyRowHeight || stickyCell.clientHeight + 1}px`;
67
- // Use getElementsByClassName here for a live node list to capture
68
- // sticky shadows
69
- const liveRightShadows = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : (_this$wrapper2$parent = _this$wrapper2.parentElement) === null || _this$wrapper2$parent === void 0 ? void 0 : _this$wrapper2$parent.getElementsByClassName(`${ClassName.TABLE_RIGHT_SHADOW}`);
70
- const liveLeftShadows = (_this$wrapper3 = this.wrapper) === null || _this$wrapper3 === void 0 ? void 0 : (_this$wrapper3$parent = _this$wrapper3.parentElement) === null || _this$wrapper3$parent === void 0 ? void 0 : _this$wrapper3$parent.getElementsByClassName(`${ClassName.TABLE_LEFT_SHADOW}`);
71
- updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
72
- updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
73
- });
72
+
73
+ // Reflow Warning! - stickyCell.clientHeight
74
+ const newStickyRowHeight = stickyRowHeight || stickyCell.clientHeight + 1;
75
+ if (newStickyRowHeight !== this.stickyRowHeight) {
76
+ var _this$wrapper2, _this$wrapper2$parent, _this$wrapper3, _this$wrapper3$parent;
77
+ this.stickyRowHeight = newStickyRowHeight;
78
+ const heightStyleOrCompute = `${newStickyRowHeight}px`;
79
+ // Use getElementsByClassName here for a live node list to capture
80
+ // sticky shadows
81
+ const liveRightShadows = (_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : (_this$wrapper2$parent = _this$wrapper2.parentElement) === null || _this$wrapper2$parent === void 0 ? void 0 : _this$wrapper2$parent.getElementsByClassName(`${ClassName.TABLE_RIGHT_SHADOW}`);
82
+ const liveLeftShadows = (_this$wrapper3 = this.wrapper) === null || _this$wrapper3 === void 0 ? void 0 : (_this$wrapper3$parent = _this$wrapper3.parentElement) === null || _this$wrapper3$parent === void 0 ? void 0 : _this$wrapper3$parent.getElementsByClassName(`${ClassName.TABLE_LEFT_SHADOW}`);
83
+ updateShadowListForStickyStyles(heightStyleOrCompute, liveLeftShadows);
84
+ updateShadowListForStickyStyles(heightStyleOrCompute, liveRightShadows);
85
+ }
86
+ }));
74
87
  this.updateShadowState = updateShadowState;
75
88
  this.table = _table;
76
89
  this.wrapper = wrapper;
@@ -84,11 +97,7 @@ export class OverflowShadowsObserver {
84
97
  if (!stickyCell) {
85
98
  return;
86
99
  }
87
- const newStickyRowHeight = stickyCell.clientHeight + 1;
88
- if (newStickyRowHeight === this.stickyRowHeight) {
89
- this.stickyRowHeight = newStickyRowHeight;
90
- this.updateStickyShadows(this.stickyRowHeight);
91
- }
100
+ this.updateStickyShadows();
92
101
  }
93
102
  getStickyCell() {
94
103
  var _this$wrapper4;
@@ -1,29 +1,11 @@
1
- import uuid from 'uuid';
2
1
  import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
3
- import { getPluginState } from '../pm-plugins/plugin-factory';
4
2
  import TableNodeView from './TableNodeViewBase';
5
3
  const DEFAULT_COL_SPAN = 1;
6
4
  const DEFAULT_ROW_SPAN = 1;
7
5
  export default class TableCell extends TableNodeView {
8
- constructor(node, view, getPos, eventDispatcher, observer) {
6
+ constructor(node, view, getPos, eventDispatcher) {
9
7
  super(node, view, getPos, eventDispatcher);
10
- this.observer = observer;
11
- const {
12
- pluginConfig,
13
- isDragAndDropEnabled
14
- } = getPluginState(view.state);
15
- this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
16
- this.isDragAndDropEnabled = !!isDragAndDropEnabled;
17
- if (observer) {
18
- this.contentDOM.id = uuid();
19
- observer.observe(this.contentDOM);
20
- }
21
8
  }
22
-
23
- // @ts-ignore
24
-
25
- // @ts-ignore
26
-
27
9
  update(node) {
28
10
  const didUpdate = this.updateNodeView(node);
29
11
  if (didUpdate) {
@@ -31,11 +13,6 @@ export default class TableCell extends TableNodeView {
31
13
  }
32
14
  return didUpdate;
33
15
  }
34
- destroy() {
35
- if (this.observer) {
36
- this.observer.unobserve(this.contentDOM);
37
- }
38
- }
39
16
  updateNodeView(node) {
40
17
  if (this.node.type !== node.type) {
41
18
  return false;
@@ -34,6 +34,12 @@ const isIE11 = browser.ie_version === 11;
34
34
  // componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
35
35
  // To make sure we capture the last update, we use setTimeout.
36
36
  const initialOverflowCaptureTimeroutDelay = 300;
37
+
38
+ // This is a hard switch for controlling whether the overflow analytics should be dispatched. There has been 6months of data
39
+ // already collected which we could use but have not. This has been disabled rather then removed entirely in the event that
40
+ // the current collected data becomes stale and we want to start collecting fresh data again in future.
41
+ // PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
42
+ const isOverflowAnalyticsEnabled = false;
37
43
  class TableComponent extends React.Component {
38
44
  constructor(props) {
39
45
  super(props);
@@ -41,7 +47,9 @@ class TableComponent extends React.Component {
41
47
  scroll: 0,
42
48
  parentWidth: undefined,
43
49
  [ShadowEvent.SHOW_BEFORE_SHADOW]: false,
44
- [ShadowEvent.SHOW_AFTER_SHADOW]: false
50
+ [ShadowEvent.SHOW_AFTER_SHADOW]: false,
51
+ tableWrapperWidth: undefined,
52
+ tableWrapperHeight: undefined
45
53
  });
46
54
  _defineProperty(this, "updateShadowState", (shadowKey, value) => {
47
55
  if (this.state[shadowKey] === value) {
@@ -293,6 +301,18 @@ class TableComponent extends React.Component {
293
301
  this.layoutSize = this.tableNodeLayoutSize(this.node, _containerWidth.width, {
294
302
  isFullWidthModeEnabled
295
303
  });
304
+ this.resizeObserver = new ResizeObserver(entries => {
305
+ for (let entry of entries) {
306
+ this.setState(prev => {
307
+ var _entry$contentRect, _entry$contentRect2;
308
+ return (prev === null || prev === void 0 ? void 0 : prev.tableWrapperWidth) === ((_entry$contentRect = entry.contentRect) === null || _entry$contentRect === void 0 ? void 0 : _entry$contentRect.width) && (prev === null || prev === void 0 ? void 0 : prev.tableWrapperHeight) === ((_entry$contentRect2 = entry.contentRect) === null || _entry$contentRect2 === void 0 ? void 0 : _entry$contentRect2.height) ? prev : {
309
+ ...prev,
310
+ tableWrapperWidth: entry.contentRect.width,
311
+ tableWrapperHeight: entry.contentRect.height
312
+ };
313
+ });
314
+ }
315
+ });
296
316
 
297
317
  // Disable inline table editing and resizing controls in Firefox
298
318
  // https://github.com/ProseMirror/prosemirror/issues/432
@@ -351,10 +371,13 @@ class TableComponent extends React.Component {
351
371
  this.onStickyState(currentStickyState);
352
372
  }
353
373
  eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
354
- const initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
355
- this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
374
+ if (isOverflowAnalyticsEnabled) {
375
+ const initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
376
+ this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
377
+ }
356
378
  }
357
379
  componentWillUnmount() {
380
+ var _this$resizeObserver;
358
381
  const {
359
382
  allowColumnResizing,
360
383
  eventDispatcher,
@@ -368,6 +391,7 @@ class TableComponent extends React.Component {
368
391
  if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
369
392
  this.dragAndDropCleanupFn();
370
393
  }
394
+ (_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 ? void 0 : _this$resizeObserver.disconnect();
371
395
  const {
372
396
  stickyScrollbar
373
397
  } = getEditorFeatureFlags();
@@ -500,29 +524,37 @@ class TableComponent extends React.Component {
500
524
  }
501
525
  this.handleTableResizingDebounced();
502
526
  }
503
- const newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
504
- const prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
505
- if (this.initialOverflowCaptureTimerId) {
506
- clearTimeout(this.initialOverflowCaptureTimerId);
507
- }
508
- if (!this.isInitialOverflowSent) {
509
- this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
527
+ if (isOverflowAnalyticsEnabled) {
528
+ const newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
529
+ const prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
530
+ if (this.initialOverflowCaptureTimerId) {
531
+ clearTimeout(this.initialOverflowCaptureTimerId);
532
+ }
533
+ if (!this.isInitialOverflowSent) {
534
+ this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
535
+ }
536
+ if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
537
+ var _this$state2;
538
+ const {
539
+ dispatch,
540
+ state: {
541
+ tr
542
+ }
543
+ } = this.props.view;
544
+ dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
545
+ isOverflowing: newIsOverflowing,
546
+ wasOverflowing: prevIsOverflowing,
547
+ editorWidth: this.props.containerWidth.width || 0,
548
+ width: this.node.attrs.width || 0,
549
+ parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
550
+ }));
551
+ }
510
552
  }
511
- if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
512
- var _this$state2;
513
- const {
514
- dispatch,
515
- state: {
516
- tr
517
- }
518
- } = this.props.view;
519
- dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
520
- isOverflowing: newIsOverflowing,
521
- wasOverflowing: prevIsOverflowing,
522
- editorWidth: this.props.containerWidth.width || 0,
523
- width: this.node.attrs.width || 0,
524
- parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
525
- }));
553
+ }
554
+ observeTable(table) {
555
+ if (table) {
556
+ var _this$resizeObserver2;
557
+ (_this$resizeObserver2 = this.resizeObserver) === null || _this$resizeObserver2 === void 0 ? void 0 : _this$resizeObserver2.observe(table);
526
558
  }
527
559
  }
528
560
  render() {
@@ -578,7 +610,8 @@ class TableComponent extends React.Component {
578
610
  ,
579
611
  selection: view.state.selection,
580
612
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
581
- stickyHeader: this.state.stickyHeader
613
+ stickyHeader: this.state.stickyHeader,
614
+ tableWrapperWidth: this.state.tableWrapperWidth
582
615
  });
583
616
  const tableContainerWidth = getTableContainerWidth(node);
584
617
  const colControls = isDragAndDropEnabled ? /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
@@ -604,7 +637,8 @@ class TableComponent extends React.Component {
604
637
  getScrollOffset: () => {
605
638
  var _this$wrapper2;
606
639
  return ((_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.scrollLeft) || 0;
607
- }
640
+ },
641
+ tableWrapperHeight: this.state.tableWrapperHeight
608
642
  }) : null;
609
643
  const shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
610
644
  const shadowStyle = memoizeOne(visible => ({
@@ -642,6 +676,7 @@ class TableComponent extends React.Component {
642
676
  isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
643
677
  isNested: isNested,
644
678
  pluginInjectionApi: pluginInjectionApi,
679
+ tableWrapperHeight: this.state.tableWrapperHeight,
645
680
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
646
681
  isResizing: isResizing,
647
682
  isTableScalingEnabled: isTableScalingEnabled
@@ -682,6 +717,7 @@ class TableComponent extends React.Component {
682
717
  if (tableElement !== this.table) {
683
718
  this.table = tableElement;
684
719
  this.createShadowSentinels(this.table);
720
+ this.observeTable(this.table);
685
721
  }
686
722
  }
687
723
  }
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useCallback, useRef } from 'react';
1
+ import React, { forwardRef, useCallback, useRef, useState } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
4
4
  import { calcTableWidth } from '@atlaskit/editor-common/styles';
@@ -42,10 +42,12 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
42
42
  tableRef,
43
43
  isResizing,
44
44
  pluginInjectionApi,
45
- isTableScalingEnabled
45
+ isTableScalingEnabled,
46
+ tableWrapperHeight
46
47
  }) => {
47
48
  const containerRef = useRef(null);
48
49
  const tableWidthRef = useRef(akEditorDefaultLayoutWidth);
50
+ const [resizing, setIsResizing] = useState(false);
49
51
  const updateContainerHeight = useCallback(height => {
50
52
  var _containerRef$current;
51
53
  // current StickyHeader State is not stable to be fetch.
@@ -53,31 +55,24 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
53
55
  // consistently fetch and refactor below
54
56
  const stickyHeaders = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getElementsByClassName('pm-table-sticky');
55
57
  if (!stickyHeaders || stickyHeaders.length < 1) {
56
- var _containerRef$current2;
57
58
  // when starting to drag, we need to keep the original space,
58
59
  // -- When sticky header not appear, margin top(24px) and margin bottom(16px), should be 40px,
59
60
  // 1px is border width but collapse make it 0.5.
60
61
  // -- When sticky header appear, we should add first row height but reduce
61
62
  // collapsed border
62
- (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.style.setProperty('height', typeof height === 'number' ? `${height + 40.5}px` : 'auto');
63
+ return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
63
64
  } else {
64
- var _containerRef$current3, _containerRef$current4;
65
- const stickyHeaderHeight = ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
66
- (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.style.setProperty('height', typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto');
65
+ var _containerRef$current2;
66
+ const stickyHeaderHeight = ((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.getElementsByTagName('th')[0].getBoundingClientRect().height) || 0;
67
+ return typeof height === 'number' ? `${height + stickyHeaderHeight + 39.5}px` : 'auto';
67
68
  }
68
69
  }, []);
69
- const resizeObserverRef = useRef(new ResizeObserver(entries => {
70
- updateContainerHeight(entries[entries.length - 1].contentRect.height);
71
- }));
72
70
  const onResizeStart = useCallback(() => {
73
- if (tableRef) {
74
- resizeObserverRef.current.observe(tableRef);
75
- }
76
- }, [tableRef]);
71
+ setIsResizing(true);
72
+ }, []);
77
73
  const onResizeStop = useCallback(() => {
78
- updateContainerHeight('auto');
79
- resizeObserverRef.current.disconnect();
80
- }, [updateContainerHeight]);
74
+ setIsResizing(false);
75
+ }, []);
81
76
  const updateWidth = useCallback(width => {
82
77
  if (!containerRef.current) {
83
78
  return;
@@ -141,7 +136,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
141
136
  }
142
137
  }, /*#__PURE__*/React.createElement("div", {
143
138
  style: {
144
- width: tableWidthRef.current
139
+ width: tableWidthRef.current,
140
+ height: resizing ? updateContainerHeight(tableWrapperHeight !== null && tableWrapperHeight !== void 0 ? tableWrapperHeight : 'auto') : 'auto'
145
141
  },
146
142
  className: ClassName.TABLE_RESIZER_CONTAINER,
147
143
  ref: containerRef
@@ -164,6 +160,7 @@ export const TableContainer = ({
164
160
  getPos,
165
161
  tableRef,
166
162
  isNested,
163
+ tableWrapperHeight,
167
164
  isResizing,
168
165
  pluginInjectionApi,
169
166
  isTableScalingEnabled
@@ -176,6 +173,7 @@ export const TableContainer = ({
176
173
  editorView: editorView,
177
174
  getPos: getPos,
178
175
  tableRef: tableRef,
176
+ tableWrapperHeight: tableWrapperHeight,
179
177
  isResizing: isResizing,
180
178
  pluginInjectionApi: pluginInjectionApi,
181
179
  isTableScalingEnabled: isTableScalingEnabled
@@ -51,7 +51,7 @@ const getResizerHandleHeight = tableRef => {
51
51
  };
52
52
  const getResizerMinWidth = node => {
53
53
  const currentColumnCount = getColgroupChildrenLength(node);
54
- const minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * COLUMN_MIN_WIDTH : 3 * COLUMN_MIN_WIDTH;
54
+ const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
55
55
  // add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
56
56
  // the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
57
57
  return minColumnWidth + 1;
@@ -49,11 +49,10 @@ const tablesPlugin = ({
49
49
  current: null
50
50
  };
51
51
  const defaultGetEditorContainerWidth = () => {
52
- var _document$body$offset, _document, _document$body, _api$width$sharedStat, _api$width;
53
- const defaultState = {
52
+ var _api$width$sharedStat, _api$width, _document$body$offset, _document, _document$body;
53
+ return (_api$width$sharedStat = api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState()) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : {
54
54
  width: (_document$body$offset = (_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) !== null && _document$body$offset !== void 0 ? _document$body$offset : 500
55
55
  };
56
- return (_api$width$sharedStat = api === null || api === void 0 ? void 0 : (_api$width = api.width) === null || _api$width === void 0 ? void 0 : _api$width.sharedState.currentState()) !== null && _api$width$sharedStat !== void 0 ? _api$width$sharedStat : defaultState;
57
56
  };
58
57
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
59
58
  return {
@@ -23,7 +23,6 @@ import { defaultHoveredCell, defaultTableSelection } from './default-table-selec
23
23
  import { createPluginState, getPluginState } from './plugin-factory';
24
24
  import { pluginKey } from './plugin-key';
25
25
  export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled) => {
26
- var _window;
27
26
  const state = createPluginState(dispatch, {
28
27
  pluginConfig,
29
28
  isTableHovered: false,
@@ -41,15 +40,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
41
40
  ...defaultTableSelection,
42
41
  getIntl
43
42
  });
44
- let elementContentRects = {};
45
- const observer = (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(entries => {
46
- entries.forEach(entry => {
47
- if (!entry.target.id) {
48
- return;
49
- }
50
- elementContentRects[entry.target.id] = entry.contentRect;
51
- });
52
- }) : undefined;
53
43
 
54
44
  // Used to prevent invalid table cell spans being reported more than once per editor/document
55
45
  const invalidTableIds = [];
@@ -151,11 +141,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
151
141
  } else if (pluginState.isResizeHandleWidgetAdded) {
152
142
  removeResizeHandleDecorations()(state, dispatch);
153
143
  }
154
- },
155
- destroy: () => {
156
- if (observer) {
157
- observer.disconnect();
158
- }
159
144
  }
160
145
  };
161
146
  },
@@ -264,8 +249,8 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
264
249
  nodeViews: {
265
250
  table: (node, view, getPos) => createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi),
266
251
  tableRow: (node, view, getPos) => new TableRow(node, view, getPos, eventDispatcher),
267
- tableCell: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher, observer),
268
- tableHeader: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher, observer)
252
+ tableCell: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher),
253
+ tableHeader: (node, view, getPos) => new TableCell(node, view, getPos, eventDispatcher)
269
254
  },
270
255
  handleDOMEvents: {
271
256
  focus: handleFocus,
@@ -274,7 +259,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
274
259
  mouseover: withCellTracking(whenTableInFocus(handleMouseOver)),
275
260
  mouseleave: handleMouseLeave,
276
261
  mouseout: whenTableInFocus(handleMouseOut),
277
- mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
262
+ mousemove: whenTableInFocus(handleMouseMove),
278
263
  mouseenter: handleMouseEnter,
279
264
  mouseup: whenTableInFocus(handleMouseUp),
280
265
  click: withCellTracking(whenTableInFocus(handleClick))
@@ -18,37 +18,15 @@ export const TableFloatingColumnControls = ({
18
18
  isTableHovered,
19
19
  tableContainerWidth,
20
20
  isNumberColumnEnabled,
21
- getScrollOffset
21
+ getScrollOffset,
22
+ tableWrapperHeight
22
23
  }) => {
23
- const [tableRect, setTableRect] = useState({
24
- width: 0,
25
- height: 0
26
- });
27
24
  const [isDragging, setIsDragging] = useState(false);
28
25
  const containerRef = useRef(null);
29
26
  const node = getNode();
30
27
  const currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
31
28
  const hasHeaderColumn = containsHeaderColumn(node);
32
29
  const stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
33
- useEffect(() => {
34
- var _window;
35
- if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
36
- const resizeObserver = new ResizeObserver(entries => {
37
- for (let entry of entries) {
38
- setTableRect(prev => {
39
- if (prev.width !== entry.contentRect.width || prev.height !== entry.contentRect.height) {
40
- return entry.contentRect;
41
- }
42
- return prev;
43
- });
44
- }
45
- });
46
- resizeObserver.observe(tableRef);
47
- return () => {
48
- resizeObserver.disconnect();
49
- };
50
- }
51
- }, [tableRef]);
52
30
  useEffect(() => {
53
31
  return monitorForElements({
54
32
  canMonitor({
@@ -71,11 +49,11 @@ export const TableFloatingColumnControls = ({
71
49
  }, [editorView, currentNodeLocalId]);
72
50
  const rowHeights = useMemo(() => {
73
51
  // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
74
- if (tableRef && !!tableRect.height) {
52
+ if (tableRef && !!tableWrapperHeight) {
75
53
  return getRowHeights(tableRef);
76
54
  }
77
55
  return [0];
78
- }, [tableRef, tableRect.height]);
56
+ }, [tableRef, tableWrapperHeight]);
79
57
  if (!tableRef || !tableActive || isResizing) {
80
58
  return null;
81
59
  }
@@ -112,7 +90,7 @@ export const TableFloatingColumnControls = ({
112
90
  }), isDragging && /*#__PURE__*/React.createElement(ColumnDropTargets, {
113
91
  tableRef: tableRef,
114
92
  isHeaderSticky: (stickyHeader === null || stickyHeader === void 0 ? void 0 : stickyHeader.sticky) && hasHeaderRow,
115
- tableHeight: tableRect.height,
93
+ tableHeight: tableWrapperHeight,
116
94
  localId: currentNodeLocalId,
117
95
  colWidths: colWidths,
118
96
  getScrollOffset: getScrollOffset