@atlaskit/editor-plugin-table 7.7.2 → 7.7.4

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 (72) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/commands/display-mode.js +23 -0
  3. package/dist/cjs/commands/index.js +8 -1
  4. package/dist/cjs/nodeviews/table.js +2 -1
  5. package/dist/cjs/plugin.js +3 -2
  6. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +1 -1
  7. package/dist/cjs/toolbar.js +43 -12
  8. package/dist/cjs/ui/FloatingContextualButton/styles.js +43 -5
  9. package/dist/cjs/ui/FloatingContextualMenu/styles.js +14 -5
  10. package/dist/cjs/ui/FloatingDragMenu/styles.js +29 -5
  11. package/dist/cjs/ui/icons/DisplayModeIcon.js +46 -0
  12. package/dist/cjs/ui/icons/index.js +7 -0
  13. package/dist/cjs/ui/ui-styles.js +1 -0
  14. package/dist/es2019/commands/display-mode.js +17 -0
  15. package/dist/es2019/commands/index.js +2 -1
  16. package/dist/es2019/nodeviews/table.js +2 -1
  17. package/dist/es2019/plugin.js +4 -3
  18. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -1
  19. package/dist/es2019/toolbar.js +41 -12
  20. package/dist/es2019/ui/FloatingContextualButton/styles.js +42 -42
  21. package/dist/es2019/ui/FloatingContextualMenu/styles.js +11 -9
  22. package/dist/es2019/ui/FloatingDragMenu/styles.js +24 -22
  23. package/dist/es2019/ui/icons/DisplayModeIcon.js +39 -0
  24. package/dist/es2019/ui/icons/index.js +1 -0
  25. package/dist/es2019/ui/ui-styles.js +1 -0
  26. package/dist/esm/commands/display-mode.js +16 -0
  27. package/dist/esm/commands/index.js +2 -1
  28. package/dist/esm/nodeviews/table.js +2 -1
  29. package/dist/esm/plugin.js +4 -3
  30. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -1
  31. package/dist/esm/toolbar.js +44 -13
  32. package/dist/esm/ui/FloatingContextualButton/styles.js +43 -4
  33. package/dist/esm/ui/FloatingContextualMenu/styles.js +14 -5
  34. package/dist/esm/ui/FloatingDragMenu/styles.js +29 -5
  35. package/dist/esm/ui/icons/DisplayModeIcon.js +39 -0
  36. package/dist/esm/ui/icons/index.js +1 -0
  37. package/dist/esm/ui/ui-styles.js +1 -0
  38. package/dist/types/commands/display-mode.d.ts +2 -0
  39. package/dist/types/commands/index.d.ts +1 -0
  40. package/dist/types/commands/toggle.d.ts +1 -1
  41. package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  42. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  43. package/dist/types/toolbar.d.ts +2 -1
  44. package/dist/types/ui/icons/DisplayModeIcon.d.ts +4 -0
  45. package/dist/types/ui/icons/index.d.ts +1 -0
  46. package/dist/types-ts4.5/commands/display-mode.d.ts +2 -0
  47. package/dist/types-ts4.5/commands/index.d.ts +1 -0
  48. package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
  49. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +3 -3
  50. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -2
  51. package/dist/types-ts4.5/toolbar.d.ts +2 -1
  52. package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +4 -0
  53. package/dist/types-ts4.5/ui/icons/index.d.ts +1 -0
  54. package/package.json +6 -3
  55. package/src/commands/display-mode.ts +19 -0
  56. package/src/commands/index.ts +1 -0
  57. package/src/commands/toggle.ts +1 -1
  58. package/src/commands-with-analytics.ts +3 -2
  59. package/src/nodeviews/table.tsx +1 -0
  60. package/src/plugin.tsx +15 -2
  61. package/src/pm-plugins/table-resizing/event-handlers.ts +2 -1
  62. package/src/pm-plugins/table-resizing/utils/misc.ts +3 -3
  63. package/src/pm-plugins/table-resizing/utils/resize-state.ts +1 -4
  64. package/src/toolbar.tsx +56 -22
  65. package/src/transforms/fix-tables.ts +1 -2
  66. package/src/types.ts +5 -0
  67. package/src/ui/FloatingContextualButton/styles.ts +48 -46
  68. package/src/ui/FloatingContextualMenu/styles.ts +11 -9
  69. package/src/ui/FloatingDragMenu/styles.ts +27 -25
  70. package/src/ui/icons/DisplayModeIcon.tsx +41 -0
  71. package/src/ui/icons/index.ts +1 -0
  72. package/src/ui/ui-styles.ts +1 -0
@@ -4,6 +4,7 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
4
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
6
6
  import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
7
8
  import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
8
9
  import { closestElement, getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
9
10
  import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
@@ -15,7 +16,7 @@ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal
15
16
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
16
17
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
17
18
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
18
- import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
19
+ import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes, setTableDisplayMode } from './commands';
19
20
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
20
21
  import { getPluginState } from './pm-plugins/plugin-factory';
21
22
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
@@ -23,6 +24,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
23
24
  import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
24
25
  import { canMergeCells } from './transforms';
25
26
  import { TableCssClassName } from './types';
27
+ import { DisplayModeIcon } from './ui/icons';
26
28
  import { FullWidthDisplay } from './ui/TableFullWidthLabel';
27
29
  import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
28
30
  export const getToolbarMenuConfig = (config, state, {
@@ -299,7 +301,7 @@ export const getClosestSelectionOrTableRect = state => {
299
301
  const tableRect = new Rect(0, 0, map.width, map.height);
300
302
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
301
303
  };
302
- export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) => config => (state, intl) => {
304
+ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) => config => (state, intl) => {
303
305
  var _tableObject$node$att, _tableObject$node, _tableObject$node$att2;
304
306
  const tableObject = findTable(state.selection);
305
307
  const pluginState = getPluginState(state);
@@ -313,7 +315,9 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
313
315
  widthToWidest
314
316
  } = pluginState;
315
317
  const currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 ? void 0 : (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 ? void 0 : (_tableObject$node$att2 = _tableObject$node.attrs) === null || _tableObject$node$att2 === void 0 ? void 0 : _tableObject$node$att2.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
316
- if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
318
+ if (isTableScalingEnabled &&
319
+ // TODO ED-21670: check if need options.isTableScalingEnabled
320
+ isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
317
321
  const {
318
322
  stickyScrollbar
319
323
  } = getEditorFeatureFlags();
@@ -362,11 +366,12 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
362
366
  const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
363
367
  const {
364
368
  isTableScalingEnabled = false
365
- } = getPluginState(state);
369
+ } = getPluginState(state); // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
370
+
366
371
  let cellItems;
367
372
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled);
368
373
  let columnSettingsItems;
369
- columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled) : [];
374
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, isTableScalingEnabled) : [];
370
375
  const colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
371
376
 
372
377
  // Check if we need to show confirm dialog for delete button
@@ -484,28 +489,52 @@ export const getDistributeConfig = (getEditorContainerWidth, editorAnalyticsAPI,
484
489
  // fixed column button should be in this function call in the future
485
490
  const getColumnSettingItems = (editorState, editorView, {
486
491
  formatMessage
487
- }, getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled = false) => {
492
+ }, getEditorContainerWidth, editorAnalyticsAPI, options, isTableScalingEnabled = false) => {
488
493
  var _newResizeStateWithAn2, _pluginState$pluginCo3;
489
494
  const pluginState = getPluginState(editorState);
490
495
  const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
491
496
  if (!selectionOrTableRect || !editorView) {
492
497
  return [];
493
498
  }
494
- const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
499
+ const newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
500
+ );
495
501
  const wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
502
+ const items = [];
503
+ const isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
504
+ if (isTableScalingLockBtnEnabled) {
505
+ var _pluginState$tableNod;
506
+ 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';
507
+ const title = areColumnWidthsLocked ? formatMessage(messages.unlockColumnWidths) : formatMessage(messages.lockColumnWidths);
508
+ items.push({
509
+ id: 'editor.table.lockColumns',
510
+ type: 'button',
511
+ title,
512
+ icon: () => jsx(DisplayModeIcon, {
513
+ size: "medium",
514
+ label: title
515
+ }),
516
+ onClick: editorCommandToPMCommand(setTableDisplayMode),
517
+ selected: areColumnWidthsLocked,
518
+ testId: 'table-lock-column-widths-btn'
519
+ });
520
+ }
496
521
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
497
- return [{
522
+ items.push({
498
523
  id: 'editor.table.distributeColumns',
499
524
  type: 'button',
500
525
  title: formatMessage(messages.distributeColumns),
501
526
  icon: DistributeColumnIcon,
502
- onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view),
527
+ onClick: (state, dispatch, view) => getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
528
+ )(state, dispatch, view),
503
529
  disabled: !wouldChange
504
- }, {
530
+ });
531
+ }
532
+ if (items.length !== 0) {
533
+ items.push({
505
534
  type: 'separator'
506
- }];
535
+ });
507
536
  }
508
- return [];
537
+ return items;
509
538
  };
510
539
  const getColorPicker = (state, menu, {
511
540
  formatMessage
@@ -1,46 +1,46 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
3
3
  import { contextualMenuTriggerSize } from '../consts';
4
- export const tableFloatingCellButtonStyles = () => css`
5
- > div {
4
+ export const tableFloatingCellButtonStyles = () => css({
5
+ '> div': {
6
6
  // Sits behind button to provide surface-color background
7
- background: ${`var(--ds-surface, ${N20})`};
8
- border-radius: ${"var(--ds-border-radius, 3px)"};
9
- display: flex;
10
- height: ${contextualMenuTriggerSize + 2}px;
11
- flex-direction: column;
12
- }
13
- && button {
14
- background: ${"var(--ds-background-neutral, none)"};
15
- flex-direction: column;
16
- margin: ${"var(--ds-space-025, 2px)"};
17
- outline: 2px solid ${`var(--ds-surface, ${N0})`};
18
- border-radius: 1px;
19
- padding: 0;
20
- height: calc(100% - 4px);
21
- display: flex;
22
- }
23
- && button:hover {
24
- background: ${`var(--ds-background-neutral-hovered, ${N30A})`};
25
- }
26
- && button:active {
27
- background: ${"var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))"};
28
- }
29
- && button > span {
30
- margin: 0px ${"var(--ds-space-negative-050, -4px)"};
31
- }
32
- && span {
33
- pointer-events: none;
34
- }
35
- `;
36
- export const tableFloatingCellButtonSelectedStyles = () => css`
37
- && button {
38
- background: ${`var(--ds-background-selected, ${N700})`};
39
- }
40
- && button:hover {
41
- background: ${`var(--ds-background-selected-hovered, ${N700})`};
42
- }
43
- && button:active {
44
- background: ${`var(--ds-background-selected-pressed, ${N700})`};
45
- }
46
- `;
7
+ background: `var(--ds-surface, ${N20})`,
8
+ borderRadius: "var(--ds-border-radius, 3px)",
9
+ display: 'flex',
10
+ height: `${contextualMenuTriggerSize + 2}px`,
11
+ flexDirection: 'column'
12
+ },
13
+ '&& button': {
14
+ background: "var(--ds-background-neutral, none)",
15
+ flexDirection: 'column',
16
+ margin: "var(--ds-space-025, 2px)",
17
+ outline: `2px solid ${`var(--ds-surface, ${N0})`}`,
18
+ borderRadius: '1px',
19
+ padding: 0,
20
+ height: 'calc(100% - 4px)',
21
+ display: 'flex'
22
+ },
23
+ '&& button:hover': {
24
+ background: `var(--ds-background-neutral-hovered, ${N30A})`
25
+ },
26
+ '&& button:active': {
27
+ background: "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))"
28
+ },
29
+ '&& button > span': {
30
+ margin: `0px ${"var(--ds-space-negative-050, -4px)"}`
31
+ },
32
+ '&& span': {
33
+ pointerEvents: 'none'
34
+ }
35
+ });
36
+ export const tableFloatingCellButtonSelectedStyles = () => css({
37
+ '&& button': {
38
+ background: `var(--ds-background-selected, ${N700})`
39
+ },
40
+ '&& button:hover': {
41
+ background: `var(--ds-background-selected-hovered, ${N700})`
42
+ },
43
+ '&& button:active': {
44
+ background: `var(--ds-background-selected-pressed, ${N700})`
45
+ }
46
+ });
@@ -3,19 +3,21 @@ import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
3
3
  import { N60A, N90 } from '@atlaskit/theme/colors';
4
4
  import { TableCssClassName as ClassName } from '../../types';
5
5
  import { contextualMenuDropdownWidth, contextualMenuDropdownWidthDnD } from '../consts';
6
- export const cellColourPreviewStyles = selectedColor => css`
7
- &::before {
8
- background: ${selectedColor};
6
+ export const cellColourPreviewStyles = selectedColor => css({
7
+ '&::before': {
8
+ background: selectedColor
9
9
  }
10
- `;
11
- export const elementBeforeIconStyles = css`
12
- margin-right: ${"var(--ds-space-negative-075, -6px)"};
13
- display: flex;
14
- `;
10
+ });
11
+ export const elementBeforeIconStyles = css({
12
+ marginRight: "var(--ds-space-negative-075, -6px)",
13
+ display: 'flex'
14
+ });
15
15
 
16
16
  // TODO Delete this comment after verifying space token -> previous value `padding: 8px`
17
17
  // TODO Delete this comment after verifying space token -> previous value `margin-left: 4px`
18
- export const tablePopupStyles = isDragAndDropEnabled => css`
18
+ export const tablePopupStyles = (isDragAndDropEnabled
19
+ // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
20
+ ) => css`
19
21
  .${ClassName.CONTEXTUAL_SUBMENU} {
20
22
  border-radius: ${"var(--ds-border-radius, 3px)"};
21
23
  background: ${"var(--ds-surface-overlay, white)"};
@@ -3,15 +3,17 @@ import { tableBackgroundBorderColor } from '@atlaskit/adf-schema';
3
3
  import { N60A, N90 } from '@atlaskit/theme/colors';
4
4
  import { TableCssClassName as ClassName } from '../../types';
5
5
  import { dragMenuDropdownWidth } from '../consts';
6
- export const cellColourPreviewStyles = selectedColor => css`
7
- &::before {
8
- background: ${selectedColor};
6
+ export const cellColourPreviewStyles = selectedColor => css({
7
+ '&::before': {
8
+ background: selectedColor
9
9
  }
10
- `;
11
- export const elementBeforeIconStyles = css`
12
- margin-right: ${"var(--ds-space-negative-075, -6px)"};
13
- display: flex;
14
- `;
10
+ });
11
+ export const elementBeforeIconStyles = css({
12
+ marginRight: "var(--ds-space-negative-075, -6px)",
13
+ display: 'flex'
14
+ });
15
+
16
+ // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
15
17
  export const dragMenuBackgroundColorStyles = css`
16
18
  .${ClassName.DRAG_SUBMENU} {
17
19
  border-radius: ${"var(--ds-border-radius, 3px)"};
@@ -48,19 +50,19 @@ export const dragMenuBackgroundColorStyles = css`
48
50
  }
49
51
  }
50
52
  `;
51
- export const toggleStyles = css`
52
- display: flex;
53
- input[type='checkbox'] {
54
- width: 30px;
55
- height: 14px;
56
- pointer-events: initial;
57
- cursor: pointer;
58
- }
59
- > label {
60
- margin: 0px;
61
- pointer-events: none;
62
- > span {
63
- pointer-events: none;
53
+ export const toggleStyles = css({
54
+ display: 'flex',
55
+ "input[type='checkbox']": {
56
+ width: '30px',
57
+ height: '14px',
58
+ pointerEvents: 'initial',
59
+ cursor: 'pointer'
60
+ },
61
+ '> label': {
62
+ margin: '0px',
63
+ pointerEvents: 'none',
64
+ '> span': {
65
+ pointerEvents: 'none'
64
66
  }
65
67
  }
66
- `;
68
+ });
@@ -0,0 +1,39 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Icon from '@atlaskit/icon';
4
+ export const DisplayModeGlyth = props => {
5
+ return /*#__PURE__*/React.createElement("svg", _extends({
6
+ width: "24",
7
+ height: "24",
8
+ viewBox: "0 0 24 24",
9
+ fill: "none",
10
+ xmlns: "http://www.w3.org/2000/svg"
11
+ }, props), /*#__PURE__*/React.createElement("rect", {
12
+ x: "4",
13
+ y: "5",
14
+ width: "4",
15
+ height: "14",
16
+ rx: "1",
17
+ fill: "currentColor"
18
+ }), /*#__PURE__*/React.createElement("path", {
19
+ fillRule: "evenodd",
20
+ clipRule: "evenodd",
21
+ d: "M11 5C10.4477 5 10 5.44772 10 6V9.10102C11.0503 8.02921 12.4424 7.29368 14 7.07089V6C14 5.44772 13.5523 5 13 5H11Z",
22
+ fill: "currentColor"
23
+ }), /*#__PURE__*/React.createElement("path", {
24
+ fillRule: "evenodd",
25
+ clipRule: "evenodd",
26
+ d: "M17 5C16.4477 5 16 5.44772 16 6V7.07089C17.5576 7.29368 18.9497 8.02921 20 9.10102V6C20 5.44772 19.5523 5 19 5H17Z",
27
+ fill: "currentColor"
28
+ }), /*#__PURE__*/React.createElement("path", {
29
+ fillRule: "evenodd",
30
+ clipRule: "evenodd",
31
+ d: "M21 14C21 17.3137 18.3137 20 15 20C11.6863 20 9 17.3137 9 14C9 10.6863 11.6863 8 15 8C18.3137 8 21 10.6863 21 14ZM12 15C12 14.4477 12.4477 14 13 14V12C13 10.8954 13.8954 10 15 10C16.1046 10 17 10.8954 17 12V14C17.5523 14 18 14.4477 18 15V17C18 17.5523 17.5523 18 17 18H13C12.4477 18 12 17.5523 12 17V15ZM16 14V12C16 11.4477 15.5523 11 15 11C14.4477 11 14 11.4477 14 12V14H16Z",
32
+ fill: "currentColor"
33
+ }));
34
+ };
35
+ export const DisplayModeIcon = props => {
36
+ return /*#__PURE__*/React.createElement(Icon, _extends({
37
+ glyph: DisplayModeGlyth
38
+ }, props));
39
+ };
@@ -1,6 +1,7 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
3
  export { DragHandleDisabledIcon } from './DragHandleDisabledIcon';
4
+ export { DisplayModeIcon } from './DisplayModeIcon';
4
5
  export { MinimisedHandleIcon } from './MinimisedHandle';
5
6
  export { MergeCellsIcon } from './MergeCellsIcon';
6
7
  export { SplitCellIcon } from './SplitCellIcon';
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @atlaskit/design-system/no-css-tagged-template-expression -- needs mahual remediation */
1
2
  import { css } from '@emotion/react';
2
3
  import { tableCellBorderWidth, tableMarginTop, tableMarginTopWithControl } from '@atlaskit/editor-common/styles';
3
4
  import { akEditorShadowZIndex, akEditorTableBorder, akEditorTableNumberColumnWidth, akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
@@ -0,0 +1,16 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { findTable } from '@atlaskit/editor-tables/utils';
5
+ export var setTableDisplayMode = function setTableDisplayMode(_ref) {
6
+ var tr = _ref.tr;
7
+ var table = findTable(tr.selection);
8
+ if (!table) {
9
+ return null;
10
+ }
11
+ var displayMode = table.node.attrs.displayMode;
12
+ tr.setNodeMarkup(table.pos, tr.doc.type.schema.nodes.table, _objectSpread(_objectSpread({}, table.node.attrs), {}, {
13
+ displayMode: !displayMode || displayMode === 'default' ? 'fixed' : 'default'
14
+ }));
15
+ return tr.setMeta('scrollIntoView', false);
16
+ };
@@ -5,4 +5,5 @@ export { clearMultipleCells } from './clear';
5
5
  export { autoSizeTable, convertFirstRowToHeader, deleteTable, hideInsertColumnOrRowButton, moveCursorBackward, selectColumn, selectColumns, selectRow, selectRows, setCellAttr, setEditorFocus, setMultipleCellAttrs, setTableRef, showInsertColumnButton, showInsertRowButton, transformSliceToAddTableHeaders, triggerUnlessTableHeader, addBoldInEmptyHeaderCells, addResizeHandleDecorations, updateWidthToWidest } from './misc';
6
6
  export { sortByColumn } from './sort';
7
7
  export { goToNextCell } from './go-to-next-cell';
8
- export { removeDescendantNodes } from './referentiality';
8
+ export { removeDescendantNodes } from './referentiality';
9
+ export { setTableDisplayMode } from './display-mode';
@@ -34,7 +34,8 @@ var tableAttributes = function tableAttributes(node) {
34
34
  'data-layout': node.attrs.layout,
35
35
  'data-autosize': node.attrs.__autoSize,
36
36
  'data-table-local-id': node.attrs.localId || '',
37
- 'data-table-width': node.attrs.width
37
+ 'data-table-width': node.attrs.width,
38
+ 'data-table-display-mode': node.attrs.displayMode
38
39
  };
39
40
  };
40
41
  var getInlineWidth = function getInlineWidth(node, options, state, pos) {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
2
+ import { table, tableCell, tableHeader, tableRow, tableStage0 } 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';
@@ -109,9 +109,10 @@ var tablesPlugin = function tablesPlugin(_ref) {
109
109
  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 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
110
110
  },
111
111
  nodes: function nodes() {
112
+ var tableNode = options !== null && options !== void 0 && options.isTableScalingEnabled && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') ? tableStage0 : table;
112
113
  return [{
113
114
  name: 'table',
114
- node: table
115
+ node: tableNode
115
116
  }, {
116
117
  name: 'tableHeader',
117
118
  node: tableHeader
@@ -421,7 +422,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
421
422
  },
422
423
  floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags, function () {
423
424
  return editorViewRef.current;
424
- })(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
425
+ }, options)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
425
426
  }
426
427
  };
427
428
  };
@@ -136,7 +136,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
136
136
  var resizedDelta = clientX - startX;
137
137
  tr = updateColumnWidths(newResizeState, table, start)(tr);
138
138
  if (getBooleanFF('platform.editor.table.colum-resizing-improvements')) {
139
- tr.setNodeAttribute(tablePos, 'width', newResizeState.tableWidth);
139
+ tr.setNodeAttribute(start - 1, 'width', newResizeState.tableWidth);
140
140
  }
141
141
  if (colIndex === map.width - 1) {
142
142
  var mouseUpTime = event.timeStamp;
@@ -5,6 +5,7 @@ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
5
5
  import { 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
+ import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
8
9
  import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
9
10
  import { closestElement, getChildrenInfo as _getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
10
11
  import { findParentDomRefOfType } from '@atlaskit/editor-prosemirror/utils';
@@ -16,7 +17,7 @@ import DistributeColumnIcon from '@atlaskit/icon/glyph/editor/layout-three-equal
16
17
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
17
18
  import TableOptionsIcon from '@atlaskit/icon/glyph/preferences';
18
19
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
- import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes } from './commands';
20
+ import { clearHoverSelection, hoverColumns, hoverMergedCells, hoverRows, hoverTable, removeDescendantNodes, setTableDisplayMode } from './commands';
20
21
  import { deleteColumnsWithAnalytics, deleteRowsWithAnalytics, deleteTableWithAnalytics, distributeColumnsWidthsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, insertRowWithAnalytics, mergeCellsWithAnalytics, setColorWithAnalytics, sortColumnWithAnalytics, splitCellWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
21
22
  import { getPluginState } from './pm-plugins/plugin-factory';
22
23
  import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
@@ -24,6 +25,7 @@ import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizin
24
25
  import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
25
26
  import { canMergeCells } from './transforms';
26
27
  import { TableCssClassName } from './types';
28
+ import { DisplayModeIcon } from './ui/icons';
27
29
  import { FullWidthDisplay } from './ui/TableFullWidthLabel';
28
30
  import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
29
31
  export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _ref, editorAnalyticsAPI) {
@@ -300,7 +302,7 @@ export var getClosestSelectionOrTableRect = function getClosestSelectionOrTableR
300
302
  var tableRect = new Rect(0, 0, map.width, map.height);
301
303
  return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
302
304
  };
303
- export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView) {
305
+ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options) {
304
306
  return function (config) {
305
307
  return function (state, intl) {
306
308
  var _tableObject$node$att, _tableObject$node;
@@ -314,7 +316,9 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
314
316
  var isTableScalingEnabled = pluginState.isTableScalingEnabled,
315
317
  widthToWidest = pluginState.widthToWidest;
316
318
  var currentTableNodeLocalId = (_tableObject$node$att = tableObject === null || tableObject === void 0 || (_tableObject$node = tableObject.node) === null || _tableObject$node === void 0 || (_tableObject$node = _tableObject$node.attrs) === null || _tableObject$node === void 0 ? void 0 : _tableObject$node.localId) !== null && _tableObject$node$att !== void 0 ? _tableObject$node$att : '';
317
- if (isTableScalingEnabled && isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
319
+ if (isTableScalingEnabled &&
320
+ // TODO ED-21670: check if need options.isTableScalingEnabled
321
+ isWidthResizing && widthToWidest && currentTableNodeLocalId && widthToWidest[currentTableNodeLocalId]) {
318
322
  var _getEditorFeatureFlag = getEditorFeatureFlags(),
319
323
  stickyScrollbar = _getEditorFeatureFlag.stickyScrollbar;
320
324
  var nodeType = state.schema.nodes.table;
@@ -362,11 +366,12 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
362
366
  var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
363
367
  var _getPluginState2 = getPluginState(state),
364
368
  _getPluginState2$isTa = _getPluginState2.isTableScalingEnabled,
365
- _isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa;
369
+ _isTableScalingEnabled = _getPluginState2$isTa === void 0 ? false : _getPluginState2$isTa; // TODO ED-21670: check if we need options.isTableScalingEnabled and not an acutual state of displayNode attr on the table
370
+
366
371
  var cellItems;
367
372
  cellItems = pluginState.isDragAndDropEnabled ? [] : getCellItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled);
368
373
  var columnSettingsItems;
369
- columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, _isTableScalingEnabled) : [];
374
+ columnSettingsItems = pluginState.isDragAndDropEnabled ? getColumnSettingItems(state, getEditorView(), intl, getEditorContainerWidth, editorAnalyticsAPI, options, _isTableScalingEnabled) : [];
370
375
  var colorPicker = getColorPicker(state, menu, intl, editorAnalyticsAPI);
371
376
 
372
377
  // Check if we need to show confirm dialog for delete button
@@ -493,32 +498,58 @@ export var getDistributeConfig = function getDistributeConfig(getEditorContainer
493
498
 
494
499
  // this create the button group for distribute column and also fixed column width
495
500
  // fixed column button should be in this function call in the future
496
- var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI) {
501
+ var getColumnSettingItems = function getColumnSettingItems(editorState, editorView, _ref4, getEditorContainerWidth, editorAnalyticsAPI, options) {
497
502
  var _newResizeStateWithAn2, _pluginState$pluginCo3;
498
503
  var formatMessage = _ref4.formatMessage;
499
- var isTableScalingEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
504
+ var isTableScalingEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
500
505
  var pluginState = getPluginState(editorState);
501
506
  var selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
502
507
  if (!selectionOrTableRect || !editorView) {
503
508
  return [];
504
509
  }
505
- var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled);
510
+ var newResizeStateWithAnalytics = getNewResizeStateFromSelectedColumns(selectionOrTableRect, editorState, editorView.domAtPos.bind(editorView), getEditorContainerWidth, isTableScalingEnabled // TODO ED-21670: Here should be actual state of tableNode's displayMode attr
511
+ );
506
512
  var wouldChange = (_newResizeStateWithAn2 = newResizeStateWithAnalytics === null || newResizeStateWithAnalytics === void 0 ? void 0 : newResizeStateWithAnalytics.changed) !== null && _newResizeStateWithAn2 !== void 0 ? _newResizeStateWithAn2 : false;
513
+ var items = [];
514
+ var isTableScalingLockBtnEnabled = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
515
+ if (isTableScalingLockBtnEnabled) {
516
+ var _pluginState$tableNod;
517
+ var areColumnWidthsLocked = (pluginState === null || pluginState === void 0 || (_pluginState$tableNod = pluginState.tableNode) === null || _pluginState$tableNod === void 0 ? void 0 : _pluginState$tableNod.attrs.displayMode) === 'fixed';
518
+ var title = areColumnWidthsLocked ? formatMessage(messages.unlockColumnWidths) : formatMessage(messages.lockColumnWidths);
519
+ items.push({
520
+ id: 'editor.table.lockColumns',
521
+ type: 'button',
522
+ title: title,
523
+ icon: function icon() {
524
+ return jsx(DisplayModeIcon, {
525
+ size: "medium",
526
+ label: title
527
+ });
528
+ },
529
+ onClick: editorCommandToPMCommand(setTableDisplayMode),
530
+ selected: areColumnWidthsLocked,
531
+ testId: 'table-lock-column-widths-btn'
532
+ });
533
+ }
507
534
  if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo3 = pluginState.pluginConfig) !== null && _pluginState$pluginCo3 !== void 0 && _pluginState$pluginCo3.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
508
- return [{
535
+ items.push({
509
536
  id: 'editor.table.distributeColumns',
510
537
  type: 'button',
511
538
  title: formatMessage(messages.distributeColumns),
512
539
  icon: DistributeColumnIcon,
513
540
  onClick: function onClick(state, dispatch, view) {
514
- return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled)(state, dispatch, view);
541
+ return getDistributeConfig(getEditorContainerWidth, editorAnalyticsAPI, isTableScalingEnabled // TODO ED-21670: Maybe here too we an actual state of tableNode's displayMode attr
542
+ )(state, dispatch, view);
515
543
  },
516
544
  disabled: !wouldChange
517
- }, {
545
+ });
546
+ }
547
+ if (items.length !== 0) {
548
+ items.push({
518
549
  type: 'separator'
519
- }];
550
+ });
520
551
  }
521
- return [];
552
+ return items;
522
553
  };
523
554
  var getColorPicker = function getColorPicker(state, menu, _ref5, editorAnalyticsAPI) {
524
555
  var _node$attrs;
@@ -1,11 +1,50 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2;
3
1
  import { css } from '@emotion/react';
4
2
  import { N0, N20, N30A, N700 } from '@atlaskit/theme/colors';
5
3
  import { contextualMenuTriggerSize } from '../consts';
6
4
  export var tableFloatingCellButtonStyles = function tableFloatingCellButtonStyles() {
7
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n > div {\n // Sits behind button to provide surface-color background\n background: ", ";\n border-radius: ", ";\n display: flex;\n height: ", "px;\n flex-direction: column;\n }\n && button {\n background: ", ";\n flex-direction: column;\n margin: ", ";\n outline: 2px solid ", ";\n border-radius: 1px;\n padding: 0;\n height: calc(100% - 4px);\n display: flex;\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n && button > span {\n margin: 0px ", ";\n }\n && span {\n pointer-events: none;\n }\n"])), "var(--ds-surface, ".concat(N20, ")"), "var(--ds-border-radius, 3px)", contextualMenuTriggerSize + 2, "var(--ds-background-neutral, none)", "var(--ds-space-025, 2px)", "var(--ds-surface, ".concat(N0, ")"), "var(--ds-background-neutral-hovered, ".concat(N30A, ")"), "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))", "var(--ds-space-negative-050, -4px)");
5
+ return css({
6
+ '> div': {
7
+ // Sits behind button to provide surface-color background
8
+ background: "var(--ds-surface, ".concat(N20, ")"),
9
+ borderRadius: "var(--ds-border-radius, 3px)",
10
+ display: 'flex',
11
+ height: "".concat(contextualMenuTriggerSize + 2, "px"),
12
+ flexDirection: 'column'
13
+ },
14
+ '&& button': {
15
+ background: "var(--ds-background-neutral, none)",
16
+ flexDirection: 'column',
17
+ margin: "var(--ds-space-025, 2px)",
18
+ outline: "2px solid ".concat("var(--ds-surface, ".concat(N0, ")")),
19
+ borderRadius: '1px',
20
+ padding: 0,
21
+ height: 'calc(100% - 4px)',
22
+ display: 'flex'
23
+ },
24
+ '&& button:hover': {
25
+ background: "var(--ds-background-neutral-hovered, ".concat(N30A, ")")
26
+ },
27
+ '&& button:active': {
28
+ background: "var(--ds-background-neutral-pressed, rgba(179, 212, 255, 0.6))"
29
+ },
30
+ '&& button > span': {
31
+ margin: "0px ".concat("var(--ds-space-negative-050, -4px)")
32
+ },
33
+ '&& span': {
34
+ pointerEvents: 'none'
35
+ }
36
+ });
8
37
  };
9
38
  export var tableFloatingCellButtonSelectedStyles = function tableFloatingCellButtonSelectedStyles() {
10
- return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n && button {\n background: ", ";\n }\n && button:hover {\n background: ", ";\n }\n && button:active {\n background: ", ";\n }\n"])), "var(--ds-background-selected, ".concat(N700, ")"), "var(--ds-background-selected-hovered, ".concat(N700, ")"), "var(--ds-background-selected-pressed, ".concat(N700, ")"));
39
+ return css({
40
+ '&& button': {
41
+ background: "var(--ds-background-selected, ".concat(N700, ")")
42
+ },
43
+ '&& button:hover': {
44
+ background: "var(--ds-background-selected-hovered, ".concat(N700, ")")
45
+ },
46
+ '&& button:active': {
47
+ background: "var(--ds-background-selected-pressed, ".concat(N700, ")")
48
+ }
49
+ });
11
50
  };