@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,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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.16.16",
3
+ "version": "7.16.17",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/adf-schema": "^36.10.7",
32
32
  "@atlaskit/button": "^17.17.0",
33
33
  "@atlaskit/custom-steps": "^0.2.0",
34
- "@atlaskit/editor-common": "^81.2.0",
34
+ "@atlaskit/editor-common": "^82.0.0",
35
35
  "@atlaskit/editor-palette": "1.6.0",
36
36
  "@atlaskit/editor-plugin-accessibility-utils": "^1.1.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.2.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/editor-plugin-selection": "^1.2.0",
42
42
  "@atlaskit/editor-plugin-width": "^1.1.0",
43
43
  "@atlaskit/editor-prosemirror": "4.0.1",
44
- "@atlaskit/editor-shared-styles": "^2.11.0",
44
+ "@atlaskit/editor-shared-styles": "^2.12.0",
45
45
  "@atlaskit/editor-tables": "^2.7.0",
46
46
  "@atlaskit/icon": "^22.3.0",
47
47
  "@atlaskit/menu": "^2.3.0",
@@ -114,6 +114,9 @@
114
114
  "platform.editor.a11y-column-resizing_emcvz": {
115
115
  "type": "boolean"
116
116
  },
117
+ "platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg": {
118
+ "type": "boolean"
119
+ },
117
120
  "platform.editor.transform-slice-for-nested-expand": {
118
121
  "type": "boolean"
119
122
  },
@@ -13,11 +13,13 @@ import {
13
13
  } from '@atlaskit/editor-common/analytics';
14
14
  import type { AnalyticsEventPayload, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
15
15
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
16
+ import { type CHANGE_ALIGNMENT_REASON } from '@atlaskit/editor-common/src/analytics/types/table-events';
16
17
  import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
18
+ import { type NodeWithPos } from '@atlaskit/editor-prosemirror/dist/types/utils';
17
19
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
18
20
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
19
21
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
20
- import type { Rect } from '@atlaskit/editor-tables/table-map';
22
+ import { type Rect, TableMap } from '@atlaskit/editor-tables/table-map';
21
23
  import {
22
24
  findCellClosestToPos,
23
25
  findCellRectClosestToPos,
@@ -36,6 +38,7 @@ import {
36
38
  getTableSelectionType,
37
39
  setMultipleCellAttrs,
38
40
  setTableAlignment,
41
+ setTableAlignmentWithTableContentWithPos,
39
42
  } from './commands/misc';
40
43
  import { sortByColumn } from './commands/sort';
41
44
  import { splitCell } from './commands/split-cell';
@@ -605,47 +608,45 @@ export const wrapTableInExpandWithAnalytics = (
605
608
  };
606
609
  })(editorAnalyticsAPI)(wrapTableInExpand);
607
610
 
608
- export const toggleTableLockWithAnalytics =
609
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
610
- (
611
- displayMode: TABLE_DISPLAY_MODE | null,
612
- inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB,
613
- ) =>
614
- withEditorAnalyticsAPI((state) => {
615
- const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
611
+ export const toggleFixedColumnWidthsOptionAnalytics = (
612
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
613
+ inputMethod: INPUT_METHOD.FLOATING_TB,
614
+ ) =>
615
+ withEditorAnalyticsAPI((state) => {
616
+ const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
616
617
 
617
- let previousDisplayMode: TABLE_DISPLAY_MODE;
618
- let newDisplayMode: TABLE_DISPLAY_MODE;
619
-
620
- switch (displayMode) {
621
- case 'fixed':
622
- previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
623
- newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
624
- break;
625
- case 'default':
626
- previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
627
- newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
628
- break;
629
- case null:
630
- default:
631
- previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
632
- newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
633
- }
618
+ let previousDisplayMode: TABLE_DISPLAY_MODE;
619
+ let newDisplayMode: TABLE_DISPLAY_MODE;
620
+
621
+ switch (table?.node.attrs.displayMode) {
622
+ case 'fixed':
623
+ previousDisplayMode = TABLE_DISPLAY_MODE.FIXED;
624
+ newDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
625
+ break;
626
+ case 'default':
627
+ previousDisplayMode = TABLE_DISPLAY_MODE.DEFAULT;
628
+ newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
629
+ break;
630
+ case null:
631
+ default:
632
+ previousDisplayMode = TABLE_DISPLAY_MODE.INITIAL;
633
+ newDisplayMode = TABLE_DISPLAY_MODE.FIXED;
634
+ }
634
635
 
635
- return {
636
- action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
637
- actionSubject: ACTION_SUBJECT.TABLE,
638
- attributes: {
639
- inputMethod,
640
- previousDisplayMode,
641
- newDisplayMode,
642
- tableWidth: table?.node.attrs.width,
643
- totalRowCount,
644
- totalColumnCount,
645
- },
646
- eventType: EVENT_TYPE.TRACK,
647
- };
648
- })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
636
+ return {
637
+ action: TABLE_ACTION.CHANGED_DISPLAY_MODE,
638
+ actionSubject: ACTION_SUBJECT.TABLE,
639
+ attributes: {
640
+ inputMethod,
641
+ previousDisplayMode,
642
+ newDisplayMode,
643
+ tableWidth: table?.node.attrs.width,
644
+ totalRowCount,
645
+ totalColumnCount,
646
+ },
647
+ eventType: EVENT_TYPE.TRACK,
648
+ };
649
+ })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableDisplayMode));
649
650
 
650
651
  export const setTableAlignmentWithAnalytics =
651
652
  (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
@@ -654,6 +655,7 @@ export const setTableAlignmentWithAnalytics =
654
655
  // previous alignment could be a breakout value, if so use 'null' to indicate alignment was not previously set
655
656
  previousAlignment: TableLayout,
656
657
  inputMethod: INPUT_METHOD.FLOATING_TB,
658
+ reason: CHANGE_ALIGNMENT_REASON,
657
659
  ) =>
658
660
  withEditorAnalyticsAPI((state) => {
659
661
  const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(state.selection);
@@ -673,6 +675,44 @@ export const setTableAlignmentWithAnalytics =
673
675
  totalRowCount,
674
676
  totalColumnCount,
675
677
  inputMethod,
678
+ reason,
676
679
  },
677
680
  };
678
681
  })(editorAnalyticsAPI)(editorCommandToPMCommand(setTableAlignment(newAlignment)));
682
+
683
+ export const setTableAlignmentWithTableContentWithPosWithAnalytics =
684
+ (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
685
+ (
686
+ newAlignment: AlignmentOptions,
687
+ previousAlignment: AlignmentOptions | null,
688
+ tableNodeWithPos: NodeWithPos,
689
+ inputMethod: INPUT_METHOD.AUTO,
690
+ reason: CHANGE_ALIGNMENT_REASON,
691
+ ) =>
692
+ withEditorAnalyticsAPI(() => {
693
+ const map = TableMap.get(tableNodeWithPos.node);
694
+ const totalRowCount = map.height;
695
+ const totalColumnCount = map.width;
696
+
697
+ const attributes = {
698
+ tableWidth: tableNodeWithPos.node.attrs.width,
699
+ newAlignment: newAlignment,
700
+ previousAlignment: previousAlignment,
701
+ totalRowCount: totalRowCount,
702
+ totalColumnCount: totalColumnCount,
703
+ inputMethod: inputMethod,
704
+ reason: reason,
705
+ };
706
+
707
+ return {
708
+ action: TABLE_ACTION.CHANGED_ALIGNMENT,
709
+ actionSubject: ACTION_SUBJECT.TABLE,
710
+ actionSubjectId: null,
711
+ eventType: EVENT_TYPE.TRACK,
712
+ attributes: attributes,
713
+ };
714
+ })(editorAnalyticsAPI)(
715
+ editorCommandToPMCommand(
716
+ setTableAlignmentWithTableContentWithPos(newAlignment, tableNodeWithPos),
717
+ ),
718
+ );
@@ -3,7 +3,11 @@ import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState }
3
3
 
4
4
  import classNames from 'classnames';
5
5
 
6
- import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
6
+ import {
7
+ CHANGE_ALIGNMENT_REASON,
8
+ INPUT_METHOD,
9
+ type TableEventPayload,
10
+ } from '@atlaskit/editor-common/analytics';
7
11
  import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
8
12
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
9
13
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
@@ -12,14 +16,15 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
12
16
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
13
17
  import {
14
18
  akEditorDefaultLayoutWidth,
15
- akEditorGutterPadding,
19
+ akEditorGutterPaddingDynamic,
16
20
  akEditorMobileBreakoutPoint,
17
21
  } from '@atlaskit/editor-shared-styles';
18
22
 
19
- import { setTableAlignmentWithTableContentWithPos } from '../commands/misc';
23
+ import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
20
24
  import { TABLE_MAX_WIDTH } from '../pm-plugins/table-resizing/utils';
21
25
  import type { PluginInjectionAPI, TableSharedState } from '../types';
22
26
  import { TableCssClassName as ClassName } from '../types';
27
+ import { ALIGN_CENTER, ALIGN_START } from '../utils/alignment';
23
28
 
24
29
  import { TableResizer } from './TableResizer';
25
30
 
@@ -69,16 +74,19 @@ const AlignmentTableContainer = ({
69
74
  getPos,
70
75
  editorView,
71
76
  }: PropsWithChildren<AlignmentTableContainerProps>) => {
72
- const alignment = node.attrs.layout;
77
+ const alignment = node.attrs.layout !== ALIGN_START ? ALIGN_CENTER : ALIGN_START;
73
78
  const { tableState } = useSharedPluginState(pluginInjectionApi, ['table']);
74
79
 
75
80
  useEffect(() => {
76
81
  if (tableState && editorView && getPos) {
77
82
  const { wasFullWidthModeEnabled, isFullWidthModeEnabled } = tableState;
83
+ const { state, dispatch } = editorView;
78
84
 
79
85
  if (
80
86
  wasFullWidthModeEnabled &&
87
+ isFullWidthModeEnabled !== undefined &&
81
88
  !isFullWidthModeEnabled &&
89
+ alignment !== ALIGN_CENTER &&
82
90
  node.attrs.width > akEditorDefaultLayoutWidth
83
91
  ) {
84
92
  const pos = getPos && getPos();
@@ -87,13 +95,15 @@ const AlignmentTableContainer = ({
87
95
  return;
88
96
  }
89
97
 
90
- const tr = setTableAlignmentWithTableContentWithPos('center', { pos, node })(
91
- editorView.state,
92
- );
93
-
94
- if (tr) {
95
- editorView.dispatch(tr);
96
- }
98
+ setTableAlignmentWithTableContentWithPosWithAnalytics(
99
+ pluginInjectionApi?.analytics?.actions,
100
+ )(
101
+ ALIGN_CENTER,
102
+ alignment,
103
+ { pos, node },
104
+ INPUT_METHOD.AUTO,
105
+ CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED,
106
+ )(state, dispatch);
97
107
  }
98
108
  }
99
109
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -276,15 +286,15 @@ export const ResizableTableContainer = React.memo(
276
286
  // scrollbarWidth can vary. Values can be 14, 15, 16 and up to 20px;
277
287
  responsiveContainerWidth = isTableScalingEnabled
278
288
  ? lineLength
279
- : containerWidth - akEditorGutterPadding * 2 - resizeHandleSpacing;
289
+ : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
280
290
  } else {
281
291
  // 76 is currently an accepted padding value considering the spacing for resizer handle
282
292
  // containerWidth = width of a DIV with test id="ak-editor-fp-content-area". It is a parent of
283
293
  // a DIV with className="ak-editor-content-area". This DIV has padding left and padding right.
284
294
  // padding left = padding right = akEditorGutterPadding = 32
285
295
  responsiveContainerWidth = isTableScalingEnabled
286
- ? containerWidth - akEditorGutterPadding * 2
287
- : containerWidth - akEditorGutterPadding * 2 - resizeHandleSpacing;
296
+ ? containerWidth - akEditorGutterPaddingDynamic() * 2
297
+ : containerWidth - akEditorGutterPaddingDynamic() * 2 - resizeHandleSpacing;
288
298
  }
289
299
  let width = Math.min(tableWidth, responsiveContainerWidth);
290
300
 
@@ -5,7 +5,11 @@ import rafSchd from 'raf-schd';
5
5
  import { useIntl } from 'react-intl-next';
6
6
 
7
7
  import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
8
- import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
8
+ import {
9
+ CHANGE_ALIGNMENT_REASON,
10
+ INPUT_METHOD,
11
+ TABLE_OVERFLOW_CHANGE_TRIGGER,
12
+ } from '@atlaskit/editor-common/analytics';
9
13
  import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
10
14
  import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
11
15
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -23,7 +27,8 @@ import { findTable } from '@atlaskit/editor-tables/utils';
23
27
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
24
28
  import { token } from '@atlaskit/tokens';
25
29
 
26
- import { setTableAlignmentWithTableContentWithPos, updateWidthToWidest } from '../commands/misc';
30
+ import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../commands-with-analytics';
31
+ import { updateWidthToWidest } from '../commands/misc';
27
32
  import { META_KEYS } from '../pm-plugins/table-analytics';
28
33
  import {
29
34
  COLUMN_MIN_WIDTH,
@@ -287,18 +292,21 @@ export const TableResizer = ({
287
292
  isResizing.current
288
293
  ) {
289
294
  const tableNodeWithPos = { pos, node };
290
- const tr = setTableAlignmentWithTableContentWithPos(ALIGN_CENTER, tableNodeWithPos)(state);
291
-
292
- if (tr) {
293
- dispatch(tr);
294
- }
295
-
295
+ setTableAlignmentWithTableContentWithPosWithAnalytics(
296
+ pluginInjectionApi?.analytics?.actions,
297
+ )(
298
+ ALIGN_CENTER,
299
+ ALIGN_START,
300
+ tableNodeWithPos,
301
+ INPUT_METHOD.AUTO,
302
+ CHANGE_ALIGNMENT_REASON.EDITOR_APPEARANCE_CHANGED,
303
+ )(state, dispatch);
296
304
  return true;
297
305
  }
298
306
 
299
307
  return false;
300
308
  },
301
- [lineLength, isTableAlignmentEnabled, isResizing],
309
+ [isTableAlignmentEnabled, lineLength, pluginInjectionApi?.analytics?.actions],
302
310
  );
303
311
 
304
312
  useEffect(() => {
package/src/plugin.tsx CHANGED
@@ -153,9 +153,11 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
153
153
  };
154
154
  const editorAnalyticsAPI = api?.analytics?.actions;
155
155
 
156
- const shouldUseIncreasedScalingPercent =
156
+ const isTableScalingWithFixedColumnWidthsOptionEnabled =
157
157
  options?.isTableScalingEnabled &&
158
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button') &&
158
+ getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
159
+ const shouldUseIncreasedScalingPercent =
160
+ isTableScalingWithFixedColumnWidthsOptionEnabled &&
159
161
  getBooleanFF('platform.editor.table.use-increased-scaling-percent');
160
162
 
161
163
  return {
@@ -660,6 +662,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
660
662
  options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
661
663
  () => editorViewRef.current,
662
664
  options,
665
+ isTableScalingWithFixedColumnWidthsOptionEnabled,
663
666
  shouldUseIncreasedScalingPercent,
664
667
  )(pluginConfig(options?.tableOptions)),
665
668
  },
@@ -4,9 +4,13 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import {
6
6
  addColumnAfter,
7
+ addColumnAfterVO,
7
8
  addColumnBefore,
9
+ addColumnBeforeVO,
8
10
  addRowAfter,
11
+ addRowAfterVO,
9
12
  addRowBefore,
13
+ addRowBeforeVO,
10
14
  backspace,
11
15
  bindKeymapWithCommand,
12
16
  decreaseMediaSize,
@@ -122,6 +126,32 @@ export function keymapPlugin(
122
126
  list,
123
127
  );
124
128
 
129
+ if (getBooleanFF('platform.editor.a11y-help-dialog-shortcut-keys-position_aghfg')) {
130
+ bindKeymapWithCommand(
131
+ addRowBeforeVO.common!,
132
+ addRowAroundSelection(editorAnalyticsAPI)('TOP'),
133
+ list,
134
+ );
135
+
136
+ bindKeymapWithCommand(
137
+ addRowAfterVO.common!,
138
+ addRowAroundSelection(editorAnalyticsAPI)('BOTTOM'),
139
+ list,
140
+ );
141
+
142
+ bindKeymapWithCommand(
143
+ addColumnBeforeVO.common!,
144
+ addColumnBeforeCommand(isTableScalingEnabled),
145
+ list,
146
+ );
147
+
148
+ bindKeymapWithCommand(
149
+ addColumnAfterVO.common!,
150
+ addColumnAfterCommand(isTableScalingEnabled),
151
+ list,
152
+ );
153
+ }
154
+
125
155
  if (dragAndDropEnabled) {
126
156
  // Move row/column shortcuts
127
157
  /**
@@ -13,7 +13,7 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
13
13
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
14
14
  import {
15
15
  akEditorFullWidthLayoutWidth,
16
- akEditorGutterPadding,
16
+ akEditorGutterPaddingDynamic,
17
17
  akEditorTableNumberColumnWidth,
18
18
  } from '@atlaskit/editor-shared-styles';
19
19
 
@@ -35,7 +35,7 @@ export function getLayoutSize(
35
35
 
36
36
  if (isFullWidthModeEnabled) {
37
37
  return containerWidth
38
- ? Math.min(containerWidth - akEditorGutterPadding * 2, akEditorFullWidthLayoutWidth)
38
+ ? Math.min(containerWidth - akEditorGutterPaddingDynamic() * 2, akEditorFullWidthLayoutWidth)
39
39
  : akEditorFullWidthLayoutWidth;
40
40
  }
41
41
 
package/src/toolbar.tsx CHANGED
@@ -3,7 +3,7 @@ import { jsx } from '@emotion/react';
3
3
 
4
4
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
5
5
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
6
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
+ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
7
  import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
8
8
  import commonMessages, { tableMessages as messages } from '@atlaskit/editor-common/messages';
9
9
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
@@ -69,10 +69,10 @@ import {
69
69
  setTableAlignmentWithAnalytics,
70
70
  sortColumnWithAnalytics,
71
71
  splitCellWithAnalytics,
72
+ toggleFixedColumnWidthsOptionAnalytics,
72
73
  toggleHeaderColumnWithAnalytics,
73
74
  toggleHeaderRowWithAnalytics,
74
75
  toggleNumberColumnWithAnalytics,
75
- toggleTableLockWithAnalytics,
76
76
  wrapTableInExpandWithAnalytics,
77
77
  } from './commands-with-analytics';
78
78
  import type { TablePluginOptions } from './plugin';
@@ -90,7 +90,6 @@ import type {
90
90
  } from './types';
91
91
  import { TableCssClassName } from './types';
92
92
  import { FloatingAlignmentButtons } from './ui/FloatingAlignmentButtons/FloatingAlignmentButtons';
93
- import { DisplayModeIcon } from './ui/icons';
94
93
  import {
95
94
  getMergedCellsPositions,
96
95
  getSelectedColumnIndexes,
@@ -104,6 +103,8 @@ export const getToolbarMenuConfig = (
104
103
  state: ToolbarMenuState,
105
104
  { formatMessage }: ToolbarMenuContext,
106
105
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
106
+ isTableScalingWithFixedColumnWidthsOptionShown = false,
107
+ areTableColumnWidthsFixed = false,
107
108
  ): FloatingToolbarItem<Command> => {
108
109
  const optionItem: typeOption = getBooleanFF(
109
110
  'platform.editor.a11y-table-floating-toolbar-dropdown-menu_zkb33',
@@ -112,6 +113,14 @@ export const getToolbarMenuConfig = (
112
113
  : 'item';
113
114
 
114
115
  const options = [
116
+ {
117
+ id: 'editor.table.lockColumnWidths',
118
+ title: formatMessage(messages.lockColumnWidths),
119
+ onClick: toggleFixedColumnWidthsOptionAnalytics(editorAnalyticsAPI, INPUT_METHOD.FLOATING_TB),
120
+ selected: areTableColumnWidthsFixed,
121
+ hidden: !isTableScalingWithFixedColumnWidthsOptionShown,
122
+ domItemOptions: { type: optionItem },
123
+ },
115
124
  {
116
125
  id: 'editor.table.headerRow',
117
126
  title: formatMessage(messages.headerRow),
@@ -156,6 +165,7 @@ export const getToolbarMenuConfig = (
156
165
  title: formatMessage(messages.tableOptions),
157
166
  hidden: options.every((option) => option.hidden),
158
167
  options,
168
+ dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined,
159
169
  };
160
170
  } else {
161
171
  return {
@@ -165,6 +175,7 @@ export const getToolbarMenuConfig = (
165
175
  title: formatMessage(messages.tableOptions),
166
176
  hidden: options.every((option) => option.hidden),
167
177
  options,
178
+ dropdownWidth: isTableScalingWithFixedColumnWidthsOptionShown ? 192 : undefined,
168
179
  };
169
180
  }
170
181
  };
@@ -434,6 +445,7 @@ export const getToolbarConfig =
434
445
  getEditorFeatureFlags: GetEditorFeatureFlags,
435
446
  getEditorView: () => EditorView | null,
436
447
  options?: TablePluginOptions,
448
+ isTableScalingWithFixedColumnWidthsOptionEnabled = false,
437
449
  shouldUseIncreasedScalingPercent = false,
438
450
  ) =>
439
451
  (config: PluginConfig): FloatingToolbarHandler =>
@@ -448,11 +460,21 @@ export const getToolbarConfig =
448
460
 
449
461
  if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
450
462
  const nodeType = state.schema.nodes.table;
451
- const menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
452
-
453
- let alignmentMenu: Array<FloatingToolbarItem<Command>>;
454
463
  const isNested = pluginState.tablePos && isTableNested(state, pluginState.tablePos);
464
+ const isTableScalingWithFixedColumnWidthsOptionShown =
465
+ isTableScalingWithFixedColumnWidthsOptionEnabled && !isNested;
466
+ const areTableColumWidthsFixed = tableObject.node.attrs.displayMode === 'fixed';
467
+
468
+ const menu = getToolbarMenuConfig(
469
+ config,
470
+ pluginState,
471
+ intl,
472
+ editorAnalyticsAPI,
473
+ isTableScalingWithFixedColumnWidthsOptionShown,
474
+ areTableColumWidthsFixed,
475
+ );
455
476
 
477
+ let alignmentMenu: Array<FloatingToolbarItem<Command>>;
456
478
  alignmentMenu =
457
479
  options?.isTableAlignmentEnabled && !isNested
458
480
  ? getAlignmentOptionsConfig(state, intl, editorAnalyticsAPI, getEditorContainerWidth)
@@ -612,29 +634,6 @@ const getCellItems = (
612
634
  return [];
613
635
  };
614
636
 
615
- export const getLockBtnConfig =
616
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null): Command =>
617
- (state, dispatch, editorView) => {
618
- const selectionOrTableRect = getClosestSelectionOrTableRect(state);
619
- if (!editorView || !selectionOrTableRect) {
620
- return false;
621
- }
622
-
623
- const { tr } = state;
624
- const table = findTable(tr.selection);
625
-
626
- if (!table) {
627
- return false;
628
- } else {
629
- const { displayMode } = table.node.attrs;
630
- toggleTableLockWithAnalytics(editorAnalyticsAPI)(displayMode, INPUT_METHOD.FLOATING_TB)(
631
- state,
632
- dispatch,
633
- );
634
- return true;
635
- }
636
- };
637
-
638
637
  export const getDistributeConfig =
639
638
  (
640
639
  getEditorContainerWidth: GetEditorContainerWidth,
@@ -693,32 +692,6 @@ const getColumnSettingItems = (
693
692
 
694
693
  const items: Array<FloatingToolbarItem<Command>> = [];
695
694
 
696
- const isNested = pluginState.tablePos && isTableNested(editorState, pluginState.tablePos);
697
-
698
- const isTableScalingLockBtnEnabled =
699
- !isNested &&
700
- isTableScalingEnabled &&
701
- getBooleanFF('platform.editor.table.preserve-widths-with-lock-button');
702
-
703
- if (isTableScalingLockBtnEnabled) {
704
- const areColumnWidthsLocked = pluginState?.tableNode?.attrs.displayMode === 'fixed';
705
-
706
- const title = areColumnWidthsLocked
707
- ? formatMessage(messages.unlockColumnWidths)
708
- : formatMessage(messages.lockColumnWidths);
709
-
710
- items.push({
711
- id: 'editor.table.lockColumns',
712
- type: 'button',
713
- title,
714
- icon: () => <DisplayModeIcon size="medium" label={title} />,
715
- onClick: (state, dispatch, view) =>
716
- getLockBtnConfig(editorAnalyticsAPI)(state, dispatch, view),
717
- selected: areColumnWidthsLocked,
718
- testId: 'table-lock-column-widths-btn',
719
- });
720
- }
721
-
722
695
  if (pluginState?.pluginConfig?.allowDistributeColumns && pluginState.isDragAndDropEnabled) {
723
696
  items.push({
724
697
  id: 'editor.table.distributeColumns',
@@ -875,6 +848,7 @@ export const getAlignmentOptionsConfig = (
875
848
  value,
876
849
  currentLayout,
877
850
  INPUT_METHOD.FLOATING_TB,
851
+ CHANGE_ALIGNMENT_REASON.TOOLBAR_OPTION_CHANGED,
878
852
  ),
879
853
  ...(isLayoutOptionDisabled(tableObject.node, getEditorContainerWidth) && {
880
854
  disabled: value !== 'center',
@@ -165,7 +165,6 @@ export const TableFloatingControls = ({
165
165
  isInDanger={isInDanger}
166
166
  isResizing={isResizing}
167
167
  />
168
-
169
168
  ))}
170
169
  <DragControls
171
170
  tableRef={tableRef}
@@ -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';
@@ -4,7 +4,7 @@ import {
4
4
  akEditorCalculatedWideLayoutWidth,
5
5
  akEditorDefaultLayoutWidth,
6
6
  akEditorFullWidthLayoutWidth,
7
- akEditorGutterPadding,
7
+ akEditorGutterPaddingDynamic,
8
8
  } from '@atlaskit/editor-shared-styles';
9
9
 
10
10
  const numberOfLanesInDefaultLayoutWidth = 12;
@@ -39,9 +39,9 @@ export const calculateDefaultTablePreserveSnappings = (
39
39
  },
40
40
  ) => {
41
41
  const dynamicFullWidthLine =
42
- editorContainerWith - akEditorGutterPadding * 2 >= akEditorFullWidthLayoutWidth
42
+ editorContainerWith - akEditorGutterPaddingDynamic() * 2 >= akEditorFullWidthLayoutWidth
43
43
  ? akEditorFullWidthLayoutWidth
44
- : editorContainerWith - akEditorGutterPadding * 2;
44
+ : editorContainerWith - akEditorGutterPaddingDynamic() * 2;
45
45
 
46
46
  const guides = [dynamicFullWidthLine - lengthOffset];
47
47
 
@@ -77,7 +77,7 @@ export const defaultTablePreserveSnappingWidths = (
77
77
  breakoutPoints: false,
78
78
  },
79
79
  ) => {
80
- return editorContainerWidth - akEditorGutterPadding * 2 > akEditorFullWidthLayoutWidth
80
+ return editorContainerWidth - akEditorGutterPaddingDynamic() * 2 > akEditorFullWidthLayoutWidth
81
81
  ? calculateDefaultSnappings()
82
82
  : calculateDefaultTablePreserveSnappings(lengthOffset, editorContainerWidth, exclude); // lengthOffset was hardcoded 0 here, created PRESERVE_TABLE_SNAPPING_LENGTH_OFFSET instead.
83
83
  };