@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
@@ -7,7 +7,6 @@ import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
7
7
  import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
8
8
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
9
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
10
- import { calcTableWidth } from '@atlaskit/editor-common/styles';
11
10
  import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
12
11
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
13
12
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -17,7 +16,6 @@ import {
17
16
  akEditorMediaResizeHandlerPaddingWide,
18
17
  akEditorMobileBreakoutPoint,
19
18
  } from '@atlaskit/editor-shared-styles';
20
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
21
19
 
22
20
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
23
21
  import type { PluginInjectionAPI } from '../types';
@@ -26,22 +24,6 @@ import { TableCssClassName as ClassName } from '../types';
26
24
  import { TableResizer } from './TableResizer';
27
25
  import type { TableResizerImprovementProps } from './TableResizer';
28
26
 
29
- const getMarginLeft = (
30
- lineLength: number | undefined,
31
- tableWidth: number | 'inherit',
32
- ) => {
33
- let marginLeft;
34
- if (tableWidth !== 'inherit' && lineLength) {
35
- const containerWidth = tableWidth;
36
-
37
- if (containerWidth) {
38
- marginLeft = (lineLength - containerWidth) / 2;
39
- }
40
- }
41
-
42
- return marginLeft;
43
- };
44
-
45
27
  type InnerContainerProps = {
46
28
  className: string;
47
29
  style?: {
@@ -218,13 +200,11 @@ export const ResizableTableContainer = React.memo(
218
200
  pluginInjectionApi,
219
201
  };
220
202
 
221
- if (getBooleanFF('platform.editor.resizing-table-height-improvement')) {
222
- tableResizerProps = {
223
- ...tableResizerProps,
224
- onResizeStart: onResizeStart,
225
- onResizeStop: onResizeStop,
226
- };
227
- }
203
+ tableResizerProps = {
204
+ ...tableResizerProps,
205
+ onResizeStart: onResizeStart,
206
+ onResizeStop: onResizeStop,
207
+ };
228
208
 
229
209
  return (
230
210
  <div
@@ -265,7 +245,6 @@ type TableContainerProps = {
265
245
  className: string;
266
246
  containerWidth: EditorContainerWidth;
267
247
  isTableResizingEnabled: boolean | undefined;
268
- isBreakoutEnabled: boolean | undefined;
269
248
  editorView: EditorView;
270
249
  getPos: () => number | undefined;
271
250
  tableRef: HTMLTableElement;
@@ -281,9 +260,8 @@ export const TableContainer = ({
281
260
  children,
282
261
  node,
283
262
  className,
284
- containerWidth: { lineLength, width: editorWidth },
263
+ containerWidth: { width: editorWidth },
285
264
  isTableResizingEnabled,
286
- isBreakoutEnabled,
287
265
  editorView,
288
266
  getPos,
289
267
  tableRef,
@@ -314,10 +292,6 @@ export const TableContainer = ({
314
292
  );
315
293
  }
316
294
 
317
- const tableWidth = isBreakoutEnabled
318
- ? calcTableWidth(node.attrs.layout, editorWidth)
319
- : 'inherit';
320
-
321
295
  return (
322
296
  <InnerContainer
323
297
  node={node}
@@ -325,8 +299,7 @@ export const TableContainer = ({
325
299
  'less-padding': editorWidth < akEditorMobileBreakoutPoint && !isNested,
326
300
  })}
327
301
  style={{
328
- width: tableWidth,
329
- marginLeft: getMarginLeft(lineLength!, tableWidth),
302
+ width: 'inherit',
330
303
  }}
331
304
  >
332
305
  {children}
@@ -270,10 +270,7 @@ export const TableResizer = ({
270
270
  );
271
271
 
272
272
  setSnappingEnabled(displayGuideline(visibleGuidelines));
273
- if (
274
- getBooleanFF('platform.editor.resizing-table-height-improvement') &&
275
- onResizeStart
276
- ) {
273
+ if (onResizeStart) {
277
274
  onResizeStart();
278
275
  }
279
276
  }, [
@@ -443,10 +440,7 @@ export const TableResizer = ({
443
440
  updateWidth(newWidth);
444
441
  scheduleResize.cancel();
445
442
 
446
- if (
447
- getBooleanFF('platform.editor.resizing-table-height-improvement') &&
448
- onResizeStop
449
- ) {
443
+ if (onResizeStop) {
450
444
  onResizeStop();
451
445
  }
452
446
 
@@ -376,7 +376,6 @@ export const createTableView = (
376
376
  ): NodeView => {
377
377
  const {
378
378
  pluginConfig,
379
- isBreakoutEnabled,
380
379
  isFullWidthModeEnabled,
381
380
  wasFullWidthModeEnabled,
382
381
  isTableResizingEnabled,
@@ -395,7 +394,6 @@ export const createTableView = (
395
394
  eventDispatcher,
396
395
  getPos: getPos as getPosHandlerNode,
397
396
  options: {
398
- isBreakoutEnabled,
399
397
  isFullWidthModeEnabled,
400
398
  wasFullWidthModeEnabled,
401
399
  isTableResizingEnabled,
@@ -11,7 +11,6 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
11
11
  import type { PluginInjectionAPI } from '../types';
12
12
 
13
13
  export type TableOptions = {
14
- isBreakoutEnabled?: boolean;
15
14
  isFullWidthModeEnabled?: boolean;
16
15
  wasFullWidthModeEnabled?: boolean;
17
16
  isTableResizingEnabled?: boolean;
package/src/plugin.tsx CHANGED
@@ -1,12 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import {
4
- table,
5
- tableCell,
6
- tableHeader,
7
- tableRow,
8
- tableWithCustomWidth,
9
- } from '@atlaskit/adf-schema';
3
+ import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
10
4
  import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
11
5
  import {
12
6
  ACTION,
@@ -86,16 +80,12 @@ import FloatingContextualMenu from './ui/FloatingContextualMenu';
86
80
  import FloatingDeleteButton from './ui/FloatingDeleteButton';
87
81
  import FloatingDragMenu from './ui/FloatingDragMenu';
88
82
  import FloatingInsertButton from './ui/FloatingInsertButton';
89
- import LayoutButton from './ui/LayoutButton';
90
- import { createTableWithWidth, isLayoutSupported } from './utils';
83
+ import { createTableWithWidth } from './utils';
91
84
 
92
85
  export interface TablePluginOptions {
93
86
  tableOptions: PluginConfig;
94
- // experimental custom table resizing experience, set inside editor-core behind a feature flag
95
- // will eventually replace breakoutEnabled
96
87
  tableResizingEnabled?: boolean;
97
88
  dragAndDropEnabled?: boolean;
98
- breakoutEnabled?: boolean;
99
89
  allowContextualMenu?: boolean;
100
90
  // TODO these two need to be rethought
101
91
  fullWidthEnabled?: boolean;
@@ -233,12 +223,8 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
233
223
  },
234
224
 
235
225
  nodes() {
236
- const tableNode = options?.tableResizingEnabled
237
- ? tableWithCustomWidth
238
- : table;
239
-
240
226
  return [
241
- { name: 'table', node: tableNode },
227
+ { name: 'table', node: table },
242
228
  { name: 'tableHeader', node: tableHeader },
243
229
  { name: 'tableRow', node: tableRow },
244
230
  { name: 'tableCell', node: tableCell },
@@ -260,7 +246,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
260
246
  fullWidthEnabled,
261
247
  wasFullWidthEnabled,
262
248
  tableResizingEnabled,
263
- breakoutEnabled,
249
+
264
250
  tableOptions,
265
251
  getEditorFeatureFlags,
266
252
  dragAndDropEnabled,
@@ -275,7 +261,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
275
261
  defaultGetEditorContainerWidth,
276
262
  getEditorFeatureFlags || defaultGetEditorFeatureFlags,
277
263
  getIntl,
278
- breakoutEnabled,
279
264
  tableResizingEnabled,
280
265
  fullWidthEnabled,
281
266
  wasFullWidthEnabled,
@@ -466,7 +451,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
466
451
  tableWidthPluginState,
467
452
  dragAndDropState,
468
453
  }) => {
469
- const { state } = editorView;
470
454
  const isColumnResizing = resizingPluginState?.dragging;
471
455
  const isTableResizing = tableWidthPluginState?.resizing;
472
456
  const isResizing = isColumnResizing || isTableResizing;
@@ -476,7 +460,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
476
460
  tablePos,
477
461
  targetCellPosition,
478
462
  isContextualMenuOpen,
479
- layout,
480
463
  tableRef,
481
464
  pluginConfig,
482
465
  insertColumnButtonIndex,
@@ -493,26 +476,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
493
476
  ? findStickyHeaderForTable(stickyHeadersState, tablePos)
494
477
  : undefined;
495
478
 
496
- const LayoutContent =
497
- options &&
498
- !options.tableResizingEnabled &&
499
- isLayoutSupported(state) &&
500
- options.breakoutEnabled ? (
501
- <LayoutButton
502
- editorView={editorView}
503
- mountPoint={popupsMountPoint}
504
- boundariesElement={popupsBoundariesElement}
505
- scrollableElement={popupsScrollableElement}
506
- targetRef={tableWrapperTarget!}
507
- layout={layout}
508
- isResizing={
509
- !!resizingPluginState && !!resizingPluginState.dragging
510
- }
511
- stickyHeader={stickyHeader}
512
- editorAnalyticsAPI={editorAnalyticsAPI}
513
- />
514
- ) : null;
515
-
516
479
  return (
517
480
  <>
518
481
  {targetCellPosition &&
@@ -531,7 +494,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
531
494
  scrollableElement={popupsScrollableElement}
532
495
  dispatchAnalyticsEvent={dispatchAnalyticsEvent}
533
496
  isContextualMenuOpen={isContextualMenuOpen}
534
- layout={layout}
535
497
  stickyHeader={stickyHeader}
536
498
  tableWrapper={tableWrapperTarget}
537
499
  />
@@ -603,7 +565,6 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
603
565
  editorAnalyticsAPI={editorAnalyticsAPI}
604
566
  />
605
567
  )}
606
- {LayoutContent}
607
568
  </>
608
569
  );
609
570
  }}
@@ -107,7 +107,6 @@ export const createPlugin = (
107
107
  getEditorContainerWidth: GetEditorContainerWidth,
108
108
  getEditorFeatureFlags: GetEditorFeatureFlags,
109
109
  getIntl: () => IntlShape,
110
- breakoutEnabled?: boolean,
111
110
  tableResizingEnabled?: boolean,
112
111
  fullWidthModeEnabled?: boolean,
113
112
  previousFullWidthModeEnabled?: boolean,
@@ -122,7 +121,6 @@ export const createPlugin = (
122
121
  insertColumnButtonIndex: undefined,
123
122
  insertRowButtonIndex: undefined,
124
123
  isFullWidthModeEnabled: fullWidthModeEnabled,
125
- isBreakoutEnabled: breakoutEnabled,
126
124
  wasFullWidthModeEnabled: previousFullWidthModeEnabled,
127
125
  isTableResizingEnabled: tableResizingEnabled,
128
126
  isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
@@ -1,4 +1,4 @@
1
- import type { CellAttributes, TableLayout } from '@atlaskit/adf-schema';
1
+ import type { CellAttributes } from '@atlaskit/adf-schema';
2
2
  import {
3
3
  ACTION_SUBJECT,
4
4
  EVENT_TYPE,
@@ -7,14 +7,12 @@ import {
7
7
  TABLE_OVERFLOW_CHANGE_TRIGGER,
8
8
  } from '@atlaskit/editor-common/analytics';
9
9
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
10
- import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
11
10
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
12
11
  import type {
13
12
  GetEditorContainerWidth,
14
13
  GetEditorFeatureFlags,
15
14
  } from '@atlaskit/editor-common/types';
16
15
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
17
- import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
18
16
  import { TableMap } from '@atlaskit/editor-tables/table-map';
19
17
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
20
18
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -30,7 +28,6 @@ import { evenColumns, setDragging, stopResizing } from './commands';
30
28
  import { getPluginState } from './plugin-factory';
31
29
  import {
32
30
  currentColWidth,
33
- getLayoutSize,
34
31
  getResizeState,
35
32
  getTableMaxWidth,
36
33
  pointsAtCell,
@@ -80,39 +77,13 @@ export const handleMouseDown = (
80
77
  dom = dom.closest('table') as HTMLTableElement;
81
78
  }
82
79
 
83
- let maxSize;
84
- if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
85
- const containerWidth = getEditorContainerWidth();
86
- const parentWidth = getParentNodeWidth(start, state, containerWidth);
87
-
88
- maxSize = getBooleanFF('platform.editor.custom-table-width')
89
- ? parentWidth ||
90
- // its safe to reference table width from node as this will not have changed
91
- originalTable.attrs.width ||
92
- getLayoutSize(
93
- dom.getAttribute('data-layout') as TableLayout,
94
- containerWidth.width,
95
- {},
96
- )
97
- : parentWidth ||
98
- getLayoutSize(
99
- dom.getAttribute('data-layout') as TableLayout,
100
- containerWidth.width,
101
- {},
102
- );
103
-
104
- if (originalTable.attrs.isNumberColumnEnabled) {
105
- maxSize -= akEditorTableNumberColumnWidth;
106
- }
107
- } else {
108
- maxSize = getTableMaxWidth({
109
- table: originalTable,
110
- tableStart: start,
111
- state,
112
- layout: originalTable.attrs.layout,
113
- getEditorContainerWidth,
114
- });
115
- }
80
+ const maxSize = getTableMaxWidth({
81
+ table: originalTable,
82
+ tableStart: start,
83
+ state,
84
+ layout: originalTable.attrs.layout,
85
+ getEditorContainerWidth,
86
+ });
116
87
 
117
88
  const shouldScale = tableDepth === 0 && isTableScalingEnabled;
118
89
  const resizeState = getResizeState({
@@ -224,6 +195,11 @@ export const handleMouseDown = (
224
195
  const resizedDelta = clientX - startX;
225
196
 
226
197
  tr = updateColumnWidths(newResizeState, table, start)(tr);
198
+
199
+ // console.log('debug newResizeState=', newResizeState);
200
+ if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
201
+ tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
202
+ }
227
203
  if (colIndex === map.width - 1) {
228
204
  const mouseUpTime = event.timeStamp;
229
205
 
@@ -3,7 +3,6 @@ import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
3
3
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
6
 
8
7
  import { getTableScalingPercent } from './misc';
9
8
 
@@ -21,70 +20,50 @@ export const getColWidthFix = (colwidth: number, tableColumnCount: number) =>
21
20
  export const generateColgroup = (table: PmNode, tableRef?: HTMLElement) => {
22
21
  const cols: Col[] = [];
23
22
 
24
- if (getBooleanFF('platform.editor.custom-table-width')) {
25
- const map = TableMap.get(table);
26
- table.content.firstChild!.content.forEach((cell) => {
27
- const colspan = cell.attrs.colspan || 1;
28
- if (Array.isArray(cell.attrs.colwidth)) {
29
- // We slice here to guard against our colwidth array having more entries
30
- // Than the we actually span. We'll patch the document at a later point.
31
- if (tableRef) {
32
- const scalePercent = getTableScalingPercent(table, tableRef);
33
- cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
34
- const fixedColWidth = getColWidthFix(width, map.width);
35
- const scaledWidth = fixedColWidth * scalePercent;
36
- const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
37
- cols.push([
38
- 'col',
39
- {
40
- style: `width: ${finalWidth}px;`,
41
- },
42
- ]);
43
- });
44
- } else {
45
- cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
46
- cols.push([
47
- 'col',
48
- {
49
- style: `width: ${getColWidthFix(
50
- width
51
- ? Math.max(width, tableCellMinWidth)
52
- : tableCellMinWidth,
53
- map.width,
54
- )}px;`,
55
- },
56
- ]);
57
- });
58
- }
59
- } else {
60
- // When we have merged cells on the first row (firstChild),
61
- // We want to ensure we're creating the appropriate amount of
62
- // cols the table still has.
63
- cols.push(
64
- ...Array.from({ length: colspan }, (_) => [
65
- 'col',
66
- { style: `width: ${tableCellMinWidth}px;` },
67
- ]),
68
- );
69
- }
70
- });
71
- } else {
72
- table.content.firstChild!.content.forEach((cell) => {
73
- const colspan = cell.attrs.colspan || 1;
74
- if (Array.isArray(cell.attrs.colwidth)) {
75
- // We slice here to guard against our colwidth array having more entries
76
- // Than the we actually span. We'll patch the document at a later point.
23
+ const map = TableMap.get(table);
24
+ table.content.firstChild!.content.forEach((cell) => {
25
+ const colspan = cell.attrs.colspan || 1;
26
+ if (Array.isArray(cell.attrs.colwidth)) {
27
+ // We slice here to guard against our colwidth array having more entries
28
+ // Than the we actually span. We'll patch the document at a later point.
29
+ if (tableRef) {
30
+ const scalePercent = getTableScalingPercent(table, tableRef);
77
31
  cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
78
- cols.push(['col', width ? { style: `width: ${width}px;` } : {}]);
32
+ const fixedColWidth = getColWidthFix(width, map.width);
33
+ const scaledWidth = fixedColWidth * scalePercent;
34
+ const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
35
+ cols.push([
36
+ 'col',
37
+ {
38
+ style: `width: ${finalWidth}px;`,
39
+ },
40
+ ]);
79
41
  });
80
42
  } else {
81
- // When we have merged cells on the first row (firstChild),
82
- // We want to ensure we're creating the appropriate amount of
83
- // cols the table still has.
84
- cols.push(...Array.from({ length: colspan }, (_) => ['col', {}]));
43
+ cell.attrs.colwidth.slice(0, colspan).forEach((width) => {
44
+ cols.push([
45
+ 'col',
46
+ {
47
+ style: `width: ${getColWidthFix(
48
+ width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth,
49
+ map.width,
50
+ )}px;`,
51
+ },
52
+ ]);
53
+ });
85
54
  }
86
- });
87
- }
55
+ } else {
56
+ // When we have merged cells on the first row (firstChild),
57
+ // We want to ensure we're creating the appropriate amount of
58
+ // cols the table still has.
59
+ cols.push(
60
+ ...Array.from({ length: colspan }, (_) => [
61
+ 'col',
62
+ { style: `width: ${tableCellMinWidth}px;` },
63
+ ]),
64
+ );
65
+ }
66
+ });
88
67
 
89
68
  return cols;
90
69
  };
@@ -26,7 +26,6 @@ import {
26
26
  akEditorGutterPadding,
27
27
  akEditorTableNumberColumnWidth,
28
28
  } from '@atlaskit/editor-shared-styles';
29
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
30
29
 
31
30
  import type { TableOptions } from '../../../nodeviews/types';
32
31
 
@@ -127,11 +126,10 @@ export const getTableMaxWidth = ({
127
126
  const containerWidth = getEditorContainerWidth();
128
127
  const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
129
128
 
130
- let maxWidth = getBooleanFF('platform.editor.custom-table-width')
131
- ? parentWidth ||
132
- table.attrs.width ||
133
- getLayoutSize(layout, containerWidth.width, {})
134
- : parentWidth || getLayoutSize(layout, containerWidth.width, {});
129
+ let maxWidth =
130
+ parentWidth ||
131
+ table.attrs.width ||
132
+ getLayoutSize(layout, containerWidth.width, {});
135
133
 
136
134
  if (table.attrs.isNumberColumnEnabled) {
137
135
  maxWidth -= akEditorTableNumberColumnWidth;
@@ -1,8 +1,11 @@
1
1
  // Resize a given column by an amount from the current state
2
2
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
4
 
4
- import { getTableScalingPercent } from './misc';
5
- import { growColumn, shrinkColumn } from './resize-logic';
5
+ import { TableCssClassName as ClassName } from '../../../types';
6
+
7
+ import { getTableContainerElementWidth, getTableScalingPercent } from './misc';
8
+ import { growColumn, shrinkColumn, updateAffectedColumn } from './resize-logic';
6
9
  import { updateColgroup } from './resize-state';
7
10
  import type { ResizeState } from './types';
8
11
 
@@ -16,20 +19,60 @@ export const resizeColumn = (
16
19
  isTableScalingEnabled = false,
17
20
  ): ResizeState => {
18
21
  let scalePercent = 1;
19
- let resizeAmount = amount;
22
+ let resizeAmount = getBooleanFF(
23
+ 'platform.editor.table.colum-resizing-improvements',
24
+ )
25
+ ? amount * 2
26
+ : amount;
20
27
 
21
28
  if (isTableScalingEnabled) {
22
29
  scalePercent = getTableScalingPercent(tableNode, tableRef);
23
30
  resizeAmount = amount / scalePercent;
24
31
  }
25
- const newState =
26
- resizeAmount > 0
27
- ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns)
28
- : resizeAmount < 0
29
- ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns)
30
- : resizeState;
32
+
33
+ const newState = getBooleanFF(
34
+ 'platform.editor.table.colum-resizing-improvements',
35
+ )
36
+ ? updateAffectedColumn(resizeState, colIndex, resizeAmount)
37
+ : resizeAmount > 0
38
+ ? growColumn(resizeState, colIndex, resizeAmount, selectedColumns)
39
+ : resizeAmount < 0
40
+ ? shrinkColumn(resizeState, colIndex, resizeAmount, selectedColumns)
41
+ : resizeState;
31
42
 
32
43
  updateColgroup(newState, tableRef, tableNode, isTableScalingEnabled);
33
44
 
45
+ if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
46
+ // use the difference in width from affected column to update overall table width
47
+ const delta =
48
+ newState.cols[colIndex].width - resizeState.cols[colIndex].width;
49
+
50
+ updateTable(delta, tableRef, tableNode);
51
+ return {
52
+ ...newState,
53
+ tableWidth: resizeState.tableWidth + delta,
54
+ };
55
+ }
56
+
34
57
  return newState;
35
58
  };
59
+
60
+ const updateTable = (
61
+ resizeAmount: number,
62
+ tableRef: HTMLElement,
63
+ tableNode: PmNode,
64
+ // isTableScalingEnabled: boolean,
65
+ ) => {
66
+ const currentWidth = getTableContainerElementWidth(tableNode);
67
+ const resizingContainer = tableRef.closest(
68
+ `.${ClassName.TABLE_RESIZER_CONTAINER}`,
69
+ );
70
+ const resizingItem = resizingContainer?.querySelector('.resizer-item');
71
+
72
+ if (resizingContainer && resizingItem) {
73
+ const newWidth = `${currentWidth + resizeAmount}px`;
74
+ tableRef.style.width = newWidth;
75
+ (resizingContainer as HTMLElement).style.width = newWidth;
76
+ (resizingItem as HTMLElement).style.width = newWidth;
77
+ }
78
+ };
@@ -278,3 +278,28 @@ function getCandidates(
278
278
  ? candidates.slice(0, destIdx)
279
279
  : candidates.slice(destIdx + 1);
280
280
  }
281
+
282
+ /**
283
+ * Update the given column based on resizeAmount, maintaining all other columns
284
+ */
285
+ export function updateAffectedColumn(
286
+ resizeState: ResizeState,
287
+ colIndex: number,
288
+ resizeAmount: number,
289
+ ): ResizeState {
290
+ const updatedCols = resizeState.cols.map((col, index) => {
291
+ if (index === colIndex) {
292
+ const newWidth = Math.max(col.width + resizeAmount, col.minWidth);
293
+ return {
294
+ ...col,
295
+ width: newWidth,
296
+ };
297
+ }
298
+ return col;
299
+ });
300
+
301
+ return {
302
+ ...resizeState,
303
+ cols: updatedCols,
304
+ };
305
+ }