@atlaskit/editor-plugin-table 7.30.2 → 7.31.1

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 (83) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/commands/column-resize.js +10 -8
  3. package/dist/cjs/commands/misc.js +4 -4
  4. package/dist/cjs/event-handlers.js +69 -65
  5. package/dist/cjs/plugin.js +94 -53
  6. package/dist/cjs/pm-plugins/decorations/utils/column-resizing.js +2 -2
  7. package/dist/cjs/pm-plugins/keymap.js +18 -15
  8. package/dist/cjs/pm-plugins/main.js +2 -2
  9. package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +2 -2
  10. package/dist/cjs/pm-plugins/table-resizing/plugin.js +2 -2
  11. package/dist/cjs/pm-plugins/view-mode-sort/index.js +35 -10
  12. package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +1 -1
  13. package/dist/cjs/ui/common-styles.js +8 -18
  14. package/dist/cjs/utils/decoration.js +28 -8
  15. package/dist/es2019/commands/column-resize.js +10 -8
  16. package/dist/es2019/commands/misc.js +4 -4
  17. package/dist/es2019/event-handlers.js +4 -4
  18. package/dist/es2019/plugin.js +53 -9
  19. package/dist/es2019/pm-plugins/decorations/utils/column-resizing.js +2 -2
  20. package/dist/es2019/pm-plugins/keymap.js +7 -4
  21. package/dist/es2019/pm-plugins/main.js +2 -2
  22. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +2 -2
  23. package/dist/es2019/pm-plugins/table-resizing/plugin.js +2 -2
  24. package/dist/es2019/pm-plugins/view-mode-sort/index.js +33 -10
  25. package/dist/es2019/ui/FloatingContextualButton/FixedButton.js +1 -1
  26. package/dist/es2019/ui/common-styles.js +0 -15
  27. package/dist/es2019/utils/decoration.js +26 -9
  28. package/dist/esm/commands/column-resize.js +10 -8
  29. package/dist/esm/commands/misc.js +4 -4
  30. package/dist/esm/event-handlers.js +69 -65
  31. package/dist/esm/plugin.js +91 -50
  32. package/dist/esm/pm-plugins/decorations/utils/column-resizing.js +2 -2
  33. package/dist/esm/pm-plugins/keymap.js +18 -15
  34. package/dist/esm/pm-plugins/main.js +2 -2
  35. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +2 -2
  36. package/dist/esm/pm-plugins/table-resizing/plugin.js +2 -2
  37. package/dist/esm/pm-plugins/view-mode-sort/index.js +35 -10
  38. package/dist/esm/ui/FloatingContextualButton/FixedButton.js +1 -1
  39. package/dist/esm/ui/common-styles.js +8 -18
  40. package/dist/esm/utils/decoration.js +28 -8
  41. package/dist/types/commands/column-resize.d.ts +5 -2
  42. package/dist/types/commands/misc.d.ts +3 -2
  43. package/dist/types/commands/toggle.d.ts +1 -1
  44. package/dist/types/commands-with-analytics.d.ts +2 -2
  45. package/dist/types/event-handlers.d.ts +2 -1
  46. package/dist/types/pm-plugins/decorations/utils/column-resizing.d.ts +2 -1
  47. package/dist/types/pm-plugins/keymap.d.ts +2 -1
  48. package/dist/types/pm-plugins/main.d.ts +1 -1
  49. package/dist/types/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
  50. package/dist/types/pm-plugins/table-resizing/plugin.d.ts +2 -1
  51. package/dist/types/pm-plugins/view-mode-sort/index.d.ts +2 -1
  52. package/dist/types/toDOM.d.ts +1 -1
  53. package/dist/types/utils/decoration.d.ts +2 -1
  54. package/dist/types-ts4.5/commands/column-resize.d.ts +5 -2
  55. package/dist/types-ts4.5/commands/misc.d.ts +3 -2
  56. package/dist/types-ts4.5/commands/toggle.d.ts +1 -1
  57. package/dist/types-ts4.5/commands-with-analytics.d.ts +2 -2
  58. package/dist/types-ts4.5/event-handlers.d.ts +2 -1
  59. package/dist/types-ts4.5/pm-plugins/decorations/utils/column-resizing.d.ts +2 -1
  60. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -1
  61. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  62. package/dist/types-ts4.5/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
  63. package/dist/types-ts4.5/pm-plugins/table-resizing/plugin.d.ts +2 -1
  64. package/dist/types-ts4.5/pm-plugins/view-mode-sort/index.d.ts +2 -1
  65. package/dist/types-ts4.5/toDOM.d.ts +1 -1
  66. package/dist/types-ts4.5/utils/decoration.d.ts +2 -1
  67. package/package.json +11 -7
  68. package/src/commands/column-resize.ts +18 -1
  69. package/src/commands/misc.ts +5 -0
  70. package/src/commands-with-analytics.ts +2 -2
  71. package/src/event-handlers.ts +22 -20
  72. package/src/plugin.tsx +63 -6
  73. package/src/pm-plugins/decorations/utils/column-resizing.ts +3 -0
  74. package/src/pm-plugins/keymap.ts +5 -0
  75. package/src/pm-plugins/main.ts +2 -1
  76. package/src/pm-plugins/table-resizing/event-handlers.ts +8 -1
  77. package/src/pm-plugins/table-resizing/plugin.ts +3 -0
  78. package/src/pm-plugins/view-mode-sort/index.ts +73 -34
  79. package/src/toDOM.ts +1 -1
  80. package/src/toolbar.tsx +1 -1
  81. package/src/ui/FloatingContextualButton/FixedButton.tsx +1 -1
  82. package/src/ui/common-styles.ts +0 -17
  83. package/src/utils/decoration.ts +39 -13
@@ -1,4 +1,5 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
2
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
5
  import type { PluginInjectionAPI } from './types';
@@ -11,7 +12,7 @@ export declare const handleMouseDown: (_: EditorView, event: Event) => boolean;
11
12
  export declare const handleMouseOut: (view: EditorView, mouseEvent: Event) => boolean;
12
13
  export declare const handleMouseEnter: (view: EditorView, mouseEvent: Event) => boolean;
13
14
  export declare const handleMouseLeave: (view: EditorView, event: Event) => boolean;
14
- export declare const handleMouseMove: (view: EditorView, event: Event) => boolean;
15
+ export declare const handleMouseMove: (nodeViewPortalProviderAPI: PortalProviderAPI) => (view: EditorView, event: Event) => boolean;
15
16
  export declare function handleTripleClick(view: EditorView, pos: number): boolean;
16
17
  export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView, isTableScalingEnabled?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => Transaction;
17
18
  export declare const isTableInFocus: (view: EditorView) => boolean;
@@ -1,4 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
2
3
  import type { DecorationTransformer } from './types';
3
- export declare const buildColumnResizingDecorations: (rowEndIndex: number, columnEndIndex: number, includeTooltip: boolean, getIntl: () => IntlShape) => DecorationTransformer;
4
+ export declare const buildColumnResizingDecorations: (rowEndIndex: number, columnEndIndex: number, includeTooltip: boolean, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => DecorationTransformer;
4
5
  export declare const clearColumnResizingDecorations: () => DecorationTransformer;
@@ -1,7 +1,8 @@
1
1
  import type { IntlShape } from 'react-intl-next/src/types';
2
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
4
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
5
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
5
6
  import type { PluginInjectionAPI, PluginInjectionAPIWithA11y } from '../types';
6
- export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isFullWidthEnabled?: boolean, pluginInjectionApi?: PluginInjectionAPIWithA11y, getIntl?: () => IntlShape, isCellBackgroundDuplicated?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean, isChromelessEditor?: boolean, isTableResizingEnabled?: boolean): SafePlugin;
7
+ export declare function keymapPlugin(getEditorContainerWidth: GetEditorContainerWidth, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null, dragAndDropEnabled?: boolean, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isFullWidthEnabled?: boolean, pluginInjectionApi?: PluginInjectionAPIWithA11y, getIntl?: () => IntlShape, isCellBackgroundDuplicated?: boolean, isTableFixedColumnWidthsOptionEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean, isChromelessEditor?: boolean, isTableResizingEnabled?: boolean): SafePlugin;
7
8
  export default keymapPlugin;
@@ -5,4 +5,4 @@ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
7
  import type { PluginConfig, PluginInjectionAPI } from '../types';
8
- export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, tableResizingEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, dragAndDropEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean, isChromelessEditor?: boolean) => SafePlugin<import("../types").TablePluginState>;
8
+ export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, nodeViewPortalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, getIntl: () => IntlShape, tableResizingEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, dragAndDropEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI, isTableScalingEnabled?: boolean, isTableAlignmentEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean, isChromelessEditor?: boolean) => SafePlugin<import("../types").TablePluginState>;
@@ -1,5 +1,6 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
2
3
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
3
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
5
  import type { PluginInjectionAPI } from '../../types';
5
- export declare const handleMouseDown: (view: EditorView, event: MouseEvent, localResizeHandlePos: number, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, isTableScalingEnabled: boolean, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI?: EditorAnalyticsAPI, isNewColumnResizingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isCommentEditor?: boolean) => boolean;
6
+ export declare const handleMouseDown: (view: EditorView, event: MouseEvent, localResizeHandlePos: number, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, isTableScalingEnabled: boolean, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isNewColumnResizingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isCommentEditor?: boolean) => boolean;
@@ -1,6 +1,7 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
2
  import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
3
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
5
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
5
6
  import type { ColumnResizingPluginState, PluginInjectionAPI } from '../../types';
6
- export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, api: PluginInjectionAPI | undefined | null, editorAnalyticsAPI?: EditorAnalyticsAPI, isTableScalingEnabled?: boolean, isNewColumnResizingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isCommentEditor?: boolean): SafePlugin<ColumnResizingPluginState>;
7
+ export declare function createPlugin(dispatch: Dispatch<ColumnResizingPluginState>, { lastColumnResizable }: ColumnResizingPluginState, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, api: PluginInjectionAPI | undefined | null, nodeViewPortalProviderAPI: PortalProviderAPI, editorAnalyticsAPI?: EditorAnalyticsAPI, isTableScalingEnabled?: boolean, isNewColumnResizingEnabled?: boolean, isTableAlignmentEnabled?: boolean, isCommentEditor?: boolean): SafePlugin<ColumnResizingPluginState>;
@@ -3,8 +3,9 @@
3
3
  * Instead of making changes to the ProseMirror document, the plugin sorts the table rows in the DOM. This allows the sorting to be
4
4
  * visible to the user without affecting the document's content.
5
5
  */
6
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
6
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
8
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
9
  import type tablePlugin from '../../plugin';
9
10
  import type { ViewModeSortPluginState } from './types';
10
- export declare const createPlugin: (api: ExtractInjectionAPI<typeof tablePlugin>) => SafePlugin<ViewModeSortPluginState>;
11
+ export declare const createPlugin: (api: ExtractInjectionAPI<typeof tablePlugin>, nodeViewPortalProviderAPI: PortalProviderAPI) => SafePlugin<ViewModeSortPluginState>;
@@ -1,4 +1,4 @@
1
- import type { GetEditorContainerWidth } from '@atlaskit/editor-common/src/types';
1
+ import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
2
2
  import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
3
3
  type Config = {
4
4
  allowColumnResizing: boolean;
@@ -1,4 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
2
3
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { ReadonlyTransaction, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
@@ -12,7 +13,7 @@ export declare const createControlsHoverDecoration: (cells: Cell[], type: 'row'
12
13
  export declare const createColumnSelectedDecoration: (tr: Transaction | ReadonlyTransaction) => Decoration[];
13
14
  export declare const createColumnControlsDecoration: (selection: Selection) => Decoration[];
14
15
  export declare const updateDecorations: (node: PmNode, decorationSet: DecorationSet, decorations: Decoration[], key: TableDecorations) => DecorationSet;
15
- export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>, includeTooltip: boolean | undefined, getIntl: () => IntlShape) => [
16
+ export declare const createResizeHandleDecoration: (tr: Transaction | ReadonlyTransaction, rowIndexTarget: number, columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>, includeTooltip: boolean | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => [
16
17
  Decoration[],
17
18
  Decoration[]
18
19
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "7.30.2",
3
+ "version": "7.31.1",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,12 +30,12 @@
30
30
  "@atlaskit/adf-schema": "^44.2.0",
31
31
  "@atlaskit/button": "^20.3.0",
32
32
  "@atlaskit/custom-steps": "^0.8.0",
33
- "@atlaskit/editor-common": "^94.13.0",
33
+ "@atlaskit/editor-common": "^94.22.0",
34
34
  "@atlaskit/editor-palette": "1.6.3",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-batch-attribute-updates": "1.1.4",
38
- "@atlaskit/editor-plugin-content-insertion": "^1.9.0",
38
+ "@atlaskit/editor-plugin-content-insertion": "^1.10.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-guideline": "^1.2.0",
41
41
  "@atlaskit/editor-plugin-selection": "^1.5.0",
@@ -49,18 +49,19 @@
49
49
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
50
50
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
51
51
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
52
- "@atlaskit/primitives": "^13.0.0",
52
+ "@atlaskit/primitives": "^13.2.0",
53
53
  "@atlaskit/theme": "^14.0.0",
54
- "@atlaskit/tmp-editor-statsig": "^2.12.0",
54
+ "@atlaskit/tmp-editor-statsig": "^2.17.0",
55
55
  "@atlaskit/toggle": "^13.4.0",
56
56
  "@atlaskit/tokens": "^2.2.0",
57
- "@atlaskit/tooltip": "^18.8.0",
57
+ "@atlaskit/tooltip": "^18.9.0",
58
58
  "@babel/runtime": "^7.0.0",
59
59
  "@emotion/react": "^11.7.1",
60
60
  "classnames": "^2.2.5",
61
61
  "lodash": "^4.17.21",
62
62
  "memoize-one": "^6.0.0",
63
- "raf-schd": "^4.0.3"
63
+ "raf-schd": "^4.0.3",
64
+ "uuid": "^3.1.0"
64
65
  },
65
66
  "peerDependencies": {
66
67
  "react": "^16.8.0 || ^17.0.0 || ~18.2.0",
@@ -118,6 +119,9 @@
118
119
  "platform-visual-refresh-icons": {
119
120
  "type": "boolean"
120
121
  },
122
+ "platform_editor_react18_plugin_portalprovider": {
123
+ "type": "boolean"
124
+ },
121
125
  "platform_editor_use_nested_table_pm_nodes": {
122
126
  "type": "boolean"
123
127
  }
@@ -1,6 +1,7 @@
1
1
  import type { IntlShape } from 'react-intl-next/src/types';
2
2
 
3
3
  import { tableMessages as messages } from '@atlaskit/editor-common/messages';
4
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
5
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
5
6
  import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
6
7
  import type { AriaLiveElementAttributes } from '@atlaskit/editor-plugin-accessibility-utils';
@@ -54,7 +55,12 @@ const getTablePluginCommand = (
54
55
  };
55
56
 
56
57
  const updateResizeHandleAndStatePosition =
57
- (rowIndex: number, columnIndex: number, nextResizeHandlePos: number): Command =>
58
+ (
59
+ rowIndex: number,
60
+ columnIndex: number,
61
+ nextResizeHandlePos: number,
62
+ nodeViewPortalProviderAPI: PortalProviderAPI,
63
+ ): Command =>
58
64
  (state, dispatch) => {
59
65
  let customTr = state.tr;
60
66
  const {
@@ -75,6 +81,7 @@ const updateResizeHandleAndStatePosition =
75
81
  columnIndex,
76
82
  true,
77
83
  getIntl,
84
+ nodeViewPortalProviderAPI,
78
85
  )({
79
86
  tr: customTr,
80
87
  decorationSet: getDecorations(state),
@@ -121,9 +128,11 @@ export const initiateKeyboardColumnResizing =
121
128
  ({
122
129
  ariaNotify,
123
130
  getIntl,
131
+ nodeViewPortalProviderAPI,
124
132
  }: {
125
133
  ariaNotify?: (message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void;
126
134
  getIntl?: () => IntlShape;
135
+ nodeViewPortalProviderAPI: PortalProviderAPI;
127
136
  }): Command =>
128
137
  (state, dispatch, view) => {
129
138
  const { selection } = state;
@@ -143,6 +152,7 @@ export const initiateKeyboardColumnResizing =
143
152
  selectionRect.top,
144
153
  selectionRect.right,
145
154
  cell.pos,
155
+ nodeViewPortalProviderAPI,
146
156
  )(state, dispatch);
147
157
  }
148
158
  return false;
@@ -153,10 +163,12 @@ export const activateNextResizeArea =
153
163
  direction,
154
164
  ariaNotify,
155
165
  getIntl,
166
+ nodeViewPortalProviderAPI,
156
167
  }: {
157
168
  direction: Direction;
158
169
  ariaNotify?: (message: string, ariaLiveElementAttributes?: AriaLiveElementAttributes) => void;
159
170
  getIntl?: () => IntlShape;
171
+ nodeViewPortalProviderAPI: PortalProviderAPI;
160
172
  }): Command =>
161
173
  (state, dispatch, view) => {
162
174
  const { resizeHandlePos } = getTableResizingPluginState(state) || {};
@@ -217,6 +229,8 @@ export const activateNextResizeArea =
217
229
  rectForNextCell.top,
218
230
  rectForNextCell.right,
219
231
  $nextCell.pos,
232
+
233
+ nodeViewPortalProviderAPI,
220
234
  )(state, dispatch, view);
221
235
  } else {
222
236
  // current position is in the one of the side columns of the table(left or right)
@@ -230,6 +244,7 @@ export const activateNextResizeArea =
230
244
  currentCellRect.top,
231
245
  tableMap.width,
232
246
  $lastCell.pos,
247
+ nodeViewPortalProviderAPI,
233
248
  )(state, dispatch, view);
234
249
  } else if (tableMap.width === currentCellRect.right) {
235
250
  const firsCellInCurrentRow =
@@ -240,6 +255,8 @@ export const activateNextResizeArea =
240
255
  currentCellRect.top,
241
256
  1,
242
257
  $nextCell.pos,
258
+
259
+ nodeViewPortalProviderAPI,
243
260
  )(state, dispatch);
244
261
  }
245
262
  }
@@ -2,6 +2,7 @@ import isEqual from 'lodash/isEqual';
2
2
 
3
3
  import type { CellAttributes, TableAttributes, TableLayout } from '@atlaskit/adf-schema';
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
6
  import type { Command, EditorCommand } from '@atlaskit/editor-common/types';
6
7
  import {
7
8
  closestElement,
@@ -560,6 +561,7 @@ export const addResizeHandleDecorations = (
560
561
  rowIndex: number,
561
562
  columnIndex: number,
562
563
  includeTooltip: boolean,
564
+ nodeViewPortalProviderAPI: PortalProviderAPI,
563
565
  isKeyboardResize?: boolean,
564
566
  ) =>
565
567
  createCommand(
@@ -582,6 +584,7 @@ export const addResizeHandleDecorations = (
582
584
  columnIndex,
583
585
  includeTooltip,
584
586
  getIntl,
587
+ nodeViewPortalProviderAPI,
585
588
  )({
586
589
  tr: state.tr,
587
590
  decorationSet: getDecorations(state),
@@ -597,6 +600,7 @@ export const addResizeHandleDecorations = (
597
600
  );
598
601
 
599
602
  export const updateResizeHandleDecorations = (
603
+ nodeViewPortalProviderAPI: PortalProviderAPI,
600
604
  rowIndex?: number,
601
605
  columnIndex?: number,
602
606
  includeTooltip?: boolean,
@@ -636,6 +640,7 @@ export const updateResizeHandleDecorations = (
636
640
  resolvedColumnIndex,
637
641
  resolvedIncludeTooltip,
638
642
  getIntl,
643
+ nodeViewPortalProviderAPI,
639
644
  )({
640
645
  tr: state.tr,
641
646
  decorationSet: getDecorations(state),
@@ -3,6 +3,7 @@ import type { IntlShape } from 'react-intl-next/src/types';
3
3
  import type { TableLayout } from '@atlaskit/adf-schema';
4
4
  import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
5
5
  import type { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
6
+ import type { AnalyticsEventPayload, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
6
7
  import {
7
8
  ACTION_SUBJECT,
8
9
  EVENT_TYPE,
@@ -10,9 +11,8 @@ import {
10
11
  TABLE_ACTION,
11
12
  TABLE_DISPLAY_MODE,
12
13
  } from '@atlaskit/editor-common/analytics';
13
- import type { AnalyticsEventPayload, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
14
+ import { type CHANGE_ALIGNMENT_REASON } from '@atlaskit/editor-common/analytics';
14
15
  import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
15
- import { type CHANGE_ALIGNMENT_REASON } from '@atlaskit/editor-common/src/analytics/types/table-events';
16
16
  import type { Command, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
17
17
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
18
18
  import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
@@ -2,6 +2,7 @@ import rafSchedule from 'raf-schd';
2
2
 
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
5
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
6
  import {
6
7
  browser,
7
8
  closestElement,
@@ -347,8 +348,8 @@ export const handleMouseLeave = (view: EditorView, event: Event): boolean => {
347
348
 
348
349
  // IMPORTANT: The mouse move handler has been setup with RAF schedule to avoid Reflows which will occur as some methods
349
350
  // need to access the mouse event offset position and also the target clientWidth vallue.
350
- const handleMouseMoveDebounce = rafSchedule(
351
- (view: EditorView, event: MouseEvent, offsetX: number) => {
351
+ const handleMouseMoveDebounce = (nodeViewPortalProviderAPI: PortalProviderAPI) =>
352
+ rafSchedule((view: EditorView, event: MouseEvent, offsetX: number) => {
352
353
  if (!(event.target instanceof HTMLElement)) {
353
354
  return false;
354
355
  }
@@ -413,6 +414,7 @@ const handleMouseMoveDebounce = rafSchedule(
413
414
  rowIndexTarget,
414
415
  columnEndIndexTarget,
415
416
  true,
417
+ nodeViewPortalProviderAPI,
416
418
  )(state, dispatch);
417
419
  }
418
420
  }
@@ -420,26 +422,26 @@ const handleMouseMoveDebounce = rafSchedule(
420
422
  }
421
423
 
422
424
  return false;
423
- },
424
- );
425
+ });
425
426
 
426
- export const handleMouseMove = (view: EditorView, event: Event) => {
427
- if (!(event.target instanceof HTMLElement)) {
428
- return false;
429
- }
427
+ export const handleMouseMove =
428
+ (nodeViewPortalProviderAPI: PortalProviderAPI) => (view: EditorView, event: Event) => {
429
+ if (!(event.target instanceof HTMLElement)) {
430
+ return false;
431
+ }
430
432
 
431
- // NOTE: When accessing offsetX in gecko from a deferred callback, it will return 0. However it will be non-zero if accessed
432
- // within the scope of it's initial mouse move handler. Also Chrome does return the correct value, however it could trigger
433
- // a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
434
- // in the deferred callback handler.
435
- // Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
436
- handleMouseMoveDebounce(
437
- view,
438
- event as MouseEvent,
439
- browser.gecko ? (event as MouseEvent).offsetX : NaN,
440
- );
441
- return false;
442
- };
433
+ // NOTE: When accessing offsetX in gecko from a deferred callback, it will return 0. However it will be non-zero if accessed
434
+ // within the scope of it's initial mouse move handler. Also Chrome does return the correct value, however it could trigger
435
+ // a reflow. So for now this will just grab the offsetX value immediately for gecko and chrome will calculate later
436
+ // in the deferred callback handler.
437
+ // Bug Tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=1882903
438
+ handleMouseMoveDebounce(nodeViewPortalProviderAPI)(
439
+ view,
440
+ event as MouseEvent,
441
+ browser.gecko ? (event as MouseEvent).offsetX : NaN,
442
+ );
443
+ return false;
444
+ };
443
445
 
444
446
  export function handleTripleClick(view: EditorView, pos: number) {
445
447
  const { state, dispatch } = view;
package/src/plugin.tsx CHANGED
@@ -22,6 +22,10 @@ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
22
22
  import { IconTable } from '@atlaskit/editor-common/icons';
23
23
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
24
24
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
25
+ import {
26
+ getParentOfTypeCount,
27
+ getPositionAfterTopParentNodeOfType,
28
+ } from '@atlaskit/editor-common/nesting';
25
29
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
26
30
  import type {
27
31
  Command,
@@ -42,11 +46,14 @@ import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
42
46
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
43
47
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
44
48
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
49
+ import { type Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
45
50
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
51
+ import { hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
46
52
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
47
53
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
48
54
  import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
49
55
  import { fg } from '@atlaskit/platform-feature-flags';
56
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
50
57
 
51
58
  import { insertTableWithSize } from './commands/insert';
52
59
  import { pluginConfig } from './create-plugin-config';
@@ -233,12 +240,32 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
233
240
  isTableResizingEnabled: options?.tableResizingEnabled,
234
241
  })(state.schema);
235
242
 
243
+ // If the cursor is inside a table
244
+ let insertAt: Selection | undefined;
245
+ if (
246
+ hasParentNodeOfType(state.schema.nodes.table)(state.selection) &&
247
+ fg('platform_editor_use_nested_table_pm_nodes')
248
+ ) {
249
+ // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
250
+ if (
251
+ editorExperiment('nested-tables-in-tables', false, { exposure: true }) ||
252
+ getParentOfTypeCount(state.schema.nodes.table)(state.selection) > 1
253
+ ) {
254
+ const positionAfterTopTable = getPositionAfterTopParentNodeOfType(
255
+ state.schema.nodes.table,
256
+ )(state.selection);
257
+ if (!positionAfterTopTable) {
258
+ return false;
259
+ }
260
+ insertAt = TextSelection.create(state.doc, positionAfterTopTable);
261
+ }
262
+ }
263
+
236
264
  return (
237
265
  api?.contentInsertion?.actions?.insert({
238
266
  state,
239
267
  dispatch,
240
268
  node,
241
-
242
269
  options: {
243
270
  selectNodeInserted: false,
244
271
  analyticsPayload: {
@@ -248,6 +275,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
248
275
  localId: node.attrs.localId,
249
276
  },
250
277
  },
278
+ insertAt,
251
279
  },
252
280
  }) ?? false
253
281
  );
@@ -307,6 +335,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
307
335
  dispatchAnalyticsEvent,
308
336
  dispatch,
309
337
  portalProviderAPI,
338
+ nodeViewPortalProviderAPI,
310
339
  eventDispatcher,
311
340
  getIntl,
312
341
  }) => {
@@ -328,6 +357,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
328
357
  dispatchAnalyticsEvent,
329
358
  dispatch,
330
359
  portalProviderAPI,
360
+ nodeViewPortalProviderAPI,
331
361
  eventDispatcher,
332
362
  pluginConfig(tableOptions),
333
363
  defaultGetEditorContainerWidth,
@@ -349,7 +379,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
349
379
  },
350
380
  {
351
381
  name: 'tablePMColResizing',
352
- plugin: ({ dispatch }) => {
382
+ plugin: ({ dispatch, nodeViewPortalProviderAPI }) => {
353
383
  const {
354
384
  fullWidthEnabled,
355
385
  tableOptions,
@@ -368,6 +398,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
368
398
  defaultGetEditorContainerWidth,
369
399
  getEditorFeatureFlags || defaultGetEditorFeatureFlags,
370
400
  api,
401
+ nodeViewPortalProviderAPI,
371
402
  editorAnalyticsAPI,
372
403
  isTableScalingEnabled || false,
373
404
  isNewColumnResizingEnabled,
@@ -382,7 +413,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
382
413
  // plugin as it is currently swallowing backspace events inside tables
383
414
  {
384
415
  name: 'tableKeymap',
385
- plugin: ({ getIntl }) => {
416
+ plugin: ({ getIntl, nodeViewPortalProviderAPI }) => {
386
417
  const {
387
418
  dragAndDropEnabled,
388
419
  isTableScalingEnabled = false,
@@ -396,6 +427,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
396
427
  return keymapPlugin(
397
428
  defaultGetEditorContainerWidth,
398
429
  api,
430
+ nodeViewPortalProviderAPI,
399
431
  editorAnalyticsAPI,
400
432
  dragAndDropEnabled,
401
433
  isTableScalingEnabled,
@@ -460,8 +492,10 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
460
492
  },
461
493
  {
462
494
  name: 'tableViewModeSort',
463
- plugin: () => {
464
- return api?.editorViewMode ? createViewModeSortPlugin(api) : undefined;
495
+ plugin: ({ nodeViewPortalProviderAPI }) => {
496
+ return api?.editorViewMode
497
+ ? createViewModeSortPlugin(api, nodeViewPortalProviderAPI)
498
+ : undefined;
465
499
  },
466
500
  },
467
501
  {
@@ -749,7 +783,30 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
749
783
  isTableResizingEnabled: options?.tableResizingEnabled,
750
784
  })(state.schema);
751
785
 
752
- const tr = insert(tableNode);
786
+ let { tr } = state;
787
+ // If the cursor is inside a table
788
+ if (
789
+ hasParentNodeOfType(state.schema.nodes.table)(state.selection) &&
790
+ fg('platform_editor_use_nested_table_pm_nodes')
791
+ ) {
792
+ // If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
793
+ if (
794
+ editorExperiment('nested-tables-in-tables', false, { exposure: true }) ||
795
+ getParentOfTypeCount(state.schema.nodes.table)(state.selection) > 1
796
+ ) {
797
+ // Nesting is too deep insert table after the top parent table
798
+ const positionAfterTopTable = getPositionAfterTopParentNodeOfType(
799
+ state.schema.nodes.table,
800
+ )(state.selection);
801
+ tr = safeInsert(tableNode, positionAfterTopTable)(tr);
802
+ tr.scrollIntoView();
803
+ } else {
804
+ // Table can be nested in parent table
805
+ tr = insert(tableNode);
806
+ }
807
+ } else {
808
+ tr = insert(tableNode);
809
+ }
753
810
 
754
811
  editorAnalyticsAPI?.attachAnalyticsEvent({
755
812
  action: ACTION.INSERTED,
@@ -1,5 +1,6 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
2
 
3
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
4
  import type { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
5
 
5
6
  import { TableDecorations } from '../../../types';
@@ -36,6 +37,7 @@ export const buildColumnResizingDecorations =
36
37
  columnEndIndex: number,
37
38
  includeTooltip: boolean,
38
39
  getIntl: () => IntlShape,
40
+ nodeViewPortalProviderAPI: PortalProviderAPI,
39
41
  ): DecorationTransformer =>
40
42
  ({ tr, decorationSet }): DecorationSet => {
41
43
  const [columnResizesDecorations, lastCellElementsDecorations] =
@@ -49,6 +51,7 @@ export const buildColumnResizingDecorations =
49
51
  },
50
52
  includeTooltip,
51
53
  getIntl,
54
+ nodeViewPortalProviderAPI,
52
55
  );
53
56
 
54
57
  return composeDecorations([
@@ -30,6 +30,7 @@ import {
30
30
  startColumnResizing,
31
31
  toggleTable,
32
32
  } from '@atlaskit/editor-common/keymaps';
33
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
33
34
  import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
34
35
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
35
36
  import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
@@ -59,6 +60,7 @@ import type { PluginInjectionAPI, PluginInjectionAPIWithA11y } from '../types';
59
60
  export function keymapPlugin(
60
61
  getEditorContainerWidth: GetEditorContainerWidth,
61
62
  api: PluginInjectionAPI | undefined | null,
63
+ nodeViewPortalProviderAPI: PortalProviderAPI,
62
64
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
63
65
  dragAndDropEnabled?: boolean,
64
66
  isTableScalingEnabled = false,
@@ -263,6 +265,7 @@ export function keymapPlugin(
263
265
  initiateKeyboardColumnResizing({
264
266
  ariaNotify: ariaNotifyPlugin,
265
267
  getIntl: getIntl,
268
+ nodeViewPortalProviderAPI,
266
269
  }),
267
270
  list,
268
271
  );
@@ -273,6 +276,7 @@ export function keymapPlugin(
273
276
  direction: 1,
274
277
  ariaNotify: ariaNotifyPlugin,
275
278
  getIntl: getIntl,
279
+ nodeViewPortalProviderAPI,
276
280
  }),
277
281
  list,
278
282
  );
@@ -283,6 +287,7 @@ export function keymapPlugin(
283
287
  direction: -1,
284
288
  ariaNotify: ariaNotifyPlugin,
285
289
  getIntl: getIntl,
290
+ nodeViewPortalProviderAPI,
286
291
  }),
287
292
  list,
288
293
  );
@@ -79,6 +79,7 @@ export const createPlugin = (
79
79
  dispatchAnalyticsEvent: DispatchAnalyticsEvent,
80
80
  dispatch: Dispatch,
81
81
  portalProviderAPI: PortalProviderAPI,
82
+ nodeViewPortalProviderAPI: PortalProviderAPI,
82
83
  eventDispatcher: EventDispatcher,
83
84
  pluginConfig: PluginConfig,
84
85
  getEditorContainerWidth: GetEditorContainerWidth,
@@ -381,7 +382,7 @@ export const createPlugin = (
381
382
  blur: handleBlur,
382
383
  mousedown: withCellTracking(handleMouseDown),
383
384
  mouseleave: handleMouseLeave,
384
- mousemove: whenTableInFocus(handleMouseMove),
385
+ mousemove: whenTableInFocus(handleMouseMove(nodeViewPortalProviderAPI)),
385
386
  mouseenter: handleMouseEnter,
386
387
  mouseup: whenTableInFocus(handleMouseUp),
387
388
  click: withCellTracking(whenTableInFocus(handleClick)),
@@ -8,6 +8,7 @@ import {
8
8
  TABLE_OVERFLOW_CHANGE_TRIGGER,
9
9
  } from '@atlaskit/editor-common/analytics';
10
10
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
11
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
11
12
  import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
12
13
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
13
14
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -50,6 +51,7 @@ export const handleMouseDown = (
50
51
  getEditorFeatureFlags: GetEditorFeatureFlags,
51
52
  isTableScalingEnabled: boolean,
52
53
  api: PluginInjectionAPI | undefined | null,
54
+ nodeViewPortalProviderAPI: PortalProviderAPI,
53
55
  editorAnalyticsAPI?: EditorAnalyticsAPI,
54
56
  isNewColumnResizingEnabled?: boolean,
55
57
  isTableAlignmentEnabled?: boolean,
@@ -150,7 +152,12 @@ export const handleMouseDown = (
150
152
 
151
153
  // When we start resizing a column we need to ensure the underlying tooltip is removed from the decoration to avoid
152
154
  // unnecessary tooltips being displayed during drag.
153
- updateResizeHandleDecorations(undefined, undefined, false)(state, dispatch);
155
+ updateResizeHandleDecorations(
156
+ nodeViewPortalProviderAPI,
157
+ undefined,
158
+ undefined,
159
+ false,
160
+ )(state, dispatch);
154
161
 
155
162
  // for new column resizing, take the current scaled version of table widths and use those as the basis for resizing
156
163
  // implication: the scaled version of the table becomes the source of truth