@atlaskit/editor-plugin-table 7.16.15 → 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 (64) hide show
  1. package/CHANGELOG.md +29 -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/TableFloatingControls/index.js +2 -2
  10. package/dist/cjs/ui/icons/index.js +0 -7
  11. package/dist/cjs/utils/snapping.js +2 -2
  12. package/dist/es2019/commands-with-analytics.js +29 -6
  13. package/dist/es2019/nodeviews/TableContainer.js +17 -13
  14. package/dist/es2019/nodeviews/TableResizer.js +11 -12
  15. package/dist/es2019/plugin.js +3 -2
  16. package/dist/es2019/pm-plugins/keymap.js +7 -1
  17. package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +2 -2
  18. package/dist/es2019/toolbar.js +22 -48
  19. package/dist/es2019/ui/TableFloatingControls/index.js +2 -2
  20. package/dist/es2019/ui/icons/index.js +0 -1
  21. package/dist/es2019/utils/snapping.js +3 -3
  22. package/dist/esm/commands-with-analytics.js +66 -41
  23. package/dist/esm/nodeviews/TableContainer.js +15 -13
  24. package/dist/esm/nodeviews/TableResizer.js +14 -15
  25. package/dist/esm/plugin.js +3 -2
  26. package/dist/esm/pm-plugins/keymap.js +7 -1
  27. package/dist/esm/pm-plugins/table-resizing/utils/misc.js +2 -2
  28. package/dist/esm/toolbar.js +24 -49
  29. package/dist/esm/ui/TableFloatingControls/index.js +2 -2
  30. package/dist/esm/ui/icons/index.js +0 -1
  31. package/dist/esm/utils/snapping.js +3 -3
  32. package/dist/types/commands/toggle.d.ts +1 -1
  33. package/dist/types/commands-with-analytics.d.ts +7 -4
  34. package/dist/types/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
  35. package/dist/types/toolbar.d.ts +2 -3
  36. package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -0
  37. package/dist/types/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -0
  38. package/dist/types/ui/TableFloatingControls/index.d.ts +2 -0
  39. package/dist/types/ui/icons/index.d.ts +0 -1
  40. package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
  41. package/dist/types-ts4.5/commands-with-analytics.d.ts +7 -4
  42. package/dist/types-ts4.5/pm-plugins/table-resizing/utils/resize-state.d.ts +1 -1
  43. package/dist/types-ts4.5/toolbar.d.ts +2 -3
  44. package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -0
  45. package/dist/types-ts4.5/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +4 -0
  46. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +2 -0
  47. package/dist/types-ts4.5/ui/icons/index.d.ts +0 -1
  48. package/package.json +10 -4
  49. package/src/commands-with-analytics.ts +80 -40
  50. package/src/nodeviews/TableContainer.tsx +24 -14
  51. package/src/nodeviews/TableResizer.tsx +17 -9
  52. package/src/plugin.tsx +5 -2
  53. package/src/pm-plugins/keymap.ts +30 -0
  54. package/src/pm-plugins/table-resizing/utils/misc.ts +2 -2
  55. package/src/toolbar.tsx +29 -55
  56. package/src/ui/TableFloatingControls/index.tsx +17 -16
  57. package/src/ui/icons/index.ts +0 -1
  58. package/src/utils/snapping.ts +4 -4
  59. package/dist/cjs/ui/icons/DisplayModeIcon.js +0 -46
  60. package/dist/es2019/ui/icons/DisplayModeIcon.js +0 -39
  61. package/dist/esm/ui/icons/DisplayModeIcon.js +0 -39
  62. package/dist/types/ui/icons/DisplayModeIcon.d.ts +0 -4
  63. package/dist/types-ts4.5/ui/icons/DisplayModeIcon.d.ts +0 -4
  64. package/src/ui/icons/DisplayModeIcon.tsx +0 -41
@@ -23,7 +23,7 @@ export declare const evenAllColumnsWidths: (resizeState: ResizeState) => ResizeS
23
23
  export declare const evenSelectedColumnsWidths: (resizeState: ResizeState, rect: Rect) => ResizeState;
24
24
  export declare const bulkColumnsResize: (resizeState: ResizeState, columnsIndexes: number[], sourceColumnIndex: number) => ResizeState;
25
25
  export declare const areColumnsEven: (resizeState: ResizeState) => boolean;
26
- export declare const normaliseTableLayout: (input: string | undefined | null) => "default" | "wide" | "full-width";
26
+ export declare const normaliseTableLayout: (input: string | undefined | null) => "wide" | "default" | "full-width";
27
27
  export declare const getNewResizeStateFromSelectedColumns: (rect: Rect, state: EditorState, domAtPos: (pos: number) => {
28
28
  node: Node;
29
29
  offset: number;
@@ -7,12 +7,11 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
7
  import { Rect } from '@atlaskit/editor-tables/table-map';
8
8
  import type { TablePluginOptions } from './plugin';
9
9
  import type { AlignmentOptions, PluginConfig, ToolbarMenuConfig, ToolbarMenuContext, ToolbarMenuState } from './types';
10
- export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => FloatingToolbarItem<Command>;
10
+ export declare const getToolbarMenuConfig: (config: ToolbarMenuConfig, state: ToolbarMenuState, { formatMessage }: ToolbarMenuContext, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingWithFixedColumnWidthsOptionShown?: boolean, areTableColumnWidthsFixed?: boolean) => FloatingToolbarItem<Command>;
11
11
  export declare const getToolbarCellOptionsConfig: (editorState: EditorState, editorView: EditorView | undefined | null, initialSelectionRect: Rect, { formatMessage }: ToolbarMenuContext, getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => FloatingToolbarDropdown<Command>;
12
12
  export declare const getClosestSelectionRect: (state: EditorState) => Rect | undefined;
13
13
  export declare const getClosestSelectionOrTableRect: (state: EditorState) => Rect | undefined;
14
- export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions, shouldUseIncreasedScalingPercent?: boolean) => (config: PluginConfig) => FloatingToolbarHandler;
15
- export declare const getLockBtnConfig: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => Command;
14
+ export declare const getToolbarConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, getEditorFeatureFlags: GetEditorFeatureFlags, getEditorView: () => EditorView | null, options?: TablePluginOptions, isTableScalingWithFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => (config: PluginConfig) => FloatingToolbarHandler;
16
15
  export declare const getDistributeConfig: (getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => Command;
17
16
  type AlignmentIcon = {
18
17
  id?: string;
@@ -140,6 +140,7 @@ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hover
140
140
  to: number;
141
141
  mark: import("prosemirror-model").Mark;
142
142
  }) => boolean;
143
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
143
144
  };
144
145
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
145
146
  ];
@@ -265,6 +266,7 @@ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hover
265
266
  to: number;
266
267
  mark: import("prosemirror-model").Mark;
267
268
  }) => boolean;
269
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
268
270
  };
269
271
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
270
272
  ];
@@ -121,6 +121,7 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
121
121
  to: number;
122
122
  mark: import("prosemirror-model").Mark;
123
123
  }) => boolean;
124
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
124
125
  };
125
126
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
126
127
  ];
@@ -246,6 +247,7 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
246
247
  to: number;
247
248
  mark: import("prosemirror-model").Mark;
248
249
  }) => boolean;
250
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
249
251
  };
250
252
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
251
253
  ];
@@ -383,6 +385,7 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
383
385
  to: number;
384
386
  mark: import("prosemirror-model").Mark;
385
387
  }) => boolean;
388
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
386
389
  };
387
390
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
388
391
  ];
@@ -508,6 +511,7 @@ export declare const DragCornerControlsWithSelection: React.FC<import("react-int
508
511
  to: number;
509
512
  mark: import("prosemirror-model").Mark;
510
513
  }) => boolean;
514
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
511
515
  };
512
516
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
513
517
  ];
@@ -149,6 +149,7 @@ export declare const TableFloatingControls: ({ editorView, tableRef, tableNode,
149
149
  to: number;
150
150
  mark: import("prosemirror-model").Mark;
151
151
  }) => boolean;
152
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
152
153
  };
153
154
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
154
155
  ];
@@ -274,6 +275,7 @@ export declare const TableFloatingControls: ({ editorView, tableRef, tableNode,
274
275
  to: number;
275
276
  mark: import("prosemirror-model").Mark;
276
277
  }) => boolean;
278
+ isRemoteReplaceDocumentTransaction: (tr: import("prosemirror-state").Transaction) => boolean;
277
279
  };
278
280
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
279
281
  ];
@@ -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.15",
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",
@@ -49,7 +49,7 @@
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
50
50
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.3.0",
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
52
- "@atlaskit/primitives": "^6.4.0",
52
+ "@atlaskit/primitives": "^6.5.0",
53
53
  "@atlaskit/theme": "^12.8.0",
54
54
  "@atlaskit/toggle": "^13.1.0",
55
55
  "@atlaskit/tokens": "^1.49.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
  },
@@ -143,6 +146,9 @@
143
146
  },
144
147
  "platform.editor.table.editor-num-col-style-changes": {
145
148
  "type": "boolean"
149
+ },
150
+ "platform.editor.drag-and-drop_wmv9t": {
151
+ "type": "boolean"
146
152
  }
147
153
  }
148
154
  }
@@ -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