@atlaskit/editor-plugin-table 7.5.4 → 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 (236) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/commands/column-resize.js +3 -3
  3. package/dist/cjs/commands/delete.js +2 -2
  4. package/dist/cjs/commands/insert.js +15 -15
  5. package/dist/cjs/commands-with-analytics.js +7 -7
  6. package/dist/cjs/event-handlers.js +27 -11
  7. package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
  8. package/dist/cjs/nodeviews/TableCell.js +5 -30
  9. package/dist/cjs/nodeviews/TableComponent.js +120 -83
  10. package/dist/cjs/nodeviews/TableContainer.js +23 -21
  11. package/dist/cjs/nodeviews/TableResizer.js +13 -13
  12. package/dist/cjs/nodeviews/table.js +9 -9
  13. package/dist/cjs/plugin.js +60 -59
  14. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
  15. package/dist/cjs/pm-plugins/keymap.js +6 -8
  16. package/dist/cjs/pm-plugins/main.js +7 -24
  17. package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
  18. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
  19. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  20. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
  21. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
  22. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
  23. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
  24. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
  25. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  26. package/dist/cjs/pm-plugins/table-width.js +6 -2
  27. package/dist/cjs/toolbar.js +21 -21
  28. package/dist/cjs/transforms/column-width.js +4 -4
  29. package/dist/cjs/transforms/delete-columns.js +2 -2
  30. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
  31. package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
  32. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
  33. package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
  34. package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
  35. package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
  36. package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
  37. package/dist/cjs/utils/column-controls.js +5 -5
  38. package/dist/cjs/utils/create.js +2 -5
  39. package/dist/cjs/utils/dom.js +13 -15
  40. package/dist/cjs/utils/drag-menu.js +4 -4
  41. package/dist/es2019/commands/column-resize.js +3 -3
  42. package/dist/es2019/commands/delete.js +2 -2
  43. package/dist/es2019/commands/insert.js +12 -12
  44. package/dist/es2019/commands-with-analytics.js +6 -6
  45. package/dist/es2019/event-handlers.js +27 -11
  46. package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
  47. package/dist/es2019/nodeviews/TableCell.js +1 -24
  48. package/dist/es2019/nodeviews/TableComponent.js +88 -63
  49. package/dist/es2019/nodeviews/TableContainer.js +20 -22
  50. package/dist/es2019/nodeviews/TableResizer.js +13 -13
  51. package/dist/es2019/nodeviews/table.js +9 -9
  52. package/dist/es2019/plugin.js +19 -20
  53. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
  54. package/dist/es2019/pm-plugins/keymap.js +5 -8
  55. package/dist/es2019/pm-plugins/main.js +6 -23
  56. package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
  57. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
  58. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  59. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
  60. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
  61. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
  62. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
  63. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
  64. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  65. package/dist/es2019/pm-plugins/table-width.js +6 -2
  66. package/dist/es2019/toolbar.js +15 -15
  67. package/dist/es2019/transforms/column-width.js +5 -5
  68. package/dist/es2019/transforms/delete-columns.js +2 -2
  69. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
  70. package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
  71. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
  72. package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
  73. package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
  74. package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
  75. package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
  76. package/dist/es2019/utils/column-controls.js +6 -6
  77. package/dist/es2019/utils/create.js +2 -5
  78. package/dist/es2019/utils/dom.js +13 -15
  79. package/dist/es2019/utils/drag-menu.js +4 -4
  80. package/dist/esm/commands/column-resize.js +3 -3
  81. package/dist/esm/commands/delete.js +2 -2
  82. package/dist/esm/commands/insert.js +15 -15
  83. package/dist/esm/commands-with-analytics.js +7 -7
  84. package/dist/esm/event-handlers.js +27 -11
  85. package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
  86. package/dist/esm/nodeviews/TableCell.js +5 -30
  87. package/dist/esm/nodeviews/TableComponent.js +119 -82
  88. package/dist/esm/nodeviews/TableContainer.js +24 -22
  89. package/dist/esm/nodeviews/TableResizer.js +13 -13
  90. package/dist/esm/nodeviews/table.js +9 -9
  91. package/dist/esm/plugin.js +60 -59
  92. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
  93. package/dist/esm/pm-plugins/keymap.js +6 -8
  94. package/dist/esm/pm-plugins/main.js +7 -24
  95. package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
  96. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
  97. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  98. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
  99. package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
  100. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
  101. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
  102. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
  103. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  104. package/dist/esm/pm-plugins/table-width.js +6 -2
  105. package/dist/esm/toolbar.js +21 -21
  106. package/dist/esm/transforms/column-width.js +5 -5
  107. package/dist/esm/transforms/delete-columns.js +2 -2
  108. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
  109. package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
  110. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
  111. package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
  112. package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
  113. package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
  114. package/dist/esm/ui/TableFloatingControls/index.js +113 -224
  115. package/dist/esm/utils/column-controls.js +6 -6
  116. package/dist/esm/utils/create.js +2 -5
  117. package/dist/esm/utils/dom.js +13 -15
  118. package/dist/esm/utils/drag-menu.js +4 -4
  119. package/dist/types/commands/column-resize.d.ts +1 -1
  120. package/dist/types/commands/delete.d.ts +1 -1
  121. package/dist/types/commands/insert.d.ts +7 -7
  122. package/dist/types/commands-with-analytics.d.ts +3 -3
  123. package/dist/types/event-handlers.d.ts +4 -5
  124. package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  125. package/dist/types/nodeviews/TableCell.d.ts +1 -5
  126. package/dist/types/nodeviews/TableComponent.d.ts +6 -3
  127. package/dist/types/nodeviews/TableContainer.d.ts +6 -4
  128. package/dist/types/nodeviews/TableResizer.d.ts +2 -2
  129. package/dist/types/nodeviews/table.d.ts +1 -1
  130. package/dist/types/nodeviews/types.d.ts +1 -0
  131. package/dist/types/plugin.d.ts +1 -0
  132. package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
  133. package/dist/types/pm-plugins/keymap.d.ts +2 -2
  134. package/dist/types/pm-plugins/main.d.ts +1 -1
  135. package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
  136. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
  137. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  138. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  139. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  140. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
  141. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
  142. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  143. package/dist/types/pm-plugins/table-width.d.ts +1 -2
  144. package/dist/types/toolbar.d.ts +2 -2
  145. package/dist/types/transforms/column-width.d.ts +1 -1
  146. package/dist/types/transforms/delete-columns.d.ts +1 -1
  147. package/dist/types/types.d.ts +1 -3
  148. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  149. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
  150. package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
  151. package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
  152. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
  153. package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
  154. package/dist/types/utils/create.d.ts +1 -2
  155. package/dist/types/utils/dom.d.ts +10 -2
  156. package/dist/types/utils/drag-menu.d.ts +1 -1
  157. package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
  158. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  159. package/dist/types-ts4.5/commands/insert.d.ts +7 -7
  160. package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
  161. package/dist/types-ts4.5/event-handlers.d.ts +4 -5
  162. package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  163. package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
  164. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +6 -3
  165. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +6 -4
  166. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
  167. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
  168. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  169. package/dist/types-ts4.5/plugin.d.ts +1 -0
  170. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
  171. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
  172. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  173. package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
  174. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
  175. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  176. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  177. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  178. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
  179. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
  180. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  181. package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
  182. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  183. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  184. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  185. package/dist/types-ts4.5/types.d.ts +1 -3
  186. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  187. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
  188. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
  189. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
  190. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
  191. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
  192. package/dist/types-ts4.5/utils/create.d.ts +1 -2
  193. package/dist/types-ts4.5/utils/dom.d.ts +10 -2
  194. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  195. package/package.json +3 -4
  196. package/src/commands/column-resize.ts +4 -3
  197. package/src/commands/delete.ts +2 -2
  198. package/src/commands/insert.ts +15 -27
  199. package/src/commands-with-analytics.ts +6 -9
  200. package/src/event-handlers.ts +107 -105
  201. package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
  202. package/src/nodeviews/TableCell.ts +0 -26
  203. package/src/nodeviews/TableComponent.tsx +107 -78
  204. package/src/nodeviews/TableContainer.tsx +26 -32
  205. package/src/nodeviews/TableResizer.tsx +15 -18
  206. package/src/nodeviews/table.tsx +6 -5
  207. package/src/nodeviews/types.ts +1 -0
  208. package/src/plugin.tsx +17 -32
  209. package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
  210. package/src/pm-plugins/keymap.ts +6 -13
  211. package/src/pm-plugins/main.ts +6 -25
  212. package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
  213. package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
  214. package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
  215. package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
  216. package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
  217. package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
  218. package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
  219. package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
  220. package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
  221. package/src/pm-plugins/table-width.ts +4 -6
  222. package/src/toolbar.tsx +16 -19
  223. package/src/transforms/column-width.ts +7 -6
  224. package/src/transforms/delete-columns.ts +2 -2
  225. package/src/types.ts +1 -4
  226. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
  227. package/src/ui/FloatingContextualMenu/index.tsx +0 -2
  228. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
  229. package/src/ui/FloatingDragMenu/index.tsx +4 -8
  230. package/src/ui/FloatingInsertButton/index.tsx +11 -22
  231. package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
  232. package/src/ui/TableFloatingControls/index.tsx +155 -241
  233. package/src/utils/column-controls.ts +5 -6
  234. package/src/utils/create.ts +2 -5
  235. package/src/utils/dom.ts +12 -19
  236. package/src/utils/drag-menu.ts +7 -12
@@ -6,7 +6,7 @@ import rafSchedule from 'raf-schd';
6
6
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
7
7
  import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
8
8
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
9
- import { browser, calcTableColumnWidths, isValidPosition } from '@atlaskit/editor-common/utils';
9
+ import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
10
10
  import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
11
11
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
12
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -18,6 +18,7 @@ import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '.
18
18
  import { META_KEYS } from '../pm-plugins/table-analytics';
19
19
  import { COLUMN_MIN_WIDTH, getLayoutSize, getResizeState, insertColgroupFromNode, scaleTable, updateColgroup } from '../pm-plugins/table-resizing/utils';
20
20
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
21
+ import { TABLE_EDITOR_MARGIN } from '../pm-plugins/table-resizing/utils/consts';
21
22
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
22
23
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
23
24
  import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
@@ -33,6 +34,12 @@ const isIE11 = browser.ie_version === 11;
33
34
  // componentDidUpdate is called multiple times. The isOverflowing value is correct only on the last update.
34
35
  // To make sure we capture the last update, we use setTimeout.
35
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;
36
43
  class TableComponent extends React.Component {
37
44
  constructor(props) {
38
45
  super(props);
@@ -40,7 +47,9 @@ class TableComponent extends React.Component {
40
47
  scroll: 0,
41
48
  parentWidth: undefined,
42
49
  [ShadowEvent.SHOW_BEFORE_SHADOW]: false,
43
- [ShadowEvent.SHOW_AFTER_SHADOW]: false
50
+ [ShadowEvent.SHOW_AFTER_SHADOW]: false,
51
+ tableWrapperWidth: undefined,
52
+ tableWrapperHeight: undefined
44
53
  });
45
54
  _defineProperty(this, "updateShadowState", (shadowKey, value) => {
46
55
  if (this.state[shadowKey] === value) {
@@ -161,7 +170,7 @@ class TableComponent extends React.Component {
161
170
  getPos,
162
171
  containerWidth,
163
172
  options,
164
- getEditorFeatureFlags
173
+ isTableScalingEnabled
165
174
  } = this.props;
166
175
  const node = getNode();
167
176
  const {
@@ -177,9 +186,6 @@ class TableComponent extends React.Component {
177
186
  width
178
187
  } = containerWidth;
179
188
  this.scaleTableDebounced.cancel();
180
- const {
181
- tablePreserveWidth = false
182
- } = getEditorFeatureFlags();
183
189
  const tr = scaleTable(this.table, {
184
190
  ...scaleOptions,
185
191
  node,
@@ -188,7 +194,7 @@ class TableComponent extends React.Component {
188
194
  containerWidth: width,
189
195
  previousContainerWidth: this.containerWidth.width || width,
190
196
  ...options
191
- }, domAtPos, tablePreserveWidth)(state.tr);
197
+ }, domAtPos, isTableScalingEnabled)(state.tr);
192
198
  dispatch(tr);
193
199
  });
194
200
  _defineProperty(this, "setTimerToSendInitialOverflowCaptured", isOverflowing => {
@@ -295,6 +301,18 @@ class TableComponent extends React.Component {
295
301
  this.layoutSize = this.tableNodeLayoutSize(this.node, _containerWidth.width, {
296
302
  isFullWidthModeEnabled
297
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
+ });
298
316
 
299
317
  // Disable inline table editing and resizing controls in Firefox
300
318
  // https://github.com/ProseMirror/prosemirror/issues/432
@@ -313,8 +331,12 @@ class TableComponent extends React.Component {
313
331
  options,
314
332
  isDragAndDropEnabled,
315
333
  getNode,
316
- getEditorFeatureFlags
334
+ getEditorFeatureFlags,
335
+ isTableScalingEnabled
317
336
  } = this.props;
337
+ if (isTableScalingEnabled) {
338
+ this.handleColgroupUpdates(true);
339
+ }
318
340
  if (allowColumnResizing && this.wrapper && !isIE11) {
319
341
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
320
342
  passive: true
@@ -349,10 +371,13 @@ class TableComponent extends React.Component {
349
371
  this.onStickyState(currentStickyState);
350
372
  }
351
373
  eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
352
- const initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
353
- 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
+ }
354
378
  }
355
379
  componentWillUnmount() {
380
+ var _this$resizeObserver;
356
381
  const {
357
382
  allowColumnResizing,
358
383
  eventDispatcher,
@@ -366,6 +391,7 @@ class TableComponent extends React.Component {
366
391
  if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
367
392
  this.dragAndDropCleanupFn();
368
393
  }
394
+ (_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 ? void 0 : _this$resizeObserver.disconnect();
369
395
  const {
370
396
  stickyScrollbar
371
397
  } = getEditorFeatureFlags();
@@ -392,24 +418,22 @@ class TableComponent extends React.Component {
392
418
  clearTimeout(this.initialOverflowCaptureTimerId);
393
419
  }
394
420
  }
395
- handleColgroupUpdates() {
421
+ handleColgroupUpdates(force = false) {
396
422
  var _this$containerWidth;
397
423
  const {
398
424
  getNode,
399
425
  containerWidth,
400
426
  isResizing,
401
427
  view,
402
- getPos,
403
- tableRef
428
+ getPos
404
429
  } = this.props;
405
- if (!tableRef) {
430
+ if (!this.table) {
406
431
  return;
407
432
  }
408
- const TABLE_MARGIN = 76;
409
433
 
410
434
  // Remove any widths styles after resizing preview is completed
411
- tableRef.style.width = '';
412
- const tableRenderWidth = containerWidth.width - TABLE_MARGIN;
435
+ this.table.style.width = '';
436
+ const tableRenderWidth = containerWidth.width - TABLE_EDITOR_MARGIN;
413
437
  const tableNode = getNode();
414
438
  const start = getPos() || 0;
415
439
  const depth = view.state.doc.resolve(start).depth;
@@ -421,17 +445,12 @@ class TableComponent extends React.Component {
421
445
  const {
422
446
  width: tableNodeWidth
423
447
  } = tableNode.attrs;
424
- const tableColumnWidths = calcTableColumnWidths(tableNode);
425
448
  const shouldTableScale = tableRenderWidth < tableNodeWidth;
426
- let isTableColumnWidthsSame = false;
427
- if (this.tableColumnWidths) {
428
- isTableColumnWidthsSame = tableColumnWidths === null || tableColumnWidths === void 0 ? void 0 : tableColumnWidths.every((width, index) => width === this.tableColumnWidths[index]);
429
- }
430
449
  const {
431
450
  width: containerWidthValue
432
451
  } = containerWidth;
433
452
  const isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
434
- if (shouldTableScale && !isResizing && (!isTableColumnWidthsSame || isWidthChanged)) {
453
+ if (force || shouldTableScale && !isResizing && isWidthChanged) {
435
454
  const resizeState = getResizeState({
436
455
  minWidth: COLUMN_MIN_WIDTH,
437
456
  maxSize: tableRenderWidth,
@@ -439,14 +458,11 @@ class TableComponent extends React.Component {
439
458
  tableRef: this.table,
440
459
  start,
441
460
  domAtPos: view.domAtPos,
442
- tablePreserveWidth: true
461
+ isTableScalingEnabled: true
443
462
  });
444
- requestAnimationFrame(() => {
445
- updateColgroup(resizeState, this.table, true);
446
- });
447
- this.tableColumnWidths = tableColumnWidths;
448
- this.containerWidth = containerWidth;
463
+ updateColgroup(resizeState, this.table, tableNode, true);
449
464
  }
465
+ this.containerWidth = containerWidth;
450
466
  }
451
467
  componentDidUpdate(_, prevState) {
452
468
  var _this$wrapper;
@@ -457,16 +473,13 @@ class TableComponent extends React.Component {
457
473
  allowColumnResizing,
458
474
  isResizing,
459
475
  options,
460
- getEditorFeatureFlags
476
+ isTableScalingEnabled
461
477
  } = this.props;
462
478
  const {
463
479
  isInDanger
464
480
  } = getPluginState(view.state);
465
- const {
466
- tablePreserveWidth = false
467
- } = getEditorFeatureFlags();
468
481
  const table = findTable(view.state.selection);
469
- if (tablePreserveWidth) {
482
+ if (isTableScalingEnabled) {
470
483
  this.handleColgroupUpdates();
471
484
  }
472
485
  if (isInDanger && !table) {
@@ -505,35 +518,43 @@ class TableComponent extends React.Component {
505
518
  } = this.props;
506
519
  const shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
507
520
  if (shouldRecreateResizeCols) {
508
- insertColgroupFromNode(this.table, currentTable, tablePreserveWidth);
521
+ insertColgroupFromNode(this.table, currentTable, isTableScalingEnabled);
509
522
  }
510
523
  updateControls()(view.state);
511
524
  }
512
525
  this.handleTableResizingDebounced();
513
526
  }
514
- const newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
515
- const prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
516
- if (this.initialOverflowCaptureTimerId) {
517
- clearTimeout(this.initialOverflowCaptureTimerId);
518
- }
519
- if (!this.isInitialOverflowSent) {
520
- 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
+ }
521
552
  }
522
- if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
523
- var _this$state2;
524
- const {
525
- dispatch,
526
- state: {
527
- tr
528
- }
529
- } = this.props.view;
530
- dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
531
- isOverflowing: newIsOverflowing,
532
- wasOverflowing: prevIsOverflowing,
533
- editorWidth: this.props.containerWidth.width || 0,
534
- width: this.node.attrs.width || 0,
535
- parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
536
- }));
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);
537
558
  }
538
559
  }
539
560
  render() {
@@ -551,7 +572,8 @@ class TableComponent extends React.Component {
551
572
  getPos,
552
573
  pluginInjectionApi,
553
574
  isDragAndDropEnabled,
554
- getEditorFeatureFlags
575
+ getEditorFeatureFlags,
576
+ isTableScalingEnabled
555
577
  } = this.props;
556
578
  const {
557
579
  showBeforeShadow,
@@ -588,7 +610,8 @@ class TableComponent extends React.Component {
588
610
  ,
589
611
  selection: view.state.selection,
590
612
  headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
591
- stickyHeader: this.state.stickyHeader
613
+ stickyHeader: this.state.stickyHeader,
614
+ tableWrapperWidth: this.state.tableWrapperWidth
592
615
  });
593
616
  const tableContainerWidth = getTableContainerWidth(node);
594
617
  const colControls = isDragAndDropEnabled ? /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
@@ -614,7 +637,8 @@ class TableComponent extends React.Component {
614
637
  getScrollOffset: () => {
615
638
  var _this$wrapper2;
616
639
  return ((_this$wrapper2 = this.wrapper) === null || _this$wrapper2 === void 0 ? void 0 : _this$wrapper2.scrollLeft) || 0;
617
- }
640
+ },
641
+ tableWrapperHeight: this.state.tableWrapperHeight
618
642
  }) : null;
619
643
  const shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
620
644
  const shadowStyle = memoizeOne(visible => ({
@@ -635,8 +659,7 @@ class TableComponent extends React.Component {
635
659
  const isNested = isTableNested(view.state, tablePos);
636
660
  const topStickyShadowPosition = isDragAndDropEnabled ? this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + 2 : this.state.stickyHeader && this.state.stickyHeader.top + this.state.stickyHeader.padding + shadowPadding + 2;
637
661
  const {
638
- stickyScrollbar,
639
- tablePreserveWidth
662
+ stickyScrollbar
640
663
  } = getEditorFeatureFlags();
641
664
  return /*#__PURE__*/React.createElement(TableContainer, {
642
665
  className: classnames(ClassName.TABLE_CONTAINER, {
@@ -653,9 +676,10 @@ class TableComponent extends React.Component {
653
676
  isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
654
677
  isNested: isNested,
655
678
  pluginInjectionApi: pluginInjectionApi,
679
+ tableWrapperHeight: this.state.tableWrapperHeight,
656
680
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
657
681
  isResizing: isResizing,
658
- tablePreserveWidth: tablePreserveWidth
682
+ isTableScalingEnabled: isTableScalingEnabled
659
683
  }, /*#__PURE__*/React.createElement("div", {
660
684
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
661
685
  "data-testid": "sticky-sentinel-top"
@@ -693,6 +717,7 @@ class TableComponent extends React.Component {
693
717
  if (tableElement !== this.table) {
694
718
  this.table = tableElement;
695
719
  this.createShadowSentinels(this.table);
720
+ this.observeTable(this.table);
696
721
  }
697
722
  }
698
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
- tablePreserveWidth
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;
@@ -107,7 +102,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
107
102
  }, [pluginInjectionApi]);
108
103
  const tableWidth = getTableContainerWidth(node);
109
104
  // 76 is currently an accepted padding value considering the spacing for resizer handle
110
- const responsiveContainerWidth = tablePreserveWidth ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
105
+ const responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide / 2 : containerWidth - akEditorGutterPadding * 2 - akEditorMediaResizeHandlerPaddingWide;
111
106
  const width = Math.min(tableWidth, responsiveContainerWidth);
112
107
  if (!isResizing) {
113
108
  tableWidthRef.current = width;
@@ -125,7 +120,7 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
125
120
  displayGuideline,
126
121
  attachAnalyticsEvent,
127
122
  displayGapCursor,
128
- tablePreserveWidth
123
+ isTableScalingEnabled
129
124
  };
130
125
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
131
126
  tableResizerProps = {
@@ -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,9 +160,10 @@ export const TableContainer = ({
164
160
  getPos,
165
161
  tableRef,
166
162
  isNested,
163
+ tableWrapperHeight,
167
164
  isResizing,
168
165
  pluginInjectionApi,
169
- tablePreserveWidth
166
+ isTableScalingEnabled
170
167
  }) => {
171
168
  if (isTableResizingEnabled && !isNested) {
172
169
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
@@ -176,9 +173,10 @@ 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
- tablePreserveWidth: tablePreserveWidth
179
+ isTableScalingEnabled: isTableScalingEnabled
182
180
  }, children);
183
181
  }
184
182
  const tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
@@ -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;
@@ -83,7 +83,7 @@ export const TableResizer = ({
83
83
  displayGuideline,
84
84
  attachAnalyticsEvent,
85
85
  displayGapCursor,
86
- tablePreserveWidth
86
+ isTableScalingEnabled
87
87
  }) => {
88
88
  var _findTable, _editorView$state;
89
89
  const currentGap = useRef(0);
@@ -130,13 +130,13 @@ export const TableResizer = ({
130
130
  }) => {
131
131
  if (gap !== currentGap.current) {
132
132
  currentGap.current = gap;
133
- const visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
133
+ const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
134
134
  displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, visibleGuidelines));
135
135
  }
136
- }, [tablePreserveWidth, containerWidth, displayGuideline]);
136
+ }, [isTableScalingEnabled, containerWidth, displayGuideline]);
137
137
  const guidelineSnaps = useMemo(() => snappingEnabled ? {
138
- x: tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
139
- } : undefined, [snappingEnabled, tablePreserveWidth, containerWidth]);
138
+ x: isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths
139
+ } : undefined, [snappingEnabled, isTableScalingEnabled, containerWidth]);
140
140
  useEffect(() => {
141
141
  return () => {
142
142
  // only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
@@ -174,12 +174,12 @@ export const TableResizer = ({
174
174
  name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED
175
175
  });
176
176
  dispatch(tr);
177
- const visibleGuidelines = getVisibleGuidelines(tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
177
+ const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
178
178
  setSnappingEnabled(displayGuideline(visibleGuidelines));
179
179
  if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
180
180
  onResizeStart();
181
181
  }
182
- }, [startMeasure, editorView, displayGapCursor, tablePreserveWidth, containerWidth, displayGuideline, onResizeStart]);
182
+ }, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
183
183
  const handleResize = useCallback((originalState, delta) => {
184
184
  countFrames();
185
185
  const newWidth = originalState.width + delta.width;
@@ -197,11 +197,11 @@ export const TableResizer = ({
197
197
  prevNode: node,
198
198
  start: pos + 1,
199
199
  parentWidth: newWidth
200
- }, editorView.domAtPos.bind(editorView), tablePreserveWidth);
201
- updateActiveGuidelines(findClosestSnap(newWidth, tablePreserveWidth ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, tablePreserveWidth ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
200
+ }, editorView.domAtPos.bind(editorView), isTableScalingEnabled);
201
+ updateActiveGuidelines(findClosestSnap(newWidth, isTableScalingEnabled ? defaultTablePreserveSnappingWidths(containerWidth) : defaultSnappingWidths, isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
202
202
  updateWidth(newWidth);
203
203
  return newWidth;
204
- }, [countFrames, tablePreserveWidth, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
204
+ }, [countFrames, isTableScalingEnabled, tableRef, node, editorView, updateActiveGuidelines, containerWidth, updateWidth, getPos]);
205
205
  const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
206
206
  const handleResizeStop = useCallback((originalState, delta) => {
207
207
  isResizing.current = false;
@@ -238,7 +238,7 @@ export const TableResizer = ({
238
238
  prevNode: node,
239
239
  start: pos + 1,
240
240
  parentWidth: newWidth
241
- }, editorView.domAtPos.bind(editorView), tablePreserveWidth)(tr);
241
+ }, editorView.domAtPos.bind(editorView), isTableScalingEnabled)(tr);
242
242
  const scaledNode = tr.doc.nodeAt(pos);
243
243
  (_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
244
244
  originalNode: node,
@@ -256,7 +256,7 @@ export const TableResizer = ({
256
256
  onResizeStop();
257
257
  }
258
258
  return newWidth;
259
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, tablePreserveWidth]);
259
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, isTableScalingEnabled]);
260
260
  const handleTableSizeChangeOnKeypress = useCallback(step => {
261
261
  const newWidth = width + step;
262
262
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -57,17 +57,15 @@ export default class TableView extends ReactNodeView {
57
57
  _defineProperty(this, "hasHoveredRows", false);
58
58
  this.getPos = props.getPos;
59
59
  this.eventDispatcher = props.eventDispatcher;
60
- this.getEditorFeatureFlags = props.getEditorFeatureFlags;
60
+ this.options = props.options;
61
61
  }
62
62
  getContentDOM() {
63
63
  const rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
64
64
  if (rendered.dom) {
65
+ var _this$options;
65
66
  this.table = rendered.dom;
66
- const {
67
- tablePreserveWidth = false
68
- } = this.getEditorFeatureFlags();
69
67
  // Preserve Table Width cannot have inline width set on the table
70
- if (!tablePreserveWidth) {
68
+ if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled)) {
71
69
  const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
72
70
  if (tableInlineWidth) {
73
71
  handleInlineTableWidth(this.table, tableInlineWidth);
@@ -157,6 +155,7 @@ export default class TableView extends ReactNodeView {
157
155
  isHeaderRowEnabled: pluginState.isHeaderRowEnabled,
158
156
  isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
159
157
  isDragAndDropEnabled: pluginState.isDragAndDropEnabled,
158
+ isTableScalingEnabled: pluginState.isTableScalingEnabled,
160
159
  tableActive: tableActive,
161
160
  ordering: pluginState.ordering,
162
161
  isResizing: isResizing,
@@ -165,8 +164,7 @@ export default class TableView extends ReactNodeView {
165
164
  contentDOM: forwardRef,
166
165
  getEditorFeatureFlags: props.getEditorFeatureFlags,
167
166
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
168
- pluginInjectionApi: props.pluginInjectionApi,
169
- tableRef: this.table
167
+ pluginInjectionApi: props.pluginInjectionApi
170
168
  });
171
169
  }
172
170
  });
@@ -234,7 +232,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
234
232
  isFullWidthModeEnabled,
235
233
  wasFullWidthModeEnabled,
236
234
  isTableResizingEnabled,
237
- isDragAndDropEnabled
235
+ isDragAndDropEnabled,
236
+ isTableScalingEnabled
238
237
  } = getPluginState(view.state);
239
238
  const {
240
239
  allowColumnResizing
@@ -252,7 +251,8 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
252
251
  isFullWidthModeEnabled,
253
252
  wasFullWidthModeEnabled,
254
253
  isTableResizingEnabled,
255
- isDragAndDropEnabled
254
+ isDragAndDropEnabled,
255
+ isTableScalingEnabled
256
256
  },
257
257
  getEditorContainerWidth,
258
258
  getEditorFeatureFlags,