@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
@@ -2,22 +2,11 @@ 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
6
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
7
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
9
8
  import { TableCssClassName as ClassName } from '../types';
10
9
  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
10
  export const InnerContainer = /*#__PURE__*/forwardRef(({
22
11
  className,
23
12
  style,
@@ -162,11 +151,9 @@ export const TableContainer = ({
162
151
  node,
163
152
  className,
164
153
  containerWidth: {
165
- lineLength,
166
154
  width: editorWidth
167
155
  },
168
156
  isTableResizingEnabled,
169
- isBreakoutEnabled,
170
157
  editorView,
171
158
  getPos,
172
159
  tableRef,
@@ -192,15 +179,13 @@ export const TableContainer = ({
192
179
  isWholeTableInDanger: isWholeTableInDanger
193
180
  }, children);
194
181
  }
195
- const tableWidth = isBreakoutEnabled ? calcTableWidth(node.attrs.layout, editorWidth) : 'inherit';
196
182
  return /*#__PURE__*/React.createElement(InnerContainer, {
197
183
  node: node,
198
184
  className: classNames(className, {
199
185
  'less-padding': editorWidth < akEditorMobileBreakoutPoint && !isNested
200
186
  }),
201
187
  style: {
202
- width: tableWidth,
203
- marginLeft: getMarginLeft(lineLength, tableWidth)
188
+ width: 'inherit'
204
189
  }
205
190
  }, children);
206
191
  };
@@ -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,
@@ -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,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,
@@ -1,12 +1,10 @@
1
1
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
2
  import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
3
3
  import { TableMap } from '@atlaskit/editor-tables/table-map';
4
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
4
  import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
6
5
  import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
7
6
  import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
8
7
  import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
9
- import { insertColumnButtonOffset } from '../ui/common-styles';
10
8
 
11
9
  /**
12
10
  * Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
@@ -111,16 +109,16 @@ export const rescaleColumns = (isTableScalingEnabled = false) => (table, view) =
111
109
  if (shouldScale) {
112
110
  previousTableInfo = {
113
111
  width: getTableElementWidth(table.node),
114
- possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ? getTableContainerElementWidth(table.node) : getTableContainerElementWidth(table.node) - insertColumnButtonOffset,
112
+ possibleMaxWidth: getTableContainerElementWidth(table.node),
115
113
  isResized
116
114
  };
117
115
  } else {
118
- var _tableRef$parentEleme, _tableRef$parentEleme2;
116
+ var _tableRef$parentEleme;
119
117
  previousTableInfo = {
120
118
  // when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
121
119
  width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
122
120
  /** the is the width the table can reach before overflowing */
123
- possibleMaxWidth: getBooleanFF('platform.editor.custom-table-width') ? (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0 : ((tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme2 = tableRef.parentElement) === null || _tableRef$parentEleme2 === void 0 ? void 0 : _tableRef$parentEleme2.clientWidth) || 0) - insertColumnButtonOffset,
121
+ possibleMaxWidth: (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0,
124
122
  isResized
125
123
  };
126
124
  }
@@ -69,7 +69,6 @@ export const TableCssClassName = {
69
69
  CONTROLS_INSERT_BUTTON_WRAP: `${tablePrefixSelector}-controls__insert-button-wrap`,
70
70
  CONTROLS_INSERT_LINE: `${tablePrefixSelector}-controls__insert-line`,
71
71
  CONTROLS_BUTTON_OVERLAY: `${tablePrefixSelector}-controls__button-overlay`,
72
- LAYOUT_BUTTON: `${tablePrefixSelector}-layout-button`,
73
72
  DRAG_CONTROLS_INSERT_BUTTON: `${tablePrefixSelector}-controls__drag-insert-button`,
74
73
  DRAG_CONTROLS_INSERT_BUTTON_INNER: `${tablePrefixSelector}-controls__drag-insert-button-inner`,
75
74
  DRAG_CONTROLS_INSERT_BUTTON_INNER_COLUMN: `${tablePrefixSelector}-controls__drag-insert-button-inner-column`,
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
  import { jsx } from '@emotion/react';
4
4
  import { useIntl } from 'react-intl-next';
5
+ import { startColumnResizing, ToolTipContent } from '@atlaskit/editor-common/keymaps';
5
6
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
6
7
  import Tooltip from '@atlaskit/tooltip';
7
8
  import { TableCssClassName } from '../../types';
@@ -21,7 +22,10 @@ export const ColumnResizeWidget = ({
21
22
  });
22
23
  }
23
24
  return jsx(Tooltip, {
24
- content: formatMessage(messages.adjustColumns),
25
+ content: jsx(ToolTipContent, {
26
+ description: formatMessage(messages.adjustColumns),
27
+ keymap: startColumnResizing
28
+ }),
25
29
  hideTooltipOnClick: true,
26
30
  hideTooltipOnMouseDown: true,
27
31
  position: "mouse",
@@ -5,6 +5,7 @@ import { ArrowKeyNavigationProvider, ArrowKeyNavigationType, DropdownMenuItem }
5
5
  import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
6
6
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
7
7
  import { MenuGroup, Section } from '@atlaskit/menu';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { dragMenuDropdownWidth } from '../consts';
9
10
  const DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropList);
10
11
  export const DropdownMenu = ({
@@ -27,6 +28,10 @@ export const DropdownMenu = ({
27
28
  const handleRef = ref => {
28
29
  setTargetRefDiv(ref);
29
30
  };
31
+
32
+ // more offsets calculation as offsets depend on the direction and updated placement here
33
+ let offsetY = direction === 'row' ? popupPlacement[0] === 'bottom' ? -8 : -34 : 0;
34
+ let offsetX = direction === 'column' ? popupPlacement[1] === 'left' ? 0 : -7 : 0;
30
35
  const innerMenu = () => {
31
36
  return /*#__PURE__*/React.createElement(DropListWithOutsideListeners, {
32
37
  isOpen: true,
@@ -69,12 +74,31 @@ export const DropdownMenu = ({
69
74
  })))));
70
75
  };
71
76
  if (disableKeyboardHandling) {
72
- return innerMenu();
77
+ if (getBooleanFF('platform.editor.table.background-color-flicker-in-drag-menu')) {
78
+ // This part need be refactor when clean up the ff, to reuse the wrapper
79
+ return /*#__PURE__*/React.createElement("div", {
80
+ className: "drag-dropdown-menu-wrapper"
81
+ }, /*#__PURE__*/React.createElement("div", {
82
+ className: "drag-dropdown-menu-popup-ref",
83
+ ref: handleRef
84
+ }), /*#__PURE__*/React.createElement(Popup, {
85
+ target: targetRefDiv,
86
+ mountTo: mountPoint,
87
+ boundariesElement: boundariesElement,
88
+ scrollableElement: scrollableElement,
89
+ onPlacementChanged: placement => {
90
+ setPopupPlacement(placement);
91
+ },
92
+ fitHeight: fitHeight,
93
+ fitWidth: fitWidth,
94
+ zIndex: akEditorFloatingPanelZIndex,
95
+ offset: [offsetX, offsetY],
96
+ allowOutOfBounds: true // required as this popup is child of a parent popup, should be allowed to be out of bound of the parent popup, otherwise horizontal offset is not right
97
+ }, innerMenu()));
98
+ } else {
99
+ return innerMenu();
100
+ }
73
101
  }
74
-
75
- // more offsets calculation as offsets depend on the direction and updated placement here
76
- let offsetY = direction === 'row' ? popupPlacement[0] === 'bottom' ? -8 : -34 : 0;
77
- let offsetX = direction === 'column' ? popupPlacement[1] === 'left' ? 0 : -7 : 0;
78
102
  return /*#__PURE__*/React.createElement("div", {
79
103
  className: "drag-dropdown-menu-wrapper"
80
104
  }, /*#__PURE__*/React.createElement("div", {
@@ -96,6 +120,7 @@ export const DropdownMenu = ({
96
120
  }, /*#__PURE__*/React.createElement(ArrowKeyNavigationProvider, {
97
121
  closeOnTab: true,
98
122
  type: ArrowKeyNavigationType.MENU,
123
+ handleClose: () => handleClose('handle'),
99
124
  onSelection: index => {
100
125
  const results = items.flatMap(item => 'items' in item ? item.items : item);
101
126