@atlaskit/editor-plugin-table 7.6.13 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +12 -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 +2 -18
  6. package/dist/cjs/nodeviews/table.js +0 -2
  7. package/dist/cjs/plugin.js +3 -20
  8. package/dist/cjs/pm-plugins/main.js +1 -2
  9. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -21
  10. package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -57
  11. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -2
  12. package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +16 -28
  13. package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -12
  14. package/dist/cjs/reducer.js +0 -2
  15. package/dist/cjs/transforms/column-width.js +3 -5
  16. package/dist/cjs/types.js +0 -1
  17. package/dist/cjs/ui/ColumnResizeWidget/index.js +5 -1
  18. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +35 -8
  19. package/dist/cjs/ui/common-styles.js +5 -12
  20. package/dist/cjs/ui/ui-styles.js +7 -12
  21. package/dist/cjs/utils/index.js +0 -6
  22. package/dist/cjs/utils/nodes.js +5 -18
  23. package/dist/es2019/commands/misc.js +0 -2
  24. package/dist/es2019/nodeviews/OverflowShadowsObserver.js +1 -3
  25. package/dist/es2019/nodeviews/TableComponent.js +3 -18
  26. package/dist/es2019/nodeviews/TableContainer.js +1 -16
  27. package/dist/es2019/nodeviews/table.js +0 -2
  28. package/dist/es2019/plugin.js +5 -24
  29. package/dist/es2019/pm-plugins/main.js +1 -2
  30. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +8 -22
  31. package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +30 -53
  32. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -2
  33. package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +14 -24
  34. package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -12
  35. package/dist/es2019/reducer.js +0 -5
  36. package/dist/es2019/transforms/column-width.js +3 -5
  37. package/dist/es2019/types.js +0 -1
  38. package/dist/es2019/ui/ColumnResizeWidget/index.js +5 -1
  39. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +30 -5
  40. package/dist/es2019/ui/common-styles.js +15 -46
  41. package/dist/es2019/ui/ui-styles.js +34 -41
  42. package/dist/es2019/utils/index.js +1 -1
  43. package/dist/es2019/utils/nodes.js +0 -15
  44. package/dist/esm/commands/misc.js +0 -2
  45. package/dist/esm/nodeviews/OverflowShadowsObserver.js +1 -3
  46. package/dist/esm/nodeviews/TableComponent.js +3 -18
  47. package/dist/esm/nodeviews/TableContainer.js +2 -18
  48. package/dist/esm/nodeviews/table.js +0 -2
  49. package/dist/esm/plugin.js +5 -22
  50. package/dist/esm/pm-plugins/main.js +1 -2
  51. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +8 -22
  52. package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -57
  53. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +1 -2
  54. package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +16 -28
  55. package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -12
  56. package/dist/esm/reducer.js +0 -2
  57. package/dist/esm/transforms/column-width.js +3 -5
  58. package/dist/esm/types.js +0 -1
  59. package/dist/esm/ui/ColumnResizeWidget/index.js +5 -1
  60. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +35 -8
  61. package/dist/esm/ui/common-styles.js +6 -13
  62. package/dist/esm/ui/ui-styles.js +7 -12
  63. package/dist/esm/utils/index.js +1 -1
  64. package/dist/esm/utils/nodes.js +0 -13
  65. package/dist/types/nodeviews/TableContainer.d.ts +1 -2
  66. package/dist/types/nodeviews/types.d.ts +0 -1
  67. package/dist/types/plugin.d.ts +0 -1
  68. package/dist/types/pm-plugins/main.d.ts +1 -1
  69. package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
  70. package/dist/types/types.d.ts +0 -9
  71. package/dist/types/ui/FloatingContextualButton/index.d.ts +0 -2
  72. package/dist/types/utils/index.d.ts +1 -1
  73. package/dist/types/utils/nodes.d.ts +0 -1
  74. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +1 -2
  75. package/dist/types-ts4.5/nodeviews/types.d.ts +0 -1
  76. package/dist/types-ts4.5/plugin.d.ts +0 -1
  77. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  78. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
  79. package/dist/types-ts4.5/types.d.ts +0 -9
  80. package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +0 -2
  81. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  82. package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
  83. package/package.json +6 -6
  84. package/src/commands/misc.ts +0 -2
  85. package/src/nodeviews/OverflowShadowsObserver.ts +1 -6
  86. package/src/nodeviews/TableComponent.tsx +2 -25
  87. package/src/nodeviews/TableContainer.tsx +2 -26
  88. package/src/nodeviews/table.tsx +0 -2
  89. package/src/nodeviews/types.ts +0 -1
  90. package/src/plugin.tsx +4 -43
  91. package/src/pm-plugins/main.ts +0 -2
  92. package/src/pm-plugins/table-resizing/event-handlers.ts +8 -37
  93. package/src/pm-plugins/table-resizing/utils/colgroup.ts +40 -61
  94. package/src/pm-plugins/table-resizing/utils/misc.ts +4 -6
  95. package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -29
  96. package/src/pm-plugins/table-resizing/utils/scale-table.ts +2 -13
  97. package/src/reducer.ts +0 -3
  98. package/src/transforms/column-width.ts +2 -10
  99. package/src/types.ts +0 -8
  100. package/src/ui/ColumnResizeWidget/index.tsx +10 -1
  101. package/src/ui/FloatingContextualButton/index.tsx +0 -2
  102. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +39 -7
  103. package/src/ui/common-styles.ts +15 -53
  104. package/src/ui/ui-styles.ts +34 -47
  105. package/src/utils/index.ts +0 -1
  106. package/src/utils/nodes.ts +0 -23
  107. package/dist/cjs/ui/LayoutButton/index.js +0 -206
  108. package/dist/es2019/ui/LayoutButton/index.js +0 -168
  109. package/dist/esm/ui/LayoutButton/index.js +0 -196
  110. package/dist/types/ui/LayoutButton/index.d.ts +0 -21
  111. package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +0 -21
  112. 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';
@@ -26,22 +25,6 @@ import { TableCssClassName as ClassName } from '../types';
26
25
  import { TableResizer } from './TableResizer';
27
26
  import type { TableResizerImprovementProps } from './TableResizer';
28
27
 
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
28
  type InnerContainerProps = {
46
29
  className: string;
47
30
  style?: {
@@ -265,7 +248,6 @@ type TableContainerProps = {
265
248
  className: string;
266
249
  containerWidth: EditorContainerWidth;
267
250
  isTableResizingEnabled: boolean | undefined;
268
- isBreakoutEnabled: boolean | undefined;
269
251
  editorView: EditorView;
270
252
  getPos: () => number | undefined;
271
253
  tableRef: HTMLTableElement;
@@ -281,9 +263,8 @@ export const TableContainer = ({
281
263
  children,
282
264
  node,
283
265
  className,
284
- containerWidth: { lineLength, width: editorWidth },
266
+ containerWidth: { width: editorWidth },
285
267
  isTableResizingEnabled,
286
- isBreakoutEnabled,
287
268
  editorView,
288
269
  getPos,
289
270
  tableRef,
@@ -314,10 +295,6 @@ export const TableContainer = ({
314
295
  );
315
296
  }
316
297
 
317
- const tableWidth = isBreakoutEnabled
318
- ? calcTableWidth(node.attrs.layout, editorWidth)
319
- : 'inherit';
320
-
321
298
  return (
322
299
  <InnerContainer
323
300
  node={node}
@@ -325,8 +302,7 @@ export const TableContainer = ({
325
302
  'less-padding': editorWidth < akEditorMobileBreakoutPoint && !isNested,
326
303
  })}
327
304
  style={{
328
- width: tableWidth,
329
- marginLeft: getMarginLeft(lineLength!, tableWidth),
305
+ width: 'inherit',
330
306
  }}
331
307
  >
332
308
  {children}
@@ -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({
@@ -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;
@@ -9,7 +9,6 @@ import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
9
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
10
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
11
11
  import type { Rect } from '@atlaskit/editor-tables/table-map';
12
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
12
 
14
13
  import { getSelectedTableInfo } from '../../../utils';
15
14
 
@@ -115,39 +114,29 @@ export const updateColgroup = (
115
114
  ): void => {
116
115
  const cols = tableRef.querySelectorAll('col');
117
116
 
118
- if (getBooleanFF('platform.editor.custom-table-width')) {
119
- const columnsCount = cols.length;
120
- if (isTableScalingEnabled && tableNode) {
121
- const scalePercent = getTableScalingPercent(tableNode, tableRef);
122
- state.cols
123
- .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
124
- .forEach((column, i) => {
125
- const fixedColWidth = getColWidthFix(column.width, columnsCount);
126
- const scaledWidth = fixedColWidth * scalePercent;
127
- const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
128
- // we aren't handling the remaining pixels here when the 48px min width is reached
129
- if (cols[i]) {
130
- cols[i].style.width = `${finalWidth}px`;
131
- }
132
- });
133
- } else {
134
- state.cols
135
- .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
136
- .forEach((column, i) => {
137
- if (cols[i]) {
138
- cols[i].style.width = `${getColWidthFix(
139
- column.width,
140
- columnsCount,
141
- )}px`;
142
- }
143
- });
144
- }
117
+ const columnsCount = cols.length;
118
+ if (isTableScalingEnabled && tableNode) {
119
+ const scalePercent = getTableScalingPercent(tableNode, tableRef);
120
+ state.cols
121
+ .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
122
+ .forEach((column, i) => {
123
+ const fixedColWidth = getColWidthFix(column.width, columnsCount);
124
+ const scaledWidth = fixedColWidth * scalePercent;
125
+ const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
126
+ // we aren't handling the remaining pixels here when the 48px min width is reached
127
+ if (cols[i]) {
128
+ cols[i].style.width = `${finalWidth}px`;
129
+ }
130
+ });
145
131
  } else {
146
132
  state.cols
147
133
  .filter((column) => column && !!column.width) // if width is 0, we dont want to apply that.
148
134
  .forEach((column, i) => {
149
135
  if (cols[i]) {
150
- cols[i].style.width = `${column.width}px`;
136
+ cols[i].style.width = `${getColWidthFix(
137
+ column.width,
138
+ columnsCount,
139
+ )}px`;
151
140
  }
152
141
  });
153
142
  }
@@ -28,7 +28,6 @@ export interface ScaleOptions {
28
28
  previousContainerWidth?: number;
29
29
  parentWidth?: number;
30
30
  layoutChanged?: boolean;
31
- isBreakoutEnabled?: boolean;
32
31
  isFullWidthModeEnabled?: boolean;
33
32
  isTableResizingEnabled?: boolean;
34
33
  }
@@ -41,34 +40,24 @@ export const scale = (
41
40
  domAtPos: DomAtPos,
42
41
  isTableScalingEnabled = false,
43
42
  ): ResizeState | undefined => {
44
- /**
45
- * isBreakoutEnabled === true -> default center aligned
46
- * isBreakoutEnabled === false -> full width mode
47
- */
48
-
49
43
  const {
50
44
  node,
51
45
  containerWidth,
52
46
  previousContainerWidth,
53
47
  prevNode,
54
48
  start,
55
- isBreakoutEnabled,
56
49
  layoutChanged,
57
50
  isTableResizingEnabled,
58
51
  } = options;
59
52
 
60
53
  const maxSize = isTableResizingEnabled
61
54
  ? getTableContainerWidth(node)
62
- : getLayoutSize(node.attrs.layout, containerWidth, {
63
- isBreakoutEnabled,
64
- });
55
+ : getLayoutSize(node.attrs.layout, containerWidth, {});
65
56
 
66
57
  const prevTableWidth = getTableWidth(prevNode);
67
58
  const previousMaxSize = isTableResizingEnabled
68
59
  ? getTableContainerWidth(node)
69
- : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
70
- isBreakoutEnabled,
71
- });
60
+ : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {});
72
61
 
73
62
  let newWidth = maxSize;
74
63
 
package/src/reducer.ts CHANGED
@@ -27,9 +27,6 @@ export default (
27
27
  case 'SET_TARGET_CELL_POSITION':
28
28
  return { ...pluginState, ...action.data, isContextualMenuOpen: false };
29
29
 
30
- case 'SET_TABLE_LAYOUT':
31
- return { ...pluginState, ...action.data };
32
-
33
30
  case 'TOGGLE_CONTEXTUAL_MENU':
34
31
  return {
35
32
  ...pluginState,
@@ -6,7 +6,6 @@ import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
6
6
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
7
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
  import { TableMap } from '@atlaskit/editor-tables/table-map';
9
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
9
 
11
10
  import type { ResizeState } from '../pm-plugins/table-resizing/utils';
12
11
  import {
@@ -17,7 +16,6 @@ import {
17
16
  import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
18
17
  import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
19
18
  import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
20
- import { insertColumnButtonOffset } from '../ui/common-styles';
21
19
 
22
20
  /**
23
21
  * Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
@@ -141,10 +139,7 @@ export const rescaleColumns =
141
139
  if (shouldScale) {
142
140
  previousTableInfo = {
143
141
  width: getTableElementWidth(table.node),
144
- possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
145
- ? getTableContainerElementWidth(table.node)
146
- : getTableContainerElementWidth(table.node) -
147
- insertColumnButtonOffset,
142
+ possibleMaxWidth: getTableContainerElementWidth(table.node),
148
143
  isResized,
149
144
  };
150
145
  } else {
@@ -152,10 +147,7 @@ export const rescaleColumns =
152
147
  // when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
153
148
  width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
154
149
  /** the is the width the table can reach before overflowing */
155
- possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width')
156
- ? tableRef?.parentElement?.clientWidth || 0
157
- : (tableRef?.parentElement?.clientWidth || 0) -
158
- insertColumnButtonOffset,
150
+ possibleMaxWidth: tableRef?.parentElement?.clientWidth || 0,
159
151
  isResized,
160
152
  };
161
153
  }
package/src/types.ts CHANGED
@@ -157,7 +157,6 @@ export interface TablePluginState {
157
157
  insertColumnButtonIndex?: number;
158
158
  insertRowButtonIndex?: number;
159
159
  isFullWidthModeEnabled?: boolean;
160
- layout?: TableLayout;
161
160
  ordering?: TableColumnOrdering;
162
161
  isResizeHandleWidgetAdded?: boolean;
163
162
  resizeHandleRowIndex?: number;
@@ -171,7 +170,6 @@ export interface TablePluginState {
171
170
 
172
171
  getIntl: () => IntlShape;
173
172
 
174
- isBreakoutEnabled?: boolean;
175
173
  wasFullWidthModeEnabled?: boolean;
176
174
  isTableResizingEnabled?: boolean;
177
175
  isDragAndDropEnabled?: boolean;
@@ -190,7 +188,6 @@ export type TablePluginAction =
190
188
  tableRef?: HTMLTableElement;
191
189
  tableNode?: PmNode;
192
190
  tableWrapperTarget?: HTMLElement;
193
- layout: TableLayout;
194
191
  isHeaderRowEnabled: boolean;
195
192
  isHeaderColumnEnabled: boolean;
196
193
  };
@@ -289,10 +286,6 @@ export type TablePluginAction =
289
286
  type: 'SELECT_COLUMN';
290
287
  data: { targetCellPosition: number; decorationSet: DecorationSet };
291
288
  }
292
- | {
293
- type: 'SET_TABLE_LAYOUT';
294
- data: { layout: TableLayout };
295
- }
296
289
  | { type: 'SHOW_INSERT_ROW_BUTTON'; data: { insertRowButtonIndex: number } }
297
290
  | {
298
291
  type: 'SHOW_INSERT_COLUMN_BUTTON';
@@ -361,7 +354,6 @@ export const TableCssClassName = {
361
354
  CONTROLS_INSERT_BUTTON_WRAP: `${tablePrefixSelector}-controls__insert-button-wrap`,
362
355
  CONTROLS_INSERT_LINE: `${tablePrefixSelector}-controls__insert-line`,
363
356
  CONTROLS_BUTTON_OVERLAY: `${tablePrefixSelector}-controls__button-overlay`,
364
- LAYOUT_BUTTON: `${tablePrefixSelector}-layout-button`,
365
357
 
366
358
  DRAG_CONTROLS_INSERT_BUTTON: `${tablePrefixSelector}-controls__drag-insert-button`,
367
359
  DRAG_CONTROLS_INSERT_BUTTON_INNER: `${tablePrefixSelector}-controls__drag-insert-button-inner`,