@atlaskit/editor-plugin-table 5.3.29 → 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 +6 -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 +2 -2
  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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.3.30
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42908](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42908) [`f1df173bd21`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f1df173bd21) - Add new drop targets to table node, add new pragmatic drag and drop autoscroller
8
+
3
9
  ## 5.3.29
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ExternalDropTargets = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _styles = require("@atlaskit/editor-common/styles");
12
+ var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
13
+ var _consts = require("../ui/consts");
14
+ var _ColumnDropTarget = require("../ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget");
15
+ var _utils = require("../utils");
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ var ExternalDropTargets = exports.ExternalDropTargets = function ExternalDropTargets(_ref) {
19
+ var editorView = _ref.editorView,
20
+ node = _ref.node,
21
+ getScrollOffset = _ref.getScrollOffset,
22
+ getTableWrapperWidth = _ref.getTableWrapperWidth;
23
+ var _useState = (0, _react.useState)(false),
24
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
25
+ isDragging = _useState2[0],
26
+ setIsDragging = _useState2[1];
27
+ var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
28
+ (0, _react.useEffect)(function () {
29
+ return (0, _element.monitorForElements)({
30
+ canMonitor: function canMonitor(_ref2) {
31
+ var source = _ref2.source;
32
+ var _ref3 = source.data,
33
+ type = _ref3.type,
34
+ indexes = _ref3.indexes,
35
+ localId = _ref3.localId;
36
+ return type === 'table-column' && !!(indexes !== null && indexes !== void 0 && indexes.length) && localId === currentNodeLocalId;
37
+ },
38
+ onDragStart: function onDragStart() {
39
+ setIsDragging(true);
40
+ },
41
+ onDrop: function onDrop() {
42
+ setIsDragging(false);
43
+ }
44
+ });
45
+ }, [currentNodeLocalId, editorView]);
46
+ if (!isDragging) {
47
+ return null;
48
+ }
49
+ var colWidths = (0, _utils.getColumnsWidths)(editorView);
50
+ return /*#__PURE__*/_react.default.createElement("div", {
51
+ style: {
52
+ width: getTableWrapperWidth(),
53
+ overflow: 'hidden',
54
+ position: 'absolute',
55
+ top: "-".concat(_consts.dropTargetExtendedWidth - _styles.tableMarginTop, "px"),
56
+ pointerEvents: 'auto',
57
+ zIndex: "".concat(_consts.dropTargetsZIndex)
58
+ }
59
+ }, /*#__PURE__*/_react.default.createElement("div", {
60
+ style: {
61
+ display: 'flex',
62
+ // move drop targets based on table wrapper scroll
63
+ marginLeft: "-".concat(getScrollOffset(), "px")
64
+ }
65
+ }, colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width, index) {
66
+ return /*#__PURE__*/_react.default.createElement(_ColumnDropTarget.ColumnDropTarget, {
67
+ key: index,
68
+ index: index,
69
+ localId: currentNodeLocalId,
70
+ width: width,
71
+ height: _consts.dropTargetExtendedWidth,
72
+ marginTop: 0
73
+ });
74
+ })));
75
+ };
@@ -24,6 +24,9 @@ var _utils = require("@atlaskit/editor-common/utils");
24
24
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
25
25
  var _utils2 = require("@atlaskit/editor-tables/utils");
26
26
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
27
+ var _combine = require("@atlaskit/pragmatic-drag-and-drop/util/combine");
28
+ var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
29
+ var _element2 = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element");
27
30
  var _commands = require("../commands");
28
31
  var _pluginFactory = require("../pm-plugins/plugin-factory");
29
32
  var _stickyHeaders = require("../pm-plugins/sticky-headers");
@@ -36,6 +39,7 @@ var _consts = require("../ui/consts");
36
39
  var _TableFloatingColumnControls = _interopRequireDefault(require("../ui/TableFloatingColumnControls"));
37
40
  var _TableFloatingControls = _interopRequireDefault(require("../ui/TableFloatingControls"));
38
41
  var _utils4 = require("../utils");
42
+ var _ExternalDropTargets = require("./ExternalDropTargets");
39
43
  var _OverflowShadowsObserver = require("./OverflowShadowsObserver");
40
44
  var _TableContainer = require("./TableContainer");
41
45
  var _TableStickyScrollbar = require("./TableStickyScrollbar");
@@ -309,7 +313,9 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
309
313
  var _this$props7 = this.props,
310
314
  allowColumnResizing = _this$props7.allowColumnResizing,
311
315
  eventDispatcher = _this$props7.eventDispatcher,
312
- options = _this$props7.options;
316
+ options = _this$props7.options,
317
+ isDragAndDropEnabled = _this$props7.isDragAndDropEnabled,
318
+ getNode = _this$props7.getNode;
313
319
  if (allowColumnResizing && this.wrapper && !isIE11) {
314
320
  this.wrapper.addEventListener('scroll', this.handleScrollDebounced, {
315
321
  passive: true
@@ -319,6 +325,56 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
319
325
  this.stickyScrollbar = new _TableStickyScrollbar.TableStickyScrollbar(this.wrapper, this.props.view);
320
326
  }
321
327
  }
328
+ if (isDragAndDropEnabled) {
329
+ this.dragAndDropCleanupFn = (0, _combine.combine)((0, _element.autoScrollForElements)({
330
+ element: this.wrapper,
331
+ canScroll: function canScroll(_ref) {
332
+ var source = _ref.source;
333
+ var _ref2 = source.data,
334
+ localId = _ref2.localId,
335
+ type = _ref2.type;
336
+ var node = getNode();
337
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
338
+ }
339
+ }), (0, _element.autoScrollWindowForElements)({
340
+ canScroll: function canScroll(_ref3) {
341
+ var source = _ref3.source;
342
+ var _ref4 = source.data,
343
+ localId = _ref4.localId,
344
+ type = _ref4.type;
345
+ var node = getNode();
346
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-row';
347
+ }
348
+ }), (0, _element2.unsafeOverflowAutoScrollForElements)({
349
+ element: this.wrapper,
350
+ canScroll: function canScroll(_ref5) {
351
+ var source = _ref5.source;
352
+ var _ref6 = source.data,
353
+ localId = _ref6.localId;
354
+ var node = getNode();
355
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId);
356
+ },
357
+ getOverflow: function getOverflow() {
358
+ return {
359
+ fromTopEdge: {
360
+ top: _consts.dropTargetExtendedWidth,
361
+ right: _consts.dropTargetExtendedWidth,
362
+ left: _consts.dropTargetExtendedWidth
363
+ },
364
+ fromRightEdge: {
365
+ right: _consts.dropTargetExtendedWidth,
366
+ top: _consts.dropTargetExtendedWidth,
367
+ bottom: _consts.dropTargetExtendedWidth
368
+ },
369
+ fromLeftEdge: {
370
+ top: _consts.dropTargetExtendedWidth,
371
+ left: _consts.dropTargetExtendedWidth,
372
+ bottom: _consts.dropTargetExtendedWidth
373
+ }
374
+ };
375
+ }
376
+ }));
377
+ }
322
378
  }
323
379
  if (allowColumnResizing) {
324
380
  /**
@@ -346,10 +402,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
346
402
  var _this$props8 = this.props,
347
403
  allowColumnResizing = _this$props8.allowColumnResizing,
348
404
  eventDispatcher = _this$props8.eventDispatcher,
349
- options = _this$props8.options;
405
+ options = _this$props8.options,
406
+ isDragAndDropEnabled = _this$props8.isDragAndDropEnabled;
350
407
  if (this.wrapper && !isIE11) {
351
408
  this.wrapper.removeEventListener('scroll', this.handleScrollDebounced);
352
409
  }
410
+ if (isDragAndDropEnabled && this.dragAndDropCleanupFn) {
411
+ this.dragAndDropCleanupFn();
412
+ }
353
413
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-sticky-scrollbar')) {
354
414
  if (this.stickyScrollbar) {
355
415
  this.stickyScrollbar.dispose();
@@ -552,7 +612,18 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
552
612
  }), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-sticky-scrollbar') && /*#__PURE__*/_react.default.createElement("div", {
553
613
  className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP,
554
614
  "data-testid": "sticky-scrollbar-sentinel-top"
555
- }), allowControls && rowControls, isDragAndDropEnabled && allowControls && colControls, /*#__PURE__*/_react.default.createElement("div", {
615
+ }), allowControls && rowControls, isDragAndDropEnabled && /*#__PURE__*/_react.default.createElement(_ExternalDropTargets.ExternalDropTargets, {
616
+ editorView: view,
617
+ node: node,
618
+ getScrollOffset: function getScrollOffset() {
619
+ var _this2$wrapper;
620
+ return ((_this2$wrapper = _this2.wrapper) === null || _this2$wrapper === void 0 ? void 0 : _this2$wrapper.scrollLeft) || 0;
621
+ },
622
+ getTableWrapperWidth: function getTableWrapperWidth() {
623
+ var _this2$wrapper2;
624
+ return ((_this2$wrapper2 = _this2.wrapper) === null || _this2$wrapper2 === void 0 ? void 0 : _this2$wrapper2.clientWidth) || 760;
625
+ }
626
+ }), /*#__PURE__*/_react.default.createElement("div", {
556
627
  style: shadowStyle(showBeforeShadow),
557
628
  className: _types.TableCssClassName.TABLE_LEFT_SHADOW
558
629
  }), this.state.stickyHeader && /*#__PURE__*/_react.default.createElement("div", {
@@ -574,7 +645,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
574
645
  }
575
646
  }
576
647
  }
577
- }), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-sticky-scrollbar') && /*#__PURE__*/_react.default.createElement("div", {
648
+ }, allowControls && colControls), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-sticky-scrollbar') && /*#__PURE__*/_react.default.createElement("div", {
578
649
  className: _types.TableCssClassName.TABLE_STICKY_SCROLLBAR_CONTAINER,
579
650
  style: {
580
651
  height: _editorSharedStyles.MAX_BROWSER_SCROLLBAR_HEIGHT,
@@ -16,8 +16,6 @@ var _debounce = _interopRequireDefault(require("lodash/debounce"));
16
16
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
17
17
  var _ui = require("@atlaskit/editor-common/ui");
18
18
  var _utils = require("@atlaskit/editor-common/utils");
19
- var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
20
- var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge");
21
19
  var _pluginFactory = require("../pm-plugins/plugin-factory");
22
20
  var _pluginKey = require("../pm-plugins/plugin-key");
23
21
  var _commands = require("../pm-plugins/sticky-headers/commands");
@@ -49,6 +47,9 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
49
47
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "listening", false);
50
48
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "padding", 0);
51
49
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "top", 0);
50
+ /**
51
+ * Methods
52
+ */
52
53
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "headerRowMouseScrollEnd", (0, _debounce.default)(function () {
53
54
  _this.dom.classList.remove('no-pointer-events');
54
55
  }, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
@@ -64,27 +65,20 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
64
65
  _this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node);
65
66
  _this.isSticky = false;
66
67
  var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
67
- pluginConfig = _getPluginState.pluginConfig,
68
- isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
68
+ pluginConfig = _getPluginState.pluginConfig;
69
69
  _this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
70
- _this.isDragAndDropEnabled = !!isDragAndDropEnabled;
71
70
  if (_this.isHeaderRow) {
72
71
  _this.dom.setAttribute('data-header-row', 'true');
73
72
  if (_this.isStickyHeaderEnabled) {
74
73
  _this.subscribe();
75
74
  }
76
75
  }
77
- if (_this.isDragAndDropEnabled) {
78
- _this.addDropTarget(_this.contentDOM);
79
- }
80
76
  return _this;
81
77
  }
82
78
 
83
79
  /**
84
80
  * Variables
85
81
  */
86
-
87
- // @ts-ignore
88
82
  (0, _createClass2.default)(TableRow, [{
89
83
  key: "update",
90
84
  value:
@@ -123,7 +117,6 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
123
117
  }, {
124
118
  key: "destroy",
125
119
  value: function destroy() {
126
- var _this$dropTargetClean;
127
120
  if (this.isStickyHeaderEnabled) {
128
121
  this.unsubscribe();
129
122
  var tree = (0, _dom2.getTree)(this.dom);
@@ -132,9 +125,6 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
132
125
  }
133
126
  this.emitOff(true);
134
127
  }
135
-
136
- // If a drop target cleanup method has been set then we should call it.
137
- (_this$dropTargetClean = this.dropTargetCleanup) === null || _this$dropTargetClean === void 0 || _this$dropTargetClean.call(this);
138
128
  }
139
129
  }, {
140
130
  key: "ignoreMutation",
@@ -161,72 +151,6 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
161
151
  }
162
152
  return true;
163
153
  }
164
-
165
- /**
166
- * Methods
167
- */
168
- }, {
169
- key: "addDropTarget",
170
- value: function addDropTarget(element) {
171
- var _this2 = this;
172
- var pos = this.getPos();
173
- if (!Number.isFinite(pos)) {
174
- return;
175
- }
176
- if (this.dropTargetCleanup) {
177
- this.dropTargetCleanup();
178
- }
179
- this.dropTargetCleanup = (0, _element.dropTargetForElements)({
180
- element: element,
181
- canDrop: function canDrop(_ref2) {
182
- var _data$indexes, _data$indexes2;
183
- var source = _ref2.source;
184
- var data = source.data;
185
- var _this2$getCurrentData = _this2.getCurrentData(),
186
- localId = _this2$getCurrentData.localId,
187
- targetIndex = _this2$getCurrentData.targetIndex;
188
- return (
189
- // Only draggables of row type can be dropped on this target
190
- data.type === 'table-row' &&
191
- // Only draggables which came from the same table can be dropped on this target
192
- data.localId === localId &&
193
- // Only draggables which DO NOT include this drop targets index can be dropped
194
- !!((_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
195
- );
196
- },
197
- getIsSticky: function getIsSticky() {
198
- return true;
199
- },
200
- getData: function getData(_ref3) {
201
- var input = _ref3.input,
202
- element = _ref3.element;
203
- var _this2$getCurrentData2 = _this2.getCurrentData(),
204
- localId = _this2$getCurrentData2.localId,
205
- targetIndex = _this2$getCurrentData2.targetIndex;
206
- var data = {
207
- localId: localId,
208
- type: 'table-row',
209
- targetIndex: targetIndex
210
- };
211
- return (0, _closestEdge.attachClosestEdge)(data, {
212
- input: input,
213
- element: element,
214
- allowedEdges: ['top', 'bottom']
215
- });
216
- }
217
- });
218
- }
219
- }, {
220
- key: "getCurrentData",
221
- value: function getCurrentData() {
222
- var resolvedPos = this.view.state.doc.resolve(this.getPos());
223
- var targetIndex = resolvedPos.index();
224
- var localId = resolvedPos.parent.attrs.localId;
225
- return {
226
- targetIndex: targetIndex,
227
- localId: localId
228
- };
229
- }
230
154
  }, {
231
155
  key: "subscribe",
232
156
  value: function subscribe() {
@@ -275,7 +199,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
275
199
  }, {
276
200
  key: "initObservers",
277
201
  value: function initObservers() {
278
- var _this3 = this;
202
+ var _this2 = this;
279
203
  if (!this.dom || this.dom.dataset.isObserved) {
280
204
  return;
281
205
  }
@@ -292,15 +216,15 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
292
216
  window.requestAnimationFrame(function () {
293
217
  var _getTree;
294
218
  // we expect tree to be defined after animation frame
295
- var tableContainer = (_getTree = (0, _dom2.getTree)(_this3.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
219
+ var tableContainer = (_getTree = (0, _dom2.getTree)(_this2.dom)) === null || _getTree === void 0 ? void 0 : _getTree.wrapper.closest(".".concat(_types.TableCssClassName.NODEVIEW_WRAPPER));
296
220
  if (tableContainer) {
297
- _this3.sentinels.top = tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
298
- _this3.sentinels.bottom = tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
299
- [_this3.sentinels.top, _this3.sentinels.bottom].forEach(function (el) {
221
+ _this2.sentinels.top = tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_TOP).item(0);
222
+ _this2.sentinels.bottom = tableContainer.getElementsByClassName(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM).item(0);
223
+ [_this2.sentinels.top, _this2.sentinels.bottom].forEach(function (el) {
300
224
  // skip if already observed for another row on this table
301
225
  if (el && !el.dataset.isObserved) {
302
226
  el.dataset.isObserved = 'true';
303
- _this3.intersectionObserver.observe(el);
227
+ _this2.intersectionObserver.observe(el);
304
228
  }
305
229
  });
306
230
  }
@@ -312,27 +236,27 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
312
236
  }, {
313
237
  key: "createResizeObserver",
314
238
  value: function createResizeObserver() {
315
- var _this4 = this;
239
+ var _this3 = this;
316
240
  this.resizeObserver = new ResizeObserver(function (entries) {
317
- var tree = (0, _dom2.getTree)(_this4.dom);
241
+ var tree = (0, _dom2.getTree)(_this3.dom);
318
242
  if (!tree) {
319
243
  return;
320
244
  }
321
245
  var table = tree.table;
322
246
  entries.forEach(function (entry) {
323
- var _this4$editorScrollab;
247
+ var _this3$editorScrollab;
324
248
  // On resize of the parent scroll element we need to adjust the width
325
249
  // of the sticky header
326
- if (entry.target.className === ((_this4$editorScrollab = _this4.editorScrollableElement) === null || _this4$editorScrollab === void 0 ? void 0 : _this4$editorScrollab.className)) {
327
- _this4.updateStickyHeaderWidth();
250
+ if (entry.target.className === ((_this3$editorScrollab = _this3.editorScrollableElement) === null || _this3$editorScrollab === void 0 ? void 0 : _this3$editorScrollab.className)) {
251
+ _this3.updateStickyHeaderWidth();
328
252
  } else {
329
253
  var newHeight = entry.contentRect ? entry.contentRect.height : entry.target.offsetHeight;
330
- if (_this4.sentinels.bottom &&
254
+ if (_this3.sentinels.bottom &&
331
255
  // When the table header is sticky, it would be taller by a 1px (border-bottom),
332
256
  // So we adding this check to allow a 1px difference.
333
- Math.abs(newHeight - (_this4.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
334
- _this4.stickyRowHeight = newHeight;
335
- _this4.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
257
+ Math.abs(newHeight - (_this3.stickyRowHeight || 0)) > _consts.stickyHeaderBorderBottomWidth) {
258
+ _this3.stickyRowHeight = newHeight;
259
+ _this3.sentinels.bottom.style.bottom = "".concat(_consts.tableScrollbarOffset + _consts.stickyRowOffsetTop + newHeight, "px");
336
260
  (0, _dom.updateStickyMargins)(table);
337
261
  }
338
262
  }
@@ -342,9 +266,9 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
342
266
  }, {
343
267
  key: "createIntersectionObserver",
344
268
  value: function createIntersectionObserver() {
345
- var _this5 = this;
269
+ var _this4 = this;
346
270
  this.intersectionObserver = new IntersectionObserver(function (entries, _) {
347
- var tree = (0, _dom2.getTree)(_this5.dom);
271
+ var tree = (0, _dom2.getTree)(_this4.dom);
348
272
  if (!tree) {
349
273
  return;
350
274
  }
@@ -367,28 +291,28 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
367
291
  var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
368
292
  if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
369
293
  var _entry$rootBounds3;
370
- tree && _this5.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
371
- _this5.lastStickyTimestamp = Date.now();
294
+ tree && _this4.makeHeaderRowSticky(tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
295
+ _this4.lastStickyTimestamp = Date.now();
372
296
  } else {
373
- table && _this5.makeRowHeaderNotSticky(table);
297
+ table && _this4.makeRowHeaderNotSticky(table);
374
298
  }
375
299
  }
376
300
  if (target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
377
301
  var _entry$rootBounds4;
378
- var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this5.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
302
+ var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
379
303
  if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
380
304
  // Not a perfect solution, but need to this code specific for FireFox ED-19177
381
305
  if (_utils.browser.gecko) {
382
- if (_this5.lastStickyTimestamp && Date.now() - _this5.lastStickyTimestamp > _consts.STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
383
- _this5.makeRowHeaderNotSticky(table);
306
+ if (_this4.lastStickyTimestamp && Date.now() - _this4.lastStickyTimestamp > _consts.STICKY_HEADER_TOGGLE_TOLERANCE_MS) {
307
+ _this4.makeRowHeaderNotSticky(table);
384
308
  }
385
309
  } else {
386
- _this5.makeRowHeaderNotSticky(table);
310
+ _this4.makeRowHeaderNotSticky(table);
387
311
  }
388
312
  } else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
389
313
  var _entry$rootBounds5;
390
- tree && _this5.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
391
- _this5.lastStickyTimestamp = Date.now();
314
+ tree && _this4.makeHeaderRowSticky(tree, entry === null || entry === void 0 || (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
315
+ _this4.lastStickyTimestamp = Date.now();
392
316
  }
393
317
  }
394
318
  return;
@@ -463,12 +387,12 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
463
387
  }, {
464
388
  key: "refireIntersectionObservers",
465
389
  value: function refireIntersectionObservers() {
466
- var _this6 = this;
390
+ var _this5 = this;
467
391
  if (this.isSticky) {
468
392
  [this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
469
- if (el && _this6.intersectionObserver) {
470
- _this6.intersectionObserver.unobserve(el);
471
- _this6.intersectionObserver.observe(el);
393
+ if (el && _this5.intersectionObserver) {
394
+ _this5.intersectionObserver.unobserve(el);
395
+ _this5.intersectionObserver.observe(el);
472
396
  }
473
397
  });
474
398
  }
@@ -477,7 +401,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
477
401
  key: "makeHeaderRowSticky",
478
402
  value: function makeHeaderRowSticky(tree, scrollTop) {
479
403
  var _tbody$firstChild,
480
- _this7 = this;
404
+ _this6 = this;
481
405
  // If header row height is more than 50% of viewport height don't do this
482
406
  if (this.isSticky || this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
483
407
  return;
@@ -514,7 +438,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_ref) {
514
438
  });
515
439
  var fastScrollThresholdMs = 500;
516
440
  setTimeout(function () {
517
- _this7.refireIntersectionObservers();
441
+ _this6.refireIntersectionObservers();
518
442
  }, fastScrollThresholdMs);
519
443
  }
520
444
  this.dom.style.top = "".concat(domTop, "px");
@@ -34,7 +34,7 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
34
34
  this.stickyScrollbarContainerElement.removeEventListener('scroll', this.handleScrollDebounced);
35
35
  this.handleScrollDebounced.cancel();
36
36
  }
37
- this.deleteIntesactionObserver();
37
+ this.deleteIntersectionObserver();
38
38
  }
39
39
  }, {
40
40
  key: "scrollLeft",
@@ -80,10 +80,10 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
80
80
  return;
81
81
  }
82
82
  if (target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_BOTTOM)) {
83
- _this2.sentenialBottomCallback(entry);
83
+ _this2.sentinelBottomCallback(entry);
84
84
  }
85
85
  if (target.classList.contains(_types.TableCssClassName.TABLE_STICKY_SCROLLBAR_SENTINEL_TOP)) {
86
- _this2.sentenialTopCallback(entry);
86
+ _this2.sentinelTopCallback(entry);
87
87
  }
88
88
  });
89
89
  }, {
@@ -96,8 +96,8 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
96
96
  });
97
97
  }
98
98
  }, {
99
- key: "deleteIntesactionObserver",
100
- value: function deleteIntesactionObserver() {
99
+ key: "deleteIntersectionObserver",
100
+ value: function deleteIntersectionObserver() {
101
101
  if (this.intersectionObserver) {
102
102
  if (this.sentinels.bottom) {
103
103
  this.intersectionObserver.unobserve(this.sentinels.bottom);
@@ -106,16 +106,16 @@ var TableStickyScrollbar = exports.TableStickyScrollbar = /*#__PURE__*/function
106
106
  }
107
107
  }
108
108
  }, {
109
- key: "sentenialBottomCallback",
110
- value: function sentenialBottomCallback(entry) {
109
+ key: "sentinelBottomCallback",
110
+ value: function sentinelBottomCallback(entry) {
111
111
  var _entry$rootBounds2;
112
112
  var sentinelIsAboveScrollArea = entry.boundingClientRect.top < (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.top) || 0);
113
113
  this.bottomSentinelState = sentinelIsAboveScrollArea ? 'above' : entry.isIntersecting ? 'visible' : 'below';
114
114
  this.toggle();
115
115
  }
116
116
  }, {
117
- key: "sentenialTopCallback",
118
- value: function sentenialTopCallback(entry) {
117
+ key: "sentinelTopCallback",
118
+ value: function sentinelTopCallback(entry) {
119
119
  var _entry$rootBounds3;
120
120
  var sentinelIsBelowScrollArea = (((_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.bottom) || 0) < entry.boundingClientRect.top;
121
121
  this.topSentinelState = sentinelIsBelowScrollArea ? 'below' : entry.isIntersecting ? 'visible' : 'above';
@@ -11,7 +11,6 @@ var _view = require("@atlaskit/editor-prosemirror/view");
11
11
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
12
12
  var _utils = require("@atlaskit/editor-tables/utils");
13
13
  var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
14
- var _pragmaticDragAndDropReactBeautifulDndAutoscroll = require("@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll");
15
14
  var _mergedCells = require("../../utils/merged-cells");
16
15
  var _pluginFactory = require("../plugin-factory");
17
16
  var _actions = require("./actions");
@@ -95,15 +94,9 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
95
94
  },
96
95
  onDragStart: function onDragStart(_ref3) {
97
96
  var location = _ref3.location;
98
- _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.start({
99
- input: location.current.input
100
- });
101
97
  (0, _commands.toggleDragMenu)(false)(editorView.state, editorView.dispatch);
102
98
  },
103
99
  onDrag: function onDrag(event) {
104
- _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.updateInput({
105
- input: event.location.current.input
106
- });
107
100
  var data = (0, _monitor.getDraggableDataFromEvent)(event);
108
101
  // If no data can be found then it's most like we do not want to perform any drag actions
109
102
  if (!data) {
@@ -119,7 +112,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
119
112
  (0, _commands.setDropTarget)(dropTargetType, targetAdjustedIndex)(editorView.state, editorView.dispatch);
120
113
  },
121
114
  onDrop: function onDrop(event) {
122
- _pragmaticDragAndDropReactBeautifulDndAutoscroll.autoScroller.stop();
123
115
  var data = (0, _monitor.getDraggableDataFromEvent)(event);
124
116
 
125
117
  // If no data can be found then it's most like we do not want to perform any drop action
@@ -61,7 +61,8 @@ var ColumnDropTarget = exports.ColumnDropTarget = function ColumnDropTarget(_ref
61
61
  width: width && "".concat(width - 1, "px"),
62
62
  height: height && "".concat(height, "px"),
63
63
  marginTop: marginTop && "".concat(marginTop, "px"),
64
- pointerEvents: 'auto'
64
+ pointerEvents: 'auto',
65
+ flexShrink: 0
65
66
  },
66
67
  "data-drop-target-index": index,
67
68
  "data-drop-target-localid": localId,
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = exports.TableFloatingColumnControls = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
- var _reactDom = _interopRequireDefault(require("react-dom"));
12
11
  var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
13
12
  var _types = require("../../types");
14
13
  var _utils = require("../../utils");
@@ -105,11 +104,10 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
105
104
  }
106
105
  var colWidths = (0, _utils.getColumnsWidths)(editorView);
107
106
  var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
108
- var mountTo = tableRef && (tableRef === null || tableRef === void 0 ? void 0 : tableRef.parentElement) || document.body;
109
107
  if (!tableActive) {
110
108
  return null;
111
109
  }
112
- return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement("div", {
110
+ return /*#__PURE__*/_react.default.createElement("div", {
113
111
  className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS_WRAPPER,
114
112
  "data-testid": "table-floating-column-controls-wrapper"
115
113
  }, /*#__PURE__*/_react.default.createElement(_ColumnControls.ColumnControls, {
@@ -131,6 +129,6 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
131
129
  localId: currentNodeLocalId,
132
130
  rowHeights: rowHeights,
133
131
  colWidths: colWidths
134
- })), mountTo);
132
+ }));
135
133
  };
136
134
  var _default = exports.default = TableFloatingColumnControls;