@atlaskit/editor-plugin-table 7.31.0 → 7.31.2

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 (92) hide show
  1. package/CHANGELOG.md +17 -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 +52 -48
  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/FloatingContextualMenu/ContextualMenu.js +12 -17
  13. package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +8 -11
  14. package/dist/cjs/ui/FloatingDragMenu/index.js +1 -4
  15. package/dist/cjs/ui/FloatingDragMenu/styles.js +1 -2
  16. package/dist/cjs/utils/decoration.js +28 -8
  17. package/dist/cjs/utils/drag-menu.js +3 -4
  18. package/dist/es2019/commands/column-resize.js +10 -8
  19. package/dist/es2019/commands/misc.js +4 -4
  20. package/dist/es2019/event-handlers.js +4 -4
  21. package/dist/es2019/plugin.js +12 -7
  22. package/dist/es2019/pm-plugins/decorations/utils/column-resizing.js +2 -2
  23. package/dist/es2019/pm-plugins/keymap.js +7 -4
  24. package/dist/es2019/pm-plugins/main.js +2 -2
  25. package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +2 -2
  26. package/dist/es2019/pm-plugins/table-resizing/plugin.js +2 -2
  27. package/dist/es2019/pm-plugins/view-mode-sort/index.js +33 -10
  28. package/dist/es2019/ui/FloatingContextualMenu/ContextualMenu.js +1 -8
  29. package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +8 -9
  30. package/dist/es2019/ui/FloatingDragMenu/index.js +1 -3
  31. package/dist/es2019/ui/FloatingDragMenu/styles.js +2 -2
  32. package/dist/es2019/utils/decoration.js +26 -9
  33. package/dist/es2019/utils/drag-menu.js +2 -2
  34. package/dist/esm/commands/column-resize.js +10 -8
  35. package/dist/esm/commands/misc.js +4 -4
  36. package/dist/esm/event-handlers.js +69 -65
  37. package/dist/esm/plugin.js +52 -48
  38. package/dist/esm/pm-plugins/decorations/utils/column-resizing.js +2 -2
  39. package/dist/esm/pm-plugins/keymap.js +18 -15
  40. package/dist/esm/pm-plugins/main.js +2 -2
  41. package/dist/esm/pm-plugins/table-resizing/event-handlers.js +2 -2
  42. package/dist/esm/pm-plugins/table-resizing/plugin.js +2 -2
  43. package/dist/esm/pm-plugins/view-mode-sort/index.js +35 -10
  44. package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +12 -17
  45. package/dist/esm/ui/FloatingDragMenu/DragMenu.js +8 -11
  46. package/dist/esm/ui/FloatingDragMenu/index.js +1 -4
  47. package/dist/esm/ui/FloatingDragMenu/styles.js +1 -2
  48. package/dist/esm/utils/decoration.js +28 -8
  49. package/dist/esm/utils/drag-menu.js +3 -4
  50. package/dist/types/commands/column-resize.d.ts +5 -2
  51. package/dist/types/commands/misc.d.ts +3 -2
  52. package/dist/types/event-handlers.d.ts +2 -1
  53. package/dist/types/pm-plugins/decorations/utils/column-resizing.d.ts +2 -1
  54. package/dist/types/pm-plugins/keymap.d.ts +2 -1
  55. package/dist/types/pm-plugins/main.d.ts +1 -1
  56. package/dist/types/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
  57. package/dist/types/pm-plugins/table-resizing/plugin.d.ts +2 -1
  58. package/dist/types/pm-plugins/view-mode-sort/index.d.ts +2 -1
  59. package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
  60. package/dist/types/ui/FloatingDragMenu/styles.d.ts +1 -1
  61. package/dist/types/utils/decoration.d.ts +2 -1
  62. package/dist/types/utils/drag-menu.d.ts +1 -1
  63. package/dist/types-ts4.5/commands/column-resize.d.ts +5 -2
  64. package/dist/types-ts4.5/commands/misc.d.ts +3 -2
  65. package/dist/types-ts4.5/event-handlers.d.ts +2 -1
  66. package/dist/types-ts4.5/pm-plugins/decorations/utils/column-resizing.d.ts +2 -1
  67. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -1
  68. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  69. package/dist/types-ts4.5/pm-plugins/table-resizing/event-handlers.d.ts +2 -1
  70. package/dist/types-ts4.5/pm-plugins/table-resizing/plugin.d.ts +2 -1
  71. package/dist/types-ts4.5/pm-plugins/view-mode-sort/index.d.ts +2 -1
  72. package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +0 -1
  73. package/dist/types-ts4.5/ui/FloatingDragMenu/styles.d.ts +1 -1
  74. package/dist/types-ts4.5/utils/decoration.d.ts +2 -1
  75. package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
  76. package/package.json +9 -5
  77. package/src/commands/column-resize.ts +18 -1
  78. package/src/commands/misc.ts +5 -0
  79. package/src/event-handlers.ts +22 -20
  80. package/src/plugin.tsx +10 -4
  81. package/src/pm-plugins/decorations/utils/column-resizing.ts +3 -0
  82. package/src/pm-plugins/keymap.ts +5 -0
  83. package/src/pm-plugins/main.ts +2 -1
  84. package/src/pm-plugins/table-resizing/event-handlers.ts +8 -1
  85. package/src/pm-plugins/table-resizing/plugin.ts +3 -0
  86. package/src/pm-plugins/view-mode-sort/index.ts +73 -34
  87. package/src/ui/FloatingContextualMenu/ContextualMenu.tsx +1 -5
  88. package/src/ui/FloatingDragMenu/DragMenu.tsx +5 -14
  89. package/src/ui/FloatingDragMenu/index.tsx +2 -6
  90. package/src/ui/FloatingDragMenu/styles.ts +4 -6
  91. package/src/utils/decoration.ts +39 -13
  92. package/src/utils/drag-menu.ts +1 -2
@@ -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
@@ -335,6 +335,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
335
335
  dispatchAnalyticsEvent,
336
336
  dispatch,
337
337
  portalProviderAPI,
338
+ nodeViewPortalProviderAPI,
338
339
  eventDispatcher,
339
340
  getIntl,
340
341
  }) => {
@@ -356,6 +357,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
356
357
  dispatchAnalyticsEvent,
357
358
  dispatch,
358
359
  portalProviderAPI,
360
+ nodeViewPortalProviderAPI,
359
361
  eventDispatcher,
360
362
  pluginConfig(tableOptions),
361
363
  defaultGetEditorContainerWidth,
@@ -377,7 +379,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
377
379
  },
378
380
  {
379
381
  name: 'tablePMColResizing',
380
- plugin: ({ dispatch }) => {
382
+ plugin: ({ dispatch, nodeViewPortalProviderAPI }) => {
381
383
  const {
382
384
  fullWidthEnabled,
383
385
  tableOptions,
@@ -396,6 +398,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
396
398
  defaultGetEditorContainerWidth,
397
399
  getEditorFeatureFlags || defaultGetEditorFeatureFlags,
398
400
  api,
401
+ nodeViewPortalProviderAPI,
399
402
  editorAnalyticsAPI,
400
403
  isTableScalingEnabled || false,
401
404
  isNewColumnResizingEnabled,
@@ -410,7 +413,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
410
413
  // plugin as it is currently swallowing backspace events inside tables
411
414
  {
412
415
  name: 'tableKeymap',
413
- plugin: ({ getIntl }) => {
416
+ plugin: ({ getIntl, nodeViewPortalProviderAPI }) => {
414
417
  const {
415
418
  dragAndDropEnabled,
416
419
  isTableScalingEnabled = false,
@@ -424,6 +427,7 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
424
427
  return keymapPlugin(
425
428
  defaultGetEditorContainerWidth,
426
429
  api,
430
+ nodeViewPortalProviderAPI,
427
431
  editorAnalyticsAPI,
428
432
  dragAndDropEnabled,
429
433
  isTableScalingEnabled,
@@ -488,8 +492,10 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
488
492
  },
489
493
  {
490
494
  name: 'tableViewModeSort',
491
- plugin: () => {
492
- return api?.editorViewMode ? createViewModeSortPlugin(api) : undefined;
495
+ plugin: ({ nodeViewPortalProviderAPI }) => {
496
+ return api?.editorViewMode
497
+ ? createViewModeSortPlugin(api, nodeViewPortalProviderAPI)
498
+ : undefined;
493
499
  },
494
500
  },
495
501
  {
@@ -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
@@ -2,6 +2,7 @@ import classnames from 'classnames';
2
2
 
3
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
4
  import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
5
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
7
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
8
 
@@ -21,6 +22,7 @@ export function createPlugin(
21
22
  getEditorContainerWidth: GetEditorContainerWidth,
22
23
  getEditorFeatureFlags: GetEditorFeatureFlags,
23
24
  api: PluginInjectionAPI | undefined | null,
25
+ nodeViewPortalProviderAPI: PortalProviderAPI,
24
26
  editorAnalyticsAPI?: EditorAnalyticsAPI,
25
27
  isTableScalingEnabled?: boolean,
26
28
  isNewColumnResizingEnabled?: boolean,
@@ -76,6 +78,7 @@ export function createPlugin(
76
78
  getEditorFeatureFlags,
77
79
  isTableScalingEnabled || false,
78
80
  api,
81
+ nodeViewPortalProviderAPI,
79
82
  editorAnalyticsAPI,
80
83
  isNewColumnResizingEnabled,
81
84
  isTableAlignmentEnabled,
@@ -8,12 +8,15 @@ import { createElement } from 'react';
8
8
 
9
9
  import ReactDOM from 'react-dom';
10
10
  import { RawIntlProvider } from 'react-intl-next';
11
+ import uuid from 'uuid/v4';
11
12
 
13
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
12
14
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
13
15
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
14
16
  import { SortOrder } from '@atlaskit/editor-common/types';
15
17
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
16
18
  import { TableMap } from '@atlaskit/editor-tables/table-map';
19
+ import { fg } from '@atlaskit/platform-feature-flags';
17
20
 
18
21
  import type tablePlugin from '../../plugin';
19
22
  import { SortingIconWrapper } from '../../ui/icons/SortingIconWrapper';
@@ -28,7 +31,10 @@ import { tableViewModeSortPluginKey as key } from './plugin-key';
28
31
  import type { ViewModeSortPluginState } from './types';
29
32
  import { getTableElements, toggleSort } from './utils';
30
33
 
31
- export const createPlugin = (api: ExtractInjectionAPI<typeof tablePlugin>) => {
34
+ export const createPlugin = (
35
+ api: ExtractInjectionAPI<typeof tablePlugin>,
36
+ nodeViewPortalProviderAPI: PortalProviderAPI,
37
+ ) => {
32
38
  return new SafePlugin({
33
39
  state: {
34
40
  init: () => ({
@@ -84,40 +90,73 @@ export const createPlugin = (api: ExtractInjectionAPI<typeof tablePlugin>) => {
84
90
  const map = TableMap.get(tableNode);
85
91
  const hasMergedCells = new Set(map.map).size !== map.map.length;
86
92
  map.mapByRow[0].forEach((cell, index) => {
93
+ const decorationRenderKey = uuid();
87
94
  decs.push(
88
- Decoration.widget(cell + pos + 2, () => {
89
- const element = document.createElement('div');
90
- element.setAttribute(SORT_INDEX_DATA_ATTRIBUTE, `${index}`);
91
- element.classList.add(SORTING_ICON_CLASS_NAME);
92
- if (hasMergedCells) {
93
- element.classList.add(IS_DISABLED_CLASS_NAME);
94
- }
95
-
96
- let sortOrdered;
97
- if (index === sort[tableId]?.index) {
98
- sortOrdered = sort[tableId]?.direction;
99
- } else {
100
- sortOrdered = SortOrder.NO_ORDER;
101
- }
102
-
103
- const { getIntl } = getPluginState(oldState);
104
-
105
- ReactDOM.render(
106
- createElement(
107
- RawIntlProvider,
108
- { value: getIntl() },
109
- createElement(SortingIconWrapper, {
110
- isSortingAllowed: !hasMergedCells,
111
- sortOrdered,
112
- onClick: () => {},
113
- onKeyDown: () => {},
114
- api,
115
- }),
116
- ),
117
- element,
118
- );
119
- return element;
120
- }),
95
+ Decoration.widget(
96
+ cell + pos + 2,
97
+ () => {
98
+ const element = document.createElement('div');
99
+ element.setAttribute(SORT_INDEX_DATA_ATTRIBUTE, `${index}`);
100
+ element.classList.add(SORTING_ICON_CLASS_NAME);
101
+ if (hasMergedCells) {
102
+ element.classList.add(IS_DISABLED_CLASS_NAME);
103
+ }
104
+
105
+ let sortOrdered;
106
+ if (index === sort[tableId]?.index) {
107
+ sortOrdered = sort[tableId]?.direction;
108
+ } else {
109
+ sortOrdered = SortOrder.NO_ORDER;
110
+ }
111
+
112
+ const { getIntl } = getPluginState(oldState);
113
+
114
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
115
+ nodeViewPortalProviderAPI.render(
116
+ () =>
117
+ createElement(
118
+ RawIntlProvider,
119
+ { value: getIntl() },
120
+ createElement(SortingIconWrapper, {
121
+ isSortingAllowed: !hasMergedCells,
122
+ sortOrdered,
123
+ onClick: () => {},
124
+ onKeyDown: () => {},
125
+ api,
126
+ }),
127
+ ),
128
+ element,
129
+ decorationRenderKey,
130
+ );
131
+ } else {
132
+ ReactDOM.render(
133
+ createElement(
134
+ RawIntlProvider,
135
+ { value: getIntl() },
136
+ createElement(SortingIconWrapper, {
137
+ isSortingAllowed: !hasMergedCells,
138
+ sortOrdered,
139
+ onClick: () => {},
140
+ onKeyDown: () => {},
141
+ api,
142
+ }),
143
+ ),
144
+ element,
145
+ );
146
+ }
147
+
148
+ return element;
149
+ },
150
+ {
151
+ destroy: (node) => {
152
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
153
+ nodeViewPortalProviderAPI.remove(decorationRenderKey);
154
+ } else {
155
+ ReactDOM.unmountComponentAtNode(node as HTMLDivElement);
156
+ }
157
+ },
158
+ },
159
+ ),
121
160
  );
122
161
  });
123
162
  });
@@ -584,13 +584,11 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
584
584
 
585
585
  private createOriginalContextMenuItems = () => {
586
586
  let items: MenuItem[] = [];
587
- const { getEditorFeatureFlags } = this.props;
588
- const { tableSortColumnReorder = false } = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
589
587
  const sortColumnItems = this.createSortColumnItems();
590
588
  const backgroundColorItem = this.createBackgroundColorItem();
591
589
  const distributeColumnsItem = this.createDistributeColumnsItem();
592
590
 
593
- tableSortColumnReorder && sortColumnItems && items.push(...sortColumnItems);
591
+ sortColumnItems && items.push(...sortColumnItems);
594
592
 
595
593
  backgroundColorItem && items.push(backgroundColorItem);
596
594
 
@@ -606,8 +604,6 @@ export class ContextualMenu extends Component<Props & WrappedComponentProps, Sta
606
604
 
607
605
  distributeColumnsItem && items.push(distributeColumnsItem);
608
606
 
609
- !tableSortColumnReorder && sortColumnItems && items.push(...sortColumnItems);
610
-
611
607
  items.push(this.createClearCellsItem());
612
608
 
613
609
  return [{ items }];
@@ -93,7 +93,6 @@ type DragMenuProps = {
93
93
  tableDuplicateCellColouring?: boolean;
94
94
  shouldUseIncreasedScalingPercent?: boolean;
95
95
  isTableFixedColumnWidthsOptionEnabled?: boolean;
96
- tableSortColumnReorder?: boolean;
97
96
  ariaNotifyPlugin?: (
98
97
  message: string,
99
98
  ariaLiveElementAttributes?: AriaLiveElementAttributes,
@@ -166,7 +165,7 @@ const MapDragMenuOptionIdToMessage: Record<DragMenuOptionIdType, MessageType> =
166
165
  },
167
166
  };
168
167
 
169
- const getGroupedDragMenuConfig = (tableSortColumnReorder: boolean) => {
168
+ const getGroupedDragMenuConfig = () => {
170
169
  let groupedDragMenuConfig: DragMenuOptionIdType[][] = [
171
170
  [
172
171
  'add_row_above',
@@ -181,9 +180,7 @@ const getGroupedDragMenuConfig = (tableSortColumnReorder: boolean) => {
181
180
  ['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down'],
182
181
  ];
183
182
  const sortColumnItems: DragMenuOptionIdType[] = ['sort_column_asc', 'sort_column_desc'];
184
- tableSortColumnReorder
185
- ? groupedDragMenuConfig.unshift(sortColumnItems)
186
- : groupedDragMenuConfig.push(sortColumnItems);
183
+ groupedDragMenuConfig.unshift(sortColumnItems);
187
184
 
188
185
  return groupedDragMenuConfig;
189
186
  };
@@ -196,10 +193,9 @@ const elementBeforeIconStyles = xcss({
196
193
  const convertToDropdownItems = (
197
194
  dragMenuConfig: DragMenuConfig[],
198
195
  formatMessage: IntlShape['formatMessage'],
199
- tableSortColumnReorder: boolean = false,
200
196
  selectionRect?: Rect,
201
197
  ) => {
202
- const groupedDragMenuConfig = getGroupedDragMenuConfig(tableSortColumnReorder);
198
+ const groupedDragMenuConfig = getGroupedDragMenuConfig();
203
199
  let menuItemsArr: MenuItem[][] = [...Array(groupedDragMenuConfig.length)].map(() => []);
204
200
  let menuCallback: { [key: string]: Command } = {};
205
201
  dragMenuConfig.forEach((item) => {
@@ -286,7 +282,6 @@ const DragMenu = React.memo(
286
282
  tableDuplicateCellColouring,
287
283
  shouldUseIncreasedScalingPercent,
288
284
  isTableFixedColumnWidthsOptionEnabled,
289
- tableSortColumnReorder,
290
285
  ariaNotifyPlugin,
291
286
  isCommentEditor,
292
287
  }: DragMenuProps & WrappedComponentProps) => {
@@ -319,7 +314,6 @@ const DragMenu = React.memo(
319
314
  tableDuplicateCellColouring,
320
315
  isTableFixedColumnWidthsOptionEnabled,
321
316
  shouldUseIncreasedScalingPercent,
322
- tableSortColumnReorder,
323
317
  ariaNotifyPlugin,
324
318
  isCommentEditor,
325
319
  );
@@ -327,7 +321,6 @@ const DragMenu = React.memo(
327
321
  const { menuItems, menuCallback } = convertToDropdownItems(
328
322
  dragMenuConfig,
329
323
  formatMessage,
330
- tableSortColumnReorder,
331
324
  selectionRect,
332
325
  );
333
326
 
@@ -383,7 +376,7 @@ const DragMenu = React.memo(
383
376
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
384
377
  className={DropdownMenuSharedCssClassName.SUBMENU}
385
378
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
386
- css={dragMenuBackgroundColorStyles(tableSortColumnReorder)}
379
+ css={dragMenuBackgroundColorStyles()}
387
380
  >
388
381
  <div
389
382
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
@@ -610,9 +603,7 @@ const DragMenu = React.memo(
610
603
  }
611
604
 
612
605
  if (allowBackgroundColor) {
613
- tableSortColumnReorder
614
- ? menuItems[1].items.unshift(createBackgroundColorMenuItem())
615
- : menuItems[0].items.unshift(createBackgroundColorMenuItem());
606
+ menuItems[1].items.unshift(createBackgroundColorMenuItem());
616
607
  }
617
608
 
618
609
  // If first row, add toggle for Header row, default is true
@@ -79,11 +79,8 @@ const FloatingDragMenu = ({
79
79
  return null;
80
80
  }
81
81
 
82
- const {
83
- tableDuplicateCellColouring = false,
84
- tableWithFixedColumnWidthsOption = false,
85
- tableSortColumnReorder = false,
86
- } = getEditorFeatureFlags ? getEditorFeatureFlags() : {};
82
+ const { tableDuplicateCellColouring = false, tableWithFixedColumnWidthsOption = false } =
83
+ getEditorFeatureFlags ? getEditorFeatureFlags() : {};
87
84
 
88
85
  const shouldUseIncreasedScalingPercent =
89
86
  isTableScalingEnabled && (tableWithFixedColumnWidthsOption || isCommentEditor);
@@ -126,7 +123,6 @@ const FloatingDragMenu = ({
126
123
  tableDuplicateCellColouring={tableDuplicateCellColouring}
127
124
  shouldUseIncreasedScalingPercent={shouldUseIncreasedScalingPercent}
128
125
  isTableFixedColumnWidthsOptionEnabled={tableWithFixedColumnWidthsOption}
129
- tableSortColumnReorder={tableSortColumnReorder}
130
126
  ariaNotifyPlugin={ariaNotifyPlugin}
131
127
  api={api}
132
128
  isCommentEditor={isCommentEditor || false}
@@ -22,18 +22,16 @@ export const cellColourPreviewStyles = (selectedColor: string) =>
22
22
  });
23
23
 
24
24
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
25
- export const dragMenuBackgroundColorStyles = (tableSortColumnReorder: boolean = false) => css`
25
+ export const dragMenuBackgroundColorStyles = () => css`
26
26
  .${ClassName.DRAG_SUBMENU} {
27
27
  border-radius: ${token('border.radius', '3px')};
28
28
  background: ${token('elevation.surface.overlay', 'white')};
29
29
  box-shadow: ${token('elevation.shadow.overlay', `0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`)};
30
30
  display: block;
31
31
  position: absolute;
32
- top: ${tableSortColumnReorder
33
- ? TABLE_DRAG_MENU_PADDING_TOP +
34
- TABLE_DRAG_MENU_SORT_GROUP_HEIGHT +
35
- TABLE_DRAG_MENU_MENU_GROUP_BEFORE_HEIGHT
36
- : 0}px; // move the submenu down when 'sort increasing/decreasing' appear before background color picker
32
+ top: ${TABLE_DRAG_MENU_PADDING_TOP +
33
+ TABLE_DRAG_MENU_SORT_GROUP_HEIGHT +
34
+ TABLE_DRAG_MENU_MENU_GROUP_BEFORE_HEIGHT}px; // move the submenu down when 'sort increasing/decreasing' appear before background color picker
37
35
  left: ${dragMenuDropdownWidth}px;
38
36
  padding: ${token('space.100', '8px')};
39
37
 
@@ -3,8 +3,10 @@ import { createElement } from 'react';
3
3
  import ReactDOM from 'react-dom';
4
4
  import { RawIntlProvider } from 'react-intl-next';
5
5
  import type { IntlShape } from 'react-intl-next';
6
+ import uuid from 'uuid/v4';
6
7
 
7
8
  import type { CellAttributes } from '@atlaskit/adf-schema';
9
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
8
10
  import { nonNullable } from '@atlaskit/editor-common/utils';
9
11
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
10
12
  // @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
@@ -18,6 +20,7 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
18
20
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
19
21
  import { TableMap } from '@atlaskit/editor-tables/table-map';
20
22
  import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
23
+ import { fg } from '@atlaskit/platform-feature-flags';
21
24
 
22
25
  import type { Cell, CellColumnPositioning } from '../types';
23
26
  import { TableCssClassName as ClassName, TableDecorations } from '../types';
@@ -308,6 +311,7 @@ export const createResizeHandleDecoration = (
308
311
  columnEndIndexTarget: Omit<CellColumnPositioning, 'left'>,
309
312
  includeTooltip: boolean = false,
310
313
  getIntl: () => IntlShape,
314
+ nodeViewPortalProviderAPI: PortalProviderAPI,
311
315
  ): [Decoration[], Decoration[]] => {
312
316
  const emptyResult: [Decoration[], Decoration[]] = [[], []];
313
317
  const table = findTable(tr.selection);
@@ -327,23 +331,41 @@ export const createResizeHandleDecoration = (
327
331
  cellPos: number,
328
332
  cellNode: PmNode,
329
333
  ): Decoration => {
334
+ const decorationRenderKey = uuid();
330
335
  const position = cellPos + cellNode.nodeSize - 1;
331
336
  return Decoration.widget(
332
337
  position,
333
338
  () => {
334
339
  const element = document.createElement('div');
335
- ReactDOM.render(
336
- createElement(
337
- RawIntlProvider,
338
- { value: getIntl() },
339
- createElement(ColumnResizeWidget, {
340
- startIndex: cellColumnPositioning.left,
341
- endIndex: cellColumnPositioning.right,
342
- includeTooltip,
343
- }),
344
- ),
345
- element,
346
- );
340
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
341
+ nodeViewPortalProviderAPI.render(
342
+ () =>
343
+ createElement(
344
+ RawIntlProvider,
345
+ { value: getIntl() },
346
+ createElement(ColumnResizeWidget, {
347
+ startIndex: cellColumnPositioning.left,
348
+ endIndex: cellColumnPositioning.right,
349
+ includeTooltip,
350
+ }),
351
+ ),
352
+ element,
353
+ decorationRenderKey,
354
+ );
355
+ } else {
356
+ ReactDOM.render(
357
+ createElement(
358
+ RawIntlProvider,
359
+ { value: getIntl() },
360
+ createElement(ColumnResizeWidget, {
361
+ startIndex: cellColumnPositioning.left,
362
+ endIndex: cellColumnPositioning.right,
363
+ includeTooltip,
364
+ }),
365
+ ),
366
+ element,
367
+ );
368
+ }
347
369
  return element;
348
370
  },
349
371
  {
@@ -351,7 +373,11 @@ export const createResizeHandleDecoration = (
351
373
  TableDecorations.COLUMN_RESIZING_HANDLE_WIDGET
352
374
  }_${rowIndex}_${columnIndex}_${includeTooltip ? 'with' : 'no'}-tooltip`,
353
375
  destroy: (node) => {
354
- ReactDOM.unmountComponentAtNode(node as HTMLDivElement);
376
+ if (fg('platform_editor_react18_plugin_portalprovider')) {
377
+ nodeViewPortalProviderAPI.remove(decorationRenderKey);
378
+ } else {
379
+ ReactDOM.unmountComponentAtNode(node as HTMLDivElement);
380
+ }
355
381
  },
356
382
  },
357
383
  );
@@ -165,7 +165,6 @@ export const getDragMenuConfig = (
165
165
  tableDuplicateCellColouring = false,
166
166
  isTableFixedColumnWidthsOptionEnabled = false,
167
167
  shouldUseIncreasedScalingPercent = false,
168
- tableSortColumnReorder = false,
169
168
  ariaNotifyPlugin?: (
170
169
  message: string,
171
170
  ariaLiveElementAttributes?: AriaLiveElementAttributes,
@@ -417,7 +416,7 @@ export const getDragMenuConfig = (
417
416
  ];
418
417
 
419
418
  let allConfigs = [...restConfigs];
420
- tableSortColumnReorder ? allConfigs.unshift(...sortConfigs) : allConfigs.push(...sortConfigs);
419
+ allConfigs.unshift(...sortConfigs);
421
420
 
422
421
  return allConfigs.filter(Boolean) as DragMenuConfig[];
423
422
  };