@atlaskit/editor-plugin-table 7.4.8 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/commands/column-resize.js +4 -2
  3. package/dist/cjs/commands/delete.js +2 -1
  4. package/dist/cjs/commands/insert.js +6 -3
  5. package/dist/cjs/commands-with-analytics.js +4 -2
  6. package/dist/cjs/event-handlers.js +2 -1
  7. package/dist/cjs/nodeviews/TableComponent.js +116 -47
  8. package/dist/cjs/nodeviews/TableContainer.js +8 -4
  9. package/dist/cjs/nodeviews/TableResizer.js +6 -5
  10. package/dist/cjs/nodeviews/table.js +12 -4
  11. package/dist/cjs/plugin.js +50 -47
  12. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +9 -6
  13. package/dist/cjs/pm-plugins/keymap.js +6 -3
  14. package/dist/cjs/pm-plugins/main.js +4 -1
  15. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -3
  16. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -11
  17. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
  18. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +24 -0
  19. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +20 -1
  20. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +2 -1
  21. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +52 -11
  22. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +19 -8
  23. package/dist/cjs/toolbar.js +17 -10
  24. package/dist/cjs/transforms/column-width.js +22 -7
  25. package/dist/cjs/transforms/delete-columns.js +2 -1
  26. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
  27. package/dist/cjs/ui/FloatingContextualMenu/index.js +5 -3
  28. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +15 -4
  29. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +53 -8
  30. package/dist/cjs/ui/FloatingDragMenu/index.js +15 -6
  31. package/dist/cjs/ui/FloatingInsertButton/index.js +5 -1
  32. package/dist/cjs/ui/consts.js +2 -1
  33. package/dist/cjs/utils/create.js +1 -1
  34. package/dist/cjs/utils/drag-menu.js +4 -3
  35. package/dist/es2019/commands/column-resize.js +4 -3
  36. package/dist/es2019/commands/delete.js +2 -2
  37. package/dist/es2019/commands/insert.js +6 -6
  38. package/dist/es2019/commands-with-analytics.js +4 -4
  39. package/dist/es2019/event-handlers.js +2 -2
  40. package/dist/es2019/nodeviews/TableComponent.js +77 -8
  41. package/dist/es2019/nodeviews/TableContainer.js +8 -4
  42. package/dist/es2019/nodeviews/TableResizer.js +6 -5
  43. package/dist/es2019/nodeviews/table.js +12 -4
  44. package/dist/es2019/plugin.js +14 -8
  45. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +7 -4
  46. package/dist/es2019/pm-plugins/keymap.js +6 -3
  47. package/dist/es2019/pm-plugins/main.js +4 -1
  48. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +7 -3
  49. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +31 -12
  50. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
  51. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +2 -2
  52. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +20 -2
  53. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +2 -2
  54. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +47 -10
  55. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +19 -12
  56. package/dist/es2019/toolbar.js +15 -12
  57. package/dist/es2019/transforms/column-width.js +24 -10
  58. package/dist/es2019/transforms/delete-columns.js +2 -2
  59. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +12 -5
  60. package/dist/es2019/ui/FloatingContextualMenu/index.js +6 -4
  61. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +15 -4
  62. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +42 -8
  63. package/dist/es2019/ui/FloatingDragMenu/index.js +16 -7
  64. package/dist/es2019/ui/FloatingInsertButton/index.js +5 -1
  65. package/dist/es2019/ui/consts.js +1 -0
  66. package/dist/es2019/utils/create.js +1 -1
  67. package/dist/es2019/utils/drag-menu.js +4 -4
  68. package/dist/esm/commands/column-resize.js +4 -2
  69. package/dist/esm/commands/delete.js +2 -1
  70. package/dist/esm/commands/insert.js +6 -3
  71. package/dist/esm/commands-with-analytics.js +4 -2
  72. package/dist/esm/event-handlers.js +2 -1
  73. package/dist/esm/nodeviews/TableComponent.js +118 -49
  74. package/dist/esm/nodeviews/TableContainer.js +8 -4
  75. package/dist/esm/nodeviews/TableResizer.js +6 -5
  76. package/dist/esm/nodeviews/table.js +12 -4
  77. package/dist/esm/plugin.js +50 -47
  78. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +9 -6
  79. package/dist/esm/pm-plugins/keymap.js +6 -3
  80. package/dist/esm/pm-plugins/main.js +4 -1
  81. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +7 -3
  82. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -11
  83. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
  84. package/dist/esm/pm-plugins/table-resizing/utils/index.js +2 -2
  85. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +22 -2
  86. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +2 -1
  87. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +52 -11
  88. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +19 -8
  89. package/dist/esm/toolbar.js +17 -10
  90. package/dist/esm/transforms/column-width.js +23 -8
  91. package/dist/esm/transforms/delete-columns.js +2 -1
  92. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +45 -38
  93. package/dist/esm/ui/FloatingContextualMenu/index.js +6 -4
  94. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +15 -4
  95. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +50 -9
  96. package/dist/esm/ui/FloatingDragMenu/index.js +16 -7
  97. package/dist/esm/ui/FloatingInsertButton/index.js +5 -1
  98. package/dist/esm/ui/consts.js +1 -0
  99. package/dist/esm/utils/create.js +1 -1
  100. package/dist/esm/utils/drag-menu.js +4 -3
  101. package/dist/types/commands/column-resize.d.ts +1 -1
  102. package/dist/types/commands/delete.d.ts +1 -1
  103. package/dist/types/commands/insert.d.ts +3 -3
  104. package/dist/types/commands-with-analytics.d.ts +2 -2
  105. package/dist/types/event-handlers.d.ts +1 -1
  106. package/dist/types/nodeviews/TableComponent.d.ts +3 -0
  107. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  108. package/dist/types/nodeviews/TableResizer.d.ts +2 -1
  109. package/dist/types/nodeviews/table.d.ts +1 -0
  110. package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
  111. package/dist/types/pm-plugins/keymap.d.ts +2 -2
  112. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  113. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  114. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +2 -2
  115. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
  116. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
  117. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
  118. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  119. package/dist/types/toolbar.d.ts +2 -2
  120. package/dist/types/transforms/column-width.d.ts +1 -1
  121. package/dist/types/transforms/delete-columns.d.ts +1 -1
  122. package/dist/types/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  123. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  124. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +7 -1
  125. package/dist/types/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
  126. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -2
  127. package/dist/types/ui/FloatingInsertButton/index.d.ts +2 -1
  128. package/dist/types/ui/consts.d.ts +1 -0
  129. package/dist/types/utils/drag-menu.d.ts +1 -1
  130. package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
  131. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  132. package/dist/types-ts4.5/commands/insert.d.ts +3 -3
  133. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
  134. package/dist/types-ts4.5/event-handlers.d.ts +1 -1
  135. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +3 -0
  136. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  137. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
  138. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -0
  139. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +3 -2
  140. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
  141. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +2 -2
  142. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +2 -0
  143. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +2 -2
  144. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +7 -0
  145. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +1 -1
  146. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -3
  147. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  148. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  149. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  150. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  151. package/dist/types-ts4.5/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
  152. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  153. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +7 -1
  154. package/dist/types-ts4.5/ui/FloatingDragMenu/DropdownMenu.d.ts +8 -2
  155. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -2
  156. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +2 -1
  157. package/dist/types-ts4.5/ui/consts.d.ts +1 -0
  158. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  159. package/package.json +3 -3
  160. package/src/commands/column-resize.ts +3 -0
  161. package/src/commands/delete.ts +2 -1
  162. package/src/commands/insert.ts +15 -6
  163. package/src/commands-with-analytics.ts +9 -3
  164. package/src/event-handlers.ts +2 -0
  165. package/src/nodeviews/TableComponent.tsx +91 -5
  166. package/src/nodeviews/TableContainer.tsx +6 -0
  167. package/src/nodeviews/TableResizer.tsx +6 -0
  168. package/src/nodeviews/table.tsx +15 -10
  169. package/src/plugin.tsx +17 -5
  170. package/src/pm-plugins/drag-and-drop/plugin.ts +16 -8
  171. package/src/pm-plugins/keymap.ts +11 -3
  172. package/src/pm-plugins/main.ts +3 -0
  173. package/src/pm-plugins/table-resizing/event-handlers.ts +11 -1
  174. package/src/pm-plugins/table-resizing/utils/colgroup.ts +49 -17
  175. package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
  176. package/src/pm-plugins/table-resizing/utils/index.ts +8 -1
  177. package/src/pm-plugins/table-resizing/utils/misc.ts +25 -1
  178. package/src/pm-plugins/table-resizing/utils/resize-column.ts +2 -1
  179. package/src/pm-plugins/table-resizing/utils/resize-state.ts +56 -11
  180. package/src/pm-plugins/table-resizing/utils/scale-table.ts +24 -6
  181. package/src/toolbar.tsx +18 -5
  182. package/src/transforms/column-width.ts +33 -11
  183. package/src/transforms/delete-columns.ts +7 -2
  184. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +20 -5
  185. package/src/ui/FloatingContextualMenu/index.tsx +4 -1
  186. package/src/ui/FloatingDragMenu/DragMenu.tsx +19 -1
  187. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +94 -50
  188. package/src/ui/FloatingDragMenu/index.tsx +17 -4
  189. package/src/ui/FloatingInsertButton/index.tsx +17 -5
  190. package/src/ui/consts.ts +1 -0
  191. package/src/utils/create.ts +1 -3
  192. package/src/utils/drag-menu.ts +4 -1
@@ -17,7 +17,7 @@ import rafSchedule from 'raf-schd';
17
17
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
18
18
  import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
19
19
  import { tableMarginSides } from '@atlaskit/editor-common/styles';
20
- import { browser, isValidPosition } from '@atlaskit/editor-common/utils';
20
+ import { browser, calcTableColumnWidths, isValidPosition } from '@atlaskit/editor-common/utils';
21
21
  import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
22
22
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
23
23
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -27,7 +27,7 @@ import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils';
27
27
  import { getPluginState } from '../pm-plugins/plugin-factory';
28
28
  import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
29
29
  import { META_KEYS } from '../pm-plugins/table-analytics';
30
- import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scaleTable } from '../pm-plugins/table-resizing/utils';
30
+ import { COLUMN_MIN_WIDTH, getLayoutSize, getResizeState, insertColgroupFromNode, scaleTable, updateColgroup } from '../pm-plugins/table-resizing/utils';
31
31
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
32
32
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
33
33
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
@@ -168,7 +168,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
168
168
  getNode = _this$props2.getNode,
169
169
  getPos = _this$props2.getPos,
170
170
  containerWidth = _this$props2.containerWidth,
171
- options = _this$props2.options;
171
+ options = _this$props2.options,
172
+ getEditorFeatureFlags = _this$props2.getEditorFeatureFlags;
172
173
  var node = getNode();
173
174
  var state = view.state,
174
175
  dispatch = view.dispatch;
@@ -179,13 +180,16 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
179
180
  var domAtPos = view.domAtPos.bind(view);
180
181
  var width = containerWidth.width;
181
182
  _this.scaleTableDebounced.cancel();
183
+ var _getEditorFeatureFlag = getEditorFeatureFlags(),
184
+ _getEditorFeatureFlag2 = _getEditorFeatureFlag.tablePreserveWidth,
185
+ tablePreserveWidth = _getEditorFeatureFlag2 === void 0 ? false : _getEditorFeatureFlag2;
182
186
  var tr = scaleTable(_this.table, _objectSpread(_objectSpread({}, scaleOptions), {}, {
183
187
  node: node,
184
188
  prevNode: _this.node || node,
185
189
  start: pos + 1,
186
190
  containerWidth: width,
187
191
  previousContainerWidth: _this.containerWidth.width || width
188
- }, options), domAtPos)(state.tr);
192
+ }, options), domAtPos, tablePreserveWidth)(state.tr);
189
193
  dispatch(tr);
190
194
  });
191
195
  _defineProperty(_assertThisInitialized(_this), "setTimerToSendInitialOverflowCaptured", function (isOverflowing) {
@@ -312,8 +316,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
312
316
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
313
317
  passive: true
314
318
  });
315
- var _getEditorFeatureFlag = getEditorFeatureFlags(),
316
- stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
319
+ var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
320
+ stickyScrollbar = _getEditorFeatureFlag3.stickyScrollbar;
317
321
  if (stickyScrollbar) {
318
322
  if (this.table) {
319
323
  this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
@@ -359,8 +363,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
359
363
  if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
360
364
  this.dragAndDropCleanupFn();
361
365
  }
362
- var _getEditorFeatureFlag2 = getEditorFeatureFlags(),
363
- stickyScrollbar = _getEditorFeatureFlag2.stickyScrollbar;
366
+ var _getEditorFeatureFlag4 = getEditorFeatureFlags(),
367
+ stickyScrollbar = _getEditorFeatureFlag4.stickyScrollbar;
364
368
  if (stickyScrollbar) {
365
369
  if (this.stickyScrollbar) {
366
370
  this.stickyScrollbar.dispose();
@@ -385,20 +389,83 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
385
389
  }
386
390
  }
387
391
  }, {
388
- key: "componentDidUpdate",
389
- value: function componentDidUpdate(_, prevState) {
390
- var _this$wrapper,
391
- _this2 = this;
392
+ key: "handleColgroupUpdates",
393
+ value: function handleColgroupUpdates() {
394
+ var _this2 = this,
395
+ _this$containerWidth;
392
396
  var _this$props9 = this.props,
393
- view = _this$props9.view,
394
397
  getNode = _this$props9.getNode,
395
- isMediaFullscreen = _this$props9.isMediaFullscreen,
396
- allowColumnResizing = _this$props9.allowColumnResizing,
398
+ containerWidth = _this$props9.containerWidth,
397
399
  isResizing = _this$props9.isResizing,
398
- options = _this$props9.options;
400
+ view = _this$props9.view,
401
+ getPos = _this$props9.getPos,
402
+ tableRef = _this$props9.tableRef;
403
+ if (!tableRef) {
404
+ return;
405
+ }
406
+ var TABLE_MARGIN = 76;
407
+
408
+ // Remove any widths styles after resizing preview is completed
409
+ tableRef.style.width = '';
410
+ var tableRenderWidth = containerWidth.width - TABLE_MARGIN;
411
+ var tableNode = getNode();
412
+ var start = getPos() || 0;
413
+ var depth = view.state.doc.resolve(start).depth;
414
+
415
+ // TODO - remove this when support is added for nested tables
416
+ if (depth !== 0) {
417
+ return;
418
+ }
419
+ var tableNodeWidth = tableNode.attrs.width;
420
+ var tableColumnWidths = calcTableColumnWidths(tableNode);
421
+ var shouldTableScale = tableRenderWidth < tableNodeWidth;
422
+ var isTableColumnWidthsSame = false;
423
+ if (this.tableColumnWidths) {
424
+ isTableColumnWidthsSame = tableColumnWidths === null || tableColumnWidths === void 0 ? void 0 : tableColumnWidths.every(function (width, index) {
425
+ return width === _this2.tableColumnWidths[index];
426
+ });
427
+ }
428
+ var containerWidthValue = containerWidth.width;
429
+ var isWidthChanged = ((_this$containerWidth = this.containerWidth) === null || _this$containerWidth === void 0 ? void 0 : _this$containerWidth.width) !== containerWidthValue;
430
+ if (shouldTableScale && !isResizing && (!isTableColumnWidthsSame || isWidthChanged)) {
431
+ var resizeState = getResizeState({
432
+ minWidth: COLUMN_MIN_WIDTH,
433
+ maxSize: tableRenderWidth,
434
+ table: tableNode,
435
+ tableRef: this.table,
436
+ start: start,
437
+ domAtPos: view.domAtPos,
438
+ tablePreserveWidth: true
439
+ });
440
+ requestAnimationFrame(function () {
441
+ updateColgroup(resizeState, _this2.table, true);
442
+ });
443
+ this.tableColumnWidths = tableColumnWidths;
444
+ this.containerWidth = containerWidth;
445
+ }
446
+ }
447
+ }, {
448
+ key: "componentDidUpdate",
449
+ value: function componentDidUpdate(_, prevState) {
450
+ var _this$wrapper,
451
+ _this3 = this;
452
+ var _this$props10 = this.props,
453
+ view = _this$props10.view,
454
+ getNode = _this$props10.getNode,
455
+ isMediaFullscreen = _this$props10.isMediaFullscreen,
456
+ allowColumnResizing = _this$props10.allowColumnResizing,
457
+ isResizing = _this$props10.isResizing,
458
+ options = _this$props10.options,
459
+ getEditorFeatureFlags = _this$props10.getEditorFeatureFlags;
399
460
  var _getPluginState = getPluginState(view.state),
400
461
  isInDanger = _getPluginState.isInDanger;
462
+ var _getEditorFeatureFlag5 = getEditorFeatureFlags(),
463
+ _getEditorFeatureFlag6 = _getEditorFeatureFlag5.tablePreserveWidth,
464
+ tablePreserveWidth = _getEditorFeatureFlag6 === void 0 ? false : _getEditorFeatureFlag6;
401
465
  var table = findTable(view.state.selection);
466
+ if (tablePreserveWidth) {
467
+ this.handleColgroupUpdates();
468
+ }
402
469
  if (isInDanger && !table) {
403
470
  clearHoverSelection()(view.state, view.dispatch);
404
471
  }
@@ -408,7 +475,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
408
475
  // that happens when a table is nested in expand and expand's width is
409
476
  // changed via breakout button
410
477
  window.requestAnimationFrame(function () {
411
- _this2.overflowShadowsObserver = new OverflowShadowsObserver(_this2.updateShadowState, _this2.table, _this2.wrapper);
478
+ _this3.overflowShadowsObserver = new OverflowShadowsObserver(_this3.updateShadowState, _this3.table, _this3.wrapper);
412
479
  });
413
480
  } else {
414
481
  this.overflowShadowsObserver = new OverflowShadowsObserver(this.updateShadowState, this.table, this.wrapper);
@@ -433,7 +500,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
433
500
  var _view = this.props.view;
434
501
  var shouldRecreateResizeCols = !(options !== null && options !== void 0 && options.isTableResizingEnabled) || !isResizing || tablesHaveDifferentNoOfColumns(currentTable, previousTable) && isResizing;
435
502
  if (shouldRecreateResizeCols) {
436
- recreateResizeColsByNode(this.table, currentTable);
503
+ insertColgroupFromNode(this.table, currentTable, tablePreserveWidth);
437
504
  }
438
505
  updateControls()(_view.state);
439
506
  }
@@ -464,24 +531,24 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
464
531
  }, {
465
532
  key: "render",
466
533
  value: function render() {
467
- var _this3 = this,
534
+ var _this4 = this,
468
535
  _classnames;
469
- var _this$props10 = this.props,
470
- view = _this$props10.view,
471
- getNode = _this$props10.getNode,
472
- isResizing = _this$props10.isResizing,
473
- _this$props10$allowCo = _this$props10.allowControls,
474
- allowControls = _this$props10$allowCo === void 0 ? true : _this$props10$allowCo,
475
- isHeaderRowEnabled = _this$props10.isHeaderRowEnabled,
476
- ordering = _this$props10.ordering,
477
- isHeaderColumnEnabled = _this$props10.isHeaderColumnEnabled,
478
- tableActive = _this$props10.tableActive,
479
- containerWidth = _this$props10.containerWidth,
480
- options = _this$props10.options,
481
- getPos = _this$props10.getPos,
482
- pluginInjectionApi = _this$props10.pluginInjectionApi,
483
- isDragAndDropEnabled = _this$props10.isDragAndDropEnabled,
484
- getEditorFeatureFlags = _this$props10.getEditorFeatureFlags;
536
+ var _this$props11 = this.props,
537
+ view = _this$props11.view,
538
+ getNode = _this$props11.getNode,
539
+ isResizing = _this$props11.isResizing,
540
+ _this$props11$allowCo = _this$props11.allowControls,
541
+ allowControls = _this$props11$allowCo === void 0 ? true : _this$props11$allowCo,
542
+ isHeaderRowEnabled = _this$props11.isHeaderRowEnabled,
543
+ ordering = _this$props11.ordering,
544
+ isHeaderColumnEnabled = _this$props11.isHeaderColumnEnabled,
545
+ tableActive = _this$props11.tableActive,
546
+ containerWidth = _this$props11.containerWidth,
547
+ options = _this$props11.options,
548
+ getPos = _this$props11.getPos,
549
+ pluginInjectionApi = _this$props11.pluginInjectionApi,
550
+ isDragAndDropEnabled = _this$props11.isDragAndDropEnabled,
551
+ getEditorFeatureFlags = _this$props11.getEditorFeatureFlags;
485
552
  var _this$state3 = this.state,
486
553
  showBeforeShadow = _this$state3.showBeforeShadow,
487
554
  showAfterShadow = _this$state3.showAfterShadow;
@@ -539,8 +606,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
539
606
  tableContainerWidth: tableContainerWidth,
540
607
  isNumberColumnEnabled: node.attrs.isNumberColumnEnabled,
541
608
  getScrollOffset: function getScrollOffset() {
542
- var _this3$wrapper;
543
- return ((_this3$wrapper = _this3.wrapper) === null || _this3$wrapper === void 0 ? void 0 : _this3$wrapper.scrollLeft) || 0;
609
+ var _this4$wrapper;
610
+ return ((_this4$wrapper = _this4.wrapper) === null || _this4$wrapper === void 0 ? void 0 : _this4$wrapper.scrollLeft) || 0;
544
611
  }
545
612
  }) : null;
546
613
  var shadowPadding = allowControls && tableActive ? -tableToolbarSize : tableMarginSides;
@@ -563,8 +630,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
563
630
  }
564
631
  var isNested = isTableNested(view.state, tablePos);
565
632
  var 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;
566
- var _getEditorFeatureFlag3 = getEditorFeatureFlags(),
567
- stickyScrollbar = _getEditorFeatureFlag3.stickyScrollbar;
633
+ var _getEditorFeatureFlag7 = getEditorFeatureFlags(),
634
+ stickyScrollbar = _getEditorFeatureFlag7.stickyScrollbar,
635
+ tablePreserveWidth = _getEditorFeatureFlag7.tablePreserveWidth;
568
636
  return /*#__PURE__*/React.createElement(TableContainer, {
569
637
  className: classnames(ClassName.TABLE_CONTAINER, (_classnames = {}, _defineProperty(_classnames, ClassName.WITH_CONTROLS, allowControls && tableActive), _defineProperty(_classnames, ClassName.TABLE_STICKY, this.state.stickyHeader && hasHeaderRow), _defineProperty(_classnames, ClassName.HOVERED_DELETE_BUTTON, isInDanger), _defineProperty(_classnames, ClassName.TABLE_SELECTED, isTableSelected(view.state.selection)), _classnames)),
570
638
  editorView: view,
@@ -576,7 +644,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
576
644
  isNested: isNested,
577
645
  pluginInjectionApi: pluginInjectionApi,
578
646
  isTableResizingEnabled: options === null || options === void 0 ? void 0 : options.isTableResizingEnabled,
579
- isResizing: isResizing
647
+ isResizing: isResizing,
648
+ tablePreserveWidth: tablePreserveWidth
580
649
  }, /*#__PURE__*/React.createElement("div", {
581
650
  className: ClassName.TABLE_STICKY_SENTINEL_TOP,
582
651
  "data-testid": "sticky-sentinel-top"
@@ -587,12 +656,12 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
587
656
  editorView: view,
588
657
  node: node,
589
658
  getScrollOffset: function getScrollOffset() {
590
- var _this3$wrapper2;
591
- return ((_this3$wrapper2 = _this3.wrapper) === null || _this3$wrapper2 === void 0 ? void 0 : _this3$wrapper2.scrollLeft) || 0;
659
+ var _this4$wrapper2;
660
+ return ((_this4$wrapper2 = _this4.wrapper) === null || _this4$wrapper2 === void 0 ? void 0 : _this4$wrapper2.scrollLeft) || 0;
592
661
  },
593
662
  getTableWrapperWidth: function getTableWrapperWidth() {
594
- var _this3$wrapper3;
595
- return ((_this3$wrapper3 = _this3.wrapper) === null || _this3$wrapper3 === void 0 ? void 0 : _this3$wrapper3.clientWidth) || 760;
663
+ var _this4$wrapper3;
664
+ return ((_this4$wrapper3 = _this4.wrapper) === null || _this4$wrapper3 === void 0 ? void 0 : _this4$wrapper3.clientWidth) || 760;
596
665
  }
597
666
  }), /*#__PURE__*/React.createElement("div", {
598
667
  style: shadowStyle(showBeforeShadow),
@@ -607,13 +676,13 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
607
676
  }), /*#__PURE__*/React.createElement("div", {
608
677
  className: classnames(ClassName.TABLE_NODE_WRAPPER),
609
678
  ref: function ref(elem) {
610
- _this3.wrapper = elem;
679
+ _this4.wrapper = elem;
611
680
  if (elem) {
612
- _this3.props.contentDOM(elem);
681
+ _this4.props.contentDOM(elem);
613
682
  var tableElement = elem.querySelector('table');
614
- if (tableElement !== _this3.table) {
615
- _this3.table = tableElement;
616
- _this3.createShadowSentinels(_this3.table);
683
+ if (tableElement !== _this4.table) {
684
+ _this4.table = tableElement;
685
+ _this4.createShadowSentinels(_this4.table);
617
686
  }
618
687
  }
619
688
  }
@@ -43,7 +43,8 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
43
43
  getPos = _ref2.getPos,
44
44
  tableRef = _ref2.tableRef,
45
45
  isResizing = _ref2.isResizing,
46
- pluginInjectionApi = _ref2.pluginInjectionApi;
46
+ pluginInjectionApi = _ref2.pluginInjectionApi,
47
+ tablePreserveWidth = _ref2.tablePreserveWidth;
47
48
  var containerRef = useRef(null);
48
49
  var tableWidthRef = useRef(akEditorDefaultLayoutWidth);
49
50
  var updateContainerHeight = useCallback(function (height) {
@@ -124,7 +125,8 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref2) {
124
125
  tableRef: tableRef,
125
126
  displayGuideline: displayGuideline,
126
127
  attachAnalyticsEvent: attachAnalyticsEvent,
127
- displayGapCursor: displayGapCursor
128
+ displayGapCursor: displayGapCursor,
129
+ tablePreserveWidth: tablePreserveWidth
128
130
  };
129
131
  if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
130
132
  tableResizerProps = _objectSpread(_objectSpread({}, tableResizerProps), {}, {
@@ -162,7 +164,8 @@ export var TableContainer = function TableContainer(_ref3) {
162
164
  tableRef = _ref3.tableRef,
163
165
  isNested = _ref3.isNested,
164
166
  isResizing = _ref3.isResizing,
165
- pluginInjectionApi = _ref3.pluginInjectionApi;
167
+ pluginInjectionApi = _ref3.pluginInjectionApi,
168
+ tablePreserveWidth = _ref3.tablePreserveWidth;
166
169
  if (isTableResizingEnabled && !isNested) {
167
170
  return /*#__PURE__*/React.createElement(ResizableTableContainer, {
168
171
  className: className,
@@ -172,7 +175,8 @@ export var TableContainer = function TableContainer(_ref3) {
172
175
  getPos: getPos,
173
176
  tableRef: tableRef,
174
177
  isResizing: isResizing,
175
- pluginInjectionApi: pluginInjectionApi
178
+ pluginInjectionApi: pluginInjectionApi,
179
+ tablePreserveWidth: tablePreserveWidth
176
180
  }, children);
177
181
  }
178
182
  var tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
@@ -87,7 +87,8 @@ export var TableResizer = function TableResizer(_ref) {
87
87
  tableRef = _ref.tableRef,
88
88
  displayGuideline = _ref.displayGuideline,
89
89
  attachAnalyticsEvent = _ref.attachAnalyticsEvent,
90
- displayGapCursor = _ref.displayGapCursor;
90
+ displayGapCursor = _ref.displayGapCursor,
91
+ tablePreserveWidth = _ref.tablePreserveWidth;
91
92
  var currentGap = useRef(0);
92
93
  // track resizing state - use ref over state to avoid re-render
93
94
  var isResizing = useRef(false);
@@ -195,11 +196,11 @@ export var TableResizer = function TableResizer(_ref) {
195
196
  prevNode: node,
196
197
  start: pos + 1,
197
198
  parentWidth: newWidth
198
- }, editorView.domAtPos.bind(editorView));
199
+ }, editorView.domAtPos.bind(editorView), tablePreserveWidth);
199
200
  updateActiveGuidelines(findClosestSnap(newWidth, defaultSnappingWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP, TABLE_HIGHLIGHT_TOLERANCE));
200
201
  updateWidth(newWidth);
201
202
  return newWidth;
202
- }, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
203
+ }, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames, tablePreserveWidth]);
203
204
  var scheduleResize = useMemo(function () {
204
205
  return rafSchd(handleResize);
205
206
  }, [handleResize]);
@@ -235,7 +236,7 @@ export var TableResizer = function TableResizer(_ref) {
235
236
  prevNode: node,
236
237
  start: pos + 1,
237
238
  parentWidth: newWidth
238
- }, editorView.domAtPos.bind(editorView))(tr);
239
+ }, editorView.domAtPos.bind(editorView), tablePreserveWidth)(tr);
239
240
  var scaledNode = tr.doc.nodeAt(pos);
240
241
  (_attachAnalyticsEvent2 = attachAnalyticsEvent(generateResizedPayload({
241
242
  originalNode: node,
@@ -253,7 +254,7 @@ export var TableResizer = function TableResizer(_ref) {
253
254
  onResizeStop();
254
255
  }
255
256
  return newWidth;
256
- }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop]);
257
+ }, [displayGapCursor, updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure, onResizeStop, tablePreserveWidth]);
257
258
  var handleTableSizeChangeOnKeypress = useCallback(function (step) {
258
259
  var newWidth = width + step;
259
260
  if (newWidth > maxWidth || newWidth < resizerMinWidth) {
@@ -72,17 +72,24 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
72
72
  _defineProperty(_assertThisInitialized(_this), "hasHoveredRows", false);
73
73
  _this.getPos = props.getPos;
74
74
  _this.eventDispatcher = props.eventDispatcher;
75
+ _this.getEditorFeatureFlags = props.getEditorFeatureFlags;
75
76
  return _this;
76
77
  }
77
78
  _createClass(TableView, [{
78
79
  key: "getContentDOM",
79
80
  value: function getContentDOM() {
80
81
  var rendered = DOMSerializer.renderSpec(document, toDOM(this.node, this.reactComponentProps));
81
- var tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
82
82
  if (rendered.dom) {
83
83
  this.table = rendered.dom;
84
- if (tableInlineWidth) {
85
- handleInlineTableWidth(this.table, tableInlineWidth);
84
+ var _this$getEditorFeatur = this.getEditorFeatureFlags(),
85
+ _this$getEditorFeatur2 = _this$getEditorFeatur.tablePreserveWidth,
86
+ tablePreserveWidth = _this$getEditorFeatur2 === void 0 ? false : _this$getEditorFeatur2;
87
+ // Preserve Table Width cannot have inline width set on the table
88
+ if (!tablePreserveWidth) {
89
+ var tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos());
90
+ if (tableInlineWidth) {
91
+ handleInlineTableWidth(this.table, tableInlineWidth);
92
+ }
86
93
  }
87
94
  }
88
95
  return rendered;
@@ -180,7 +187,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
180
187
  contentDOM: forwardRef,
181
188
  getEditorFeatureFlags: props.getEditorFeatureFlags,
182
189
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
183
- pluginInjectionApi: props.pluginInjectionApi
190
+ pluginInjectionApi: props.pluginInjectionApi,
191
+ tableRef: _this3.table
184
192
  });
185
193
  }
186
194
  });
@@ -147,8 +147,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
147
147
  name: 'tableKeymap',
148
148
  plugin: function plugin() {
149
149
  var _ref6 = options || {},
150
- dragAndDropEnabled = _ref6.dragAndDropEnabled;
151
- return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled);
150
+ dragAndDropEnabled = _ref6.dragAndDropEnabled,
151
+ getEditorFeatureFlags = _ref6.getEditorFeatureFlags;
152
+ return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, dragAndDropEnabled);
152
153
  }
153
154
  }, {
154
155
  name: 'tableSelectionKeymap',
@@ -189,40 +190,40 @@ var tablesPlugin = function tablesPlugin(_ref) {
189
190
  }, {
190
191
  name: 'tableDragAndDrop',
191
192
  plugin: function plugin(_ref10) {
192
- var dispatch = _ref10.dispatch,
193
- eventDispatcher = _ref10.eventDispatcher,
194
- dispatchAnalyticsEvent = _ref10.dispatchAnalyticsEvent;
195
- return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) : undefined;
193
+ var dispatch = _ref10.dispatch;
194
+ var _ref11 = options || {},
195
+ getEditorFeatureFlags = _ref11.getEditorFeatureFlags;
196
+ return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, getEditorFeatureFlags, editorAnalyticsAPI) : undefined;
196
197
  }
197
198
  }, {
198
199
  name: 'tableLocalId',
199
- plugin: function plugin(_ref11) {
200
- var dispatch = _ref11.dispatch;
200
+ plugin: function plugin(_ref12) {
201
+ var dispatch = _ref12.dispatch;
201
202
  return createTableLocalIdPlugin(dispatch);
202
203
  }
203
204
  }, {
204
205
  name: 'tableWidth',
205
- plugin: function plugin(_ref12) {
206
+ plugin: function plugin(_ref13) {
206
207
  var _options$fullWidthEna;
207
- var dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent,
208
- dispatch = _ref12.dispatch;
208
+ var dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent,
209
+ dispatch = _ref13.dispatch;
209
210
  return options !== null && options !== void 0 && options.tableResizingEnabled ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options === null || options === void 0 ? void 0 : options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) : undefined;
210
211
  }
211
212
  },
212
213
  // TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
213
214
  {
214
215
  name: 'tableOverflowAnalyticsPlugin',
215
- plugin: function plugin(_ref13) {
216
+ plugin: function plugin(_ref14) {
216
217
  var _options$tableResizin;
217
- var dispatch = _ref13.dispatch,
218
- dispatchAnalyticsEvent = _ref13.dispatchAnalyticsEvent;
218
+ var dispatch = _ref14.dispatch,
219
+ dispatchAnalyticsEvent = _ref14.dispatchAnalyticsEvent;
219
220
  return createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false);
220
221
  }
221
222
  }, {
222
223
  name: 'tableAnalyticsPlugin',
223
- plugin: function plugin(_ref14) {
224
- var dispatch = _ref14.dispatch,
225
- dispatchAnalyticsEvent = _ref14.dispatchAnalyticsEvent;
224
+ plugin: function plugin(_ref15) {
225
+ var dispatch = _ref15.dispatch,
226
+ dispatchAnalyticsEvent = _ref15.dispatchAnalyticsEvent;
226
227
  return getBooleanFF('platform.editor.table.analytics-plugin-moved-event') ? createTableAnalyticsPlugin(dispatch, dispatchAnalyticsEvent) : undefined;
227
228
  }
228
229
  }, {
@@ -253,12 +254,12 @@ var tablesPlugin = function tablesPlugin(_ref) {
253
254
  }
254
255
  return plugins;
255
256
  },
256
- contentComponent: function contentComponent(_ref15) {
257
- var editorView = _ref15.editorView,
258
- popupsMountPoint = _ref15.popupsMountPoint,
259
- popupsBoundariesElement = _ref15.popupsBoundariesElement,
260
- popupsScrollableElement = _ref15.popupsScrollableElement,
261
- dispatchAnalyticsEvent = _ref15.dispatchAnalyticsEvent;
257
+ contentComponent: function contentComponent(_ref16) {
258
+ var editorView = _ref16.editorView,
259
+ popupsMountPoint = _ref16.popupsMountPoint,
260
+ popupsBoundariesElement = _ref16.popupsBoundariesElement,
261
+ popupsScrollableElement = _ref16.popupsScrollableElement,
262
+ dispatchAnalyticsEvent = _ref16.dispatchAnalyticsEvent;
262
263
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
263
264
  component: ACTION_SUBJECT.TABLES_PLUGIN,
264
265
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -272,30 +273,30 @@ var tablesPlugin = function tablesPlugin(_ref) {
272
273
  stickyHeadersState: stickyHeadersPluginKey,
273
274
  dragAndDropState: dragAndDropPluginKey
274
275
  },
275
- render: function render(_ref16) {
276
- var resizingPluginState = _ref16.tableResizingPluginState,
277
- stickyHeadersState = _ref16.stickyHeadersState,
278
- tablePluginState = _ref16.tablePluginState,
279
- tableWidthPluginState = _ref16.tableWidthPluginState,
280
- dragAndDropState = _ref16.dragAndDropState;
276
+ render: function render(_ref17) {
277
+ var resizingPluginState = _ref17.tableResizingPluginState,
278
+ stickyHeadersState = _ref17.stickyHeadersState,
279
+ tablePluginState = _ref17.tablePluginState,
280
+ tableWidthPluginState = _ref17.tableWidthPluginState,
281
+ dragAndDropState = _ref17.dragAndDropState;
281
282
  var state = editorView.state;
282
283
  var isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
283
284
  var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
284
285
  var isResizing = isColumnResizing || isTableResizing;
285
- var _ref17 = tablePluginState,
286
- tableNode = _ref17.tableNode,
287
- tablePos = _ref17.tablePos,
288
- targetCellPosition = _ref17.targetCellPosition,
289
- isContextualMenuOpen = _ref17.isContextualMenuOpen,
290
- layout = _ref17.layout,
291
- tableRef = _ref17.tableRef,
292
- pluginConfig = _ref17.pluginConfig,
293
- insertColumnButtonIndex = _ref17.insertColumnButtonIndex,
294
- insertRowButtonIndex = _ref17.insertRowButtonIndex,
295
- isHeaderColumnEnabled = _ref17.isHeaderColumnEnabled,
296
- isHeaderRowEnabled = _ref17.isHeaderRowEnabled,
297
- isDragAndDropEnabled = _ref17.isDragAndDropEnabled,
298
- tableWrapperTarget = _ref17.tableWrapperTarget;
286
+ var _ref18 = tablePluginState,
287
+ tableNode = _ref18.tableNode,
288
+ tablePos = _ref18.tablePos,
289
+ targetCellPosition = _ref18.targetCellPosition,
290
+ isContextualMenuOpen = _ref18.isContextualMenuOpen,
291
+ layout = _ref18.layout,
292
+ tableRef = _ref18.tableRef,
293
+ pluginConfig = _ref18.pluginConfig,
294
+ insertColumnButtonIndex = _ref18.insertColumnButtonIndex,
295
+ insertRowButtonIndex = _ref18.insertRowButtonIndex,
296
+ isHeaderColumnEnabled = _ref18.isHeaderColumnEnabled,
297
+ isHeaderRowEnabled = _ref18.isHeaderRowEnabled,
298
+ isDragAndDropEnabled = _ref18.isDragAndDropEnabled,
299
+ tableWrapperTarget = _ref18.tableWrapperTarget;
299
300
  var allowControls = pluginConfig.allowControls;
300
301
  var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
301
302
  var LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
@@ -336,7 +337,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
336
337
  hasStickyHeaders: stickyHeader && stickyHeader.sticky,
337
338
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
338
339
  editorAnalyticsAPI: editorAnalyticsAPI,
339
- getEditorContainerWidth: defaultGetEditorContainerWidth
340
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
341
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
340
342
  }), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
341
343
  editorView: editorView,
342
344
  mountPoint: popupsMountPoint,
@@ -360,7 +362,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
360
362
  getEditorContainerWidth: defaultGetEditorContainerWidth,
361
363
  editorAnalyticsAPI: editorAnalyticsAPI,
362
364
  stickyHeaders: stickyHeader,
363
- pluginConfig: pluginConfig
365
+ pluginConfig: pluginConfig,
366
+ getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
364
367
  }), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
365
368
  editorView: editorView,
366
369
  selection: editorView.state.selection,
@@ -376,8 +379,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
376
379
  }));
377
380
  },
378
381
  pluginsOptions: {
379
- quickInsert: function quickInsert(_ref18) {
380
- var formatMessage = _ref18.formatMessage;
382
+ quickInsert: function quickInsert(_ref19) {
383
+ var formatMessage = _ref19.formatMessage;
381
384
  return [{
382
385
  id: 'table',
383
386
  title: formatMessage(messages.table),
@@ -17,7 +17,7 @@ import { DropTargetType } from './consts';
17
17
  import { createPluginState, getPluginState } from './plugin-factory';
18
18
  import { pluginKey } from './plugin-key';
19
19
  import { getDraggableDataFromEvent } from './utils/monitor';
20
- var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
20
+ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI, getEditorFeatureFlags) {
21
21
  var editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
22
22
  var rowAutoScrollers = editorPageScrollContainer ? [monitorForElements({
23
23
  canMonitor: function canMonitor(_ref) {
@@ -147,7 +147,10 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
147
147
  tableRef = _getTablePluginState3.tableRef,
148
148
  tableNode = _getTablePluginState3.tableNode;
149
149
  if (tableRef && tableNode) {
150
- insertColgroupFromNode(tableRef, tableNode);
150
+ var _ref8 = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {},
151
+ _ref8$tablePreserveWi = _ref8.tablePreserveWidth,
152
+ tablePreserveWidth = _ref8$tablePreserveWi === void 0 ? false : _ref8$tablePreserveWi;
153
+ insertColgroupFromNode(tableRef, tableNode, tablePreserveWidth);
151
154
  }
152
155
  }
153
156
  editorView.focus();
@@ -155,7 +158,7 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
155
158
  }
156
159
  })]));
157
160
  };
158
- export var createPlugin = function createPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) {
161
+ export var createPlugin = function createPlugin(dispatch, getEditorFeatureFlags, editorAnalyticsAPI) {
159
162
  return new SafePlugin({
160
163
  state: createPluginState(dispatch, function (state) {
161
164
  return {
@@ -223,7 +226,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
223
226
  },
224
227
  view: function view(editorView) {
225
228
  return {
226
- destroy: destroyFn(editorView, editorAnalyticsAPI)
229
+ destroy: destroyFn(editorView, editorAnalyticsAPI, getEditorFeatureFlags)
227
230
  };
228
231
  },
229
232
  props: {
@@ -233,7 +236,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
233
236
  return decorationSet;
234
237
  },
235
238
  handleKeyDown: function handleKeyDown(view, event) {
236
- var _ref8;
239
+ var _ref9;
237
240
  var tr = view.state.tr;
238
241
  var keysToTrapWhen = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
239
242
 
@@ -254,7 +257,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
254
257
  return true;
255
258
  }
256
259
  }
257
- var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((_ref8 = event.target || null) === null || _ref8 === void 0 ? void 0 : _ref8.id);
260
+ var isDragHandleFocused = ['drag-handle-button-row', 'drag-handle-button-column'].includes((_ref9 = event.target || null) === null || _ref9 === void 0 ? void 0 : _ref9.id);
258
261
  var keysToTrap = ['Enter', ' '];
259
262
  var _getPluginState3 = getPluginState(view.state),
260
263
  isDragMenuOpen = _getPluginState3.isDragMenuOpen;