@atlaskit/editor-plugin-table 7.5.4 → 7.5.5

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 (202) hide show
  1. package/CHANGELOG.md +7 -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 +2 -2
  7. package/dist/cjs/nodeviews/TableComponent.js +46 -59
  8. package/dist/cjs/nodeviews/TableContainer.js +5 -5
  9. package/dist/cjs/nodeviews/TableResizer.js +12 -12
  10. package/dist/cjs/nodeviews/table.js +9 -9
  11. package/dist/cjs/plugin.js +58 -56
  12. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +13 -13
  13. package/dist/cjs/pm-plugins/keymap.js +6 -8
  14. package/dist/cjs/pm-plugins/main.js +4 -6
  15. package/dist/cjs/pm-plugins/sticky-headers/plugin.js +2 -3
  16. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -12
  17. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  18. package/dist/cjs/pm-plugins/table-resizing/utils/consts.js +4 -2
  19. package/dist/cjs/pm-plugins/table-resizing/utils/index.js +2 -2
  20. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +3 -3
  21. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +3 -3
  22. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +11 -12
  23. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  24. package/dist/cjs/pm-plugins/table-width.js +6 -2
  25. package/dist/cjs/toolbar.js +21 -21
  26. package/dist/cjs/transforms/column-width.js +4 -4
  27. package/dist/cjs/transforms/delete-columns.js +2 -2
  28. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
  29. package/dist/cjs/ui/FloatingContextualMenu/index.js +2 -4
  30. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
  31. package/dist/cjs/ui/FloatingDragMenu/index.js +6 -6
  32. package/dist/cjs/ui/FloatingInsertButton/index.js +6 -7
  33. package/dist/cjs/utils/create.js +2 -5
  34. package/dist/cjs/utils/drag-menu.js +4 -4
  35. package/dist/es2019/commands/column-resize.js +3 -3
  36. package/dist/es2019/commands/delete.js +2 -2
  37. package/dist/es2019/commands/insert.js +12 -12
  38. package/dist/es2019/commands-with-analytics.js +6 -6
  39. package/dist/es2019/event-handlers.js +2 -2
  40. package/dist/es2019/nodeviews/TableComponent.js +25 -36
  41. package/dist/es2019/nodeviews/TableContainer.js +5 -5
  42. package/dist/es2019/nodeviews/TableResizer.js +12 -12
  43. package/dist/es2019/nodeviews/table.js +9 -9
  44. package/dist/es2019/plugin.js +17 -17
  45. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +6 -6
  46. package/dist/es2019/pm-plugins/keymap.js +5 -8
  47. package/dist/es2019/pm-plugins/main.js +3 -5
  48. package/dist/es2019/pm-plugins/sticky-headers/plugin.js +1 -1
  49. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +5 -5
  50. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  51. package/dist/es2019/pm-plugins/table-resizing/utils/consts.js +3 -1
  52. package/dist/es2019/pm-plugins/table-resizing/utils/index.js +1 -1
  53. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
  54. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +3 -2
  55. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +12 -13
  56. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  57. package/dist/es2019/pm-plugins/table-width.js +6 -2
  58. package/dist/es2019/toolbar.js +15 -15
  59. package/dist/es2019/transforms/column-width.js +5 -5
  60. package/dist/es2019/transforms/delete-columns.js +2 -2
  61. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +9 -12
  62. package/dist/es2019/ui/FloatingContextualMenu/index.js +2 -4
  63. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +2 -2
  64. package/dist/es2019/ui/FloatingDragMenu/index.js +5 -5
  65. package/dist/es2019/ui/FloatingInsertButton/index.js +5 -6
  66. package/dist/es2019/utils/create.js +2 -5
  67. package/dist/es2019/utils/drag-menu.js +4 -4
  68. package/dist/esm/commands/column-resize.js +3 -3
  69. package/dist/esm/commands/delete.js +2 -2
  70. package/dist/esm/commands/insert.js +15 -15
  71. package/dist/esm/commands-with-analytics.js +7 -7
  72. package/dist/esm/event-handlers.js +2 -2
  73. package/dist/esm/nodeviews/TableComponent.js +45 -58
  74. package/dist/esm/nodeviews/TableContainer.js +5 -5
  75. package/dist/esm/nodeviews/TableResizer.js +12 -12
  76. package/dist/esm/nodeviews/table.js +9 -9
  77. package/dist/esm/plugin.js +58 -56
  78. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +13 -13
  79. package/dist/esm/pm-plugins/keymap.js +6 -8
  80. package/dist/esm/pm-plugins/main.js +4 -6
  81. package/dist/esm/pm-plugins/sticky-headers/plugin.js +2 -3
  82. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +12 -12
  83. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +2 -2
  84. package/dist/esm/pm-plugins/table-resizing/utils/consts.js +3 -1
  85. package/dist/esm/pm-plugins/table-resizing/utils/index.js +1 -1
  86. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
  87. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +4 -3
  88. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +13 -14
  89. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +13 -13
  90. package/dist/esm/pm-plugins/table-width.js +6 -2
  91. package/dist/esm/toolbar.js +21 -21
  92. package/dist/esm/transforms/column-width.js +5 -5
  93. package/dist/esm/transforms/delete-columns.js +2 -2
  94. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +53 -55
  95. package/dist/esm/ui/FloatingContextualMenu/index.js +2 -4
  96. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +2 -2
  97. package/dist/esm/ui/FloatingDragMenu/index.js +6 -6
  98. package/dist/esm/ui/FloatingInsertButton/index.js +6 -7
  99. package/dist/esm/utils/create.js +2 -5
  100. package/dist/esm/utils/drag-menu.js +4 -4
  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 +7 -7
  104. package/dist/types/commands-with-analytics.d.ts +3 -3
  105. package/dist/types/event-handlers.d.ts +1 -1
  106. package/dist/types/nodeviews/TableComponent.d.ts +2 -3
  107. package/dist/types/nodeviews/TableContainer.d.ts +4 -4
  108. package/dist/types/nodeviews/TableResizer.d.ts +2 -2
  109. package/dist/types/nodeviews/table.d.ts +1 -1
  110. package/dist/types/nodeviews/types.d.ts +1 -0
  111. package/dist/types/plugin.d.ts +1 -0
  112. package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
  113. package/dist/types/pm-plugins/keymap.d.ts +2 -2
  114. package/dist/types/pm-plugins/main.d.ts +1 -1
  115. package/dist/types/pm-plugins/sticky-headers/plugin.d.ts +2 -3
  116. package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
  117. package/dist/types/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  118. package/dist/types/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  119. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  120. package/dist/types/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
  121. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
  122. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  123. package/dist/types/pm-plugins/table-width.d.ts +1 -2
  124. package/dist/types/toolbar.d.ts +2 -2
  125. package/dist/types/transforms/column-width.d.ts +1 -1
  126. package/dist/types/transforms/delete-columns.d.ts +1 -1
  127. package/dist/types/types.d.ts +1 -0
  128. package/dist/types/ui/FloatingContextualMenu/index.d.ts +1 -1
  129. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
  130. package/dist/types/ui/FloatingDragMenu/index.d.ts +2 -3
  131. package/dist/types/ui/FloatingInsertButton/index.d.ts +1 -2
  132. package/dist/types/utils/create.d.ts +1 -2
  133. package/dist/types/utils/drag-menu.d.ts +1 -1
  134. package/dist/types-ts4.5/commands/column-resize.d.ts +1 -1
  135. package/dist/types-ts4.5/commands/delete.d.ts +1 -1
  136. package/dist/types-ts4.5/commands/insert.d.ts +7 -7
  137. package/dist/types-ts4.5/commands-with-analytics.d.ts +3 -3
  138. package/dist/types-ts4.5/event-handlers.d.ts +1 -1
  139. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +2 -3
  140. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -4
  141. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -2
  142. package/dist/types-ts4.5/nodeviews/table.d.ts +1 -1
  143. package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
  144. package/dist/types-ts4.5/plugin.d.ts +1 -0
  145. package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
  146. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
  147. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  148. package/dist/types-ts4.5/pm-plugins/sticky-headers/plugin.d.ts +2 -3
  149. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -1
  150. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/consts.d.ts +1 -0
  151. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/index.d.ts +1 -1
  152. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
  153. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -1
  154. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +4 -4
  155. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +4 -4
  156. package/dist/types-ts4.5/pm-plugins/table-width.d.ts +1 -2
  157. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  158. package/dist/types-ts4.5/transforms/column-width.d.ts +1 -1
  159. package/dist/types-ts4.5/transforms/delete-columns.d.ts +1 -1
  160. package/dist/types-ts4.5/types.d.ts +1 -0
  161. package/dist/types-ts4.5/ui/FloatingContextualMenu/index.d.ts +1 -1
  162. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +2 -2
  163. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +2 -3
  164. package/dist/types-ts4.5/ui/FloatingInsertButton/index.d.ts +1 -2
  165. package/dist/types-ts4.5/utils/create.d.ts +1 -2
  166. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  167. package/package.json +2 -2
  168. package/src/commands/column-resize.ts +4 -3
  169. package/src/commands/delete.ts +2 -2
  170. package/src/commands/insert.ts +15 -27
  171. package/src/commands-with-analytics.ts +6 -9
  172. package/src/event-handlers.ts +2 -2
  173. package/src/nodeviews/TableComponent.tsx +31 -46
  174. package/src/nodeviews/TableContainer.tsx +7 -7
  175. package/src/nodeviews/TableResizer.tsx +14 -14
  176. package/src/nodeviews/table.tsx +6 -5
  177. package/src/nodeviews/types.ts +1 -0
  178. package/src/plugin.tsx +12 -28
  179. package/src/pm-plugins/drag-and-drop/plugin.ts +10 -15
  180. package/src/pm-plugins/keymap.ts +6 -13
  181. package/src/pm-plugins/main.ts +3 -3
  182. package/src/pm-plugins/sticky-headers/plugin.ts +2 -11
  183. package/src/pm-plugins/table-resizing/event-handlers.ts +6 -4
  184. package/src/pm-plugins/table-resizing/utils/colgroup.ts +2 -2
  185. package/src/pm-plugins/table-resizing/utils/consts.ts +2 -0
  186. package/src/pm-plugins/table-resizing/utils/index.ts +1 -1
  187. package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
  188. package/src/pm-plugins/table-resizing/utils/resize-column.ts +5 -2
  189. package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -13
  190. package/src/pm-plugins/table-resizing/utils/scale-table.ts +14 -14
  191. package/src/pm-plugins/table-width.ts +4 -6
  192. package/src/toolbar.tsx +16 -19
  193. package/src/transforms/column-width.ts +7 -6
  194. package/src/transforms/delete-columns.ts +2 -2
  195. package/src/types.ts +1 -0
  196. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +11 -16
  197. package/src/ui/FloatingContextualMenu/index.tsx +0 -2
  198. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -3
  199. package/src/ui/FloatingDragMenu/index.tsx +4 -8
  200. package/src/ui/FloatingInsertButton/index.tsx +11 -22
  201. package/src/utils/create.ts +2 -5
  202. package/src/utils/drag-menu.ts +7 -12
@@ -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,
@@ -18,6 +18,7 @@ import { createPlugin as createDecorationsPlugin } from './pm-plugins/decoration
18
18
  import { createPlugin as createDragAndDropPlugin, pluginKey as dragAndDropPluginKey } from './pm-plugins/drag-and-drop';
19
19
  import { keymapPlugin } from './pm-plugins/keymap';
20
20
  import { createPlugin } from './pm-plugins/main';
21
+ import { getPluginState } from './pm-plugins/plugin-factory';
21
22
  import { pluginKey } from './pm-plugins/plugin-key';
22
23
  import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
23
24
  import { createPlugin as createStickyHeadersPlugin, findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from './pm-plugins/sticky-headers';
@@ -68,7 +69,7 @@ const tablesPlugin = ({
68
69
  actions: {
69
70
  insertTable: analyticsPayload => (state, dispatch) => {
70
71
  var _api$contentInsertion, _api$contentInsertion2, _api$contentInsertion3;
71
- const node = createTableWithWidth(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags)(state.schema);
72
+ const node = createTableWithWidth(options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.fullWidthEnabled)(state.schema);
72
73
  return (_api$contentInsertion = api === null || api === void 0 ? void 0 : (_api$contentInsertion2 = api.contentInsertion) === null || _api$contentInsertion2 === void 0 ? void 0 : (_api$contentInsertion3 = _api$contentInsertion2.actions) === null || _api$contentInsertion3 === void 0 ? void 0 : _api$contentInsertion3.insert({
73
74
  state,
74
75
  dispatch,
@@ -81,7 +82,7 @@ const tablesPlugin = ({
81
82
  }
82
83
  },
83
84
  commands: {
84
- insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
85
+ insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
85
86
  },
86
87
  nodes() {
87
88
  const tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
@@ -116,9 +117,10 @@ const tablesPlugin = ({
116
117
  breakoutEnabled,
117
118
  tableOptions,
118
119
  getEditorFeatureFlags,
119
- dragAndDropEnabled
120
+ dragAndDropEnabled,
121
+ isTableScalingEnabled
120
122
  } = options || {};
121
- return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
123
+ return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled);
122
124
  }
123
125
  }, {
124
126
  name: 'tablePMColResizing',
@@ -148,9 +150,9 @@ const tablesPlugin = ({
148
150
  plugin: () => {
149
151
  const {
150
152
  dragAndDropEnabled,
151
- getEditorFeatureFlags
153
+ isTableScalingEnabled = false
152
154
  } = options || {};
153
- return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, dragAndDropEnabled);
155
+ return keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled);
154
156
  }
155
157
  }, {
156
158
  name: 'tableSelectionKeymap',
@@ -184,16 +186,13 @@ const tablesPlugin = ({
184
186
  plugin: ({
185
187
  dispatch,
186
188
  eventDispatcher
187
- }) => options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, () => [], (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined
189
+ }) => options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, () => []) : undefined
188
190
  }, {
189
191
  name: 'tableDragAndDrop',
190
192
  plugin: ({
191
193
  dispatch
192
194
  }) => {
193
- const {
194
- getEditorFeatureFlags
195
- } = options || {};
196
- return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, getEditorFeatureFlags, editorAnalyticsAPI) : undefined;
195
+ return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, editorAnalyticsAPI) : undefined;
197
196
  }
198
197
  }, {
199
198
  name: 'tableLocalId',
@@ -207,7 +206,7 @@ const tablesPlugin = ({
207
206
  dispatch
208
207
  }) => {
209
208
  var _options$fullWidthEna;
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;
209
+ 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) : undefined;
211
210
  }
212
211
  },
213
212
  // TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
@@ -344,8 +343,7 @@ const tablesPlugin = ({
344
343
  hasStickyHeaders: stickyHeader && stickyHeader.sticky,
345
344
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
346
345
  editorAnalyticsAPI: editorAnalyticsAPI,
347
- getEditorContainerWidth: defaultGetEditorContainerWidth,
348
- getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
346
+ getEditorContainerWidth: defaultGetEditorContainerWidth
349
347
  }), (options === null || options === void 0 ? void 0 : options.allowContextualMenu) && /*#__PURE__*/React.createElement(FloatingContextualMenu, {
350
348
  editorView: editorView,
351
349
  mountPoint: popupsMountPoint,
@@ -369,8 +367,7 @@ const tablesPlugin = ({
369
367
  getEditorContainerWidth: defaultGetEditorContainerWidth,
370
368
  editorAnalyticsAPI: editorAnalyticsAPI,
371
369
  stickyHeaders: stickyHeader,
372
- pluginConfig: pluginConfig,
373
- getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
370
+ pluginConfig: pluginConfig
374
371
  }), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
375
372
  editorView: editorView,
376
373
  selection: editorView.state.selection,
@@ -400,7 +397,10 @@ const tablesPlugin = ({
400
397
  var _api$table;
401
398
  // see comment on tablesPlugin.getSharedState on usage
402
399
  const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
403
- const tr = insert(createTableWithWidth(tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled, options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags)(state.schema));
400
+ const {
401
+ isTableScalingEnabled = false
402
+ } = getPluginState(state);
403
+ const tr = insert(createTableWithWidth(isTableScalingEnabled, tableState === null || tableState === void 0 ? void 0 : tableState.isFullWidthModeEnabled)(state.schema));
404
404
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
405
405
  action: ACTION.INSERTED,
406
406
  actionSubject: ACTION_SUBJECT.DOCUMENT,
@@ -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
- const destroyFn = (editorView, editorAnalyticsAPI, getEditorFeatureFlags) => {
20
+ const destroyFn = (editorView, editorAnalyticsAPI) => {
21
21
  const editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
22
22
  const rowAutoScrollers = editorPageScrollContainer ? [monitorForElements({
23
23
  canMonitor({
@@ -162,9 +162,9 @@ const destroyFn = (editorView, editorAnalyticsAPI, getEditorFeatureFlags) => {
162
162
  } = getTablePluginState(editorView.state);
163
163
  if (tableRef && tableNode) {
164
164
  const {
165
- tablePreserveWidth = false
166
- } = (getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags()) || {};
167
- insertColgroupFromNode(tableRef, tableNode, tablePreserveWidth);
165
+ isTableScalingEnabled = false
166
+ } = getTablePluginState(editorView.state);
167
+ insertColgroupFromNode(tableRef, tableNode, isTableScalingEnabled);
168
168
  }
169
169
  }
170
170
  editorView.focus();
@@ -172,7 +172,7 @@ const destroyFn = (editorView, editorAnalyticsAPI, getEditorFeatureFlags) => {
172
172
  }
173
173
  }));
174
174
  };
175
- export const createPlugin = (dispatch, getEditorFeatureFlags, editorAnalyticsAPI) => {
175
+ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
176
176
  return new SafePlugin({
177
177
  state: createPluginState(dispatch, state => ({
178
178
  decorationSet: DecorationSet.empty,
@@ -241,7 +241,7 @@ export const createPlugin = (dispatch, getEditorFeatureFlags, editorAnalyticsAPI
241
241
  },
242
242
  view: editorView => {
243
243
  return {
244
- destroy: destroyFn(editorView, editorAnalyticsAPI, getEditorFeatureFlags)
244
+ destroy: destroyFn(editorView, editorAnalyticsAPI)
245
245
  };
246
246
  },
247
247
  props: {
@@ -18,7 +18,7 @@ const createTableWithAnalytics = editorAnalyticsAPI => withEditorAnalyticsAPI({
18
18
  },
19
19
  eventType: EVENT_TYPE.TRACK
20
20
  })(editorAnalyticsAPI)(createTable());
21
- export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, dragAndDropEnabled) {
21
+ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAndDropEnabled, isTableScalingEnabled = false) {
22
22
  const list = {};
23
23
  bindKeymapWithCommand(nextCell.common, goToNextCell(editorAnalyticsAPI)(1), list);
24
24
  bindKeymapWithCommand(previousCell.common, goToNextCell(editorAnalyticsAPI)(-1), list);
@@ -29,8 +29,8 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEdi
29
29
  // Add row/column shortcuts
30
30
  bindKeymapWithCommand(addRowBefore.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
31
31
  bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
32
- bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(getEditorContainerWidth), list);
33
- bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(getEditorContainerWidth), list);
32
+ bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled), list);
33
+ bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled), list);
34
34
  if (dragAndDropEnabled) {
35
35
  // Move row/column shortcuts
36
36
  /**
@@ -50,14 +50,11 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, getEdi
50
50
  bindKeymapWithCommand(deleteRow.common, deleteSelectedRowsOrColumnsWithAnalyticsViaShortcut(editorAnalyticsAPI), list);
51
51
  }
52
52
  if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
53
- const {
54
- tablePreserveWidth = false
55
- } = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
56
53
  bindKeymapWithCommand(startColumnResizing.common, initiateKeyboardColumnResizing, list);
57
54
  bindKeymapWithCommand(moveRight.common, activateNextResizeArea(1), list);
58
55
  bindKeymapWithCommand(moveLeft.common, activateNextResizeArea(-1), list);
59
- bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, tablePreserveWidth, INPUT_METHOD.SHORTCUT), list);
60
- bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, tablePreserveWidth, INPUT_METHOD.SHORTCUT), list);
56
+ bindKeymapWithCommand(decreaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(-10, getEditorContainerWidth, isTableScalingEnabled, INPUT_METHOD.SHORTCUT), list);
57
+ bindKeymapWithCommand(increaseMediaSize.common, changeColumnWidthByStepWithAnalytics(editorAnalyticsAPI)(10, getEditorContainerWidth, isTableScalingEnabled, INPUT_METHOD.SHORTCUT), list);
61
58
  bindKeymapWithCommand(escape.common, stopKeyboardColumnResizing(), list);
62
59
  }
63
60
  return keymap(list);
@@ -22,7 +22,7 @@ import { isHeaderRowRequired } from '../utils/paste';
22
22
  import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
23
23
  import { createPluginState, getPluginState } from './plugin-factory';
24
24
  import { pluginKey } from './plugin-key';
25
- export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) => {
25
+ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled) => {
26
26
  var _window;
27
27
  const state = createPluginState(dispatch, {
28
28
  pluginConfig,
@@ -36,6 +36,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
36
36
  isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
37
37
  isHeaderColumnEnabled: false,
38
38
  isDragAndDropEnabled: dragAndDropEnabled,
39
+ isTableScalingEnabled: isTableScalingEnabled,
39
40
  ...defaultHoveredCell,
40
41
  ...defaultTableSelection,
41
42
  getIntl
@@ -82,12 +83,9 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
82
83
  }
83
84
  });
84
85
  }
85
- const {
86
- tablePreserveWidth = false
87
- } = getEditorFeatureFlags();
88
86
  if (tr) {
89
87
  // "fixTables" removes empty rows as we don't allow that in schema
90
- const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined, tablePreserveWidth);
88
+ const updatedTr = handleCut(tr, oldState, newState, editorAnalyticsAPI, editorViewRef || undefined, isTableScalingEnabled);
91
89
  return fixTables(updatedTr) || updatedTr;
92
90
  }
93
91
  if (transactions.find(tr => tr.docChanged)) {
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { pluginKey } from './plugin-key';
3
3
  import { createPluginState } from './plugin-state';
4
- export const createPlugin = (dispatch, eventDispatcher, initialState = () => [], getEditorFeatureFlags) => {
4
+ export const createPlugin = (dispatch, initialState = () => []) => {
5
5
  return new SafePlugin({
6
6
  state: createPluginState(dispatch, initialState),
7
7
  key: pluginKey
@@ -22,8 +22,8 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
22
22
  const editorDisabled = !view.editable;
23
23
  const domAtPos = view.domAtPos.bind(view);
24
24
  const {
25
- tablePreserveWidth = false
26
- } = getEditorFeatureFlags();
25
+ isTableScalingEnabled = false
26
+ } = getTablePluginState(state);
27
27
  if (editorDisabled || localResizeHandlePos === null || !pointsAtCell(state.doc.resolve(localResizeHandlePos))) {
28
28
  return false;
29
29
  }
@@ -71,7 +71,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
71
71
  tableRef: dom,
72
72
  start,
73
73
  domAtPos,
74
- tablePreserveWidth
74
+ isTableScalingEnabled: isTableScalingEnabled
75
75
  });
76
76
  if (evenColumns({
77
77
  resizeState,
@@ -153,7 +153,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
153
153
  const selectedColumns = selectionRect ? getSelectedColumnIndexes(selectionRect) : [];
154
154
  // only selected (or selected - 1) columns should be distributed
155
155
  const resizingSelectedColumns = selectedColumns.indexOf(colIndex) > -1 || selectedColumns.indexOf(colIndex + 1) > -1;
156
- const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, resizingSelectedColumns ? selectedColumns : undefined, tablePreserveWidth);
156
+ const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, isTableScalingEnabled);
157
157
  const resizedDelta = clientX - startX;
158
158
  tr = updateColumnWidths(newResizeState, table, start)(tr);
159
159
  if (colIndex === map.width - 1) {
@@ -222,7 +222,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
222
222
  const table = $cell.node(-1);
223
223
  const map = TableMap.get(table);
224
224
  const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
225
- resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, undefined, tablePreserveWidth);
225
+ resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom, table, undefined, isTableScalingEnabled);
226
226
  updateControls()(state);
227
227
  }
228
228
  window.addEventListener('mouseup', finish);
@@ -75,12 +75,12 @@ export const generateColgroup = (table, tableRef) => {
75
75
  }
76
76
  return cols;
77
77
  };
78
- export const insertColgroupFromNode = (tableRef, table, tablePreserveWidth = false, shouldRemove = true) => {
78
+ export const insertColgroupFromNode = (tableRef, table, isTableScalingEnabled = false, shouldRemove = true) => {
79
79
  let colgroup = tableRef.querySelector('colgroup');
80
80
  if (colgroup && shouldRemove) {
81
81
  tableRef.removeChild(colgroup);
82
82
  }
83
- colgroup = renderColgroupFromNode(table, tablePreserveWidth ? tableRef : undefined);
83
+ colgroup = renderColgroupFromNode(table, isTableScalingEnabled ? tableRef : undefined);
84
84
  if (shouldRemove) {
85
85
  tableRef.insertBefore(colgroup, tableRef.firstChild);
86
86
  }
@@ -1,4 +1,6 @@
1
1
  export const COLUMN_MIN_WIDTH = 48;
2
2
  export const TABLE_DEFAULT_WIDTH = 760;
3
3
  export const TABLE_MAX_WIDTH = 1800;
4
- export const MAX_SCALING_PERCENT = 0.3;
4
+ export const MAX_SCALING_PERCENT = 0.3;
5
+ // Used to calculate the width of a table using the Editor width
6
+ export const TABLE_EDITOR_MARGIN = 76;
@@ -3,7 +3,7 @@ export { contentWidth } from './content-width';
3
3
  export { getColumnStateFromDOM, getFreeSpace, getCellsRefsInColumn, calculateColumnWidth, addContainerLeftRightPadding } from './column-state';
4
4
  export { growColumn, shrinkColumn, reduceSpace } from './resize-logic';
5
5
  export { getResizeState, updateColgroup, getTotalWidth, evenAllColumnsWidths, bulkColumnsResize, areColumnsEven, adjustColumnsWidths } from './resize-state';
6
- export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth, getTableElementWidth, getTableContainerElement } from './misc';
6
+ export { getLayoutSize, getDefaultLayoutMaxWidth, pointsAtCell, currentColWidth, domCellAround, getTableMaxWidth, getTableElementWidth, getTableContainerElementWidth } from './misc';
7
7
  export { updateControls, isClickNear, getResizeCellPos } from './dom';
8
8
  export { scale, scaleWithParent, scaleTable, previewScaleTable } from './scale-table';
9
9
  export { resizeColumn } from './resize-column';
@@ -85,8 +85,8 @@ export const getTableElementWidth = table => {
85
85
  // TODO: is there a scenario where ADF columns are SMALLER than container width?
86
86
  return calcTableColumnWidths(table).reduce((sum, width) => sum + width, 0);
87
87
  }
88
- return getTableContainerElement(table);
88
+ return getTableContainerElementWidth(table);
89
89
  };
90
- export const getTableContainerElement = table => {
90
+ export const getTableContainerElementWidth = table => {
91
91
  return getTableContainerWidth(table);
92
92
  };
@@ -1,8 +1,9 @@
1
1
  // Resize a given column by an amount from the current state
2
+
2
3
  import { growColumn, shrinkColumn } from './resize-logic';
3
4
  import { updateColgroup } from './resize-state';
4
- export const resizeColumn = (resizeState, colIndex, amount, tableRef, selectedColumns, tablePreserveWidth = false) => {
5
+ export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false) => {
5
6
  const newState = amount > 0 ? growColumn(resizeState, colIndex, amount, selectedColumns) : amount < 0 ? shrinkColumn(resizeState, colIndex, amount, selectedColumns) : resizeState;
6
- updateColgroup(newState, tableRef, tablePreserveWidth);
7
+ updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
7
8
  return newState;
8
9
  };
@@ -5,8 +5,8 @@ import { getSelectedTableInfo } from '../../../utils';
5
5
  import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
6
6
  import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
7
7
  import { syncStickyRowToTable } from './dom';
8
- import { getTableMaxWidth } from './misc';
9
- import { MAX_SCALING_PERCENT, TABLE_DEFAULT_WIDTH } from './index';
8
+ import { getTableContainerElementWidth, getTableMaxWidth } from './misc';
9
+ import { COLUMN_MIN_WIDTH, MAX_SCALING_PERCENT, TABLE_DEFAULT_WIDTH } from './index';
10
10
  export const getResizeState = ({
11
11
  minWidth,
12
12
  maxSize,
@@ -14,7 +14,7 @@ export const getResizeState = ({
14
14
  tableRef,
15
15
  start,
16
16
  domAtPos,
17
- tablePreserveWidth = false
17
+ isTableScalingEnabled = false
18
18
  }) => {
19
19
  // If the table has been resized, we can use the column widths from the table node
20
20
  if (hasTableBeenResized(table)) {
@@ -34,19 +34,19 @@ export const getResizeState = ({
34
34
  overflow
35
35
  };
36
36
  }
37
- const shouldReinsertColgroup = !tablePreserveWidth;
37
+ const shouldReinsertColgroup = !isTableScalingEnabled;
38
38
 
39
39
  // Getting the resize state from DOM
40
- const colgroupChildren = insertColgroupFromNode(tableRef, table, tablePreserveWidth, shouldReinsertColgroup // don't reinsert colgroup when preserving table width - this causes widths to jump
40
+ const colgroupChildren = insertColgroupFromNode(tableRef, table, isTableScalingEnabled, shouldReinsertColgroup // don't reinsert colgroup when preserving table width - this causes widths to jump
41
41
  );
42
42
  const cols = Array.from(colgroupChildren).map((_, index) => {
43
43
  // If the table hasn't been resized and we have a table width attribute, we can use it
44
44
  // to calculate the widths of the columns
45
- if (tablePreserveWidth && table.attrs.width) {
45
+ if (isTableScalingEnabled && table.attrs.width) {
46
46
  return {
47
47
  index,
48
48
  width: table.attrs.width / colgroupChildren.length,
49
- minWidth: 48
49
+ minWidth: COLUMN_MIN_WIDTH
50
50
  };
51
51
  }
52
52
  const cellsRefs = getCellsRefsInColumn(index, table, start, domAtPos);
@@ -65,13 +65,12 @@ export const getResizeState = ({
65
65
  };
66
66
 
67
67
  // updates Colgroup DOM node with new widths
68
- export const updateColgroup = (state, tableRef, tablePreserveWidth) => {
68
+ export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled) => {
69
69
  const cols = tableRef.querySelectorAll('col');
70
70
  if (getBooleanFF('platform.editor.custom-table-width')) {
71
71
  const columnsCount = cols.length;
72
- if (tablePreserveWidth) {
73
- var _tableRef$dataset;
74
- const tableWidth = parseInt(((_tableRef$dataset = tableRef.dataset) === null || _tableRef$dataset === void 0 ? void 0 : _tableRef$dataset.tableWidth) || ''); // TODO - get this value from the table node, not the dom
72
+ if (isTableScalingEnabled && tableNode) {
73
+ const tableWidth = getTableContainerElementWidth(tableNode);
75
74
  if (tableWidth) {
76
75
  var _tableRef$parentEleme;
77
76
  let renderWidth = ((_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || TABLE_DEFAULT_WIDTH;
@@ -275,7 +274,7 @@ export const normaliseTableLayout = input => {
275
274
  return 'default';
276
275
  }
277
276
  };
278
- export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getEditorContainerWidth, tablePreserveWidth = false) => {
277
+ export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getEditorContainerWidth, isTableScalingEnabled = false) => {
279
278
  // Fail early so that we don't do complex calculations for no reason
280
279
  const numColumnsSelected = rect.right - rect.left;
281
280
  if (numColumnsSelected <= 1) {
@@ -314,7 +313,7 @@ export const getNewResizeStateFromSelectedColumns = (rect, state, domAtPos, getE
314
313
  tableRef,
315
314
  start: table.start,
316
315
  domAtPos,
317
- tablePreserveWidth
316
+ isTableScalingEnabled
318
317
  });
319
318
  const newResizeState = evenSelectedColumnsWidths(resizeState, rect);
320
319
  const widthsBefore = resizeState.widths;
@@ -10,7 +10,7 @@ import { hasTableBeenResized, insertColgroupFromNode } from './colgroup';
10
10
  import { syncStickyRowToTable } from './dom';
11
11
  // Base function to trigger the actual scale on a table node.
12
12
  // Will only resize/scale if a table has been previously resized.
13
- export const scale = (tableRef, options, domAtPos, tablePreserveWidth = false) => {
13
+ export const scale = (tableRef, options, domAtPos, isTableScalingEnabled = false) => {
14
14
  /**
15
15
  * isBreakoutEnabled === true -> default center aligned
16
16
  * isBreakoutEnabled === false -> full width mode
@@ -58,11 +58,11 @@ export const scale = (tableRef, options, domAtPos, tablePreserveWidth = false) =
58
58
  tableRef,
59
59
  start,
60
60
  domAtPos,
61
- tablePreserveWidth
61
+ isTableScalingEnabled
62
62
  });
63
63
  return scaleTableTo(resizeState, newWidth);
64
64
  };
65
- export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, tablePreserveWidth = false) => {
65
+ export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, isTableScalingEnabled = false) => {
66
66
  const resizeState = getResizeState({
67
67
  minWidth: tableCellMinWidth,
68
68
  maxSize: parentWidth,
@@ -70,7 +70,7 @@ export const scaleWithParent = (tableRef, parentWidth, table, start, domAtPos, t
70
70
  tableRef,
71
71
  start,
72
72
  domAtPos,
73
- tablePreserveWidth
73
+ isTableScalingEnabled
74
74
  });
75
75
  if (table.attrs.isNumberColumnEnabled) {
76
76
  parentWidth -= akEditorTableNumberColumnWidth;
@@ -105,7 +105,7 @@ export function scaleTableTo(state, maxSize) {
105
105
  }
106
106
  return adjustColumnsWidths(newState, maxSize);
107
107
  }
108
- export const previewScaleTable = (tableRef, options, domAtPos, tablePreserveWidth = false) => {
108
+ export const previewScaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false) => {
109
109
  const {
110
110
  node,
111
111
  start,
@@ -121,19 +121,19 @@ export const previewScaleTable = (tableRef, options, domAtPos, tablePreserveWidt
121
121
  }
122
122
 
123
123
  // If the table hasn't been resize, the colgroup 48px width values will gracefully scale down.
124
- // If we are scaling the table down with tablePreserveWidth, the colgroup widths may be scaled to a value that is not 48px.
125
- if (!hasTableBeenResized(node) && !tablePreserveWidth) {
124
+ // If we are scaling the table down with isTableScalingEnabled, the colgroup widths may be scaled to a value that is not 48px.
125
+ if (!hasTableBeenResized(node) && !isTableScalingEnabled) {
126
126
  syncStickyRowToTable(tableRef);
127
127
  return;
128
128
  }
129
- const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, tablePreserveWidth) : scale(tableRef, options, domAtPos, tablePreserveWidth);
129
+ const resizeState = parentWidth ? scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabled) : scale(tableRef, options, domAtPos, isTableScalingEnabled);
130
130
  if (resizeState) {
131
- updateColgroup(resizeState, tableRef, tablePreserveWidth);
131
+ updateColgroup(resizeState, tableRef, node, isTableScalingEnabled);
132
132
  }
133
133
  };
134
134
 
135
135
  // Scale the table to meet new requirements (col, layout change etc)
136
- export const scaleTable = (tableRef, options, domAtPos, tablePreserveWidth = false) => tr => {
136
+ export const scaleTable = (tableRef, options, domAtPos, isTableScalingEnabled = false) => tr => {
137
137
  if (!tableRef) {
138
138
  return tr;
139
139
  }
@@ -147,7 +147,7 @@ export const scaleTable = (tableRef, options, domAtPos, tablePreserveWidth = fal
147
147
  if (hasTableBeenResized(node) === false) {
148
148
  // If its not a re-sized table, we still want to re-create cols
149
149
  // To force reflow of columns upon delete.
150
- if (!tablePreserveWidth) {
150
+ if (!isTableScalingEnabled) {
151
151
  insertColgroupFromNode(tableRef, node);
152
152
  }
153
153
  tr.setMeta('scrollIntoView', false);
@@ -155,9 +155,9 @@ export const scaleTable = (tableRef, options, domAtPos, tablePreserveWidth = fal
155
155
  }
156
156
  let resizeState;
157
157
  if (parentWidth) {
158
- resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, tablePreserveWidth);
158
+ resizeState = scaleWithParent(tableRef, parentWidth, node, start, domAtPos, isTableScalingEnabled);
159
159
  } else {
160
- resizeState = scale(tableRef, options, domAtPos, tablePreserveWidth);
160
+ resizeState = scale(tableRef, options, domAtPos, isTableScalingEnabled);
161
161
  }
162
162
  if (resizeState) {
163
163
  tr = updateColumnWidths(resizeState, node, start)(tr);
@@ -11,9 +11,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
11
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
12
12
  import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
13
13
  import { findTable } from '@atlaskit/editor-tables/utils';
14
+ import { getPluginState } from './plugin-factory';
14
15
  import { TABLE_MAX_WIDTH } from './table-resizing/utils';
15
16
  export const pluginKey = new PluginKey('tableWidthPlugin');
16
- const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, getEditorFeatureFlags) => {
17
+ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled) => {
17
18
  return new SafePlugin({
18
19
  key: pluginKey,
19
20
  state: {
@@ -78,7 +79,10 @@ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, getEdi
78
79
  return hasStepReplacingEntireDocument;
79
80
  });
80
81
  const referentialityTr = transactions.find(tr => tr.getMeta('referentialityTableInserted'));
81
- const shouldPatchTable = fullWidthEnabled && getEditorFeatureFlags && getEditorFeatureFlags()['tablePreserveWidth'];
82
+ const {
83
+ isTableScalingEnabled = false
84
+ } = getPluginState(newState);
85
+ const shouldPatchTable = fullWidthEnabled && isTableScalingEnabled;
82
86
  if (!isReplaceDocumentOperation && (!shouldPatchTable || !referentialityTr)) {
83
87
  return null;
84
88
  }