@atlaskit/editor-plugin-table 7.6.3 → 7.6.5

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 (141) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/commands/column-resize.js +62 -16
  3. package/dist/cjs/commands/go-to-next-cell.js +5 -2
  4. package/dist/cjs/commands/misc.js +3 -2
  5. package/dist/cjs/commands-with-analytics.js +8 -2
  6. package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -0
  7. package/dist/cjs/nodeviews/TableComponent.js +8 -6
  8. package/dist/cjs/nodeviews/TableContainer.js +32 -20
  9. package/dist/cjs/nodeviews/TableResizer.js +40 -28
  10. package/dist/cjs/plugin.js +60 -58
  11. package/dist/cjs/pm-plugins/keymap.js +26 -8
  12. package/dist/cjs/pm-plugins/main.js +15 -4
  13. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +4 -2
  14. package/dist/cjs/toolbar.js +5 -4
  15. package/dist/cjs/ui/DragHandle/index.js +2 -2
  16. package/dist/cjs/ui/DragPreview/index.js +2 -0
  17. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +10 -6
  18. package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  19. package/dist/cjs/ui/FloatingDeleteButton/index.js +2 -0
  20. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +3 -3
  21. package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  22. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +1 -0
  23. package/dist/cjs/ui/LayoutButton/index.js +2 -0
  24. package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  25. package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  26. package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  27. package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  28. package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  29. package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  30. package/dist/cjs/ui/common-styles.js +4 -0
  31. package/dist/cjs/ui/ui-styles.js +93 -37
  32. package/dist/cjs/utils/guidelines.js +1 -1
  33. package/dist/es2019/commands/column-resize.js +53 -4
  34. package/dist/es2019/commands/go-to-next-cell.js +5 -2
  35. package/dist/es2019/commands/misc.js +6 -2
  36. package/dist/es2019/commands-with-analytics.js +8 -2
  37. package/dist/es2019/nodeviews/ExternalDropTargets.js +2 -0
  38. package/dist/es2019/nodeviews/TableComponent.js +9 -7
  39. package/dist/es2019/nodeviews/TableContainer.js +17 -3
  40. package/dist/es2019/nodeviews/TableResizer.js +27 -17
  41. package/dist/es2019/plugin.js +6 -3
  42. package/dist/es2019/pm-plugins/keymap.js +25 -9
  43. package/dist/es2019/pm-plugins/main.js +15 -4
  44. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +4 -2
  45. package/dist/es2019/toolbar.js +5 -4
  46. package/dist/es2019/ui/DragHandle/index.js +2 -2
  47. package/dist/es2019/ui/DragPreview/index.js +2 -0
  48. package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +10 -6
  49. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  50. package/dist/es2019/ui/FloatingDeleteButton/index.js +2 -0
  51. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +3 -3
  52. package/dist/es2019/ui/FloatingDragMenu/DropdownMenu.js +20 -27
  53. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -0
  54. package/dist/es2019/ui/LayoutButton/index.js +2 -0
  55. package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  56. package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  57. package/dist/es2019/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  58. package/dist/es2019/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  59. package/dist/es2019/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  60. package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  61. package/dist/es2019/ui/common-styles.js +4 -0
  62. package/dist/es2019/ui/ui-styles.js +66 -70
  63. package/dist/es2019/utils/guidelines.js +1 -1
  64. package/dist/esm/commands/column-resize.js +62 -16
  65. package/dist/esm/commands/go-to-next-cell.js +5 -2
  66. package/dist/esm/commands/misc.js +3 -2
  67. package/dist/esm/commands-with-analytics.js +8 -2
  68. package/dist/esm/nodeviews/ExternalDropTargets.js +2 -0
  69. package/dist/esm/nodeviews/TableComponent.js +9 -7
  70. package/dist/esm/nodeviews/TableContainer.js +32 -20
  71. package/dist/esm/nodeviews/TableResizer.js +41 -29
  72. package/dist/esm/plugin.js +60 -58
  73. package/dist/esm/pm-plugins/keymap.js +26 -8
  74. package/dist/esm/pm-plugins/main.js +15 -4
  75. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +4 -2
  76. package/dist/esm/toolbar.js +5 -4
  77. package/dist/esm/ui/DragHandle/index.js +2 -2
  78. package/dist/esm/ui/DragPreview/index.js +2 -0
  79. package/dist/esm/ui/FloatingContextualButton/FixedButton.js +10 -6
  80. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +16 -16
  81. package/dist/esm/ui/FloatingDeleteButton/index.js +2 -0
  82. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +3 -3
  83. package/dist/esm/ui/FloatingDragMenu/DropdownMenu.js +21 -28
  84. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -0
  85. package/dist/esm/ui/LayoutButton/index.js +2 -0
  86. package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -0
  87. package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +3 -0
  88. package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -0
  89. package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -0
  90. package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +4 -0
  91. package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +3 -1
  92. package/dist/esm/ui/common-styles.js +4 -0
  93. package/dist/esm/ui/ui-styles.js +93 -37
  94. package/dist/esm/utils/guidelines.js +1 -1
  95. package/dist/types/commands/column-resize.d.ts +23 -4
  96. package/dist/types/commands/go-to-next-cell.d.ts +2 -1
  97. package/dist/types/commands/misc.d.ts +2 -1
  98. package/dist/types/commands-with-analytics.d.ts +2 -1
  99. package/dist/types/nodeviews/TableResizer.d.ts +3 -1
  100. package/dist/types/pm-plugins/keymap.d.ts +3 -1
  101. package/dist/types/types.d.ts +13 -3
  102. package/dist/types-ts4.5/commands/column-resize.d.ts +23 -4
  103. package/dist/types-ts4.5/commands/go-to-next-cell.d.ts +2 -1
  104. package/dist/types-ts4.5/commands/misc.d.ts +2 -1
  105. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -1
  106. package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +3 -1
  107. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -1
  108. package/dist/types-ts4.5/types.d.ts +13 -3
  109. package/package.json +3 -6
  110. package/src/commands/column-resize.ts +105 -29
  111. package/src/commands/go-to-next-cell.ts +10 -2
  112. package/src/commands/misc.ts +6 -3
  113. package/src/commands-with-analytics.ts +11 -5
  114. package/src/nodeviews/ExternalDropTargets.tsx +2 -0
  115. package/src/nodeviews/TableComponent.tsx +14 -16
  116. package/src/nodeviews/TableContainer.tsx +18 -3
  117. package/src/nodeviews/TableResizer.tsx +35 -21
  118. package/src/plugin.tsx +4 -1
  119. package/src/pm-plugins/keymap.ts +44 -6
  120. package/src/pm-plugins/main.ts +18 -4
  121. package/src/pm-plugins/table-resizing/event-handlers.ts +6 -2
  122. package/src/toolbar.tsx +20 -19
  123. package/src/types.ts +14 -2
  124. package/src/ui/DragHandle/index.tsx +2 -2
  125. package/src/ui/DragPreview/index.tsx +2 -0
  126. package/src/ui/FloatingContextualButton/FixedButton.tsx +9 -6
  127. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +66 -112
  128. package/src/ui/FloatingDeleteButton/index.tsx +2 -0
  129. package/src/ui/FloatingDragMenu/DragMenu.tsx +3 -12
  130. package/src/ui/FloatingDragMenu/DropdownMenu.tsx +19 -28
  131. package/src/ui/FloatingInsertButton/InsertButton.tsx +1 -0
  132. package/src/ui/LayoutButton/index.tsx +2 -0
  133. package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -0
  134. package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +3 -0
  135. package/src/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +1 -0
  136. package/src/ui/TableFloatingControls/NumberColumn/index.tsx +1 -0
  137. package/src/ui/TableFloatingControls/RowControls/ClassicControls.tsx +4 -0
  138. package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +5 -1
  139. package/src/ui/common-styles.ts +2 -0
  140. package/src/ui/ui-styles.ts +90 -79
  141. package/src/utils/guidelines.ts +5 -4
@@ -1,3 +1,4 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
1
2
  import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
2
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
@@ -11,7 +12,7 @@ export declare const splitCellWithAnalytics: (editorAnalyticsAPI: EditorAnalytic
11
12
  export declare const setColorWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, cellColor: string, targetCellPosition?: number) => Command;
12
13
  export declare const addRowAroundSelection: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (side: RowInsertPosition) => Command;
13
14
  export declare const insertRowWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: InsertRowMethods, options: InsertRowOptions) => Command;
14
- export declare const changeColumnWidthByStepWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (stepSize: number, getEditorContainerWidth: GetEditorContainerWidth, isTableScalingEnabled: boolean, inputMethod: INPUT_METHOD.SHORTCUT) => Command;
15
+ export declare const changeColumnWidthByStepWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (stepSize: number, getEditorContainerWidth: GetEditorContainerWidth, isTableScalingEnabled: boolean, inputMethod: INPUT_METHOD.SHORTCUT, ariaNotify?: ((message: string) => void) | undefined, getIntl?: () => IntlShape) => Command;
15
16
  export declare const insertColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, position: number) => Command;
16
17
  export declare const deleteRowsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect, isHeaderRowRequired: boolean) => Command;
17
18
  export declare const deleteColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect) => Command;
@@ -4,6 +4,7 @@ import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { PluginInjectionAPI } from '../types';
7
8
  interface TableResizerProps {
8
9
  width: number;
9
10
  maxWidth: number;
@@ -16,6 +17,7 @@ interface TableResizerProps {
16
17
  displayGuideline: (guideline: GuidelineConfig[]) => boolean;
17
18
  attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
18
19
  displayGapCursor: (toggle: boolean) => boolean;
20
+ pluginInjectionApi?: PluginInjectionAPI;
19
21
  isTableScalingEnabled?: boolean;
20
22
  isWholeTableInDanger?: boolean;
21
23
  }
@@ -23,5 +25,5 @@ export interface TableResizerImprovementProps extends TableResizerProps {
23
25
  onResizeStop?: () => void;
24
26
  onResizeStart?: () => void;
25
27
  }
26
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
28
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
27
29
  export {};
@@ -1,5 +1,7 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
1
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
4
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
- export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isFullWidthEnabled?: boolean): SafePlugin;
5
+ import type { PluginInjectionAPIWithA11y } from '../types';
6
+ export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isFullWidthEnabled?: boolean, pluginInjectionApi?: PluginInjectionAPIWithA11y, getIntl?: () => IntlShape): SafePlugin;
5
7
  export default keymapPlugin;
@@ -26,7 +26,14 @@ export interface InsertRowOptions {
26
26
  moveCursorToInsertedRow: boolean;
27
27
  }
28
28
  export type PluginInjectionAPI = ExtractInjectionAPI<TablePlugin>;
29
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode'> & {
29
+ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
30
+ accessibilityUtils?: {
31
+ actions: {
32
+ ariaNotify: (message: string) => void | undefined;
33
+ };
34
+ };
35
+ };
36
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
30
37
  isResizing: boolean;
31
38
  isTableResizing?: boolean;
32
39
  isWholeTableInDanger?: boolean;
@@ -60,6 +67,9 @@ export interface CellHoverMeta {
60
67
  colIndex?: number;
61
68
  rowIndex?: number;
62
69
  }
70
+ export interface WidthToWidest {
71
+ [tableLocalId: string]: boolean;
72
+ }
63
73
  export interface TablePluginState {
64
74
  editorHasFocus?: boolean;
65
75
  hoveredColumns: number[];
@@ -89,7 +99,7 @@ export interface TablePluginState {
89
99
  isKeyboardResize?: boolean;
90
100
  isTableCollapsed?: boolean;
91
101
  canCollapseTable?: boolean;
92
- widthToWidest?: boolean;
102
+ widthToWidest?: WidthToWidest;
93
103
  getIntl: () => IntlShape;
94
104
  isBreakoutEnabled?: boolean;
95
105
  wasFullWidthModeEnabled?: boolean;
@@ -178,7 +188,7 @@ export type TablePluginAction = {
178
188
  } | {
179
189
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST';
180
190
  data: {
181
- widthToWidest: boolean | undefined;
191
+ widthToWidest: WidthToWidest | undefined;
182
192
  };
183
193
  } | {
184
194
  type: 'REMOVE_RESIZE_HANDLE_DECORATIONS';
@@ -1,7 +1,26 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
1
2
  import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { Direction } from '@atlaskit/editor-tables/types';
4
- export declare const initiateKeyboardColumnResizing: Command;
5
- export declare const activateNextResizeArea: (direction: Direction) => Command;
6
- export declare const changeColumnWidthByStep: (stepSize: number, getEditorContainerWidth: GetEditorContainerWidth, isTableScalingEnabled?: boolean) => Command;
7
- export declare const stopKeyboardColumnResizing: (originalTr?: Transaction) => Command;
5
+ export declare const initiateKeyboardColumnResizing: ({ ariaNotify, getIntl, }: {
6
+ ariaNotify?: ((message: string) => void) | undefined;
7
+ getIntl?: (() => IntlShape) | undefined;
8
+ }) => Command;
9
+ export declare const activateNextResizeArea: ({ direction, ariaNotify, getIntl, }: {
10
+ direction: Direction;
11
+ ariaNotify?: ((message: string) => void) | undefined;
12
+ getIntl?: (() => IntlShape) | undefined;
13
+ }) => Command;
14
+ export declare const changeColumnWidthByStep: ({ stepSize, getEditorContainerWidth, isTableScalingEnabled, ariaNotify, getIntl, }: {
15
+ stepSize: number;
16
+ getEditorContainerWidth: GetEditorContainerWidth;
17
+ isTableScalingEnabled: boolean;
18
+ ariaNotify?: ((message: string) => void) | undefined;
19
+ getIntl?: (() => IntlShape) | undefined;
20
+ originalTr?: Transaction | undefined;
21
+ }) => Command;
22
+ export declare const stopKeyboardColumnResizing: ({ ariaNotify, getIntl, originalTr, }: {
23
+ ariaNotify?: ((message: string) => void) | undefined;
24
+ getIntl?: (() => IntlShape) | undefined;
25
+ originalTr?: Transaction | undefined;
26
+ }) => Command;
@@ -1,4 +1,5 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
1
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { Command } from '@atlaskit/editor-common/types';
3
4
  import type { Direction } from '@atlaskit/editor-tables/types';
4
- export declare const goToNextCell: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (direction: Direction) => Command;
5
+ export declare const goToNextCell: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, ariaNotify?: ((message: string) => void) | undefined, getIntl?: () => IntlShape) => (direction: Direction) => Command;
@@ -3,6 +3,7 @@ import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror
3
3
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { WidthToWidest } from '../types';
6
7
  export declare const setEditorFocus: (editorHasFocus: boolean) => Command;
7
8
  export declare const setTableRef: (ref?: HTMLTableElement) => Command;
8
9
  export declare const setCellAttr: (name: string, value: any) => Command;
@@ -33,4 +34,4 @@ export declare const autoSizeTable: (view: EditorView, node: PMNode, table: HTML
33
34
  containerWidth: number;
34
35
  }) => boolean;
35
36
  export declare const addBoldInEmptyHeaderCells: (tableCellHeader: ContentNodeWithPos) => Command;
36
- export declare const updateWidthToWidest: (widthToWidest: boolean) => Command;
37
+ export declare const updateWidthToWidest: (widthToWidest: WidthToWidest) => Command;
@@ -1,3 +1,4 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
1
2
  import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
2
3
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
@@ -11,7 +12,7 @@ export declare const splitCellWithAnalytics: (editorAnalyticsAPI: EditorAnalytic
11
12
  export declare const setColorWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, cellColor: string, targetCellPosition?: number) => Command;
12
13
  export declare const addRowAroundSelection: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (side: RowInsertPosition) => Command;
13
14
  export declare const insertRowWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: InsertRowMethods, options: InsertRowOptions) => Command;
14
- export declare const changeColumnWidthByStepWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (stepSize: number, getEditorContainerWidth: GetEditorContainerWidth, isTableScalingEnabled: boolean, inputMethod: INPUT_METHOD.SHORTCUT) => Command;
15
+ export declare const changeColumnWidthByStepWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (stepSize: number, getEditorContainerWidth: GetEditorContainerWidth, isTableScalingEnabled: boolean, inputMethod: INPUT_METHOD.SHORTCUT, ariaNotify?: ((message: string) => void) | undefined, getIntl?: () => IntlShape) => Command;
15
16
  export declare const insertColumnWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.TABLE_CONTEXT_MENU, position: number) => Command;
16
17
  export declare const deleteRowsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect, isHeaderRowRequired: boolean) => Command;
17
18
  export declare const deleteColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, isTableScalingEnabled?: boolean) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.FLOATING_TB | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TABLE_CONTEXT_MENU, rect: Rect) => Command;
@@ -4,6 +4,7 @@ import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
4
4
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
+ import type { PluginInjectionAPI } from '../types';
7
8
  interface TableResizerProps {
8
9
  width: number;
9
10
  maxWidth: number;
@@ -16,6 +17,7 @@ interface TableResizerProps {
16
17
  displayGuideline: (guideline: GuidelineConfig[]) => boolean;
17
18
  attachAnalyticsEvent: (payload: TableEventPayload) => ((tr: Transaction) => boolean) | undefined;
18
19
  displayGapCursor: (toggle: boolean) => boolean;
20
+ pluginInjectionApi?: PluginInjectionAPI;
19
21
  isTableScalingEnabled?: boolean;
20
22
  isWholeTableInDanger?: boolean;
21
23
  }
@@ -23,5 +25,5 @@ export interface TableResizerImprovementProps extends TableResizerProps {
23
25
  onResizeStop?: () => void;
24
26
  onResizeStart?: () => void;
25
27
  }
26
- export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
28
+ export declare const TableResizer: ({ children, width, maxWidth, containerWidth, updateWidth, onResizeStop, onResizeStart, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, displayGapCursor, isTableScalingEnabled, isWholeTableInDanger, pluginInjectionApi, }: PropsWithChildren<TableResizerImprovementProps>) => JSX.Element;
27
29
  export {};
@@ -1,5 +1,7 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
1
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
4
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
- export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isFullWidthEnabled?: boolean): SafePlugin;
5
+ import type { PluginInjectionAPIWithA11y } from '../types';
6
+ export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isFullWidthEnabled?: boolean, pluginInjectionApi?: PluginInjectionAPIWithA11y, getIntl?: () => IntlShape): SafePlugin;
5
7
  export default keymapPlugin;
@@ -26,7 +26,14 @@ export interface InsertRowOptions {
26
26
  moveCursorToInsertedRow: boolean;
27
27
  }
28
28
  export type PluginInjectionAPI = ExtractInjectionAPI<TablePlugin>;
29
- export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode'> & {
29
+ export type PluginInjectionAPIWithA11y = ExtractInjectionAPI<TablePlugin> & {
30
+ accessibilityUtils?: {
31
+ actions: {
32
+ ariaNotify: (message: string) => void | undefined;
33
+ };
34
+ };
35
+ };
36
+ export type TableSharedStateInternal = Pick<TablePluginState, 'isFullWidthModeEnabled' | 'wasFullWidthModeEnabled' | 'isHeaderRowEnabled' | 'isHeaderColumnEnabled' | 'ordering' | 'isInDanger' | 'hoveredRows' | 'hoveredCell' | 'isTableHovered' | 'tableNode' | 'widthToWidest'> & {
30
37
  isResizing: boolean;
31
38
  isTableResizing?: boolean;
32
39
  isWholeTableInDanger?: boolean;
@@ -60,6 +67,9 @@ export interface CellHoverMeta {
60
67
  colIndex?: number;
61
68
  rowIndex?: number;
62
69
  }
70
+ export interface WidthToWidest {
71
+ [tableLocalId: string]: boolean;
72
+ }
63
73
  export interface TablePluginState {
64
74
  editorHasFocus?: boolean;
65
75
  hoveredColumns: number[];
@@ -89,7 +99,7 @@ export interface TablePluginState {
89
99
  isKeyboardResize?: boolean;
90
100
  isTableCollapsed?: boolean;
91
101
  canCollapseTable?: boolean;
92
- widthToWidest?: boolean;
102
+ widthToWidest?: WidthToWidest;
93
103
  getIntl: () => IntlShape;
94
104
  isBreakoutEnabled?: boolean;
95
105
  wasFullWidthModeEnabled?: boolean;
@@ -178,7 +188,7 @@ export type TablePluginAction = {
178
188
  } | {
179
189
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST';
180
190
  data: {
181
- widthToWidest: boolean | undefined;
191
+ widthToWidest: WidthToWidest | undefined;
182
192
  };
183
193
  } | {
184
194
  type: 'REMOVE_RESIZE_HANDLE_DECORATIONS';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.6.3",
3
+ "version": "7.6.5",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^35.7.0",
32
32
  "@atlaskit/custom-steps": "^0.0.16",
33
- "@atlaskit/editor-common": "^78.21.0",
33
+ "@atlaskit/editor-common": "^78.22.0",
34
34
  "@atlaskit/editor-palette": "1.5.3",
35
35
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
36
36
  "@atlaskit/editor-plugin-content-insertion": "^1.0.0",
@@ -46,7 +46,7 @@
46
46
  "@atlaskit/pragmatic-drag-and-drop": "^1.1.0",
47
47
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.0.0",
48
48
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
49
- "@atlaskit/primitives": "^5.1.0",
49
+ "@atlaskit/primitives": "^5.2.0",
50
50
  "@atlaskit/theme": "^12.7.0",
51
51
  "@atlaskit/toggle": "^13.0.0",
52
52
  "@atlaskit/tokens": "^1.42.0",
@@ -128,9 +128,6 @@
128
128
  "platform.editor.a11y-table-resizing_uapcv": {
129
129
  "type": "boolean"
130
130
  },
131
- "platform.editor.table.new-cell-context-menu-styling": {
132
- "type": "boolean"
133
- },
134
131
  "platform.editor.a11y.table-selection_9uv33": {
135
132
  "type": "boolean"
136
133
  },
@@ -1,3 +1,6 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
2
+
3
+ import { tableMessages as messages } from '@atlaskit/editor-common/messages';
1
4
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
2
5
  import type {
3
6
  Command,
@@ -121,36 +124,54 @@ const updateResizeHandleAndStatePosition =
121
124
  return false;
122
125
  };
123
126
 
124
- export const initiateKeyboardColumnResizing: Command = (
125
- state,
126
- dispatch,
127
- view,
128
- ) => {
129
- if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
127
+ export const initiateKeyboardColumnResizing =
128
+ ({
129
+ ariaNotify,
130
+ getIntl,
131
+ }: {
132
+ ariaNotify?: (message: string) => void;
133
+ getIntl?: () => IntlShape;
134
+ }): Command =>
135
+ (state, dispatch, view) => {
136
+ if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
137
+ return false;
138
+ }
139
+
140
+ const { selection } = state;
141
+ const selectionRect = isSelectionType(selection, 'cell')
142
+ ? getSelectionRect(selection)!
143
+ : findCellRectClosestToPos(selection.$from);
144
+ const cell = findCellClosestToPos(selection.$from);
145
+
146
+ if (ariaNotify && getIntl) {
147
+ ariaNotify(getIntl().formatMessage(messages.startedColumnResize));
148
+ }
149
+
150
+ if (selectionRect && cell && view) {
151
+ return updateResizeHandleAndStatePosition(
152
+ selectionRect.top,
153
+ selectionRect.right,
154
+ cell.pos,
155
+ )(state, dispatch);
156
+ }
130
157
  return false;
131
- }
132
- const { selection } = state;
133
- const selectionRect = isSelectionType(selection, 'cell')
134
- ? getSelectionRect(selection)!
135
- : findCellRectClosestToPos(selection.$from);
136
- const cell = findCellClosestToPos(selection.$from);
137
-
138
- if (selectionRect && cell && view) {
139
- return updateResizeHandleAndStatePosition(
140
- selectionRect.top,
141
- selectionRect.right,
142
- cell.pos,
143
- )(state, dispatch);
144
- }
145
- return false;
146
- };
158
+ };
147
159
 
148
160
  export const activateNextResizeArea =
149
- (direction: Direction): Command =>
161
+ ({
162
+ direction,
163
+ ariaNotify,
164
+ getIntl,
165
+ }: {
166
+ direction: Direction;
167
+ ariaNotify?: (message: string) => void;
168
+ getIntl?: () => IntlShape;
169
+ }): Command =>
150
170
  (state, dispatch, view) => {
151
171
  if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
152
172
  return false;
153
173
  }
174
+
154
175
  const { resizeHandlePos } = getTableResizingPluginState(state) || {};
155
176
  // If No resizing has initiated, skip to regular handler
156
177
  if (!resizeHandlePos) {
@@ -182,6 +203,23 @@ export const activateNextResizeArea =
182
203
  );
183
204
 
184
205
  const $nextCell = nextCell($currentCell, 'horiz', direction);
206
+ if (ariaNotify && getIntl) {
207
+ let columnDirection = '';
208
+
209
+ if (direction === 1) {
210
+ columnDirection = getIntl().formatMessage(messages.columnRightResize);
211
+ }
212
+
213
+ if (direction === -1) {
214
+ columnDirection = getIntl().formatMessage(messages.columnLeftResize);
215
+ }
216
+
217
+ ariaNotify(
218
+ getIntl().formatMessage(messages.focusedOtherResize, {
219
+ direction: columnDirection,
220
+ }),
221
+ );
222
+ }
185
223
 
186
224
  if ($nextCell) {
187
225
  // we are somewhere in between the side columns of the table
@@ -221,15 +259,25 @@ export const activateNextResizeArea =
221
259
  )(state, dispatch);
222
260
  }
223
261
  }
262
+
224
263
  return false;
225
264
  };
226
265
 
227
266
  export const changeColumnWidthByStep =
228
- (
229
- stepSize: number,
230
- getEditorContainerWidth: GetEditorContainerWidth,
231
- isTableScalingEnabled = false,
232
- ): Command =>
267
+ ({
268
+ stepSize,
269
+ getEditorContainerWidth,
270
+ isTableScalingEnabled,
271
+ ariaNotify,
272
+ getIntl,
273
+ }: {
274
+ stepSize: number;
275
+ getEditorContainerWidth: GetEditorContainerWidth;
276
+ isTableScalingEnabled: boolean;
277
+ ariaNotify?: (message: string) => void;
278
+ getIntl?: () => IntlShape;
279
+ originalTr?: Transaction;
280
+ }): Command =>
233
281
  (state, dispatch, view) => {
234
282
  let customTr = state.tr;
235
283
  const fakeDispatch = (tr: Transaction) => {
@@ -323,11 +371,36 @@ export const changeColumnWidthByStep =
323
371
  dispatch(customTr);
324
372
  }
325
373
 
374
+ if (ariaNotify && getIntl) {
375
+ ariaNotify(
376
+ getIntl().formatMessage(messages.changedColumnWidth, {
377
+ width: Math.floor(newResizeState.cols[colIndex].width),
378
+ }),
379
+ );
380
+
381
+ if (newResizeState.cols.length === colIndex + 1) {
382
+ if (newResizeState.overflow === true) {
383
+ ariaNotify(getIntl().formatMessage(messages.columnResizeLast));
384
+ }
385
+ if (newResizeState.overflow === false) {
386
+ ariaNotify(getIntl().formatMessage(messages.columnResizeOverflow));
387
+ }
388
+ }
389
+ }
390
+
326
391
  return true;
327
392
  };
328
393
 
329
394
  export const stopKeyboardColumnResizing =
330
- (originalTr?: Transaction): Command =>
395
+ ({
396
+ ariaNotify,
397
+ getIntl,
398
+ originalTr,
399
+ }: {
400
+ ariaNotify?: (message: string) => void;
401
+ getIntl?: () => IntlShape;
402
+ originalTr?: Transaction;
403
+ }): Command =>
331
404
  (state, dispatch) => {
332
405
  if (!getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
333
406
  return false;
@@ -364,6 +437,9 @@ export const stopKeyboardColumnResizing =
364
437
  },
365
438
  () => customTr.setMeta('scrollIntoView', false),
366
439
  )(state, fakeDispatch);
440
+ if (ariaNotify && getIntl) {
441
+ ariaNotify(getIntl().formatMessage(messages.columnResizeStop));
442
+ }
367
443
 
368
444
  if (dispatch) {
369
445
  dispatch(customTr);
@@ -1,4 +1,5 @@
1
1
  // #region Constants
2
+ import type { IntlShape } from 'react-intl-next/src/types';
2
3
 
3
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
5
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
@@ -21,7 +22,11 @@ const TAB_FORWARD_DIRECTION = 1;
21
22
  const TAB_BACKWARD_DIRECTION = -1;
22
23
 
23
24
  export const goToNextCell =
24
- (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) =>
25
+ (
26
+ editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
27
+ ariaNotify?: (message: string) => void,
28
+ getIntl?: () => IntlShape,
29
+ ) =>
25
30
  (direction: Direction): Command =>
26
31
  (state, dispatch, view) => {
27
32
  const table = findTable(state.selection);
@@ -32,7 +37,10 @@ export const goToNextCell =
32
37
  if (getBooleanFF('platform.editor.a11y-column-resizing_emcvz')) {
33
38
  const isColumnResizing = getPluginState(state)?.isKeyboardResize;
34
39
  if (isColumnResizing) {
35
- stopKeyboardColumnResizing()(state, dispatch, view);
40
+ stopKeyboardColumnResizing({
41
+ ariaNotify: ariaNotify,
42
+ getIntl: getIntl,
43
+ })(state, dispatch, view);
36
44
  return true;
37
45
  }
38
46
  }
@@ -1,3 +1,5 @@
1
+ import isEqual from 'lodash/isEqual';
2
+
1
3
  import type { CellAttributes } from '@atlaskit/adf-schema';
2
4
  import type { Command } from '@atlaskit/editor-common/types';
3
5
  import {
@@ -45,6 +47,7 @@ import {
45
47
  } from '../pm-plugins/decorations/utils';
46
48
  import { createCommand, getPluginState } from '../pm-plugins/plugin-factory';
47
49
  import { fixAutoSizedTable } from '../transforms';
50
+ import type { WidthToWidest } from '../types';
48
51
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
49
52
  import {
50
53
  createColumnControlsDecoration,
@@ -779,18 +782,18 @@ export const addBoldInEmptyHeaderCells =
779
782
  return false;
780
783
  };
781
784
 
782
- export const updateWidthToWidest = (widthToWidest: boolean) =>
785
+ export const updateWidthToWidest = (widthToWidest: WidthToWidest) =>
783
786
  createCommand((state) => {
784
787
  let { widthToWidest: prevWidthToWidest } = getPluginState(state);
785
788
 
786
- if (prevWidthToWidest === widthToWidest) {
789
+ if (isEqual(widthToWidest, prevWidthToWidest)) {
787
790
  return false;
788
791
  }
789
792
 
790
793
  return {
791
794
  type: 'UPDATE_TABLE_WIDTH_TO_WIDEST',
792
795
  data: {
793
- widthToWidest,
796
+ widthToWidest: { ...prevWidthToWidest, ...widthToWidest },
794
797
  },
795
798
  };
796
799
  });
@@ -1,3 +1,5 @@
1
+ import type { IntlShape } from 'react-intl-next/src/types';
2
+
1
3
  import type { TableLayout } from '@atlaskit/adf-schema';
2
4
  import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
3
5
  import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
@@ -259,6 +261,8 @@ export const changeColumnWidthByStepWithAnalytics =
259
261
  getEditorContainerWidth: GetEditorContainerWidth,
260
262
  isTableScalingEnabled: boolean,
261
263
  inputMethod: INPUT_METHOD.SHORTCUT,
264
+ ariaNotify?: (message: string) => void,
265
+ getIntl?: () => IntlShape,
262
266
  ) =>
263
267
  withEditorAnalyticsAPI((state) => {
264
268
  const { table, totalRowCount, totalColumnCount } = getSelectedTableInfo(
@@ -283,11 +287,13 @@ export const changeColumnWidthByStepWithAnalytics =
283
287
  },
284
288
  };
285
289
  })(editorAnalyticsAPI)(
286
- changeColumnWidthByStep(
287
- stepSize,
288
- getEditorContainerWidth,
289
- isTableScalingEnabled,
290
- ),
290
+ changeColumnWidthByStep({
291
+ stepSize: stepSize,
292
+ getEditorContainerWidth: getEditorContainerWidth,
293
+ isTableScalingEnabled: isTableScalingEnabled,
294
+ ariaNotify: ariaNotify,
295
+ getIntl: getIntl,
296
+ }),
291
297
  );
292
298
 
293
299
  export const insertColumnWithAnalytics =
@@ -56,6 +56,7 @@ export const ExternalDropTargets = ({
56
56
  width: getTableWrapperWidth(),
57
57
  overflow: 'hidden',
58
58
  position: 'absolute',
59
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
59
60
  top: `-${dropTargetExtendedWidth - tableMarginTop}px`,
60
61
  pointerEvents: 'auto',
61
62
  zIndex: `${dropTargetsZIndex}`,
@@ -66,6 +67,7 @@ export const ExternalDropTargets = ({
66
67
  style={{
67
68
  display: 'flex',
68
69
  // move drop targets based on table wrapper scroll
70
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
69
71
  marginLeft: `-${getScrollOffset()}px`,
70
72
  }}
71
73
  >