@atlaskit/editor-plugin-table 7.16.16 → 7.16.17

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 (61) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/commands-with-analytics.js +66 -41
  3. package/dist/cjs/nodeviews/TableContainer.js +14 -12
  4. package/dist/cjs/nodeviews/TableResizer.js +12 -13
  5. package/dist/cjs/plugin.js +3 -2
  6. package/dist/cjs/pm-plugins/keymap.js +6 -0
  7. package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -1
  8. package/dist/cjs/toolbar.js +23 -48
  9. package/dist/cjs/ui/icons/index.js +0 -7
  10. package/dist/cjs/utils/snapping.js +2 -2
  11. package/dist/es2019/commands-with-analytics.js +29 -6
  12. package/dist/es2019/nodeviews/TableContainer.js +17 -13
  13. package/dist/es2019/nodeviews/TableResizer.js +11 -12
  14. package/dist/es2019/plugin.js +3 -2
  15. package/dist/es2019/pm-plugins/keymap.js +7 -1
  16. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
  17. package/dist/es2019/toolbar.js +22 -48
  18. package/dist/es2019/ui/icons/index.js +0 -1
  19. package/dist/es2019/utils/snapping.js +3 -3
  20. package/dist/esm/commands-with-analytics.js +66 -41
  21. package/dist/esm/nodeviews/TableContainer.js +15 -13
  22. package/dist/esm/nodeviews/TableResizer.js +14 -15
  23. package/dist/esm/plugin.js +3 -2
  24. package/dist/esm/pm-plugins/keymap.js +7 -1
  25. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
  26. package/dist/esm/toolbar.js +24 -49
  27. package/dist/esm/ui/icons/index.js +0 -1
  28. package/dist/esm/utils/snapping.js +3 -3
  29. package/dist/types/commands/toggle.d.ts +1 -1
  30. package/dist/types/commands-with-analytics.d.ts +7 -4
  31. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
  32. package/dist/types/toolbar.d.ts +2 -3
  33. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -0
  34. package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -0
  35. package/dist/types/ui/TableFloatingControls/index.d.ts +2 -0
  36. package/dist/types/ui/icons/index.d.ts +0 -1
  37. package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
  38. package/dist/types-ts4.5/commands-with-analytics.d.ts +7 -4
  39. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
  40. package/dist/types-ts4.5/toolbar.d.ts +2 -3
  41. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -0
  42. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -0
  43. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +2 -0
  44. package/dist/types-ts4.5/ui/icons/index.d.ts +0 -1
  45. package/package.json +6 -3
  46. package/src/commands-with-analytics.ts +80 -40
  47. package/src/nodeviews/TableContainer.tsx +24 -14
  48. package/src/nodeviews/TableResizer.tsx +17 -9
  49. package/src/plugin.tsx +5 -2
  50. package/src/pm-plugins/keymap.ts +30 -0
  51. package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
  52. package/src/toolbar.tsx +29 -55
  53. package/src/ui/TableFloatingControls/index.tsx +0 -1
  54. package/src/ui/icons/index.ts +0 -1
  55. package/src/utils/snapping.ts +4 -4
  56. package/dist/cjs/ui/icons/DisplayModeIcon.js +0 -46
  57. package/dist/es2019/ui/icons/DisplayModeIcon.js +0 -39
  58. package/dist/esm/ui/icons/DisplayModeIcon.js +0 -39
  59. package/dist/types/ui/icons/DisplayModeIcon.d.ts +0 -4
  60. package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +0 -4
  61. package/src/ui/icons/DisplayModeIcon.tsx +0 -41
@@ -1,11 +1,13 @@
1
1
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import classNames from 'classnames';
3
+ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
5
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
- import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
6
- import { setTableAlignmentWithTableContentWithPos } from '../commands/misc';
6
+ import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
7
+ import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
7
8
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
8
9
  import { TableCssClassName as ClassName } from '../types';
10
+ import { ALIGN_CENTER, ALIGN_START } from '../utils/alignment';
9
11
  import { TableResizer } from './TableResizer';
10
12
  export const InnerContainer = /*#__PURE__*/forwardRef(({
11
13
  className,
@@ -41,7 +43,7 @@ const AlignmentTableContainer = ({
41
43
  getPos,
42
44
  editorView
43
45
  }) => {
44
- const alignment = node.attrs.layout;
46
+ const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
45
47
  const {
46
48
  tableState
47
49
  } = useSharedPluginState(pluginInjectionApi, ['table']);
@@ -51,18 +53,20 @@ const AlignmentTableContainer = ({
51
53
  wasFullWidthModeEnabled,
52
54
  isFullWidthModeEnabled
53
55
  } = tableState;
54
- if (wasFullWidthModeEnabled && !isFullWidthModeEnabled && node.attrs.width > akEditorDefaultLayoutWidth) {
56
+ const {
57
+ state,
58
+ dispatch
59
+ } = editorView;
60
+ if (wasFullWidthModeEnabled && isFullWidthModeEnabled !== undefined && !isFullWidthModeEnabled && alignment !== ALIGN_CENTER && node.attrs.width > akEditorDefaultLayoutWidth) {
61
+ var _pluginInjectionApi$a;
55
62
  const pos = getPos && getPos();
56
63
  if (typeof pos !== 'number') {
57
64
  return;
58
65
  }
59
- const tr = setTableAlignmentWithTableContentWithPos('center', {
66
+ setTableAlignmentWithTableContentWithPosWithAnalytics(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(ALIGN_CENTER, alignment, {
60
67
  pos,
61
68
  node
62
- })(editorView.state);
63
- if (tr) {
64
- editorView.dispatch(tr);
65
- }
69
+ }, INPUT_METHOD.AUTO, CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED)(state, dispatch);
66
70
  }
67
71
  }
68
72
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -176,8 +180,8 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
176
180
  })) !== null && _pluginInjectionApi$g !== void 0 ? _pluginInjectionApi$g : false;
177
181
  }, [pluginInjectionApi, editorView]);
178
182
  const attachAnalyticsEvent = useCallback(payload => {
179
- var _pluginInjectionApi$a;
180
- return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.attachAnalyticsEvent(payload);
183
+ var _pluginInjectionApi$a2;
184
+ return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.attachAnalyticsEvent(payload);
181
185
  }, [pluginInjectionApi]);
182
186
  const displayGapCursor = useCallback(toggle => {
183
187
  var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
@@ -198,13 +202,13 @@ export const ResizableTableContainer = /*#__PURE__*/React.memo(({
198
202
  // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
199
203
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
200
204
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
201
- responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - akEditorGutterPadding * 2 - resizeHandleSpacing;
205
+ responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
202
206
  } else {
203
207
  // 76 is currently an accepted padding value considering the spacing for resizer handle
204
208
  // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
205
209
  // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
206
210
  // padding left = padding right = akEditorGutterPadding = 32
207
- responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 : containerWidth - akEditorGutterPadding * 2 - resizeHandleSpacing;
211
+ responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPaddingDynamic() * 2 : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
208
212
  }
209
213
  let width = Math.min(tableWidth, responsiveContainerWidth);
210
214
  if (!isResizing) {
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
2
2
  import rafSchd from 'raf-schd';
3
3
  import { useIntl } from 'react-intl-next';
4
- import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
4
+ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
5
5
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
6
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
7
  import { focusTableResizer, ToolTipContent } from '@atlaskit/editor-common/keymaps';
@@ -12,7 +12,8 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
12
12
  import { akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
13
13
  import { findTable } from '@atlaskit/editor-tables/utils';
14
14
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
15
- import { setTableAlignmentWithTableContentWithPos, updateWidthToWidest } from '../commands/misc';
15
+ import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
16
+ import { updateWidthToWidest } from '../commands/misc';
16
17
  import { META_KEYS } from '../pm-plugins/table-analytics';
17
18
  import { COLUMN_MIN_WIDTH, getColgroupChildrenLength, previewScaleTable, scaleTable, TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
18
19
  import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
@@ -110,7 +111,7 @@ export const TableResizer = ({
110
111
  pluginInjectionApi,
111
112
  isFullWidthModeEnabled
112
113
  }) => {
113
- var _findTable, _editorView$state;
114
+ var _findTable, _editorView$state, _pluginInjectionApi$a2;
114
115
  const currentGap = useRef(0);
115
116
  // track resizing state - use ref over state to avoid re-render
116
117
  const isResizing = useRef(false);
@@ -160,18 +161,16 @@ export const TableResizer = ({
160
161
  if (isTableAlignmentEnabled && node && node.attrs.layout === ALIGN_START && newWidth > lineLength && lineLength < FULL_WIDTH_EDITOR_CONTENT_WIDTH &&
161
162
  // We don't want to switch alignment in Full-width editor
162
163
  isResizing.current) {
164
+ var _pluginInjectionApi$a;
163
165
  const tableNodeWithPos = {
164
166
  pos,
165
167
  node
166
168
  };
167
- const tr = setTableAlignmentWithTableContentWithPos(ALIGN_CENTER, tableNodeWithPos)(state);
168
- if (tr) {
169
- dispatch(tr);
170
- }
169
+ setTableAlignmentWithTableContentWithPosWithAnalytics(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(ALIGN_CENTER, ALIGN_START, tableNodeWithPos, INPUT_METHOD.AUTO, CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED)(state, dispatch);
171
170
  return true;
172
171
  }
173
172
  return false;
174
- }, [lineLength, isTableAlignmentEnabled, isResizing]);
173
+ }, [isTableAlignmentEnabled, lineLength, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions]);
175
174
  useEffect(() => {
176
175
  return () => {
177
176
  // only bring back the cursor if this table was deleted - i.e. if a user was resizing, then another
@@ -311,13 +310,13 @@ export const TableResizer = ({
311
310
  dispatch(tr);
312
311
  if (getBooleanFF('platform.editor.a11y-table-resizing_uapcv')) {
313
312
  if (delta.width < 0) {
314
- var _pluginInjectionApi$a;
315
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify(formatMessage(messages.tableSizeDecreaseScreenReaderInformation, {
313
+ var _pluginInjectionApi$a3;
314
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions.ariaNotify(formatMessage(messages.tableSizeDecreaseScreenReaderInformation, {
316
315
  newWidth: newWidth
317
316
  }));
318
317
  } else if (delta.width > 0) {
319
- var _pluginInjectionApi$a2;
320
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.ariaNotify(formatMessage(messages.tableSizeIncreaseScreenReaderInformation, {
318
+ var _pluginInjectionApi$a4;
319
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions.ariaNotify(formatMessage(messages.tableSizeIncreaseScreenReaderInformation, {
321
320
  newWidth: newWidth
322
321
  }));
323
322
  }
@@ -61,7 +61,8 @@ const tablesPlugin = ({
61
61
  };
62
62
  };
63
63
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
64
- const shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
64
+ const isTableScalingWithFixedColumnWidthsOptionEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
65
+ const shouldUseIncreasedScalingPercent = isTableScalingWithFixedColumnWidthsOptionEnabled && getBooleanFF('platform.editor.table.use-increased-scaling-percent');
65
66
  return {
66
67
  name: 'table',
67
68
  // Use getSharedState to store fullWidthEnabled and wasFullWidthModeEnabled to guarantee access
@@ -460,7 +461,7 @@ const tablesPlugin = ({
460
461
  return tr;
461
462
  }
462
463
  }],
463
- floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
464
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, () => editorViewRef.current, options, isTableScalingWithFixedColumnWidthsOptionEnabled, shouldUseIncreasedScalingPercent)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
464
465
  }
465
466
  };
466
467
  };
@@ -1,5 +1,5 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
2
+ import { addColumnAfter, addColumnAfterVO, addColumnBefore, addColumnBeforeVO, addRowAfter, addRowAfterVO, addRowBefore, addRowBeforeVO, backspace, bindKeymapWithCommand, decreaseMediaSize, deleteColumn, deleteRow, escape, increaseMediaSize, moveColumnLeft, moveColumnRight, moveLeft, moveRight, moveRowDown, moveRowUp, nextCell, previousCell, startColumnResizing, toggleTable } from '@atlaskit/editor-common/keymaps';
3
3
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
4
4
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
5
5
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -23,6 +23,12 @@ export function keymapPlugin(getEditorContainerWidth, editorAnalyticsAPI, dragAn
23
23
  bindKeymapWithCommand(addRowAfter.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
24
24
  bindKeymapWithCommand(addColumnBefore.common, addColumnBeforeCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
25
25
  bindKeymapWithCommand(addColumnAfter.common, addColumnAfterCommand(isTableScalingEnabled, shouldUseIncreasedScalingPercent), list);
26
+ if (getBooleanFF('platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg')) {
27
+ bindKeymapWithCommand(addRowBeforeVO.common, addRowAroundSelection(editorAnalyticsAPI)('TOP'), list);
28
+ bindKeymapWithCommand(addRowAfterVO.common, addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'), list);
29
+ bindKeymapWithCommand(addColumnBeforeVO.common, addColumnBeforeCommand(isTableScalingEnabled), list);
30
+ bindKeymapWithCommand(addColumnAfterVO.common, addColumnAfterCommand(isTableScalingEnabled), list);
31
+ }
26
32
  if (dragAndDropEnabled) {
27
33
  // Move row/column shortcuts
28
34
  /**
@@ -2,7 +2,7 @@ import { getParentNodeWidth, getTableContainerWidth, layoutToWidth } from '@atla
2
2
  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
- import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
5
+ import { akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
6
6
  import { hasTableBeenResized } from './colgroup';
7
7
  import { MAX_SCALING_PERCENT, MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION } from './consts';
8
8
 
@@ -12,7 +12,7 @@ export function getLayoutSize(tableLayout, containerWidth = 0, options) {
12
12
  isFullWidthModeEnabled
13
13
  } = options;
14
14
  if (isFullWidthModeEnabled) {
15
- return containerWidth ? Math.min(containerWidth - akEditorGutterPadding * 2, akEditorFullWidthLayoutWidth) : akEditorFullWidthLayoutWidth;
15
+ return containerWidth ? Math.min(containerWidth - akEditorGutterPaddingDynamic() * 2, akEditorFullWidthLayoutWidth) : akEditorFullWidthLayoutWidth;
16
16
  }
17
17
  const calculatedTableWidth = calcTableWidth(tableLayout, containerWidth, true);
18
18
  if (calculatedTableWidth !== 'inherit') {
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
  import { jsx } from '@emotion/react';
4
4
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
5
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
7
7
  import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
8
8
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
@@ -20,7 +20,7 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
20
20
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
21
21
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
22
22
  import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
23
- import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, setTableAlignmentWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, toggleTableLockWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
23
+ import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, setTableAlignmentWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleFixedColumnWidthsOptionAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
24
24
  import { getPluginState } from './pm-plugins/plugin-factory';
25
25
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
26
26
  import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
@@ -28,14 +28,22 @@ import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
28
28
  import { canMergeCells } from './transforms';
29
29
  import { TableCssClassName } from './types';
30
30
  import { FloatingAlignmentButtons } from './ui/FloatingAlignmentButtons/FloatingAlignmentButtons';
31
- import { DisplayModeIcon } from './ui/icons';
32
31
  import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes, isTableNested } from './utils';
33
32
  import { normaliseAlignment } from './utils/alignment';
34
33
  export const getToolbarMenuConfig = (config, state, {
35
34
  formatMessage
36
- }, editorAnalyticsAPI) => {
35
+ }, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown = false, areTableColumnWidthsFixed = false) => {
37
36
  const optionItem = getBooleanFF('platform.editor.a11y-table-floating-toolbar-dropdown-menu_zkb33') ? 'item-checkbox' : 'item';
38
37
  const options = [{
38
+ id: 'editor.table.lockColumnWidths',
39
+ title: formatMessage(messages.lockColumnWidths),
40
+ onClick: toggleFixedColumnWidthsOptionAnalytics(editorAnalyticsAPI, INPUT_METHOD.FLOATING_TB),
41
+ selected: areTableColumnWidthsFixed,
42
+ hidden: !isTableScalingWithFixedColumnWidthsOptionShown,
43
+ domItemOptions: {
44
+ type: optionItem
45
+ }
46
+ }, {
39
47
  id: 'editor.table.headerRow',
40
48
  title: formatMessage(messages.headerRow),
41
49
  onClick: toggleHeaderRowWithAnalytics(editorAnalyticsAPI),
@@ -81,7 +89,8 @@ export const getToolbarMenuConfig = (config, state, {
81
89
  icon: TableOptionsIcon,
82
90
  title: formatMessage(messages.tableOptions),
83
91
  hidden: options.every(option => option.hidden),
84
- options
92
+ options,
93
+ dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined
85
94
  };
86
95
  } else {
87
96
  return {
@@ -90,7 +99,8 @@ export const getToolbarMenuConfig = (config, state, {
90
99
  testId: 'table_options',
91
100
  title: formatMessage(messages.tableOptions),
92
101
  hidden: options.every(option => option.hidden),
93
- options
102
+ options,
103
+ dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined
94
104
  };
95
105
  }
96
106
  };
@@ -305,7 +315,7 @@ export const getClosestSelectionOrTableRect = state => {
305
315
  const tableRect = new Rect(0, 0, map.width, map.height);
306
316
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
307
317
  };
308
- export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
318
+ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, isTableScalingWithFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
309
319
  const tableObject = findTable(state.selection);
310
320
  const pluginState = getPluginState(state);
311
321
  const resizeState = tableResizingPluginKey.getState(state);
@@ -315,9 +325,11 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
315
325
  const isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
316
326
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
317
327
  const nodeType = state.schema.nodes.table;
318
- const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
319
- let alignmentMenu;
320
328
  const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
329
+ const isTableScalingWithFixedColumnWidthsOptionShown = isTableScalingWithFixedColumnWidthsOptionEnabled && !isNested;
330
+ const areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
331
+ const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown, areTableColumWidthsFixed);
332
+ let alignmentMenu;
321
333
  alignmentMenu = options !== null && options !== void 0 && options.isTableAlignmentEnabled && !isNested ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth) : [];
322
334
  let cellItems;
323
335
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, shouldUseIncreasedScalingPercent);
@@ -424,25 +436,6 @@ const getCellItems = (state, view, {
424
436
  }
425
437
  return [];
426
438
  };
427
- export const getLockBtnConfig = editorAnalyticsAPI => (state, dispatch, editorView) => {
428
- const selectionOrTableRect = getClosestSelectionOrTableRect(state);
429
- if (!editorView || !selectionOrTableRect) {
430
- return false;
431
- }
432
- const {
433
- tr
434
- } = state;
435
- const table = findTable(tr.selection);
436
- if (!table) {
437
- return false;
438
- } else {
439
- const {
440
- displayMode
441
- } = table.node.attrs;
442
- toggleTableLockWithAnalytics(editorAnalyticsAPI)(displayMode, INPUT_METHOD.FLOATING_TB)(state, dispatch);
443
- return true;
444
- }
445
- };
446
439
  export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => (state, dispatch, editorView) => {
447
440
  const selectionOrTableRect = getClosestSelectionOrTableRect(state);
448
441
  if (!editorView || !selectionOrTableRect) {
@@ -470,25 +463,6 @@ const getColumnSettingItems = (editorState, editorView, {
470
463
  const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
471
464
  const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
472
465
  const items = [];
473
- const isNested = pluginState.tablePos && isTableNested(editorState, pluginState.tablePos);
474
- const isTableScalingLockBtnEnabled = !isNested && isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
475
- if (isTableScalingLockBtnEnabled) {
476
- var _pluginState$tableNod;
477
- const areColumnWidthsLocked = (pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
478
- const title = areColumnWidthsLocked ? formatMessage(messages.unlockColumnWidths) : formatMessage(messages.lockColumnWidths);
479
- items.push({
480
- id: 'editor.table.lockColumns',
481
- type: 'button',
482
- title,
483
- icon: () => jsx(DisplayModeIcon, {
484
- size: "medium",
485
- label: title
486
- }),
487
- onClick: (state, dispatch, view) => getLockBtnConfig(editorAnalyticsAPI)(state, dispatch, view),
488
- selected: areColumnWidthsLocked,
489
- testId: 'table-lock-column-widths-btn'
490
- });
491
- }
492
466
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
493
467
  items.push({
494
468
  id: 'editor.table.distributeColumns',
@@ -598,7 +572,7 @@ export const getAlignmentOptionsConfig = (editorState, {
598
572
  icon: icon,
599
573
  title: formatMessage(layoutToMessages[value]),
600
574
  selected: normaliseAlignment(currentLayout) === value,
601
- onClick: setTableAlignmentWithAnalytics(editorAnalyticsAPI)(value, currentLayout, INPUT_METHOD.FLOATING_TB),
575
+ onClick: setTableAlignmentWithAnalytics(editorAnalyticsAPI)(value, currentLayout, INPUT_METHOD.FLOATING_TB, CHANGE_ALIGNMENT_REASON.TOOLBAR_OPTION_CHANGED),
602
576
  ...(isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth) && {
603
577
  disabled: value !== 'center'
604
578
  })
@@ -1,7 +1,6 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
3
  export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
4
- export { DisplayModeIcon } from './DisplayModeIcon';
5
4
  export { MinimisedHandleIcon } from './MinimisedHandle';
6
5
  export { MergeCellsIcon } from './MergeCellsIcon';
7
6
  export { SplitCellIcon } from './SplitCellIcon';
@@ -1,5 +1,5 @@
1
1
  import { isVerticalPosition } from '@atlaskit/editor-common/guideline';
2
- import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
2
+ import { akEditorCalculatedWideLayoutWidth, akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic } from '@atlaskit/editor-shared-styles';
3
3
  const numberOfLanesInDefaultLayoutWidth = 12;
4
4
  const calculateSubSnappingWidths = (totalLanes, totalWidth) => new Array(Math.round(totalLanes / 2) - 1).fill(totalWidth / totalLanes).map((v, i) => v * (i + 1) * 2);
5
5
  export const calculateDefaultSnappings = (lengthOffset = 0) => [...calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, akEditorDefaultLayoutWidth + lengthOffset), akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset, akEditorFullWidthLayoutWidth + lengthOffset];
@@ -8,7 +8,7 @@ export const calculateDefaultTablePreserveSnappings = (lengthOffset = 0, editorC
8
8
  innerGuidelines: false,
9
9
  breakoutPoints: false
10
10
  }) => {
11
- const dynamicFullWidthLine = editorContainerWith - akEditorGutterPadding * 2 >= akEditorFullWidthLayoutWidth ? akEditorFullWidthLayoutWidth : editorContainerWith - akEditorGutterPadding * 2;
11
+ const dynamicFullWidthLine = editorContainerWith - akEditorGutterPaddingDynamic() * 2 >= akEditorFullWidthLayoutWidth ? akEditorFullWidthLayoutWidth : editorContainerWith - akEditorGutterPaddingDynamic() * 2;
12
12
  const guides = [dynamicFullWidthLine - lengthOffset];
13
13
  if (!exclude.breakoutPoints) {
14
14
  guides.unshift(akEditorDefaultLayoutWidth + lengthOffset, akEditorCalculatedWideLayoutWidth + lengthOffset);
@@ -25,7 +25,7 @@ export const defaultTablePreserveSnappingWidths = (lengthOffset, editorContainer
25
25
  innerGuidelines: false,
26
26
  breakoutPoints: false
27
27
  }) => {
28
- return editorContainerWidth - akEditorGutterPadding * 2 > akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(lengthOffset, editorContainerWidth, exclude); // lengthOffset was hardcoded 0 here, created PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET instead.
28
+ return editorContainerWidth - akEditorGutterPaddingDynamic() * 2 > akEditorFullWidthLayoutWidth ? calculateDefaultSnappings() : calculateDefaultTablePreserveSnappings(lengthOffset, editorContainerWidth, exclude); // lengthOffset was hardcoded 0 here, created PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET instead.
29
29
  };
30
30
 
31
31
  /**
@@ -5,6 +5,7 @@ import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
5
5
  import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_BREAKOUT, TABLE_DISPLAY_MODE } from '@atlaskit/editor-common/analytics';
6
6
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
7
7
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
8
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
8
9
  import { findCellClosestToPos, findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tables/utils';
9
10
  import { clearMultipleCells } from './commands/clear';
10
11
  import { wrapTableInExpand } from './commands/collapse';
@@ -12,7 +13,7 @@ import { changeColumnWidthByStep } from './commands/column-resize';
12
13
  import { deleteColumnsCommand } from './commands/delete';
13
14
  import { setTableDisplayMode } from './commands/display-mode';
14
15
  import { insertColumn, insertRow } from './commands/insert';
15
- import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs, setTableAlignment } from './commands/misc';
16
+ import { deleteTable, deleteTableIfSelected, getTableSelectionType, setMultipleCellAttrs, setTableAlignment, setTableAlignmentWithTableContentWithPos } from './commands/misc';
16
17
  import { sortByColumn } from './commands/sort';
17
18
  import { splitCell } from './commands/split-cell';
18
19
  import { getNextLayout, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout } from './commands/toggle';
@@ -493,47 +494,45 @@ export var wrapTableInExpandWithAnalytics = function wrapTableInExpandWithAnalyt
493
494
  };
494
495
  })(editorAnalyticsAPI)(wrapTableInExpand);
495
496
  };
496
- export var toggleTableLockWithAnalytics = function toggleTableLockWithAnalytics(editorAnalyticsAPI) {
497
- return function (displayMode, inputMethod) {
498
- return withEditorAnalyticsAPI(function (state) {
499
- var _getSelectedTableInfo13 = getSelectedTableInfo(state.selection),
500
- table = _getSelectedTableInfo13.table,
501
- totalRowCount = _getSelectedTableInfo13.totalRowCount,
502
- totalColumnCount = _getSelectedTableInfo13.totalColumnCount;
503
- var previousDisplayMode;
504
- var newDisplayMode;
505
- switch (displayMode) {
506
- case 'fixed':
507
- previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
508
- newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
509
- break;
510
- case 'default':
511
- previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
512
- newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
513
- break;
514
- case null:
515
- default:
516
- previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
517
- newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
518
- }
519
- return {
520
- action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
521
- actionSubject: ACTION_SUBJECT.TABLE,
522
- attributes: {
523
- inputMethod: inputMethod,
524
- previousDisplayMode: previousDisplayMode,
525
- newDisplayMode: newDisplayMode,
526
- tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
527
- totalRowCount: totalRowCount,
528
- totalColumnCount: totalColumnCount
529
- },
530
- eventType: EVENT_TYPE.TRACK
531
- };
532
- })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
533
- };
497
+ export var toggleFixedColumnWidthsOptionAnalytics = function toggleFixedColumnWidthsOptionAnalytics(editorAnalyticsAPI, inputMethod) {
498
+ return withEditorAnalyticsAPI(function (state) {
499
+ var _getSelectedTableInfo13 = getSelectedTableInfo(state.selection),
500
+ table = _getSelectedTableInfo13.table,
501
+ totalRowCount = _getSelectedTableInfo13.totalRowCount,
502
+ totalColumnCount = _getSelectedTableInfo13.totalColumnCount;
503
+ var previousDisplayMode;
504
+ var newDisplayMode;
505
+ switch (table === null || table === void 0 ? void 0 : table.node.attrs.displayMode) {
506
+ case 'fixed':
507
+ previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
508
+ newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
509
+ break;
510
+ case 'default':
511
+ previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
512
+ newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
513
+ break;
514
+ case null:
515
+ default:
516
+ previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
517
+ newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
518
+ }
519
+ return {
520
+ action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
521
+ actionSubject: ACTION_SUBJECT.TABLE,
522
+ attributes: {
523
+ inputMethod: inputMethod,
524
+ previousDisplayMode: previousDisplayMode,
525
+ newDisplayMode: newDisplayMode,
526
+ tableWidth: table === null || table === void 0 ? void 0 : table.node.attrs.width,
527
+ totalRowCount: totalRowCount,
528
+ totalColumnCount: totalColumnCount
529
+ },
530
+ eventType: EVENT_TYPE.TRACK
531
+ };
532
+ })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
534
533
  };
535
534
  export var setTableAlignmentWithAnalytics = function setTableAlignmentWithAnalytics(editorAnalyticsAPI) {
536
- return function (newAlignment, previousAlignment, inputMethod) {
535
+ return function (newAlignment, previousAlignment, inputMethod, reason) {
537
536
  return withEditorAnalyticsAPI(function (state) {
538
537
  var _getSelectedTableInfo14 = getSelectedTableInfo(state.selection),
539
538
  table = _getSelectedTableInfo14.table,
@@ -550,9 +549,35 @@ export var setTableAlignmentWithAnalytics = function setTableAlignmentWithAnalyt
550
549
  previousAlignment: previousAlignment === 'center' || previousAlignment === 'align-start' ? previousAlignment : null,
551
550
  totalRowCount: totalRowCount,
552
551
  totalColumnCount: totalColumnCount,
553
- inputMethod: inputMethod
552
+ inputMethod: inputMethod,
553
+ reason: reason
554
554
  }
555
555
  };
556
556
  })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableAlignment(newAlignment)));
557
557
  };
558
+ };
559
+ export var setTableAlignmentWithTableContentWithPosWithAnalytics = function setTableAlignmentWithTableContentWithPosWithAnalytics(editorAnalyticsAPI) {
560
+ return function (newAlignment, previousAlignment, tableNodeWithPos, inputMethod, reason) {
561
+ return withEditorAnalyticsAPI(function () {
562
+ var map = TableMap.get(tableNodeWithPos.node);
563
+ var totalRowCount = map.height;
564
+ var totalColumnCount = map.width;
565
+ var attributes = {
566
+ tableWidth: tableNodeWithPos.node.attrs.width,
567
+ newAlignment: newAlignment,
568
+ previousAlignment: previousAlignment,
569
+ totalRowCount: totalRowCount,
570
+ totalColumnCount: totalColumnCount,
571
+ inputMethod: inputMethod,
572
+ reason: reason
573
+ };
574
+ return {
575
+ action: TABLE_ACTION.CHANGED_ALIGNMENT,
576
+ actionSubject: ACTION_SUBJECT.TABLE,
577
+ actionSubjectId: null,
578
+ eventType: EVENT_TYPE.TRACK,
579
+ attributes: attributes
580
+ };
581
+ })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos)));
582
+ };
558
583
  };
@@ -1,12 +1,14 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import classNames from 'classnames';
4
+ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
6
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
6
- import { akEditorDefaultLayoutWidth, akEditorGutterPadding, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
7
- import { setTableAlignmentWithTableContentWithPos } from '../commands/misc';
7
+ import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
8
+ import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
8
9
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
9
10
  import { TableCssClassName as ClassName } from '../types';
11
+ import { ALIGN_CENTER, ALIGN_START } from '../utils/alignment';
10
12
  import { TableResizer } from './TableResizer';
11
13
  export var InnerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
12
14
  var className = _ref.className,
@@ -40,25 +42,25 @@ var AlignmentTableContainer = function AlignmentTableContainer(_ref2) {
40
42
  pluginInjectionApi = _ref2.pluginInjectionApi,
41
43
  getPos = _ref2.getPos,
42
44
  editorView = _ref2.editorView;
43
- var alignment = node.attrs.layout;
45
+ var alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
44
46
  var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['table']),
45
47
  tableState = _useSharedPluginState.tableState;
46
48
  useEffect(function () {
47
49
  if (tableState && editorView && getPos) {
48
50
  var wasFullWidthModeEnabled = tableState.wasFullWidthModeEnabled,
49
51
  isFullWidthModeEnabled = tableState.isFullWidthModeEnabled;
50
- if (wasFullWidthModeEnabled && !isFullWidthModeEnabled && node.attrs.width > akEditorDefaultLayoutWidth) {
52
+ var state = editorView.state,
53
+ dispatch = editorView.dispatch;
54
+ if (wasFullWidthModeEnabled && isFullWidthModeEnabled !== undefined && !isFullWidthModeEnabled && alignment !== ALIGN_CENTER && node.attrs.width > akEditorDefaultLayoutWidth) {
55
+ var _pluginInjectionApi$a;
51
56
  var pos = getPos && getPos();
52
57
  if (typeof pos !== 'number') {
53
58
  return;
54
59
  }
55
- var tr = setTableAlignmentWithTableContentWithPos('center', {
60
+ setTableAlignmentWithTableContentWithPosWithAnalytics(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(ALIGN_CENTER, alignment, {
56
61
  pos: pos,
57
62
  node: node
58
- })(editorView.state);
59
- if (tr) {
60
- editorView.dispatch(tr);
61
- }
63
+ }, INPUT_METHOD.AUTO, CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED)(state, dispatch);
62
64
  }
63
65
  }
64
66
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -171,8 +173,8 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
171
173
  })) !== null && _pluginInjectionApi$g !== void 0 ? _pluginInjectionApi$g : false;
172
174
  }, [pluginInjectionApi, editorView]);
173
175
  var attachAnalyticsEvent = useCallback(function (payload) {
174
- var _pluginInjectionApi$a;
175
- return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.attachAnalyticsEvent(payload);
176
+ var _pluginInjectionApi$a2;
177
+ return pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions.attachAnalyticsEvent(payload);
176
178
  }, [pluginInjectionApi]);
177
179
  var displayGapCursor = useCallback(function (toggle) {
178
180
  var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$s;
@@ -192,13 +194,13 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
192
194
  // When: Show scroll bars -> containerWidth = akEditorGutterPadding * 2 + lineLength;
193
195
  // When: Always -> containerWidth = akEditorGutterPadding * 2 + lineLength + scrollbarWidth;
194
196
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
195
- responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - akEditorGutterPadding * 2 - resizeHandleSpacing;
197
+ responsiveContainerWidth = isTableScalingEnabled ? lineLength : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
196
198
  } else {
197
199
  // 76 is currently an accepted padding value considering the spacing for resizer handle
198
200
  // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
199
201
  // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
200
202
  // padding left = padding right = akEditorGutterPadding = 32
201
- responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPadding * 2 : containerWidth - akEditorGutterPadding * 2 - resizeHandleSpacing;
203
+ responsiveContainerWidth = isTableScalingEnabled ? containerWidth - akEditorGutterPaddingDynamic() * 2 : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
202
204
  }
203
205
  var width = Math.min(tableWidth, responsiveContainerWidth);
204
206
  if (!isResizing) {