@atlaskit/editor-plugin-table 7.19.11 → 7.19.12

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 +16 -0
  2. package/dist/cjs/commands/column-resize.js +1 -1
  3. package/dist/cjs/commands/selection.js +25 -4
  4. package/dist/cjs/plugin.js +59 -56
  5. package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +23 -9
  6. package/dist/cjs/pm-plugins/keymap.js +6 -6
  7. package/dist/cjs/pm-plugins/main.js +1 -1
  8. package/dist/cjs/pm-plugins/table-selection-keymap.js +6 -3
  9. package/dist/cjs/toolbar.js +8 -5
  10. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -2
  11. package/dist/cjs/ui/FloatingDragMenu/index.js +5 -3
  12. package/dist/cjs/ui/TableFloatingControls/index.js +8 -2
  13. package/dist/cjs/utils/drag-menu.js +5 -1
  14. package/dist/es2019/commands/column-resize.js +2 -2
  15. package/dist/es2019/commands/selection.js +25 -4
  16. package/dist/es2019/plugin.js +11 -7
  17. package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +18 -3
  18. package/dist/es2019/pm-plugins/keymap.js +7 -7
  19. package/dist/es2019/pm-plugins/main.js +2 -2
  20. package/dist/es2019/pm-plugins/table-selection-keymap.js +6 -3
  21. package/dist/es2019/toolbar.js +8 -5
  22. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -2
  23. package/dist/es2019/ui/FloatingDragMenu/index.js +6 -4
  24. package/dist/es2019/ui/TableFloatingControls/index.js +9 -3
  25. package/dist/es2019/utils/drag-menu.js +6 -2
  26. package/dist/esm/commands/column-resize.js +2 -2
  27. package/dist/esm/commands/selection.js +25 -4
  28. package/dist/esm/plugin.js +60 -57
  29. package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +23 -9
  30. package/dist/esm/pm-plugins/keymap.js +7 -7
  31. package/dist/esm/pm-plugins/main.js +2 -2
  32. package/dist/esm/pm-plugins/table-selection-keymap.js +6 -3
  33. package/dist/esm/toolbar.js +8 -5
  34. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -2
  35. package/dist/esm/ui/FloatingDragMenu/index.js +6 -4
  36. package/dist/esm/ui/TableFloatingControls/index.js +9 -3
  37. package/dist/esm/utils/drag-menu.js +5 -1
  38. package/dist/types/commands/selection.d.ts +4 -2
  39. package/dist/types/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +4 -2
  40. package/dist/types/pm-plugins/table-selection-keymap.d.ts +3 -3
  41. package/dist/types/toolbar.d.ts +2 -2
  42. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
  43. package/dist/types/ui/FloatingDragMenu/index.d.ts +3 -1
  44. package/dist/types/utils/drag-menu.d.ts +2 -1
  45. package/dist/types-ts4.5/commands/selection.d.ts +4 -2
  46. package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +4 -2
  47. package/dist/types-ts4.5/pm-plugins/table-selection-keymap.d.ts +3 -3
  48. package/dist/types-ts4.5/toolbar.d.ts +2 -2
  49. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
  50. package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +3 -1
  51. package/dist/types-ts4.5/utils/drag-menu.d.ts +2 -1
  52. package/package.json +7 -4
  53. package/src/commands/column-resize.ts +2 -2
  54. package/src/commands/selection.ts +49 -4
  55. package/src/plugin.tsx +8 -7
  56. package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +43 -3
  57. package/src/pm-plugins/keymap.ts +23 -7
  58. package/src/pm-plugins/main.ts +2 -2
  59. package/src/pm-plugins/table-selection-keymap.ts +18 -6
  60. package/src/toolbar.tsx +7 -1
  61. package/src/ui/FloatingDragMenu/DragMenu.tsx +7 -0
  62. package/src/ui/FloatingDragMenu/index.tsx +9 -2
  63. package/src/ui/TableFloatingControls/index.tsx +12 -4
  64. package/src/utils/drag-menu.ts +8 -1
package/src/toolbar.tsx CHANGED
@@ -521,6 +521,7 @@ export const getToolbarConfig =
521
521
  getDomRef,
522
522
  editorView,
523
523
  shouldUseIncreasedScalingPercent,
524
+ options?.fullWidthEnabled,
524
525
  )
525
526
  : [];
526
527
 
@@ -852,6 +853,7 @@ export const getAlignmentOptionsConfig = (
852
853
  getDomRef: (editorView: EditorView) => HTMLElement | undefined,
853
854
  editorView: EditorView | null,
854
855
  shouldUseIncreasedScalingPercent: boolean,
856
+ isFullWidthEditor?: boolean,
855
857
  ): Array<FloatingToolbarDropdown<Command>> => {
856
858
  const tableObject = findTable(editorState.selection);
857
859
 
@@ -900,6 +902,7 @@ export const getAlignmentOptionsConfig = (
900
902
  getDomRef,
901
903
  editorView,
902
904
  shouldUseIncreasedScalingPercent,
905
+ isFullWidthEditor,
903
906
  ) && {
904
907
  disabled: value !== 'center',
905
908
  }),
@@ -942,6 +945,7 @@ export const isLayoutOptionDisabled = (
942
945
  getDomRef: (editorView: EditorView) => HTMLElement | undefined,
943
946
  editorView: EditorView | null,
944
947
  shouldUseIncreasedScalingPercent: boolean,
948
+ isFullWidthEditor: boolean | undefined,
945
949
  ) => {
946
950
  const { lineLength } = getEditorContainerWidth();
947
951
  let tableContainerWidth = getTableContainerWidth(selectedNode);
@@ -958,7 +962,9 @@ export const isLayoutOptionDisabled = (
958
962
  tableContainerWidth = tableContainerWidth * scalePercent;
959
963
  }
960
964
 
961
- if (selectedNode && lineLength && tableContainerWidth > lineLength) {
965
+ // If fixed-width editor, we disable 'left-alignment' when table width is 760px.
966
+ // tableContainerWidth +1 here because tableContainerWidth is 759 in fixed-width editor
967
+ if (selectedNode && !isFullWidthEditor && lineLength && tableContainerWidth + 1 >= lineLength) {
962
968
  return true;
963
969
  }
964
970
 
@@ -27,6 +27,7 @@ import {
27
27
  import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
28
28
  import { closestElement } from '@atlaskit/editor-common/utils';
29
29
  import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
30
+ import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
30
31
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
31
32
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
32
33
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -93,6 +94,10 @@ type DragMenuProps = {
93
94
  shouldUseIncreasedScalingPercent?: boolean;
94
95
  isTableFixedColumnWidthsOptionEnabled?: boolean;
95
96
  tableSortColumnReorder?: boolean;
97
+ ariaNotifyPlugin?: (
98
+ message: string,
99
+ ariaLiveElementAttributes?: AriaLiveElementAttributes,
100
+ ) => void;
96
101
  };
97
102
 
98
103
  type PluralOptionType = 'noOfCols' | 'noOfRows' | 'noOfCells' | null;
@@ -275,6 +280,7 @@ export const DragMenu = React.memo(
275
280
  shouldUseIncreasedScalingPercent,
276
281
  isTableFixedColumnWidthsOptionEnabled,
277
282
  tableSortColumnReorder,
283
+ ariaNotifyPlugin,
278
284
  }: DragMenuProps & WrappedComponentProps) => {
279
285
  const { state, dispatch } = editorView;
280
286
  const { selection } = state;
@@ -305,6 +311,7 @@ export const DragMenu = React.memo(
305
311
  isTableFixedColumnWidthsOptionEnabled,
306
312
  shouldUseIncreasedScalingPercent,
307
313
  tableSortColumnReorder,
314
+ ariaNotifyPlugin,
308
315
  );
309
316
 
310
317
  const { menuItems, menuCallback } = convertToDropdownItems(
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
5
  import { Popup } from '@atlaskit/editor-common/ui';
6
+ import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
6
7
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
9
  import {
@@ -10,7 +11,7 @@ import {
10
11
  akEditorFloatingOverlapPanelZIndex,
11
12
  } from '@atlaskit/editor-shared-styles';
12
13
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
13
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
14
15
 
15
16
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
16
17
  import type { PluginConfig, TableDirection } from '../../types';
@@ -35,6 +36,10 @@ export interface Props {
35
36
  pluginConfig?: PluginConfig;
36
37
  isTableScalingEnabled?: boolean;
37
38
  getEditorFeatureFlags?: GetEditorFeatureFlags;
39
+ ariaNotifyPlugin?: (
40
+ message: string,
41
+ ariaLiveElementAttributes?: AriaLiveElementAttributes,
42
+ ) => void;
38
43
  }
39
44
 
40
45
  const FloatingDragMenu = ({
@@ -53,6 +58,7 @@ const FloatingDragMenu = ({
53
58
  pluginConfig,
54
59
  isTableScalingEnabled,
55
60
  getEditorFeatureFlags,
61
+ ariaNotifyPlugin,
56
62
  }: Props) => {
57
63
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
58
64
  return null;
@@ -79,7 +85,7 @@ const FloatingDragMenu = ({
79
85
  const shouldUseIncreasedScalingPercent =
80
86
  isTableScalingEnabled &&
81
87
  tableWithFixedColumnWidthsOption &&
82
- getBooleanFF('platform.editor.table.use-increased-scaling-percent');
88
+ fg('platform.editor.table.use-increased-scaling-percent');
83
89
 
84
90
  return (
85
91
  <Popup
@@ -120,6 +126,7 @@ const FloatingDragMenu = ({
120
126
  shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
121
127
  isTableFixedColumnWidthsOptionEnabled={tableWithFixedColumnWidthsOption}
122
128
  tableSortColumnReorder={tableSortColumnReorder}
129
+ ariaNotifyPlugin={ariaNotifyPlugin}
123
130
  />
124
131
  </Popup>
125
132
  );
@@ -7,13 +7,15 @@ import { browser } from '@atlaskit/editor-common/utils';
7
7
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
9
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
+ import { findTable } from '@atlaskit/editor-tables/utils';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
 
12
13
  import { hoverCell, hoverRows, selectRow, selectRows } from '../../commands';
13
14
  import type { TablePlugin } from '../../plugin';
14
15
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
15
16
  import { TableCssClassName as ClassName } from '../../types';
16
17
  import type { CellHoverMeta } from '../../types';
18
+ import { isTableNested } from '../../utils/nodes';
17
19
 
18
20
  import {
19
21
  CornerControls,
@@ -127,6 +129,12 @@ export const TableFloatingControls = ({
127
129
  ? ClassName.DRAG_ROW_CONTROLS_WRAPPER
128
130
  : ClassName.ROW_CONTROLS_WRAPPER;
129
131
 
132
+ const tablePos = findTable(editorView.state.selection)?.pos;
133
+ const isNested = tablePos !== undefined && isTableNested(editorView.state, tablePos!);
134
+ const shouldShowCornerControls = fg('platform_editor_element_drag_and_drop_ed_24041')
135
+ ? !featureFlagsState?.elementDragAndDrop || isNested
136
+ : !featureFlagsState?.elementDragAndDrop;
137
+
130
138
  return (
131
139
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
132
140
  <div className={wrapperClassName}>
@@ -152,8 +160,8 @@ export const TableFloatingControls = ({
152
160
  <>
153
161
  {isDragAndDropEnabled ? (
154
162
  <>
155
- {!featureFlagsState?.elementDragAndDrop &&
156
- (getBooleanFF('platform.editor.table.use-shared-state-hook') ? (
163
+ {shouldShowCornerControls &&
164
+ (fg('platform.editor.table.use-shared-state-hook') ? (
157
165
  <DragCornerControlsWithSelection
158
166
  editorView={editorView}
159
167
  tableRef={tableRef}
@@ -185,7 +193,7 @@ export const TableFloatingControls = ({
185
193
  updateCellHoverLocation={updateCellHoverLocation}
186
194
  />
187
195
  </>
188
- ) : getBooleanFF('platform.editor.table.use-shared-state-hook') ? (
196
+ ) : fg('platform.editor.table.use-shared-state-hook') ? (
189
197
  <FloatingControlsWithSelection
190
198
  editorView={editorView}
191
199
  tableRef={tableRef}
@@ -22,6 +22,7 @@ import type {
22
22
  GetEditorContainerWidth,
23
23
  IconProps,
24
24
  } from '@atlaskit/editor-common/types';
25
+ import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
25
26
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
26
27
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
27
28
  import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
@@ -45,6 +46,7 @@ import {
45
46
  sortColumnWithAnalytics,
46
47
  } from '../commands-with-analytics';
47
48
  import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
49
+ import { getPluginState as getTablePluginState } from '../pm-plugins/plugin-factory';
48
50
  import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
49
51
  import { getClosestSelectionRect } from '../toolbar';
50
52
  import type { DraggableData, DraggableType, TableDirection } from '../types';
@@ -148,8 +150,13 @@ export const getDragMenuConfig = (
148
150
  isTableFixedColumnWidthsOptionEnabled = false,
149
151
  shouldUseIncreasedScalingPercent = false,
150
152
  tableSortColumnReorder = false,
153
+ ariaNotifyPlugin?: (
154
+ message: string,
155
+ ariaLiveElementAttributes?: AriaLiveElementAttributes,
156
+ ) => void,
151
157
  ): DragMenuConfig[] => {
152
158
  const { selection } = editorView.state;
159
+ const { getIntl } = getTablePluginState(editorView.state);
153
160
  const addOptions =
154
161
  direction === 'row'
155
162
  ? [
@@ -358,7 +365,7 @@ export const getDragMenuConfig = (
358
365
  onClick: (state: EditorState, dispatch?: CommandDispatch) => {
359
366
  if (canMove) {
360
367
  requestAnimationFrame(() => {
361
- moveSourceWithAnalytics(editorAnalyticsAPI)(
368
+ moveSourceWithAnalytics(editorAnalyticsAPI, ariaNotifyPlugin, getIntl)(
362
369
  INPUT_METHOD.TABLE_CONTEXT_MENU,
363
370
  `table-${direction}`,
364
371
  getOriginIndexes(selectionRect!),