@atlaskit/editor-plugin-table 7.6.14 → 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/commands/misc.js +0 -2
  3. package/dist/cjs/nodeviews/OverflowShadowsObserver.js +1 -3
  4. package/dist/cjs/nodeviews/TableComponent.js +3 -18
  5. package/dist/cjs/nodeviews/TableContainer.js +6 -25
  6. package/dist/cjs/nodeviews/TableResizer.js +2 -2
  7. package/dist/cjs/nodeviews/table.js +0 -2
  8. package/dist/cjs/plugin.js +3 -20
  9. package/dist/cjs/pm-plugins/main.js +1 -2
  10. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +12 -21
  11. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -57
  12. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -2
  13. package/dist/cjs/pm-plugins/table-resizing/utils/resize-column.js +29 -4
  14. package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +19 -0
  15. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +16 -28
  16. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -12
  17. package/dist/cjs/reducer.js +0 -2
  18. package/dist/cjs/transforms/column-width.js +3 -5
  19. package/dist/cjs/types.js +0 -1
  20. package/dist/cjs/ui/ColumnResizeWidget/index.js +5 -1
  21. package/dist/cjs/ui/common-styles.js +5 -12
  22. package/dist/cjs/ui/ui-styles.js +7 -12
  23. package/dist/cjs/utils/index.js +0 -6
  24. package/dist/cjs/utils/nodes.js +5 -18
  25. package/dist/es2019/commands/misc.js +0 -2
  26. package/dist/es2019/nodeviews/OverflowShadowsObserver.js +1 -3
  27. package/dist/es2019/nodeviews/TableComponent.js +3 -18
  28. package/dist/es2019/nodeviews/TableContainer.js +6 -24
  29. package/dist/es2019/nodeviews/TableResizer.js +2 -2
  30. package/dist/es2019/nodeviews/table.js +0 -2
  31. package/dist/es2019/plugin.js +5 -24
  32. package/dist/es2019/pm-plugins/main.js +1 -2
  33. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +13 -22
  34. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +30 -53
  35. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -2
  36. package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +28 -4
  37. package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +20 -0
  38. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +14 -24
  39. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -12
  40. package/dist/es2019/reducer.js +0 -5
  41. package/dist/es2019/transforms/column-width.js +3 -5
  42. package/dist/es2019/types.js +0 -1
  43. package/dist/es2019/ui/ColumnResizeWidget/index.js +5 -1
  44. package/dist/es2019/ui/common-styles.js +15 -46
  45. package/dist/es2019/ui/ui-styles.js +34 -41
  46. package/dist/es2019/utils/index.js +1 -1
  47. package/dist/es2019/utils/nodes.js +0 -15
  48. package/dist/esm/commands/misc.js +0 -2
  49. package/dist/esm/nodeviews/OverflowShadowsObserver.js +1 -3
  50. package/dist/esm/nodeviews/TableComponent.js +3 -18
  51. package/dist/esm/nodeviews/TableContainer.js +6 -25
  52. package/dist/esm/nodeviews/TableResizer.js +2 -2
  53. package/dist/esm/nodeviews/table.js +0 -2
  54. package/dist/esm/plugin.js +5 -22
  55. package/dist/esm/pm-plugins/main.js +1 -2
  56. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +13 -22
  57. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -57
  58. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +1 -2
  59. package/dist/esm/pm-plugins/table-resizing/utils/resize-column.js +30 -4
  60. package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +18 -0
  61. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +16 -28
  62. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -12
  63. package/dist/esm/reducer.js +0 -2
  64. package/dist/esm/transforms/column-width.js +3 -5
  65. package/dist/esm/types.js +0 -1
  66. package/dist/esm/ui/ColumnResizeWidget/index.js +5 -1
  67. package/dist/esm/ui/common-styles.js +6 -13
  68. package/dist/esm/ui/ui-styles.js +7 -12
  69. package/dist/esm/utils/index.js +1 -1
  70. package/dist/esm/utils/nodes.js +0 -13
  71. package/dist/types/nodeviews/TableContainer.d.ts +1 -2
  72. package/dist/types/nodeviews/types.d.ts +0 -1
  73. package/dist/types/plugin.d.ts +0 -1
  74. package/dist/types/pm-plugins/main.d.ts +1 -1
  75. package/dist/types/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
  76. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
  77. package/dist/types/types.d.ts +0 -9
  78. package/dist/types/ui/FloatingContextualButton/index.d.ts +0 -2
  79. package/dist/types/utils/index.d.ts +1 -1
  80. package/dist/types/utils/nodes.d.ts +0 -1
  81. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +1 -2
  82. package/dist/types-ts4.5/nodeviews/types.d.ts +0 -1
  83. package/dist/types-ts4.5/plugin.d.ts +0 -1
  84. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  85. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
  86. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
  87. package/dist/types-ts4.5/types.d.ts +0 -9
  88. package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +0 -2
  89. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  90. package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
  91. package/package.json +7 -10
  92. package/src/commands/misc.ts +0 -2
  93. package/src/nodeviews/OverflowShadowsObserver.ts +1 -6
  94. package/src/nodeviews/TableComponent.tsx +2 -25
  95. package/src/nodeviews/TableContainer.tsx +7 -34
  96. package/src/nodeviews/TableResizer.tsx +2 -8
  97. package/src/nodeviews/table.tsx +0 -2
  98. package/src/nodeviews/types.ts +0 -1
  99. package/src/plugin.tsx +4 -43
  100. package/src/pm-plugins/main.ts +0 -2
  101. package/src/pm-plugins/table-resizing/event-handlers.ts +13 -37
  102. package/src/pm-plugins/table-resizing/utils/colgroup.ts +40 -61
  103. package/src/pm-plugins/table-resizing/utils/misc.ts +4 -6
  104. package/src/pm-plugins/table-resizing/utils/resize-column.ts +52 -9
  105. package/src/pm-plugins/table-resizing/utils/resize-logic.ts +25 -0
  106. package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -29
  107. package/src/pm-plugins/table-resizing/utils/scale-table.ts +2 -13
  108. package/src/reducer.ts +0 -3
  109. package/src/transforms/column-width.ts +2 -10
  110. package/src/types.ts +0 -8
  111. package/src/ui/ColumnResizeWidget/index.tsx +10 -1
  112. package/src/ui/FloatingContextualButton/index.tsx +0 -2
  113. package/src/ui/common-styles.ts +15 -53
  114. package/src/ui/ui-styles.ts +34 -47
  115. package/src/utils/index.ts +0 -1
  116. package/src/utils/nodes.ts +0 -23
  117. package/dist/cjs/ui/LayoutButton/index.js +0 -206
  118. package/dist/es2019/ui/LayoutButton/index.js +0 -168
  119. package/dist/esm/ui/LayoutButton/index.js +0 -196
  120. package/dist/types/ui/LayoutButton/index.d.ts +0 -21
  121. package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +0 -21
  122. package/src/ui/LayoutButton/index.tsx +0 -217
@@ -119,16 +119,12 @@ class TableComponent extends React.Component {
119
119
  const node = getNode();
120
120
  const prevAttrs = prevNode.attrs;
121
121
  const isNested = isTableNested(this.props.view.state, this.props.getPos());
122
- // We only consider a layout change valid if it's done outside of an autoSize.
123
- const layoutChanged = prevAttrs.layout !== node.attrs.layout && prevAttrs.__autoSize === node.attrs.__autoSize;
124
122
  const parentWidth = this.getParentNodeWidth();
125
123
  const parentWidthChanged = parentWidth && parentWidth !== this.state.parentWidth;
126
124
  const layoutSize = this.tableNodeLayoutSize(node, containerWidth.width, options);
127
125
  const hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
128
126
  const noOfColumnsChanged = tablesHaveDifferentNoOfColumns(node, prevNode);
129
127
  if (
130
- // Breakout mode/layout changed
131
- layoutChanged ||
132
128
  // We need to react if our parent changes
133
129
  // Scales the cols widths relative to the new parent width.
134
130
  parentWidthChanged ||
@@ -142,8 +138,7 @@ class TableComponent extends React.Component {
142
138
  // If column has been inserted/deleted avoid multi dispatch
143
139
  if (shouldScaleTable) {
144
140
  this.scaleTable({
145
- parentWidth,
146
- layoutChanged
141
+ parentWidth
147
142
  });
148
143
  }
149
144
 
@@ -151,8 +146,7 @@ class TableComponent extends React.Component {
151
146
  if (options !== null && options !== void 0 && options.isTableResizingEnabled && hasNumberedColumnChanged) {
152
147
  if (!hasTableBeenResized(prevNode)) {
153
148
  this.scaleTable({
154
- parentWidth: node.attrs.width,
155
- layoutChanged
149
+ parentWidth: node.attrs.width
156
150
  });
157
151
  }
158
152
  }
@@ -239,22 +233,17 @@ class TableComponent extends React.Component {
239
233
  }
240
234
  });
241
235
  _defineProperty(this, "handleWindowResize", () => {
242
- var _node$attrs, _node$attrs2;
243
236
  const {
244
237
  getNode,
245
238
  containerWidth
246
239
  } = this.props;
247
240
  const node = getNode();
248
- const prevNode = this.node;
249
241
  const layoutSize = this.tableNodeLayoutSize(node);
250
- const prevAttrs = prevNode === null || prevNode === void 0 ? void 0 : prevNode.attrs;
251
- const layoutChanged = (prevAttrs === null || prevAttrs === void 0 ? void 0 : prevAttrs.layout) !== (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) && (prevAttrs === null || prevAttrs === void 0 ? void 0 : prevAttrs.__autoSize) === (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.__autoSize);
252
242
  if (containerWidth.width > layoutSize) {
253
243
  return;
254
244
  }
255
245
  const parentWidth = this.getParentNodeWidth();
256
246
  this.scaleTableDebounced({
257
- layoutChanged: layoutChanged,
258
247
  parentWidth: parentWidth
259
248
  });
260
249
  });
@@ -702,7 +691,6 @@ class TableComponent extends React.Component {
702
691
  node: node,
703
692
  tableRef: tableRef,
704
693
  containerWidth: containerWidth,
705
- isBreakoutEnabled: options === null || options === void 0 ? void 0 : options.isBreakoutEnabled,
706
694
  isNested: isNested,
707
695
  pluginInjectionApi: pluginInjectionApi,
708
696
  tableWrapperHeight: this.state.tableWrapperHeight,
@@ -773,10 +761,7 @@ class TableComponent extends React.Component {
773
761
  }), this.state.stickyHeader && /*#__PURE__*/React.createElement("div", {
774
762
  style: {
775
763
  position: 'absolute',
776
- right: getBooleanFF('platform.editor.custom-table-width') ? `${"var(--ds-space-400, 32px)" // tableOverflowShadowWidthWide
777
- }` :
778
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
779
- '22px'
764
+ right: "var(--ds-space-400, 32px)" // tableOverflowShadowWidthWide
780
765
  }
781
766
  }, /*#__PURE__*/React.createElement("div", {
782
767
  className: `${ClassName.TABLE_RIGHT_SHADOW} ${ClassName.TABLE_STICKY_SHADOW}`,
@@ -2,22 +2,10 @@ import React, { forwardRef, useCallback, useRef, useState } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
- import { calcTableWidth } from '@atlaskit/editor-common/styles';
6
5
  import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMediaResizeHandlerPaddingWide, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
7
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
6
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
9
7
  import { TableCssClassName as ClassName } from '../types';
10
8
  import { TableResizer } from './TableResizer';
11
- const getMarginLeft = (lineLength, tableWidth) => {
12
- let marginLeft;
13
- if (tableWidth !== 'inherit' && lineLength) {
14
- const containerWidth = tableWidth;
15
- if (containerWidth) {
16
- marginLeft = (lineLength - containerWidth) / 2;
17
- }
18
- }
19
- return marginLeft;
20
- };
21
9
  export const InnerContainer = /*#__PURE__*/forwardRef(({
22
10
  className,
23
11
  style,
@@ -130,13 +118,11 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
130
118
  isWholeTableInDanger,
131
119
  pluginInjectionApi
132
120
  };
133
- if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
134
- tableResizerProps = {
135
- ...tableResizerProps,
136
- onResizeStart: onResizeStart,
137
- onResizeStop: onResizeStop
138
- };
139
- }
121
+ tableResizerProps = {
122
+ ...tableResizerProps,
123
+ onResizeStart: onResizeStart,
124
+ onResizeStop: onResizeStop
125
+ };
140
126
  return /*#__PURE__*/React.createElement("div", {
141
127
  style: {
142
128
  display: 'flex',
@@ -162,11 +148,9 @@ export const TableContainer = ({
162
148
  node,
163
149
  className,
164
150
  containerWidth: {
165
- lineLength,
166
151
  width: editorWidth
167
152
  },
168
153
  isTableResizingEnabled,
169
- isBreakoutEnabled,
170
154
  editorView,
171
155
  getPos,
172
156
  tableRef,
@@ -192,15 +176,13 @@ export const TableContainer = ({
192
176
  isWholeTableInDanger: isWholeTableInDanger
193
177
  }, children);
194
178
  }
195
- const tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
196
179
  return /*#__PURE__*/React.createElement(InnerContainer, {
197
180
  node: node,
198
181
  className: classNames(className, {
199
182
  'less-padding': editorWidth < akEditorMobileBreakoutPoint && !isNested
200
183
  }),
201
184
  style: {
202
- width: tableWidth,
203
- marginLeft: getMarginLeft(lineLength, tableWidth)
185
+ width: 'inherit'
204
186
  }
205
187
  }, children);
206
188
  };
@@ -165,7 +165,7 @@ export const TableResizer = ({
165
165
  dispatch(tr);
166
166
  const visibleGuidelines = getVisibleGuidelines(isTableScalingEnabled ? defaultGuidelinesForPreserveTable(containerWidth) : defaultGuidelines, containerWidth);
167
167
  setSnappingEnabled(displayGuideline(visibleGuidelines));
168
- if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStart) {
168
+ if (onResizeStart) {
169
169
  onResizeStart();
170
170
  }
171
171
  }, [startMeasure, editorView, displayGapCursor, isTableScalingEnabled, containerWidth, displayGuideline, onResizeStart]);
@@ -272,7 +272,7 @@ export const TableResizer = ({
272
272
  displayGuideline([]);
273
273
  updateWidth(newWidth);
274
274
  scheduleResize.cancel();
275
- if (getBooleanFF('platform.editor.resizing-table-height-improvement') && onResizeStop) {
275
+ if (onResizeStop) {
276
276
  onResizeStop();
277
277
  }
278
278
  return newWidth;
@@ -246,7 +246,6 @@ export default class TableView extends ReactNodeView {
246
246
  export const createTableView = (node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, dispatchAnalyticsEvent, pluginInjectionApi) => {
247
247
  const {
248
248
  pluginConfig,
249
- isBreakoutEnabled,
250
249
  isFullWidthModeEnabled,
251
250
  wasFullWidthModeEnabled,
252
251
  isTableResizingEnabled,
@@ -267,7 +266,6 @@ export const createTableView = (node, view, getPos, portalProviderAPI, eventDisp
267
266
  eventDispatcher,
268
267
  getPos: getPos,
269
268
  options: {
270
- isBreakoutEnabled,
271
269
  isFullWidthModeEnabled,
272
270
  wasFullWidthModeEnabled,
273
271
  isTableResizingEnabled,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { table, tableCell, tableHeader, tableRow, tableWithCustomWidth } from '@atlaskit/adf-schema';
2
+ import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
4
4
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
5
5
  import { IconTable } from '@atlaskit/editor-common/icons';
@@ -33,8 +33,7 @@ import FloatingContextualMenu from './ui/FloatingContextualMenu';
33
33
  import FloatingDeleteButton from './ui/FloatingDeleteButton';
34
34
  import FloatingDragMenu from './ui/FloatingDragMenu';
35
35
  import FloatingInsertButton from './ui/FloatingInsertButton';
36
- import LayoutButton from './ui/LayoutButton';
37
- import { createTableWithWidth, isLayoutSupported } from './utils';
36
+ import { createTableWithWidth } from './utils';
38
37
  const defaultGetEditorFeatureFlags = () => ({});
39
38
 
40
39
  // TODO: duplicating type instead of importing media plugin causing a circular dependency
@@ -107,10 +106,9 @@ const tablesPlugin = ({
107
106
  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)
108
107
  },
109
108
  nodes() {
110
- const tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
111
109
  return [{
112
110
  name: 'table',
113
- node: tableNode
111
+ node: table
114
112
  }, {
115
113
  name: 'tableHeader',
116
114
  node: tableHeader
@@ -136,13 +134,12 @@ const tablesPlugin = ({
136
134
  fullWidthEnabled,
137
135
  wasFullWidthEnabled,
138
136
  tableResizingEnabled,
139
- breakoutEnabled,
140
137
  tableOptions,
141
138
  getEditorFeatureFlags,
142
139
  dragAndDropEnabled,
143
140
  isTableScalingEnabled
144
141
  } = options || {};
145
- return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled);
142
+ return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled);
146
143
  }
147
144
  }, {
148
145
  name: 'tablePMColResizing',
@@ -305,9 +302,6 @@ const tablesPlugin = ({
305
302
  tableWidthPluginState,
306
303
  dragAndDropState
307
304
  }) => {
308
- const {
309
- state
310
- } = editorView;
311
305
  const isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
312
306
  const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
313
307
  const isResizing = isColumnResizing || isTableResizing;
@@ -316,7 +310,6 @@ const tablesPlugin = ({
316
310
  tablePos,
317
311
  targetCellPosition,
318
312
  isContextualMenuOpen,
319
- layout,
320
313
  tableRef,
321
314
  pluginConfig,
322
315
  insertColumnButtonIndex,
@@ -330,17 +323,6 @@ const tablesPlugin = ({
330
323
  allowControls
331
324
  } = pluginConfig;
332
325
  const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
333
- const LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
334
- editorView: editorView,
335
- mountPoint: popupsMountPoint,
336
- boundariesElement: popupsBoundariesElement,
337
- scrollableElement: popupsScrollableElement,
338
- targetRef: tableWrapperTarget,
339
- layout: layout,
340
- isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
341
- stickyHeader: stickyHeader,
342
- editorAnalyticsAPI: editorAnalyticsAPI
343
- }) : null;
344
326
  return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
345
327
  isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
346
328
  editorView: editorView,
@@ -350,7 +332,6 @@ const tablesPlugin = ({
350
332
  scrollableElement: popupsScrollableElement,
351
333
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
352
334
  isContextualMenuOpen: isContextualMenuOpen,
353
- layout: layout,
354
335
  stickyHeader: stickyHeader,
355
336
  tableWrapper: tableWrapperTarget
356
337
  }), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
@@ -403,7 +384,7 @@ const tablesPlugin = ({
403
384
  stickyHeaders: stickyHeader,
404
385
  isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
405
386
  editorAnalyticsAPI: editorAnalyticsAPI
406
- }), LayoutContent);
387
+ }));
407
388
  }
408
389
  }));
409
390
  },
@@ -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, isTableScalingEnabled) => {
25
+ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled) => {
26
26
  var _accessibilityUtils;
27
27
  const state = createPluginState(dispatch, {
28
28
  pluginConfig,
@@ -30,7 +30,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
30
30
  insertColumnButtonIndex: undefined,
31
31
  insertRowButtonIndex: undefined,
32
32
  isFullWidthModeEnabled: fullWidthModeEnabled,
33
- isBreakoutEnabled: breakoutEnabled,
34
33
  wasFullWidthModeEnabled: previousFullWidthModeEnabled,
35
34
  isTableResizingEnabled: tableResizingEnabled,
36
35
  isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
@@ -1,7 +1,5 @@
1
1
  import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
2
- import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
3
2
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
4
- import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
5
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
4
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
7
5
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -13,7 +11,7 @@ import { getPluginState as getTablePluginState } from '../plugin-factory';
13
11
  import { META_KEYS } from '../table-analytics';
14
12
  import { evenColumns, setDragging, stopResizing } from './commands';
15
13
  import { getPluginState } from './plugin-factory';
16
- import { currentColWidth, getLayoutSize, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, updateControls } from './utils';
14
+ import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, updateControls } from './utils';
17
15
  export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) => {
18
16
  const {
19
17
  state,
@@ -47,25 +45,13 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
47
45
  if (dom && dom.nodeName !== 'TABLE') {
48
46
  dom = dom.closest('table');
49
47
  }
50
- let maxSize;
51
- if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
52
- const containerWidth = getEditorContainerWidth();
53
- const parentWidth = getParentNodeWidth(start, state, containerWidth);
54
- maxSize = getBooleanFF('platform.editor.custom-table-width') ? parentWidth ||
55
- // its safe to reference table width from node as this will not have changed
56
- originalTable.attrs.width || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {}) : parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
57
- if (originalTable.attrs.isNumberColumnEnabled) {
58
- maxSize -= akEditorTableNumberColumnWidth;
59
- }
60
- } else {
61
- maxSize = getTableMaxWidth({
62
- table: originalTable,
63
- tableStart: start,
64
- state,
65
- layout: originalTable.attrs.layout,
66
- getEditorContainerWidth
67
- });
68
- }
48
+ const maxSize = getTableMaxWidth({
49
+ table: originalTable,
50
+ tableStart: start,
51
+ state,
52
+ layout: originalTable.attrs.layout,
53
+ getEditorContainerWidth
54
+ });
69
55
  const shouldScale = tableDepth === 0 && isTableScalingEnabled;
70
56
  const resizeState = getResizeState({
71
57
  minWidth: tableCellMinWidth,
@@ -162,6 +148,11 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
162
148
  const newResizeState = resizeColumn(resizeState, colIndex, clientX - startX, dom, originalTable, resizingSelectedColumns ? selectedColumns : undefined, shouldScale);
163
149
  const resizedDelta = clientX - startX;
164
150
  tr = updateColumnWidths(newResizeState, table, start)(tr);
151
+
152
+ // console.log('debug newResizeState=', newResizeState);
153
+ if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
154
+ tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
155
+ }
165
156
  if (colIndex === map.width - 1) {
166
157
  const mouseUpTime = event.timeStamp;
167
158
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
@@ -2,7 +2,6 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
2
  import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
3
3
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
4
4
  import { TableMap } from '@atlaskit/editor-tables/table-map';
5
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
5
  import { getTableScalingPercent } from './misc';
7
6
  /**
8
7
  * This ensures the combined width of the columns (and tbody) of table is always smaller or equal
@@ -13,62 +12,40 @@ import { getTableScalingPercent } from './misc';
13
12
  export const getColWidthFix = (colwidth, tableColumnCount) => colwidth - 1 / tableColumnCount;
14
13
  export const generateColgroup = (table, tableRef) => {
15
14
  const cols = [];
16
- if (getBooleanFF('platform.editor.custom-table-width')) {
17
- const map = TableMap.get(table);
18
- table.content.firstChild.content.forEach(cell => {
19
- const colspan = cell.attrs.colspan || 1;
20
- if (Array.isArray(cell.attrs.colwidth)) {
21
- // We slice here to guard against our colwidth array having more entries
22
- // Than the we actually span. We'll patch the document at a later point.
23
- if (tableRef) {
24
- const scalePercent = getTableScalingPercent(table, tableRef);
25
- cell.attrs.colwidth.slice(0, colspan).forEach(width => {
26
- const fixedColWidth = getColWidthFix(width, map.width);
27
- const scaledWidth = fixedColWidth * scalePercent;
28
- const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
29
- cols.push(['col', {
30
- style: `width: ${finalWidth}px;`
31
- }]);
32
- });
33
- } else {
34
- cell.attrs.colwidth.slice(0, colspan).forEach(width => {
35
- cols.push(['col', {
36
- style: `width: ${getColWidthFix(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, map.width)}px;`
37
- }]);
38
- });
39
- }
40
- } else {
41
- // When we have merged cells on the first row (firstChild),
42
- // We want to ensure we're creating the appropriate amount of
43
- // cols the table still has.
44
- cols.push(...Array.from({
45
- length: colspan
46
- }, _ => ['col', {
47
- style: `width: ${tableCellMinWidth}px;`
48
- }]));
49
- }
50
- });
51
- } else {
52
- table.content.firstChild.content.forEach(cell => {
53
- const colspan = cell.attrs.colspan || 1;
54
- if (Array.isArray(cell.attrs.colwidth)) {
55
- // We slice here to guard against our colwidth array having more entries
56
- // Than the we actually span. We'll patch the document at a later point.
15
+ const map = TableMap.get(table);
16
+ table.content.firstChild.content.forEach(cell => {
17
+ const colspan = cell.attrs.colspan || 1;
18
+ if (Array.isArray(cell.attrs.colwidth)) {
19
+ // We slice here to guard against our colwidth array having more entries
20
+ // Than the we actually span. We'll patch the document at a later point.
21
+ if (tableRef) {
22
+ const scalePercent = getTableScalingPercent(table, tableRef);
57
23
  cell.attrs.colwidth.slice(0, colspan).forEach(width => {
58
- cols.push(['col', width ? {
59
- style: `width: ${width}px;`
60
- } : {}]);
24
+ const fixedColWidth = getColWidthFix(width, map.width);
25
+ const scaledWidth = fixedColWidth * scalePercent;
26
+ const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
27
+ cols.push(['col', {
28
+ style: `width: ${finalWidth}px;`
29
+ }]);
61
30
  });
62
31
  } else {
63
- // When we have merged cells on the first row (firstChild),
64
- // We want to ensure we're creating the appropriate amount of
65
- // cols the table still has.
66
- cols.push(...Array.from({
67
- length: colspan
68
- }, _ => ['col', {}]));
32
+ cell.attrs.colwidth.slice(0, colspan).forEach(width => {
33
+ cols.push(['col', {
34
+ style: `width: ${getColWidthFix(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, map.width)}px;`
35
+ }]);
36
+ });
69
37
  }
70
- });
71
- }
38
+ } else {
39
+ // When we have merged cells on the first row (firstChild),
40
+ // We want to ensure we're creating the appropriate amount of
41
+ // cols the table still has.
42
+ cols.push(...Array.from({
43
+ length: colspan
44
+ }, _ => ['col', {
45
+ style: `width: ${tableCellMinWidth}px;`
46
+ }]));
47
+ }
48
+ });
72
49
  return cols;
73
50
  };
74
51
  export const insertColgroupFromNode = (tableRef, table, isTableScalingEnabled = false, shouldRemove = true) => {
@@ -3,7 +3,6 @@ import { calcTableWidth } from '@atlaskit/editor-common/styles';
3
3
  import { getBreakpoint, mapBreakpointToLayoutMaxWidth } from '@atlaskit/editor-common/ui';
4
4
  import { calcTableColumnWidths, containsClassName } from '@atlaskit/editor-common/utils';
5
5
  import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
6
  import { hasTableBeenResized } from './colgroup';
8
7
  import { MAX_SCALING_PERCENT } from './consts';
9
8
 
@@ -69,7 +68,7 @@ export const getTableMaxWidth = ({
69
68
  }) => {
70
69
  const containerWidth = getEditorContainerWidth();
71
70
  const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
72
- let maxWidth = getBooleanFF('platform.editor.custom-table-width') ? parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {}) : parentWidth || getLayoutSize(layout, containerWidth.width, {});
71
+ let maxWidth = parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {});
73
72
  if (table.attrs.isNumberColumnEnabled) {
74
73
  maxWidth -= akEditorTableNumberColumnWidth;
75
74
  }
@@ -1,16 +1,40 @@
1
1
  // Resize a given column by an amount from the current state
2
2
 
3
- import { getTableScalingPercent } from './misc';
4
- import { growColumn, shrinkColumn } from './resize-logic';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
+ import { TableCssClassName as ClassName } from '../../../types';
5
+ import { getTableContainerElementWidth, getTableScalingPercent } from './misc';
6
+ import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
5
7
  import { updateColgroup } from './resize-state';
6
8
  export const resizeColumn = (resizeState, colIndex, amount, tableRef, tableNode, selectedColumns, isTableScalingEnabled = false) => {
7
9
  let scalePercent = 1;
8
- let resizeAmount = amount;
10
+ let resizeAmount = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? amount * 2 : amount;
9
11
  if (isTableScalingEnabled) {
10
12
  scalePercent = getTableScalingPercent(tableNode, tableRef);
11
13
  resizeAmount = amount / scalePercent;
12
14
  }
13
- const newState = resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
15
+ const newState = getBooleanFF('platform.editor.table.colum-resizing-improvements') ? updateAffectedColumn(resizeState, colIndex, resizeAmount) : resizeAmount > 0 ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeAmount < 0 ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns) : resizeState;
14
16
  updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
17
+ if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
18
+ // use the difference in width from affected column to update overall table width
19
+ const delta = newState.cols[colIndex].width - resizeState.cols[colIndex].width;
20
+ updateTable(delta, tableRef, tableNode);
21
+ return {
22
+ ...newState,
23
+ tableWidth: resizeState.tableWidth + delta
24
+ };
25
+ }
15
26
  return newState;
27
+ };
28
+ const updateTable = (resizeAmount, tableRef, tableNode
29
+ // isTableScalingEnabled: boolean,
30
+ ) => {
31
+ const currentWidth = getTableContainerElementWidth(tableNode);
32
+ const resizingContainer = tableRef.closest(`.${ClassName.TABLE_RESIZER_CONTAINER}`);
33
+ const resizingItem = resizingContainer === null || resizingContainer === void 0 ? void 0 : resizingContainer.querySelector('.resizer-item');
34
+ if (resizingContainer && resizingItem) {
35
+ const newWidth = `${currentWidth + resizeAmount}px`;
36
+ tableRef.style.width = newWidth;
37
+ resizingContainer.style.width = newWidth;
38
+ resizingItem.style.width = newWidth;
39
+ }
16
40
  };
@@ -193,4 +193,24 @@ function getCandidates(state, destIdx, amount) {
193
193
 
194
194
  // only consider rows after the selected column in the direction of resize
195
195
  return amount < 0 ? candidates.slice(0, destIdx) : candidates.slice(destIdx + 1);
196
+ }
197
+
198
+ /**
199
+ * Update the given column based on resizeAmount, maintaining all other columns
200
+ */
201
+ export function updateAffectedColumn(resizeState, colIndex, resizeAmount) {
202
+ const updatedCols = resizeState.cols.map((col, index) => {
203
+ if (index === colIndex) {
204
+ const newWidth = Math.max(col.width + resizeAmount, col.minWidth);
205
+ return {
206
+ ...col,
207
+ width: newWidth
208
+ };
209
+ }
210
+ return col;
211
+ });
212
+ return {
213
+ ...resizeState,
214
+ cols: updatedCols
215
+ };
196
216
  }
@@ -1,7 +1,6 @@
1
1
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
2
2
  import { tableCellMinWidth, tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
3
3
  import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
4
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
4
  import { getSelectedTableInfo } from '../../../utils';
6
5
  import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
7
6
  import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
@@ -74,33 +73,24 @@ export const getResizeState = ({
74
73
  // updates Colgroup DOM node with new widths
75
74
  export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled) => {
76
75
  const cols = tableRef.querySelectorAll('col');
77
- if (getBooleanFF('platform.editor.custom-table-width')) {
78
- const columnsCount = cols.length;
79
- if (isTableScalingEnabled && tableNode) {
80
- const scalePercent = getTableScalingPercent(tableNode, tableRef);
81
- state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
82
- .forEach((column, i) => {
83
- const fixedColWidth = getColWidthFix(column.width, columnsCount);
84
- const scaledWidth = fixedColWidth * scalePercent;
85
- const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
86
- // we aren't handling the remaining pixels here when the 48px min width is reached
87
- if (cols[i]) {
88
- cols[i].style.width = `${finalWidth}px`;
89
- }
90
- });
91
- } else {
92
- state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
93
- .forEach((column, i) => {
94
- if (cols[i]) {
95
- cols[i].style.width = `${getColWidthFix(column.width, columnsCount)}px`;
96
- }
97
- });
98
- }
76
+ const columnsCount = cols.length;
77
+ if (isTableScalingEnabled && tableNode) {
78
+ const scalePercent = getTableScalingPercent(tableNode, tableRef);
79
+ state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
80
+ .forEach((column, i) => {
81
+ const fixedColWidth = getColWidthFix(column.width, columnsCount);
82
+ const scaledWidth = fixedColWidth * scalePercent;
83
+ const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
84
+ // we aren't handling the remaining pixels here when the 48px min width is reached
85
+ if (cols[i]) {
86
+ cols[i].style.width = `${finalWidth}px`;
87
+ }
88
+ });
99
89
  } else {
100
90
  state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
101
91
  .forEach((column, i) => {
102
92
  if (cols[i]) {
103
- cols[i].style.width = `${column.width}px`;
93
+ cols[i].style.width = `${getColWidthFix(column.width, columnsCount)}px`;
104
94
  }
105
95
  });
106
96
  }
@@ -11,28 +11,18 @@ 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
13
  export const scale = (tableRef, options, domAtPos, isTableScalingEnabled = false) => {
14
- /**
15
- * isBreakoutEnabled === true -> default center aligned
16
- * isBreakoutEnabled === false -> full width mode
17
- */
18
-
19
14
  const {
20
15
  node,
21
16
  containerWidth,
22
17
  previousContainerWidth,
23
18
  prevNode,
24
19
  start,
25
- isBreakoutEnabled,
26
20
  layoutChanged,
27
21
  isTableResizingEnabled
28
22
  } = options;
29
- const maxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(node.attrs.layout, containerWidth, {
30
- isBreakoutEnabled
31
- });
23
+ const maxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(node.attrs.layout, containerWidth, {});
32
24
  const prevTableWidth = getTableWidth(prevNode);
33
- const previousMaxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
34
- isBreakoutEnabled
35
- });
25
+ const previousMaxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {});
36
26
  let newWidth = maxSize;
37
27
 
38
28
  // adjust table width if layout is updated
@@ -29,11 +29,6 @@ export default ((pluginState, action) => {
29
29
  ...action.data,
30
30
  isContextualMenuOpen: false
31
31
  };
32
- case 'SET_TABLE_LAYOUT':
33
- return {
34
- ...pluginState,
35
- ...action.data
36
- };
37
32
  case 'TOGGLE_CONTEXTUAL_MENU':
38
33
  return {
39
34
  ...pluginState,