@atlaskit/editor-plugin-table 5.3.28 → 5.3.30

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 (71) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/nodeviews/ExternalDropTargets.js +75 -0
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +75 -4
  4. package/dist/cjs/plugins/table/nodeviews/TableRow.js +36 -112
  5. package/dist/cjs/plugins/table/nodeviews/TableStickyScrollbar.js +9 -9
  6. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
  7. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
  8. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
  9. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -10
  10. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +61 -0
  11. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +21 -15
  12. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  13. package/dist/cjs/plugins/table/ui/consts.js +4 -2
  14. package/dist/es2019/plugins/table/nodeviews/ExternalDropTargets.js +64 -0
  15. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +80 -5
  16. package/dist/es2019/plugins/table/nodeviews/TableRow.js +4 -78
  17. package/dist/es2019/plugins/table/nodeviews/TableStickyScrollbar.js +6 -6
  18. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
  19. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
  20. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
  21. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +58 -8
  22. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +55 -0
  23. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +17 -11
  24. package/dist/es2019/plugins/table/ui/common-styles.js +2 -2
  25. package/dist/es2019/plugins/table/ui/consts.js +3 -1
  26. package/dist/esm/plugins/table/nodeviews/ExternalDropTargets.js +65 -0
  27. package/dist/esm/plugins/table/nodeviews/TableComponent.js +76 -5
  28. package/dist/esm/plugins/table/nodeviews/TableRow.js +36 -112
  29. package/dist/esm/plugins/table/nodeviews/TableStickyScrollbar.js +9 -9
  30. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +0 -8
  31. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -1
  32. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +2 -4
  33. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -11
  34. package/dist/esm/plugins/table/ui/TableFloatingControls/RowDropTarget/index.js +52 -0
  35. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +21 -15
  36. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  37. package/dist/esm/plugins/table/ui/consts.js +3 -1
  38. package/dist/types/plugins/table/nodeviews/ExternalDropTargets.d.ts +9 -0
  39. package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +1 -0
  40. package/dist/types/plugins/table/nodeviews/TableRow.d.ts +0 -4
  41. package/dist/types/plugins/table/nodeviews/TableStickyScrollbar.d.ts +3 -3
  42. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  43. package/dist/types/plugins/table/ui/TableFloatingControls/RowDropTarget/index.d.ts +8 -0
  44. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -1
  45. package/dist/types/plugins/table/ui/consts.d.ts +2 -0
  46. package/dist/types/plugins/table/utils/column-controls.d.ts +2 -2
  47. package/dist/types-ts4.5/plugins/table/nodeviews/ExternalDropTargets.d.ts +9 -0
  48. package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +1 -0
  49. package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +0 -4
  50. package/dist/types-ts4.5/plugins/table/nodeviews/TableStickyScrollbar.d.ts +3 -3
  51. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -1
  52. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowDropTarget/index.d.ts +8 -0
  53. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -1
  54. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
  55. package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +2 -2
  56. package/package.json +3 -3
  57. package/src/__tests__/unit/ui/RowDragControls.tsx +2 -0
  58. package/src/plugins/table/nodeviews/ExternalDropTargets.tsx +86 -0
  59. package/src/plugins/table/nodeviews/TableComponent.tsx +92 -7
  60. package/src/plugins/table/nodeviews/TableRow.ts +2 -65
  61. package/src/plugins/table/nodeviews/TableStickyScrollbar.ts +6 -6
  62. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +0 -7
  63. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +1 -0
  64. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +2 -7
  65. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +80 -21
  66. package/src/plugins/table/ui/TableFloatingControls/RowDropTarget/index.tsx +62 -0
  67. package/src/plugins/table/ui/TableFloatingControls/index.tsx +29 -8
  68. package/src/plugins/table/ui/common-styles.ts +2 -1
  69. package/src/plugins/table/ui/consts.ts +3 -0
  70. package/src/plugins/table/utils/column-controls.ts +2 -2
  71. package/tsconfig.app.json +2 -2
@@ -6,7 +6,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
6
  import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
7
7
  import { fontSize } from '@atlaskit/theme/constants';
8
8
  import { TableCssClassName as ClassName } from '../types';
9
- import { columnControlsDecorationHeight, resizeHandlerAreaWidth, resizeLineWidth, rowControlsZIndex, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableBorderColor, tableBorderDeleteColor, tableBorderRadiusSize, tableBorderSelectedColor, tableCellBackgroundColor, tableCellDeleteColor, tableCellSelectedColor, tableControlsSpacing, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tablePadding, tableScrollbarOffset, tableTextColor, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
9
+ import { columnControlsDecorationHeight, dropTargetExtendedWidth, resizeHandlerAreaWidth, resizeLineWidth, rowControlsZIndex, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableBorderColor, tableBorderDeleteColor, tableBorderRadiusSize, tableBorderSelectedColor, tableCellBackgroundColor, tableCellDeleteColor, tableCellSelectedColor, tableControlsSpacing, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tablePadding, tableScrollbarOffset, tableTextColor, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
10
10
  import { columnControlsDecoration, columnControlsLineMarker, DeleteButton, disabledCell, dragCornerControlButton, dragInsertButtonWrapper, floatingColumnControls, HeaderButton, HeaderButtonDanger, HeaderButtonHover, hoveredCell, hoveredDeleteButton, hoveredWarningCell, insertColumnButtonWrapper, insertLine, InsertMarker, insertRowButtonWrapper, OverflowShadow, resizeHandle, rowControlsWrapperDotStyle } from './ui-styles';
11
11
  const cornerControlHeight = tableToolbarSize + 1;
12
12
 
@@ -611,7 +611,7 @@ export const tableStyles = props => {
611
611
  display: grid;
612
612
  align-items: center;
613
613
  position: absolute;
614
- left: -4px;
614
+ left: -${dropTargetExtendedWidth + 4}px;
615
615
  z-index: ${akEditorUnitZIndex};
616
616
 
617
617
  .${ClassName.DRAG_ROW_FLOATING_INSERT_DOT_WRAPPER} {
@@ -102,8 +102,10 @@ export const stickyRowOffsetTop = 8;
102
102
  export const stickyHeaderBorderBottomWidth = 1;
103
103
  export const tableOverflowShadowWidth = 8;
104
104
  export const tableOverflowShadowWidthWide = 32;
105
+ export const dropTargetsZIndex = 14;
105
106
  export const TABLE_SNAP_GAP = 9;
106
107
  export const TABLE_HIGHLIGHT_GAP = 10;
107
108
  export const TABLE_HIGHLIGHT_TOLERANCE = 2;
108
109
  export const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
109
- export const dragMenuDropdownWidth = 240;
110
+ export const dragMenuDropdownWidth = 240;
111
+ export const dropTargetExtendedWidth = 150;
@@ -0,0 +1,65 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useEffect, useState } from 'react';
3
+ import { tableMarginTop } from '@atlaskit/editor-common/styles';
4
+ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
5
+ import { dropTargetExtendedWidth, dropTargetsZIndex } from '../ui/consts';
6
+ import { ColumnDropTarget } from '../ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget';
7
+ import { getColumnsWidths } from '../utils';
8
+ export var ExternalDropTargets = function ExternalDropTargets(_ref) {
9
+ var editorView = _ref.editorView,
10
+ node = _ref.node,
11
+ getScrollOffset = _ref.getScrollOffset,
12
+ getTableWrapperWidth = _ref.getTableWrapperWidth;
13
+ var _useState = useState(false),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ isDragging = _useState2[0],
16
+ setIsDragging = _useState2[1];
17
+ var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
18
+ useEffect(function () {
19
+ return monitorForElements({
20
+ canMonitor: function canMonitor(_ref2) {
21
+ var source = _ref2.source;
22
+ var _ref3 = source.data,
23
+ type = _ref3.type,
24
+ indexes = _ref3.indexes,
25
+ localId = _ref3.localId;
26
+ return type === 'table-column' && !!(indexes !== null && indexes !== void 0 && indexes.length) && localId === currentNodeLocalId;
27
+ },
28
+ onDragStart: function onDragStart() {
29
+ setIsDragging(true);
30
+ },
31
+ onDrop: function onDrop() {
32
+ setIsDragging(false);
33
+ }
34
+ });
35
+ }, [currentNodeLocalId, editorView]);
36
+ if (!isDragging) {
37
+ return null;
38
+ }
39
+ var colWidths = getColumnsWidths(editorView);
40
+ return /*#__PURE__*/React.createElement("div", {
41
+ style: {
42
+ width: getTableWrapperWidth(),
43
+ overflow: 'hidden',
44
+ position: 'absolute',
45
+ top: "-".concat(dropTargetExtendedWidth - tableMarginTop, "px"),
46
+ pointerEvents: 'auto',
47
+ zIndex: "".concat(dropTargetsZIndex)
48
+ }
49
+ }, /*#__PURE__*/React.createElement("div", {
50
+ style: {
51
+ display: 'flex',
52
+ // move drop targets based on table wrapper scroll
53
+ marginLeft: "-".concat(getScrollOffset(), "px")
54
+ }
55
+ }, colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width, index) {
56
+ return /*#__PURE__*/React.createElement(ColumnDropTarget, {
57
+ key: index,
58
+ index: index,
59
+ localId: currentNodeLocalId,
60
+ width: width,
61
+ height: dropTargetExtendedWidth,
62
+ marginTop: 0
63
+ });
64
+ })));
65
+ };
@@ -21,6 +21,9 @@ import { analyticsEventKey, browser, isValidPosition } from '@atlaskit/editor-co
21
21
  import { MAX_BROWSER_SCROLLBAR_HEIGHT, akEditorTableToolbarSize as tableToolbarSize } from '@atlaskit/editor-shared-styles';
22
22
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
23
23
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
24
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
25
+ import { autoScrollForElements, autoScrollWindowForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
26
+ import { unsafeOverflowAutoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element';
24
27
  import { autoSizeTable, clearHoverSelection } from '../commands';
25
28
  import { getPluginState } from '../pm-plugins/plugin-factory';
26
29
  import { findStickyHeaderForTable, pluginKey as stickyHeadersPluginKey } from '../pm-plugins/sticky-headers';
@@ -29,10 +32,11 @@ import { getLayoutSize, insertColgroupFromNode as recreateResizeColsByNode, scal
29
32
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
30
33
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
31
34
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
32
- import { tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
35
+ import { dropTargetExtendedWidth, tableOverflowShadowWidth, tableOverflowShadowWidthWide } from '../ui/consts';
33
36
  import TableFloatingColumnControls from '../ui/TableFloatingColumnControls';
34
37
  import TableFloatingControls from '../ui/TableFloatingControls';
35
38
  import { containsHeaderRow, isTableNested, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns } from '../utils';
39
+ import { ExternalDropTargets } from './ExternalDropTargets';
36
40
  import { OverflowShadowsObserver } from './OverflowShadowsObserver';
37
41
  import { TableContainer } from './TableContainer';
38
42
  import { TableStickyScrollbar } from './TableStickyScrollbar';
@@ -302,7 +306,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
302
306
  var _this$props7 = this.props,
303
307
  allowColumnResizing = _this$props7.allowColumnResizing,
304
308
  eventDispatcher = _this$props7.eventDispatcher,
305
- options = _this$props7.options;
309
+ options = _this$props7.options,
310
+ isDragAndDropEnabled = _this$props7.isDragAndDropEnabled,
311
+ getNode = _this$props7.getNode;
306
312
  if (allowColumnResizing && this.wrapper && !isIE11) {
307
313
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
308
314
  passive: true
@@ -312,6 +318,56 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
312
318
  this.stickyScrollbar = new TableStickyScrollbar(this.wrapper, this.props.view);
313
319
  }
314
320
  }
321
+ if (isDragAndDropEnabled) {
322
+ this.dragAndDropCleanupFn = combine(autoScrollForElements({
323
+ element: this.wrapper,
324
+ canScroll: function canScroll(_ref) {
325
+ var source = _ref.source;
326
+ var _ref2 = source.data,
327
+ localId = _ref2.localId,
328
+ type = _ref2.type;
329
+ var node = getNode();
330
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
331
+ }
332
+ }), autoScrollWindowForElements({
333
+ canScroll: function canScroll(_ref3) {
334
+ var source = _ref3.source;
335
+ var _ref4 = source.data,
336
+ localId = _ref4.localId,
337
+ type = _ref4.type;
338
+ var node = getNode();
339
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-row';
340
+ }
341
+ }), unsafeOverflowAutoScrollForElements({
342
+ element: this.wrapper,
343
+ canScroll: function canScroll(_ref5) {
344
+ var source = _ref5.source;
345
+ var _ref6 = source.data,
346
+ localId = _ref6.localId;
347
+ var node = getNode();
348
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId);
349
+ },
350
+ getOverflow: function getOverflow() {
351
+ return {
352
+ fromTopEdge: {
353
+ top: dropTargetExtendedWidth,
354
+ right: dropTargetExtendedWidth,
355
+ left: dropTargetExtendedWidth
356
+ },
357
+ fromRightEdge: {
358
+ right: dropTargetExtendedWidth,
359
+ top: dropTargetExtendedWidth,
360
+ bottom: dropTargetExtendedWidth
361
+ },
362
+ fromLeftEdge: {
363
+ top: dropTargetExtendedWidth,
364
+ left: dropTargetExtendedWidth,
365
+ bottom: dropTargetExtendedWidth
366
+ }
367
+ };
368
+ }
369
+ }));
370
+ }
315
371
  }
316
372
  if (allowColumnResizing) {
317
373
  /**
@@ -339,10 +395,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
339
395
  var _this$props8 = this.props,
340
396
  allowColumnResizing = _this$props8.allowColumnResizing,
341
397
  eventDispatcher = _this$props8.eventDispatcher,
342
- options = _this$props8.options;
398
+ options = _this$props8.options,
399
+ isDragAndDropEnabled = _this$props8.isDragAndDropEnabled;
343
400
  if (this.wrapper && !isIE11) {
344
401
  this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
345
402
  }
403
+ if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
404
+ this.dragAndDropCleanupFn();
405
+ }
346
406
  if (getBooleanFF('platform.editor.table-sticky-scrollbar')) {
347
407
  if (this.stickyScrollbar) {
348
408
  this.stickyScrollbar.dispose();
@@ -545,7 +605,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
545
605
  }), getBooleanFF('platform.editor.table-sticky-scrollbar') && /*#__PURE__*/React.createElement("div", {
546
606
  className: ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
547
607
  "data-testid": "sticky-scrollbar-sentinel-top"
548
- }), allowControls && rowControls, isDragAndDropEnabled && allowControls && colControls, /*#__PURE__*/React.createElement("div", {
608
+ }), allowControls && rowControls, isDragAndDropEnabled && /*#__PURE__*/React.createElement(ExternalDropTargets, {
609
+ editorView: view,
610
+ node: node,
611
+ getScrollOffset: function getScrollOffset() {
612
+ var _this2$wrapper;
613
+ return ((_this2$wrapper = _this2.wrapper) === null || _this2$wrapper === void 0 ? void 0 : _this2$wrapper.scrollLeft) || 0;
614
+ },
615
+ getTableWrapperWidth: function getTableWrapperWidth() {
616
+ var _this2$wrapper2;
617
+ return ((_this2$wrapper2 = _this2.wrapper) === null || _this2$wrapper2 === void 0 ? void 0 : _this2$wrapper2.clientWidth) || 760;
618
+ }
619
+ }), /*#__PURE__*/React.createElement("div", {
549
620
  style: shadowStyle(showBeforeShadow),
550
621
  className: ClassName.TABLE_LEFT_SHADOW
551
622
  }), this.state.stickyHeader && /*#__PURE__*/React.createElement("div", {
@@ -567,7 +638,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
567
638
  }
568
639
  }
569
640
  }
570
- }), getBooleanFF('platform.editor.table-sticky-scrollbar') && /*#__PURE__*/React.createElement("div", {
641
+ }, allowControls && colControls), getBooleanFF('platform.editor.table-sticky-scrollbar') && /*#__PURE__*/React.createElement("div", {
571
642
  className: ClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
572
643
  style: {
573
644
  height: MAX_BROWSER_SCROLLBAR_HEIGHT,
@@ -11,8 +11,6 @@ import debounce from 'lodash/debounce';
11
11
  import throttle from 'lodash/throttle';
12
12
  import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
13
13
  import { browser } from '@atlaskit/editor-common/utils';
14
- import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
15
- import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
16
14
  import { getPluginState } from '../pm-plugins/plugin-factory';
17
15
  import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
18
16
  import { updateStickyState } from '../pm-plugins/sticky-headers/commands';
@@ -43,6 +41,9 @@ var TableRow = /*#__PURE__*/function (_ref) {
43
41
  _defineProperty(_assertThisInitialized(_this), "listening", false);
44
42
  _defineProperty(_assertThisInitialized(_this), "padding", 0);
45
43
  _defineProperty(_assertThisInitialized(_this), "top", 0);
44
+ /**
45
+ * Methods
46
+ */
46
47
  _defineProperty(_assertThisInitialized(_this), "headerRowMouseScrollEnd", debounce(function () {
47
48
  _this.dom.classList.remove('no-pointer-events');
48
49
  }, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
@@ -58,27 +59,20 @@ var TableRow = /*#__PURE__*/function (_ref) {
58
59
  _this.isHeaderRow = supportedHeaderRow(node);
59
60
  _this.isSticky = false;
60
61
  var _getPluginState = getPluginState(view.state),
61
- pluginConfig = _getPluginState.pluginConfig,
62
- isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
62
+ pluginConfig = _getPluginState.pluginConfig;
63
63
  _this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
64
- _this.isDragAndDropEnabled = !!isDragAndDropEnabled;
65
64
  if (_this.isHeaderRow) {
66
65
  _this.dom.setAttribute('data-header-row', 'true');
67
66
  if (_this.isStickyHeaderEnabled) {
68
67
  _this.subscribe();
69
68
  }
70
69
  }
71
- if (_this.isDragAndDropEnabled) {
72
- _this.addDropTarget(_this.contentDOM);
73
- }
74
70
  return _this;
75
71
  }
76
72
 
77
73
  /**
78
74
  * Variables
79
75
  */
80
-
81
- // @ts-ignore
82
76
  _createClass(TableRow, [{
83
77
  key: "update",
84
78
  value:
@@ -117,7 +111,6 @@ var TableRow = /*#__PURE__*/function (_ref) {
117
111
  }, {
118
112
  key: "destroy",
119
113
  value: function destroy() {
120
- var _this$dropTargetClean;
121
114
  if (this.isStickyHeaderEnabled) {
122
115
  this.unsubscribe();
123
116
  var tree = getTree(this.dom);
@@ -126,9 +119,6 @@ var TableRow = /*#__PURE__*/function (_ref) {
126
119
  }
127
120
  this.emitOff(true);
128
121
  }
129
-
130
- // If a drop target cleanup method has been set then we should call it.
131
- (_this$dropTargetClean = this.dropTargetCleanup) === null || _this$dropTargetClean === void 0 || _this$dropTargetClean.call(this);
132
122
  }
133
123
  }, {
134
124
  key: "ignoreMutation",
@@ -155,72 +145,6 @@ var TableRow = /*#__PURE__*/function (_ref) {
155
145
  }
156
146
  return true;
157
147
  }
158
-
159
- /**
160
- * Methods
161
- */
162
- }, {
163
- key: "addDropTarget",
164
- value: function addDropTarget(element) {
165
- var _this2 = this;
166
- var pos = this.getPos();
167
- if (!Number.isFinite(pos)) {
168
- return;
169
- }
170
- if (this.dropTargetCleanup) {
171
- this.dropTargetCleanup();
172
- }
173
- this.dropTargetCleanup = dropTargetForElements({
174
- element: element,
175
- canDrop: function canDrop(_ref2) {
176
- var _data$indexes, _data$indexes2;
177
- var source = _ref2.source;
178
- var data = source.data;
179
- var _this2$getCurrentData = _this2.getCurrentData(),
180
- localId = _this2$getCurrentData.localId,
181
- targetIndex = _this2$getCurrentData.targetIndex;
182
- return (
183
- // Only draggables of row type can be dropped on this target
184
- data.type === 'table-row' &&
185
- // Only draggables which came from the same table can be dropped on this target
186
- data.localId === localId &&
187
- // Only draggables which DO NOT include this drop targets index can be dropped
188
- !!((_data$indexes = data.indexes) !== null && _data$indexes !== void 0 && _data$indexes.length) && ((_data$indexes2 = data.indexes) === null || _data$indexes2 === void 0 ? void 0 : _data$indexes2.indexOf(targetIndex)) === -1
189
- );
190
- },
191
- getIsSticky: function getIsSticky() {
192
- return true;
193
- },
194
- getData: function getData(_ref3) {
195
- var input = _ref3.input,
196
- element = _ref3.element;
197
- var _this2$getCurrentData2 = _this2.getCurrentData(),
198
- localId = _this2$getCurrentData2.localId,
199
- targetIndex = _this2$getCurrentData2.targetIndex;
200
- var data = {
201
- localId: localId,
202
- type: 'table-row',
203
- targetIndex: targetIndex
204
- };
205
- return attachClosestEdge(data, {
206
- input: input,
207
- element: element,
208
- allowedEdges: ['top', 'bottom']
209
- });
210
- }
211
- });
212
- }
213
- }, {
214
- key: "getCurrentData",
215
- value: function getCurrentData() {
216
- var resolvedPos = this.view.state.doc.resolve(this.getPos());
217
- var targetIndex = resolvedPos.index();
218
- var localId = resolvedPos.parent.attrs.localId;
219
- return {
220
- targetIndex: targetIndex,
221
- localId: localId
222
- };
223
- }
224
148
  }, {
225
149
  key: "subscribe",
226
150
  value: function subscribe() {
@@ -269,7 +193,7 @@ var TableRow = /*#__PURE__*/function (_ref) {
269
193
  }, {
270
194
  key: "initObservers",
271
195
  value: function initObservers() {
272
- var _this3 = this;
196
+ var _this2 = this;
273
197
  if (!this.dom || this.dom.dataset.isObserved) {
274
198
  return;
275
199
  }
@@ -286,15 +210,15 @@ var TableRow = /*#__PURE__*/function (_ref) {
286
210
  window.requestAnimationFrame(function () {
287
211
  var _getTree;
288
212
  // we expect tree to be defined after animation frame
289
- var tableContainer = (_getTree = getTree(_this3.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
213
+ var tableContainer = (_getTree = getTree(_this2.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(TableCssClassName.NODEVIEW_WRAPPER));
290
214
  if (tableContainer) {
291
- _this3.sentinels.top = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
292
- _this3.sentinels.bottom = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
293
- [_this3.sentinels.top, _this3.sentinels.bottom].forEach(function (el) {
215
+ _this2.sentinels.top = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
216
+ _this2.sentinels.bottom = tableContainer.getElementsByClassName(ClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
217
+ [_this2.sentinels.top, _this2.sentinels.bottom].forEach(function (el) {
294
218
  // skip if already observed for another row on this table
295
219
  if (el && !el.dataset.isObserved) {
296
220
  el.dataset.isObserved = 'true';
297
- _this3.intersectionObserver.observe(el);
221
+ _this2.intersectionObserver.observe(el);
298
222
  }
299
223
  });
300
224
  }
@@ -306,27 +230,27 @@ var TableRow = /*#__PURE__*/function (_ref) {
306
230
  }, {
307
231
  key: "createResizeObserver",
308
232
  value: function createResizeObserver() {
309
- var _this4 = this;
233
+ var _this3 = this;
310
234
  this.resizeObserver = new ResizeObserver(function (entries) {
311
- var tree = getTree(_this4.dom);
235
+ var tree = getTree(_this3.dom);
312
236
  if (!tree) {
313
237
  return;
314
238
  }
315
239
  var table = tree.table;
316
240
  entries.forEach(function (entry) {
317
- var _this4$editorScrollab;
241
+ var _this3$editorScrollab;
318
242
  // On resize of the parent scroll element we need to adjust the width
319
243
  // of the sticky header
320
- if (entry.target.className === ((_this4$editorScrollab = _this4.editorScrollableElement) === null || _this4$editorScrollab === void 0 ? void 0 : _this4$editorScrollab.className)) {
321
- _this4.updateStickyHeaderWidth();
244
+ if (entry.target.className === ((_this3$editorScrollab = _this3.editorScrollableElement) === null || _this3$editorScrollab === void 0 ? void 0 : _this3$editorScrollab.className)) {
245
+ _this3.updateStickyHeaderWidth();
322
246
  } else {
323
247
  var newHeight = entry.contentRect ? entry.contentRect.height : entry.target.offsetHeight;
324
- if (_this4.sentinels.bottom &&
248
+ if (_this3.sentinels.bottom &&
325
249
  // When the table header is sticky, it would be taller by a 1px (border-bottom),
326
250
  // So we adding this check to allow a 1px difference.
327
- Math.abs(newHeight - (_this4.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
328
- _this4.stickyRowHeight = newHeight;
329
- _this4.sentinels.bottom.style.bottom = "".concat(tableScrollbarOffset + stickyRowOffsetTop + newHeight, "px");
251
+ Math.abs(newHeight - (_this3.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
252
+ _this3.stickyRowHeight = newHeight;
253
+ _this3.sentinels.bottom.style.bottom = "".concat(tableScrollbarOffset + stickyRowOffsetTop + newHeight, "px");
330
254
  updateTableMargin(table);
331
255
  }
332
256
  }
@@ -336,9 +260,9 @@ var TableRow = /*#__PURE__*/function (_ref) {
336
260
  }, {
337
261
  key: "createIntersectionObserver",
338
262
  value: function createIntersectionObserver() {
339
- var _this5 = this;
263
+ var _this4 = this;
340
264
  this.intersectionObserver = new IntersectionObserver(function (entries, _) {
341
- var tree = getTree(_this5.dom);
265
+ var tree = getTree(_this4.dom);
342
266
  if (!tree) {
343
267
  return;
344
268
  }
@@ -361,28 +285,28 @@ var TableRow = /*#__PURE__*/function (_ref) {
361
285
  var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
362
286
  if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
363
287
  var _entry$rootBounds3;
364
- tree && _this5.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
365
- _this5.lastStickyTimestamp = Date.now();
288
+ tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
289
+ _this4.lastStickyTimestamp = Date.now();
366
290
  } else {
367
- table && _this5.makeRowHeaderNotSticky(table);
291
+ table && _this4.makeRowHeaderNotSticky(table);
368
292
  }
369
293
  }
370
294
  if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
371
295
  var _entry$rootBounds4;
372
- var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this5.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
296
+ var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
373
297
  if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
374
298
  // Not a perfect solution, but need to this code specific for FireFox ED-19177
375
299
  if (browser.gecko) {
376
- if (_this5.lastStickyTimestamp && Date.now() - _this5.lastStickyTimestamp > STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
377
- _this5.makeRowHeaderNotSticky(table);
300
+ if (_this4.lastStickyTimestamp && Date.now() - _this4.lastStickyTimestamp > STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
301
+ _this4.makeRowHeaderNotSticky(table);
378
302
  }
379
303
  } else {
380
- _this5.makeRowHeaderNotSticky(table);
304
+ _this4.makeRowHeaderNotSticky(table);
381
305
  }
382
306
  } else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
383
307
  var _entry$rootBounds5;
384
- tree && _this5.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
385
- _this5.lastStickyTimestamp = Date.now();
308
+ tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
309
+ _this4.lastStickyTimestamp = Date.now();
386
310
  }
387
311
  }
388
312
  return;
@@ -457,12 +381,12 @@ var TableRow = /*#__PURE__*/function (_ref) {
457
381
  }, {
458
382
  key: "refireIntersectionObservers",
459
383
  value: function refireIntersectionObservers() {
460
- var _this6 = this;
384
+ var _this5 = this;
461
385
  if (this.isSticky) {
462
386
  [this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
463
- if (el && _this6.intersectionObserver) {
464
- _this6.intersectionObserver.unobserve(el);
465
- _this6.intersectionObserver.observe(el);
387
+ if (el && _this5.intersectionObserver) {
388
+ _this5.intersectionObserver.unobserve(el);
389
+ _this5.intersectionObserver.observe(el);
466
390
  }
467
391
  });
468
392
  }
@@ -471,7 +395,7 @@ var TableRow = /*#__PURE__*/function (_ref) {
471
395
  key: "makeHeaderRowSticky",
472
396
  value: function makeHeaderRowSticky(tree, scrollTop) {
473
397
  var _tbody$firstChild,
474
- _this7 = this;
398
+ _this6 = this;
475
399
  // If header row height is more than 50% of viewport height don't do this
476
400
  if (this.isSticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
477
401
  return;
@@ -508,7 +432,7 @@ var TableRow = /*#__PURE__*/function (_ref) {
508
432
  });
509
433
  var fastScrollThresholdMs = 500;
510
434
  setTimeout(function () {
511
- _this7.refireIntersectionObservers();
435
+ _this6.refireIntersectionObservers();
512
436
  }, fastScrollThresholdMs);
513
437
  }
514
438
  this.dom.style.top = "".concat(domTop, "px");
@@ -27,7 +27,7 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
27
27
  this.stickyScrollbarContainerElement.removeEventListener('scroll', this.handleScrollDebounced);
28
28
  this.handleScrollDebounced.cancel();
29
29
  }
30
- this.deleteIntesactionObserver();
30
+ this.deleteIntersectionObserver();
31
31
  }
32
32
  }, {
33
33
  key: "scrollLeft",
@@ -73,10 +73,10 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
73
73
  return;
74
74
  }
75
75
  if (target.classList.contains(ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM)) {
76
- _this2.sentenialBottomCallback(entry);
76
+ _this2.sentinelBottomCallback(entry);
77
77
  }
78
78
  if (target.classList.contains(ClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP)) {
79
- _this2.sentenialTopCallback(entry);
79
+ _this2.sentinelTopCallback(entry);
80
80
  }
81
81
  });
82
82
  }, {
@@ -89,8 +89,8 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
89
89
  });
90
90
  }
91
91
  }, {
92
- key: "deleteIntesactionObserver",
93
- value: function deleteIntesactionObserver() {
92
+ key: "deleteIntersectionObserver",
93
+ value: function deleteIntersectionObserver() {
94
94
  if (this.intersectionObserver) {
95
95
  if (this.sentinels.bottom) {
96
96
  this.intersectionObserver.unobserve(this.sentinels.bottom);
@@ -99,16 +99,16 @@ export var TableStickyScrollbar = /*#__PURE__*/function () {
99
99
  }
100
100
  }
101
101
  }, {
102
- key: "sentenialBottomCallback",
103
- value: function sentenialBottomCallback(entry) {
102
+ key: "sentinelBottomCallback",
103
+ value: function sentinelBottomCallback(entry) {
104
104
  var _entry$rootBounds2;
105
105
  var sentinelIsAboveScrollArea = entry.boundingClientRect.top < (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.top) || 0);
106
106
  this.bottomSentinelState = sentinelIsAboveScrollArea ? 'above' : entry.isIntersecting ? 'visible' : 'below';
107
107
  this.toggle();
108
108
  }
109
109
  }, {
110
- key: "sentenialTopCallback",
111
- value: function sentenialTopCallback(entry) {
110
+ key: "sentinelTopCallback",
111
+ value: function sentinelTopCallback(entry) {
112
112
  var _entry$rootBounds3;
113
113
  var sentinelIsBelowScrollArea = (((_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.bottom) || 0) < entry.boundingClientRect.top;
114
114
  this.topSentinelState = sentinelIsBelowScrollArea ? 'below' : entry.isIntersecting ? 'visible' : 'above';
@@ -4,7 +4,6 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
4
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
5
  import { getCellsInRow } from '@atlaskit/editor-tables/utils';
6
6
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
7
- import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
8
7
  import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils/merged-cells';
9
8
  import { getPluginState as getTablePluginState } from '../plugin-factory';
10
9
  import { DragAndDropActionType } from './actions';
@@ -88,15 +87,9 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
88
87
  },
89
88
  onDragStart: function onDragStart(_ref3) {
90
89
  var location = _ref3.location;
91
- autoScroller.start({
92
- input: location.current.input
93
- });
94
90
  toggleDragMenu(false)(editorView.state, editorView.dispatch);
95
91
  },
96
92
  onDrag: function onDrag(event) {
97
- autoScroller.updateInput({
98
- input: event.location.current.input
99
- });
100
93
  var data = getDraggableDataFromEvent(event);
101
94
  // If no data can be found then it's most like we do not want to perform any drag actions
102
95
  if (!data) {
@@ -112,7 +105,6 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
112
105
  setDropTarget(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
113
106
  },
114
107
  onDrop: function onDrop(event) {
115
- autoScroller.stop();
116
108
  var data = getDraggableDataFromEvent(event);
117
109
 
118
110
  // If no data can be found then it's most like we do not want to perform any drop action
@@ -52,7 +52,8 @@ export var ColumnDropTarget = function ColumnDropTarget(_ref) {
52
52
  width: width && "".concat(width - 1, "px"),
53
53
  height: height && "".concat(height, "px"),
54
54
  marginTop: marginTop && "".concat(marginTop, "px"),
55
- pointerEvents: 'auto'
55
+ pointerEvents: 'auto',
56
+ flexShrink: 0
56
57
  },
57
58
  "data-drop-target-index": index,
58
59
  "data-drop-target-localid": localId,
@@ -3,7 +3,6 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
3
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  import React, { useEffect, useMemo, useState } from 'react';
6
- import ReactDOM from 'react-dom';
7
6
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
8
7
  import { TableCssClassName as ClassName } from '../../types';
9
8
  import { containsHeaderColumn, getColumnsWidths, getRowHeights } from '../../utils';
@@ -95,11 +94,10 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
95
94
  }
96
95
  var colWidths = getColumnsWidths(editorView);
97
96
  var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
98
- var mountTo = tableRef && (tableRef === null || tableRef === void 0 ? void 0 : tableRef.parentElement) || document.body;
99
97
  if (!tableActive) {
100
98
  return null;
101
99
  }
102
- return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement("div", {
100
+ return /*#__PURE__*/React.createElement("div", {
103
101
  className: ClassName.DRAG_COLUMN_CONTROLS_WRAPPER,
104
102
  "data-testid": "table-floating-column-controls-wrapper"
105
103
  }, /*#__PURE__*/React.createElement(ColumnControls, {
@@ -121,6 +119,6 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
121
119
  localId: currentNodeLocalId,
122
120
  rowHeights: rowHeights,
123
121
  colWidths: colWidths
124
- })), mountTo);
122
+ }));
125
123
  };
126
124
  export default TableFloatingColumnControls;