@atlaskit/editor-plugin-table 5.3.29 → 5.3.31

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 (75) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/event-handlers.js +10 -2
  3. package/dist/cjs/plugins/table/nodeviews/ExternalDropTargets.js +75 -0
  4. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +75 -4
  5. package/dist/cjs/plugins/table/nodeviews/TableRow.js +36 -112
  6. package/dist/cjs/plugins/table/nodeviews/TableStickyScrollbar.js +9 -9
  7. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
  8. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
  9. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
  10. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -10
  11. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +61 -0
  12. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +21 -15
  13. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  14. package/dist/cjs/plugins/table/ui/consts.js +4 -2
  15. package/dist/es2019/plugins/table/event-handlers.js +11 -3
  16. package/dist/es2019/plugins/table/nodeviews/ExternalDropTargets.js +64 -0
  17. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +80 -5
  18. package/dist/es2019/plugins/table/nodeviews/TableRow.js +4 -78
  19. package/dist/es2019/plugins/table/nodeviews/TableStickyScrollbar.js +6 -6
  20. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
  21. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
  22. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
  23. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +58 -8
  24. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +55 -0
  25. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -11
  26. package/dist/es2019/plugins/table/ui/common-styles.js +2 -2
  27. package/dist/es2019/plugins/table/ui/consts.js +3 -1
  28. package/dist/esm/plugins/table/event-handlers.js +10 -2
  29. package/dist/esm/plugins/table/nodeviews/ExternalDropTargets.js +65 -0
  30. package/dist/esm/plugins/table/nodeviews/TableComponent.js +76 -5
  31. package/dist/esm/plugins/table/nodeviews/TableRow.js +36 -112
  32. package/dist/esm/plugins/table/nodeviews/TableStickyScrollbar.js +9 -9
  33. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
  34. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
  35. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
  36. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -11
  37. package/dist/esm/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +52 -0
  38. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +21 -15
  39. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  40. package/dist/esm/plugins/table/ui/consts.js +3 -1
  41. package/dist/types/plugins/table/nodeviews/ExternalDropTargets.d.ts +9 -0
  42. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -0
  43. package/dist/types/plugins/table/nodeviews/TableRow.d.ts +0 -4
  44. package/dist/types/plugins/table/nodeviews/TableStickyScrollbar.d.ts +3 -3
  45. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  46. package/dist/types/plugins/table/ui/TableFloatingControls/RowDropTarget/index.d.ts +8 -0
  47. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -1
  48. package/dist/types/plugins/table/ui/consts.d.ts +2 -0
  49. package/dist/types/plugins/table/utils/column-controls.d.ts +2 -2
  50. package/dist/types-ts4.5/plugins/table/nodeviews/ExternalDropTargets.d.ts +9 -0
  51. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +1 -0
  52. package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +0 -4
  53. package/dist/types-ts4.5/plugins/table/nodeviews/TableStickyScrollbar.d.ts +3 -3
  54. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  55. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowDropTarget/index.d.ts +8 -0
  56. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -1
  57. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
  58. package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +2 -2
  59. package/package.json +3 -3
  60. package/src/__tests__/unit/ui/RowDragControls.tsx +2 -0
  61. package/src/plugins/table/event-handlers.ts +14 -1
  62. package/src/plugins/table/nodeviews/ExternalDropTargets.tsx +86 -0
  63. package/src/plugins/table/nodeviews/TableComponent.tsx +92 -7
  64. package/src/plugins/table/nodeviews/TableRow.ts +2 -65
  65. package/src/plugins/table/nodeviews/TableStickyScrollbar.ts +6 -6
  66. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +0 -7
  67. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +1 -0
  68. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +2 -7
  69. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +80 -21
  70. package/src/plugins/table/ui/TableFloatingControls/RowDropTarget/index.tsx +62 -0
  71. package/src/plugins/table/ui/TableFloatingControls/index.tsx +29 -8
  72. package/src/plugins/table/ui/common-styles.ts +2 -1
  73. package/src/plugins/table/ui/consts.ts +3 -0
  74. package/src/plugins/table/utils/column-controls.ts +2 -2
  75. package/tsconfig.app.json +2 -2
@@ -9,7 +9,6 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
9
9
  */
10
10
  private isHeaderRow;
11
11
  private isStickyHeaderEnabled;
12
- private isDragAndDropEnabled;
13
12
  private editorScrollableElement?;
14
13
  private colControlsOffset;
15
14
  private focused;
@@ -23,7 +22,6 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
23
22
  private listening;
24
23
  private padding;
25
24
  private top;
26
- private dropTargetCleanup?;
27
25
  /**
28
26
  * Methods: Nodeview Lifecycle
29
27
  */
@@ -36,8 +34,6 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
36
34
  /**
37
35
  * Methods
38
36
  */
39
- private addDropTarget;
40
- private getCurrentData;
41
37
  private headerRowMouseScrollEnd;
42
38
  private headerRowMouseScroll;
43
39
  private subscribe;
@@ -13,9 +13,9 @@ export declare class TableStickyScrollbar {
13
13
  scrollLeft(left: number): void;
14
14
  private init;
15
15
  private createIntersectionObserver;
16
- private deleteIntesactionObserver;
17
- private sentenialBottomCallback;
18
- private sentenialTopCallback;
16
+ private deleteIntersectionObserver;
17
+ private sentinelBottomCallback;
18
+ private sentinelTopCallback;
19
19
  private toggle;
20
20
  private hide;
21
21
  private show;
@@ -7,11 +7,11 @@ type DragControlsProps = {
7
7
  editorView: EditorView;
8
8
  tableRef: HTMLTableElement;
9
9
  tableNode?: PmNode;
10
+ tableWidth: number;
10
11
  tableActive?: boolean;
11
12
  hoveredCell?: CellHoverMeta;
12
13
  isInDanger?: boolean;
13
14
  isResizing?: boolean;
14
- hasHeaderRow?: boolean;
15
15
  hoverRows: (rows: number[], danger?: boolean) => void;
16
16
  selectRow: (row: number, expand: boolean) => void;
17
17
  updateCellHoverLocation: (rowIndex: number) => void;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export type RowDropTargetProps = {
3
+ index: number;
4
+ localId?: string;
5
+ style?: React.CSSProperties;
6
+ };
7
+ declare const RowDropTarget: ({ index, localId, style }: RowDropTargetProps) => JSX.Element;
8
+ export default RowDropTarget;
@@ -26,11 +26,13 @@ export interface Props {
26
26
  insertRowButtonIndex?: number;
27
27
  }
28
28
  interface State {
29
- tableHeight: number;
29
+ tableWrapperWidth: number;
30
+ tableWrapperHeight: number;
30
31
  }
31
32
  export default class TableFloatingControls extends Component<Props, State> {
32
33
  static displayName: string;
33
34
  private resizeObserver?;
35
+ constructor(props: Props);
34
36
  componentDidMount(): void;
35
37
  componentDidUpdate(): void;
36
38
  private tryInitResizeObserver;
@@ -47,8 +47,10 @@ export declare const stickyRowOffsetTop = 8;
47
47
  export declare const stickyHeaderBorderBottomWidth = 1;
48
48
  export declare const tableOverflowShadowWidth = 8;
49
49
  export declare const tableOverflowShadowWidthWide = 32;
50
+ export declare const dropTargetsZIndex = 14;
50
51
  export declare const TABLE_SNAP_GAP = 9;
51
52
  export declare const TABLE_HIGHLIGHT_GAP = 10;
52
53
  export declare const TABLE_HIGHLIGHT_TOLERANCE = 2;
53
54
  export declare const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
54
55
  export declare const dragMenuDropdownWidth = 240;
56
+ export declare const dropTargetExtendedWidth = 150;
@@ -1,5 +1,5 @@
1
- import { Selection } from '@atlaskit/editor-prosemirror/state';
2
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
3
  export declare const getColumnsWidths: (view: EditorView) => Array<number | undefined>;
4
4
  export declare const isColumnDeleteButtonVisible: (selection: Selection) => boolean;
5
5
  export declare const getColumnDeleteButtonParams: (columnsWidths: Array<number | undefined>, selection: Selection) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.3.29",
3
+ "version": "5.3.31",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^32.0.0",
31
31
  "@atlaskit/custom-steps": "^0.0.2",
32
- "@atlaskit/editor-common": "^76.20.0",
32
+ "@atlaskit/editor-common": "^76.21.0",
33
33
  "@atlaskit/editor-palette": "1.5.2",
34
34
  "@atlaskit/editor-plugin-analytics": "^0.3.0",
35
35
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",
@@ -42,8 +42,8 @@
42
42
  "@atlaskit/icon": "^21.12.0",
43
43
  "@atlaskit/platform-feature-flags": "^0.2.1",
44
44
  "@atlaskit/pragmatic-drag-and-drop": "^0.24.0",
45
+ "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^0.7.0",
45
46
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.12.0",
46
- "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^0.6.4",
47
47
  "@atlaskit/primitives": "^1.10.0",
48
48
  "@atlaskit/theme": "^12.6.0",
49
49
  "@atlaskit/tokens": "^1.28.0",
@@ -74,6 +74,7 @@ describe('NumberColumn', () => {
74
74
  hoverRows={jest.fn()}
75
75
  selectRow={jest.fn()}
76
76
  updateCellHoverLocation={jest.fn()}
77
+ tableWidth={760}
77
78
  />
78
79
  </IntlProvider>,
79
80
  );
@@ -110,6 +111,7 @@ describe('NumberColumn', () => {
110
111
  hoverRows={jest.fn()}
111
112
  selectRow={jest.fn()}
112
113
  updateCellHoverLocation={jest.fn()}
114
+ tableWidth={760}
113
115
  />
114
116
  </IntlProvider>,
115
117
  );
@@ -533,6 +533,20 @@ const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
533
533
  target as HTMLElement,
534
534
  ) as HTMLTableCellElement | null;
535
535
  const tableRef = getPluginState(view.state).tableRef;
536
+ const { hoveredCell, tableNode } = getPluginState(view.state);
537
+
538
+ const tableElement = closestElement(
539
+ target as HTMLElement,
540
+ 'table',
541
+ ) as HTMLTableElement;
542
+
543
+ // hover will only trigger if target localId is the same with selected localId
544
+ if (
545
+ tableElement?.dataset?.tableLocalId &&
546
+ tableElement.dataset.tableLocalId !== tableNode?.attrs.localId
547
+ ) {
548
+ return;
549
+ }
536
550
 
537
551
  if (!maybeTableCell || !tableRef) {
538
552
  return;
@@ -544,7 +558,6 @@ const trackCellLocation = (view: EditorView, mouseEvent: Event) => {
544
558
  'tr',
545
559
  ) as HTMLTableRowElement;
546
560
  const rowIndex = rowElement && rowElement.rowIndex;
547
- const { hoveredCell } = getPluginState(view.state);
548
561
 
549
562
  const colHeight = tableRef.offsetHeight;
550
563
  const colWidth = maybeTableCell.offsetWidth;
@@ -0,0 +1,86 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+ import { tableMarginTop } from '@atlaskit/editor-common/styles';
4
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
7
+
8
+ import type { DraggableSourceData } from '../types';
9
+ import { dropTargetExtendedWidth, dropTargetsZIndex } from '../ui/consts';
10
+ import { ColumnDropTarget } from '../ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget';
11
+ import { getColumnsWidths } from '../utils';
12
+
13
+ export const ExternalDropTargets = ({
14
+ editorView,
15
+ node,
16
+ getScrollOffset,
17
+ getTableWrapperWidth,
18
+ }: {
19
+ editorView: EditorView;
20
+ node?: PMNode;
21
+ getScrollOffset: () => number;
22
+ getTableWrapperWidth: () => number;
23
+ }) => {
24
+ const [isDragging, setIsDragging] = useState(false);
25
+ const currentNodeLocalId = node?.attrs.localId;
26
+
27
+ useEffect(() => {
28
+ return monitorForElements({
29
+ canMonitor({ source }) {
30
+ const { type, indexes, localId } =
31
+ source.data as Partial<DraggableSourceData>;
32
+ return (
33
+ type === 'table-column' &&
34
+ !!indexes?.length &&
35
+ localId === currentNodeLocalId
36
+ );
37
+ },
38
+ onDragStart() {
39
+ setIsDragging(true);
40
+ },
41
+ onDrop() {
42
+ setIsDragging(false);
43
+ },
44
+ });
45
+ }, [currentNodeLocalId, editorView]);
46
+
47
+ if (!isDragging) {
48
+ return null;
49
+ }
50
+
51
+ const colWidths = getColumnsWidths(editorView);
52
+
53
+ return (
54
+ <div
55
+ style={{
56
+ width: getTableWrapperWidth(),
57
+ overflow: 'hidden',
58
+ position: 'absolute',
59
+ top: `-${dropTargetExtendedWidth - tableMarginTop}px`,
60
+ pointerEvents: 'auto',
61
+ zIndex: `${dropTargetsZIndex}`,
62
+ }}
63
+ >
64
+ <div
65
+ style={{
66
+ display: 'flex',
67
+ // move drop targets based on table wrapper scroll
68
+ marginLeft: `-${getScrollOffset()}px`,
69
+ }}
70
+ >
71
+ {colWidths?.map((width, index) => {
72
+ return (
73
+ <ColumnDropTarget
74
+ key={index}
75
+ index={index}
76
+ localId={currentNodeLocalId}
77
+ width={width}
78
+ height={dropTargetExtendedWidth}
79
+ marginTop={0}
80
+ />
81
+ );
82
+ })}
83
+ </div>
84
+ </div>
85
+ );
86
+ };
@@ -33,6 +33,13 @@ import {
33
33
  } from '@atlaskit/editor-shared-styles';
34
34
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
35
35
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
36
+ import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
37
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
38
+ import {
39
+ autoScrollForElements,
40
+ autoScrollWindowForElements,
41
+ } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
42
+ import { unsafeOverflowAutoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element';
36
43
 
37
44
  import { autoSizeTable, clearHoverSelection } from '../commands';
38
45
  import { getPluginState } from '../pm-plugins/plugin-factory';
@@ -52,9 +59,10 @@ import {
52
59
  } from '../pm-plugins/table-resizing/utils';
53
60
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
54
61
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
55
- import type { PluginInjectionAPI } from '../types';
62
+ import type { DraggableSourceData, PluginInjectionAPI } from '../types';
56
63
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
57
64
  import {
65
+ dropTargetExtendedWidth,
58
66
  tableOverflowShadowWidth,
59
67
  tableOverflowShadowWidthWide,
60
68
  } from '../ui/consts';
@@ -67,6 +75,7 @@ import {
67
75
  tablesHaveDifferentNoOfColumns,
68
76
  } from '../utils';
69
77
 
78
+ import { ExternalDropTargets } from './ExternalDropTargets';
70
79
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
71
80
  import { TableContainer } from './TableContainer';
72
81
  import { TableStickyScrollbar } from './TableStickyScrollbar';
@@ -129,6 +138,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
129
138
  private isInitialOverflowSent: boolean;
130
139
  private initialOverflowCaptureTimerId?: ReturnType<typeof setTimeout>;
131
140
 
141
+ private dragAndDropCleanupFn?: CleanupFn;
142
+
132
143
  constructor(props: ComponentProps) {
133
144
  super(props);
134
145
  const { options, containerWidth, getNode } = props;
@@ -160,7 +171,14 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
160
171
  }
161
172
 
162
173
  componentDidMount() {
163
- const { allowColumnResizing, eventDispatcher, options } = this.props;
174
+ const {
175
+ allowColumnResizing,
176
+ eventDispatcher,
177
+ options,
178
+ isDragAndDropEnabled,
179
+ getNode,
180
+ } = this.props;
181
+
164
182
  if (allowColumnResizing && this.wrapper && !isIE11) {
165
183
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
166
184
  passive: true,
@@ -174,6 +192,53 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
174
192
  );
175
193
  }
176
194
  }
195
+
196
+ if (isDragAndDropEnabled) {
197
+ this.dragAndDropCleanupFn = combine(
198
+ autoScrollForElements({
199
+ element: this.wrapper,
200
+ canScroll: ({ source }) => {
201
+ const { localId, type } =
202
+ source.data as Partial<DraggableSourceData>;
203
+ const node = getNode();
204
+ return localId === node?.attrs.localId && type === 'table-column';
205
+ },
206
+ }),
207
+ autoScrollWindowForElements({
208
+ canScroll: ({ source }) => {
209
+ const { localId, type } =
210
+ source.data as Partial<DraggableSourceData>;
211
+ const node = getNode();
212
+ return localId === node?.attrs.localId && type === 'table-row';
213
+ },
214
+ }),
215
+ unsafeOverflowAutoScrollForElements({
216
+ element: this.wrapper,
217
+ canScroll: ({ source }) => {
218
+ const { localId } = source.data as Partial<DraggableSourceData>;
219
+ const node = getNode();
220
+ return localId === node?.attrs.localId;
221
+ },
222
+ getOverflow: () => ({
223
+ fromTopEdge: {
224
+ top: dropTargetExtendedWidth,
225
+ right: dropTargetExtendedWidth,
226
+ left: dropTargetExtendedWidth,
227
+ },
228
+ fromRightEdge: {
229
+ right: dropTargetExtendedWidth,
230
+ top: dropTargetExtendedWidth,
231
+ bottom: dropTargetExtendedWidth,
232
+ },
233
+ fromLeftEdge: {
234
+ top: dropTargetExtendedWidth,
235
+ left: dropTargetExtendedWidth,
236
+ bottom: dropTargetExtendedWidth,
237
+ },
238
+ }),
239
+ }),
240
+ );
241
+ }
177
242
  }
178
243
 
179
244
  if (allowColumnResizing) {
@@ -207,11 +272,20 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
207
272
  }
208
273
 
209
274
  componentWillUnmount() {
210
- const { allowColumnResizing, eventDispatcher, options } = this.props;
275
+ const {
276
+ allowColumnResizing,
277
+ eventDispatcher,
278
+ options,
279
+ isDragAndDropEnabled,
280
+ } = this.props;
211
281
  if (this.wrapper && !isIE11) {
212
282
  this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
213
283
  }
214
284
 
285
+ if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
286
+ this.dragAndDropCleanupFn();
287
+ }
288
+
215
289
  if (getBooleanFF('platform.editor.table-sticky-scrollbar')) {
216
290
  if (this.stickyScrollbar) {
217
291
  this.stickyScrollbar.dispose();
@@ -509,9 +583,18 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
509
583
  )}
510
584
 
511
585
  {allowControls && rowControls}
512
-
513
- {isDragAndDropEnabled && allowControls && colControls}
514
-
586
+ {isDragAndDropEnabled && (
587
+ <ExternalDropTargets
588
+ editorView={view}
589
+ node={node}
590
+ getScrollOffset={() => {
591
+ return this.wrapper?.scrollLeft || 0;
592
+ }}
593
+ getTableWrapperWidth={() => {
594
+ return this.wrapper?.clientWidth || 760;
595
+ }}
596
+ />
597
+ )}
515
598
  <div
516
599
  style={shadowStyle(showBeforeShadow)}
517
600
  className={ClassName.TABLE_LEFT_SHADOW}
@@ -544,7 +627,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
544
627
  }
545
628
  }
546
629
  }}
547
- />
630
+ >
631
+ {allowControls && colControls}
632
+ </div>
548
633
  {getBooleanFF('platform.editor.table-sticky-scrollbar') && (
549
634
  <div
550
635
  className={ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER}
@@ -6,8 +6,6 @@ import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
6
6
  import { browser } from '@atlaskit/editor-common/utils';
7
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
9
- import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
10
- import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
11
9
 
12
10
  import { getPluginState } from '../pm-plugins/plugin-factory';
13
11
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
@@ -16,7 +14,7 @@ import {
16
14
  syncStickyRowToTable,
17
15
  updateStickyMargins as updateTableMargin,
18
16
  } from '../pm-plugins/table-resizing/utils/dom';
19
- import type { DraggableSourceData, TablePluginState } from '../types';
17
+ import type { TablePluginState } from '../types';
20
18
  import { TableCssClassName as ClassName, TableCssClassName } from '../types';
21
19
  import {
22
20
  STICKY_HEADER_TOGGLE_TOLERANCE_MS,
@@ -53,10 +51,9 @@ export default class TableRow
53
51
  this.isHeaderRow = supportedHeaderRow(node);
54
52
  this.isSticky = false;
55
53
 
56
- const { pluginConfig, isDragAndDropEnabled } = getPluginState(view.state);
54
+ const { pluginConfig } = getPluginState(view.state);
57
55
 
58
56
  this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
59
- this.isDragAndDropEnabled = !!isDragAndDropEnabled;
60
57
 
61
58
  if (this.isHeaderRow) {
62
59
  this.dom.setAttribute('data-header-row', 'true');
@@ -64,10 +61,6 @@ export default class TableRow
64
61
  this.subscribe();
65
62
  }
66
63
  }
67
-
68
- if (this.isDragAndDropEnabled) {
69
- this.addDropTarget(this.contentDOM);
70
- }
71
64
  }
72
65
 
73
66
  /**
@@ -75,8 +68,6 @@ export default class TableRow
75
68
  */
76
69
  private isHeaderRow: boolean;
77
70
  private isStickyHeaderEnabled: boolean;
78
- // @ts-ignore
79
- private isDragAndDropEnabled: boolean;
80
71
  private editorScrollableElement?: HTMLElement | Window;
81
72
  private colControlsOffset = 0;
82
73
  private focused = false;
@@ -93,7 +84,6 @@ export default class TableRow
93
84
  private listening = false;
94
85
  private padding: number = 0;
95
86
  private top: number = 0;
96
- private dropTargetCleanup?: () => void;
97
87
 
98
88
  /**
99
89
  * Methods: Nodeview Lifecycle
@@ -140,9 +130,6 @@ export default class TableRow
140
130
 
141
131
  this.emitOff(true);
142
132
  }
143
-
144
- // If a drop target cleanup method has been set then we should call it.
145
- this.dropTargetCleanup?.();
146
133
  }
147
134
 
148
135
  ignoreMutation(
@@ -181,56 +168,6 @@ export default class TableRow
181
168
  /**
182
169
  * Methods
183
170
  */
184
-
185
- private addDropTarget(element: HTMLElement) {
186
- const pos = this.getPos()!;
187
- if (!Number.isFinite(pos)) {
188
- return;
189
- }
190
-
191
- if (this.dropTargetCleanup) {
192
- this.dropTargetCleanup();
193
- }
194
-
195
- this.dropTargetCleanup = dropTargetForElements({
196
- element: element,
197
- canDrop: ({ source }) => {
198
- const data = source.data as DraggableSourceData;
199
- const { localId, targetIndex } = this.getCurrentData();
200
- return (
201
- // Only draggables of row type can be dropped on this target
202
- data.type === 'table-row' &&
203
- // Only draggables which came from the same table can be dropped on this target
204
- data.localId === localId &&
205
- // Only draggables which DO NOT include this drop targets index can be dropped
206
- !!data.indexes?.length &&
207
- data.indexes?.indexOf(targetIndex) === -1
208
- );
209
- },
210
- getIsSticky: () => true,
211
- getData: ({ input, element }) => {
212
- const { localId, targetIndex } = this.getCurrentData();
213
- const data = {
214
- localId,
215
- type: 'table-row',
216
- targetIndex,
217
- };
218
- return attachClosestEdge(data, {
219
- input,
220
- element,
221
- allowedEdges: ['top', 'bottom'],
222
- });
223
- },
224
- });
225
- }
226
-
227
- private getCurrentData() {
228
- const resolvedPos = this.view.state.doc.resolve(this.getPos()!);
229
- const targetIndex = resolvedPos.index();
230
- const localId = resolvedPos.parent.attrs.localId;
231
- return { targetIndex, localId };
232
- }
233
-
234
171
  private headerRowMouseScrollEnd = debounce(() => {
235
172
  this.dom.classList.remove('no-pointer-events');
236
173
  }, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT);
@@ -38,7 +38,7 @@ export class TableStickyScrollbar {
38
38
  this.handleScrollDebounced.cancel();
39
39
  }
40
40
 
41
- this.deleteIntesactionObserver();
41
+ this.deleteIntersectionObserver();
42
42
  }
43
43
 
44
44
  scrollLeft(left: number) {
@@ -95,7 +95,7 @@ export class TableStickyScrollbar {
95
95
  ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM,
96
96
  )
97
97
  ) {
98
- this.sentenialBottomCallback(entry);
98
+ this.sentinelBottomCallback(entry);
99
99
  }
100
100
 
101
101
  if (
@@ -103,7 +103,7 @@ export class TableStickyScrollbar {
103
103
  ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
104
104
  )
105
105
  ) {
106
- this.sentenialTopCallback(entry);
106
+ this.sentinelTopCallback(entry);
107
107
  }
108
108
  });
109
109
  },
@@ -123,7 +123,7 @@ export class TableStickyScrollbar {
123
123
  );
124
124
  }
125
125
 
126
- private deleteIntesactionObserver() {
126
+ private deleteIntersectionObserver() {
127
127
  if (this.intersectionObserver) {
128
128
  if (this.sentinels.bottom) {
129
129
  this.intersectionObserver.unobserve(this.sentinels.bottom);
@@ -132,7 +132,7 @@ export class TableStickyScrollbar {
132
132
  }
133
133
  }
134
134
 
135
- private sentenialBottomCallback(entry: IntersectionObserverEntry) {
135
+ private sentinelBottomCallback(entry: IntersectionObserverEntry) {
136
136
  const sentinelIsAboveScrollArea =
137
137
  entry.boundingClientRect.top < (entry.rootBounds?.top || 0);
138
138
 
@@ -145,7 +145,7 @@ export class TableStickyScrollbar {
145
145
  this.toggle();
146
146
  }
147
147
 
148
- private sentenialTopCallback(entry: IntersectionObserverEntry) {
148
+ private sentinelTopCallback(entry: IntersectionObserverEntry) {
149
149
  const sentinelIsBelowScrollArea =
150
150
  (entry.rootBounds?.bottom || 0) < entry.boundingClientRect.top;
151
151
 
@@ -8,7 +8,6 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
8
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
9
9
  import { getCellsInRow } from '@atlaskit/editor-tables/utils';
10
10
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
11
- import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
12
11
 
13
12
  import type { DraggableSourceData } from '../../types';
14
13
  import {
@@ -109,14 +108,9 @@ export const createPlugin = (
109
108
  return localId === tableNode?.attrs.localId;
110
109
  },
111
110
  onDragStart: ({ location }) => {
112
- autoScroller.start({ input: location.current.input });
113
111
  toggleDragMenu(false)(editorView.state, editorView.dispatch);
114
112
  },
115
113
  onDrag(event) {
116
- autoScroller.updateInput({
117
- input: event.location.current.input,
118
- });
119
-
120
114
  const data = getDraggableDataFromEvent(event);
121
115
  // If no data can be found then it's most like we do not want to perform any drag actions
122
116
  if (!data) {
@@ -138,7 +132,6 @@ export const createPlugin = (
138
132
  );
139
133
  },
140
134
  onDrop(event) {
141
- autoScroller.stop();
142
135
  const data = getDraggableDataFromEvent(event);
143
136
 
144
137
  // If no data can be found then it's most like we do not want to perform any drop action
@@ -65,6 +65,7 @@ export const ColumnDropTarget: React.FC<Props> = ({
65
65
  height: height && `${height}px`,
66
66
  marginTop: marginTop && `${marginTop}px`,
67
67
  pointerEvents: 'auto',
68
+ flexShrink: 0,
68
69
  }}
69
70
  data-drop-target-index={index}
70
71
  data-drop-target-localid={localId}
@@ -1,7 +1,5 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
2
 
3
- import ReactDOM from 'react-dom';
4
-
5
3
  import type { TableColumnOrdering } from '@atlaskit/custom-steps';
6
4
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
7
5
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
@@ -121,13 +119,11 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
121
119
  ? stickyHeader.top
122
120
  : undefined;
123
121
 
124
- const mountTo = (tableRef && tableRef?.parentElement) || document.body;
125
-
126
122
  if (!tableActive) {
127
123
  return null;
128
124
  }
129
125
 
130
- return ReactDOM.createPortal(
126
+ return (
131
127
  <div
132
128
  className={ClassName.DRAG_COLUMN_CONTROLS_WRAPPER}
133
129
  data-testid="table-floating-column-controls-wrapper"
@@ -155,8 +151,7 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
155
151
  colWidths={colWidths}
156
152
  />
157
153
  )}
158
- </div>,
159
- mountTo,
154
+ </div>
160
155
  );
161
156
  };
162
157