@atlaskit/editor-plugin-table 5.8.1 → 5.8.3

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 (27) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/nodeviews/TableComponent.js +17 -62
  3. package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +153 -123
  4. package/dist/cjs/pm-plugins/drag-and-drop/utils/autoscrollers.js +53 -0
  5. package/dist/cjs/pm-plugins/drag-and-drop/utils/index.js +8 -1
  6. package/dist/cjs/ui/FloatingInsertButton/InsertButton.js +1 -1
  7. package/dist/es2019/nodeviews/TableComponent.js +5 -55
  8. package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +158 -124
  9. package/dist/es2019/pm-plugins/drag-and-drop/utils/autoscrollers.js +50 -0
  10. package/dist/es2019/pm-plugins/drag-and-drop/utils/index.js +2 -1
  11. package/dist/es2019/ui/FloatingInsertButton/InsertButton.js +1 -1
  12. package/dist/esm/nodeviews/TableComponent.js +7 -52
  13. package/dist/esm/pm-plugins/drag-and-drop/plugin.js +152 -122
  14. package/dist/esm/pm-plugins/drag-and-drop/utils/autoscrollers.js +47 -0
  15. package/dist/esm/pm-plugins/drag-and-drop/utils/index.js +2 -1
  16. package/dist/esm/ui/FloatingInsertButton/InsertButton.js +1 -1
  17. package/dist/types/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +7 -0
  18. package/dist/types/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
  19. package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/autoscrollers.d.ts +7 -0
  20. package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/index.d.ts +1 -0
  21. package/package.json +1 -1
  22. package/src/__tests__/visual-regression/sticky-header.ts +1 -2
  23. package/src/nodeviews/TableComponent.tsx +5 -49
  24. package/src/pm-plugins/drag-and-drop/plugin.ts +202 -157
  25. package/src/pm-plugins/drag-and-drop/utils/autoscrollers.ts +52 -0
  26. package/src/pm-plugins/drag-and-drop/utils/index.ts +2 -0
  27. package/src/ui/FloatingInsertButton/InsertButton.tsx +1 -1
@@ -1,5 +1,5 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import { INPUT_METHOD, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
@@ -7,7 +7,9 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  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
+ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
10
11
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
12
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
11
13
  import { findNearestCellIndexToPoint, hasMergedCellsInBetween } from '../../utils';
12
14
  import { getPluginState as getTablePluginState } from '../plugin-factory';
13
15
  import { pluginKey as tablePluginKey } from '../plugin-key';
@@ -19,6 +21,148 @@ import { DRAGGABLE_TABLE_NODE_SIZE_LIMIT, DropTargetType } from './consts';
19
21
  import { createPluginState, getPluginState } from './plugin-factory';
20
22
  import { pluginKey } from './plugin-key';
21
23
  import { getDraggableDataFromEvent } from './utils/monitor';
24
+ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
25
+ var editorPageScrollContainer = document.querySelector('.fabric-editor-popup-scroll-parent');
26
+ var rowAutoScrollers = editorPageScrollContainer ? [monitorForElements({
27
+ canMonitor: function canMonitor(_ref) {
28
+ var source = _ref.source;
29
+ var _ref2 = source.data,
30
+ type = _ref2.type;
31
+ return type === 'table-row';
32
+ },
33
+ onDragStart: function onDragStart() {
34
+ // auto scroller doesn't work when scroll-behavior: smooth is set, this monitor temporarily removes it via inline styles
35
+ editorPageScrollContainer.style.setProperty('scroll-behavior', 'unset');
36
+ },
37
+ onDrop: function onDrop() {
38
+ // 'null' will remove the inline style
39
+ editorPageScrollContainer.style.setProperty('scroll-behavior', null);
40
+ }
41
+ }), autoScrollForElements({
42
+ element: editorPageScrollContainer,
43
+ canScroll: function canScroll(_ref3) {
44
+ var source = _ref3.source;
45
+ var _ref4 = source.data,
46
+ type = _ref4.type;
47
+ return type === 'table-row';
48
+ }
49
+ })] : [];
50
+ return combine.apply(void 0, rowAutoScrollers.concat([monitorForElements({
51
+ canMonitor: function canMonitor(_ref5) {
52
+ var source = _ref5.source;
53
+ var _ref6 = source.data,
54
+ type = _ref6.type,
55
+ localId = _ref6.localId,
56
+ indexes = _ref6.indexes;
57
+
58
+ // First; Perform any quick checks so we can abort early.
59
+ if (!indexes || !localId ||
60
+ // FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
61
+ // of more then 1 item.
62
+ indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
63
+ return false;
64
+ }
65
+ var _getTablePluginState = getTablePluginState(editorView.state),
66
+ tableNode = _getTablePluginState.tableNode;
67
+ // If the draggable localId is the same as the current selected table localId then we will allow the monitor
68
+ // watch for changes
69
+ return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
70
+ },
71
+ onDragStart: function onDragStart(_ref7) {
72
+ var location = _ref7.location;
73
+ toggleDragMenu(false)(editorView.state, editorView.dispatch);
74
+ },
75
+ onDrag: function onDrag(event) {
76
+ var data = getDraggableDataFromEvent(event);
77
+ // If no data can be found then it's most like we do not want to perform any drag actions
78
+ if (!data) {
79
+ clearDropTarget()(editorView.state, editorView.dispatch);
80
+ return;
81
+ }
82
+
83
+ // TODO: as we drag an element around we are going to want to update the state to acurately reflect the current
84
+ // insert location as to where the draggable will most likely be go. For example;
85
+ var sourceType = data.sourceType,
86
+ targetAdjustedIndex = data.targetAdjustedIndex;
87
+ var dropTargetType = sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN;
88
+ var hasMergedCells = hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], dropTargetType)(editorView.state.selection);
89
+ setDropTarget(dropTargetType, targetAdjustedIndex, hasMergedCells)(editorView.state, editorView.dispatch);
90
+ },
91
+ onDrop: function onDrop(event) {
92
+ var _cell$row, _cell$col;
93
+ var data = getDraggableDataFromEvent(event);
94
+
95
+ // On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
96
+ // over. This is so the drag handles update their positions to correctly align with the users mouse. Unfortunately
97
+ // at this point in time and during the drag opertation, the drop targets are eating all the mouse events so
98
+ // it's not possible to know what row/col the mouse is over (via mouse events). This attempts to locate the nearest cell and
99
+ // then tries to update the main table hoveredCell value by piggy-backing the transaction onto the command
100
+ // triggered by this on drop event.
101
+ var _getTablePluginState2 = getTablePluginState(editorView.state),
102
+ hoveredCell = _getTablePluginState2.hoveredCell;
103
+ var cell = findNearestCellIndexToPoint(event.location.current.input.clientX, event.location.current.input.clientY);
104
+ var tr = editorView.state.tr;
105
+ var action = {
106
+ type: 'HOVER_CELL',
107
+ data: {
108
+ hoveredCell: {
109
+ rowIndex: (_cell$row = cell === null || cell === void 0 ? void 0 : cell.row) !== null && _cell$row !== void 0 ? _cell$row : hoveredCell.rowIndex,
110
+ colIndex: (_cell$col = cell === null || cell === void 0 ? void 0 : cell.col) !== null && _cell$col !== void 0 ? _cell$col : hoveredCell.colIndex
111
+ }
112
+ }
113
+ };
114
+ tr.setMeta(tablePluginKey, action);
115
+
116
+ // If no data can be found then it's most like we do not want to perform any drop action
117
+ if (!data) {
118
+ var _event$source, _event$source2;
119
+ // If we're able to determine the source type of the dropped element then we should report to analytics that
120
+ // the drop event was cancelled. Otherwise we will cancel silently.
121
+ if ((event === null || event === void 0 || (_event$source = event.source) === null || _event$source === void 0 || (_event$source = _event$source.data) === null || _event$source === void 0 ? void 0 : _event$source.type) === 'table-row' || (event === null || event === void 0 || (_event$source2 = event.source) === null || _event$source2 === void 0 || (_event$source2 = _event$source2.data) === null || _event$source2 === void 0 ? void 0 : _event$source2.type) === 'table-column') {
122
+ return clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
123
+ }
124
+ return clearDropTarget(tr)(editorView.state, editorView.dispatch);
125
+ }
126
+ var sourceType = data.sourceType,
127
+ sourceIndexes = data.sourceIndexes,
128
+ targetIndex = data.targetIndex,
129
+ targetAdjustedIndex = data.targetAdjustedIndex,
130
+ direction = data.direction;
131
+
132
+ // When we drop on a target we will know the targets row/col index for certain,
133
+ if (sourceType === 'table-row') {
134
+ action.data.hoveredCell.rowIndex = targetIndex;
135
+ } else {
136
+ action.data.hoveredCell.colIndex = targetIndex;
137
+ }
138
+
139
+ // If the drop target index contains merged cells then we should not allow the drop to occur.
140
+ if (hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN)(editorView.state.selection)) {
141
+ clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType,
142
+ // This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
143
+ TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
144
+ return;
145
+ }
146
+ var _sourceIndexes = _slicedToArray(sourceIndexes, 1),
147
+ sourceIndex = _sourceIndexes[0];
148
+ requestAnimationFrame(function () {
149
+ moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
150
+
151
+ // force a colgroup update here, otherwise dropped columns don't have
152
+ // the correct width immediately after the drop
153
+ if (sourceType === 'table-column') {
154
+ var _getTablePluginState3 = getTablePluginState(editorView.state),
155
+ tableRef = _getTablePluginState3.tableRef,
156
+ tableNode = _getTablePluginState3.tableNode;
157
+ if (tableRef && tableNode) {
158
+ insertColgroupFromNode(tableRef, tableNode);
159
+ }
160
+ }
161
+ editorView.focus();
162
+ });
163
+ }
164
+ })]));
165
+ };
22
166
  export var createPlugin = function createPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) {
23
167
  return new SafePlugin({
24
168
  state: createPluginState(dispatch, function (state) {
@@ -34,12 +178,12 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
34
178
  }),
35
179
  key: pluginKey,
36
180
  appendTransaction: function appendTransaction(transactions, oldState, newState) {
37
- var _getTablePluginState = getTablePluginState(oldState),
38
- oldTargetCellPosition = _getTablePluginState.targetCellPosition,
39
- oldTableNode = _getTablePluginState.tableNode;
40
- var _getTablePluginState2 = getTablePluginState(newState),
41
- newTargetCellPosition = _getTablePluginState2.targetCellPosition,
42
- newTableNode = _getTablePluginState2.tableNode;
181
+ var _getTablePluginState4 = getTablePluginState(oldState),
182
+ oldTargetCellPosition = _getTablePluginState4.targetCellPosition,
183
+ oldTableNode = _getTablePluginState4.tableNode;
184
+ var _getTablePluginState5 = getTablePluginState(newState),
185
+ newTargetCellPosition = _getTablePluginState5.targetCellPosition,
186
+ newTableNode = _getTablePluginState5.tableNode;
43
187
  var _getPluginState = getPluginState(newState),
44
188
  isDragMenuOpen = _getPluginState.isDragMenuOpen,
45
189
  dragMenuIndex = _getPluginState.dragMenuIndex,
@@ -93,121 +237,7 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher, edito
93
237
  },
94
238
  view: function view(editorView) {
95
239
  return {
96
- destroy: monitorForElements({
97
- canMonitor: function canMonitor(_ref) {
98
- var source = _ref.source;
99
- var _ref2 = source.data,
100
- type = _ref2.type,
101
- localId = _ref2.localId,
102
- indexes = _ref2.indexes;
103
-
104
- // First; Perform any quick checks so we can abort early.
105
- if (!indexes || !localId ||
106
- // FIXME: We currently don't support DragNDrop of multiple elements. For now we will not bother to monitor drags
107
- // of more then 1 item.
108
- indexes.length !== 1 || !(type === 'table-row' || type === 'table-column')) {
109
- return false;
110
- }
111
- var _getTablePluginState3 = getTablePluginState(editorView.state),
112
- tableNode = _getTablePluginState3.tableNode;
113
- // If the draggable localId is the same as the current selected table localId then we will allow the monitor
114
- // watch for changes
115
- return localId === (tableNode === null || tableNode === void 0 ? void 0 : tableNode.attrs.localId);
116
- },
117
- onDragStart: function onDragStart(_ref3) {
118
- var location = _ref3.location;
119
- toggleDragMenu(false)(editorView.state, editorView.dispatch);
120
- },
121
- onDrag: function onDrag(event) {
122
- var data = getDraggableDataFromEvent(event);
123
- // If no data can be found then it's most like we do not want to perform any drag actions
124
- if (!data) {
125
- clearDropTarget()(editorView.state, editorView.dispatch);
126
- return;
127
- }
128
-
129
- // TODO: as we drag an element around we are going to want to update the state to acurately reflect the current
130
- // insert location as to where the draggable will most likely be go. For example;
131
- var sourceType = data.sourceType,
132
- targetAdjustedIndex = data.targetAdjustedIndex;
133
- var dropTargetType = sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN;
134
- var hasMergedCells = hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], dropTargetType)(editorView.state.selection);
135
- setDropTarget(dropTargetType, targetAdjustedIndex, hasMergedCells)(editorView.state, editorView.dispatch);
136
- },
137
- onDrop: function onDrop(event) {
138
- var _cell$row, _cell$col;
139
- var data = getDraggableDataFromEvent(event);
140
-
141
- // On Drop we need to update the table main plugin hoveredCell value with the current row/col that the mouse is
142
- // over. This is so the drag handles update their positions to correctly align with the users mouse. Unfortunately
143
- // at this point in time and during the drag opertation, the drop targets are eating all the mouse events so
144
- // it's not possible to know what row/col the mouse is over (via mouse events). This attempts to locate the nearest cell and
145
- // then tries to update the main table hoveredCell value by piggy-backing the transaction onto the command
146
- // triggered by this on drop event.
147
- var _getTablePluginState4 = getTablePluginState(editorView.state),
148
- hoveredCell = _getTablePluginState4.hoveredCell;
149
- var cell = findNearestCellIndexToPoint(event.location.current.input.clientX, event.location.current.input.clientY);
150
- var tr = editorView.state.tr;
151
- var action = {
152
- type: 'HOVER_CELL',
153
- data: {
154
- hoveredCell: {
155
- rowIndex: (_cell$row = cell === null || cell === void 0 ? void 0 : cell.row) !== null && _cell$row !== void 0 ? _cell$row : hoveredCell.rowIndex,
156
- colIndex: (_cell$col = cell === null || cell === void 0 ? void 0 : cell.col) !== null && _cell$col !== void 0 ? _cell$col : hoveredCell.colIndex
157
- }
158
- }
159
- };
160
- tr.setMeta(tablePluginKey, action);
161
-
162
- // If no data can be found then it's most like we do not want to perform any drop action
163
- if (!data) {
164
- var _event$source, _event$source2;
165
- // If we're able to determine the source type of the dropped element then we should report to analytics that
166
- // the drop event was cancelled. Otherwise we will cancel silently.
167
- if ((event === null || event === void 0 || (_event$source = event.source) === null || _event$source === void 0 || (_event$source = _event$source.data) === null || _event$source === void 0 ? void 0 : _event$source.type) === 'table-row' || (event === null || event === void 0 || (_event$source2 = event.source) === null || _event$source2 === void 0 || (_event$source2 = _event$source2.data) === null || _event$source2 === void 0 ? void 0 : _event$source2.type) === 'table-column') {
168
- return clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
169
- }
170
- return clearDropTarget(tr)(editorView.state, editorView.dispatch);
171
- }
172
- var sourceType = data.sourceType,
173
- sourceIndexes = data.sourceIndexes,
174
- targetIndex = data.targetIndex,
175
- targetAdjustedIndex = data.targetAdjustedIndex,
176
- direction = data.direction;
177
-
178
- // When we drop on a target we will know the targets row/col index for certain,
179
- if (sourceType === 'table-row') {
180
- action.data.hoveredCell.rowIndex = targetIndex;
181
- } else {
182
- action.data.hoveredCell.colIndex = targetIndex;
183
- }
184
-
185
- // If the drop target index contains merged cells then we should not allow the drop to occur.
186
- if (hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN)(editorView.state.selection)) {
187
- clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType,
188
- // This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
189
- TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
190
- return;
191
- }
192
- var _sourceIndexes = _slicedToArray(sourceIndexes, 1),
193
- sourceIndex = _sourceIndexes[0];
194
- requestAnimationFrame(function () {
195
- moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
196
-
197
- // force a colgroup update here, otherwise dropped columns don't have
198
- // the correct width immediately after the drop
199
- if (sourceType === 'table-column') {
200
- var _getTablePluginState5 = getTablePluginState(editorView.state),
201
- tableRef = _getTablePluginState5.tableRef,
202
- tableNode = _getTablePluginState5.tableNode;
203
- if (tableRef && tableNode) {
204
- insertColgroupFromNode(tableRef, tableNode);
205
- }
206
- }
207
- editorView.focus();
208
- });
209
- }
210
- })
240
+ destroy: destroyFn(editorView, editorAnalyticsAPI)
211
241
  };
212
242
  },
213
243
  props: {
@@ -0,0 +1,47 @@
1
+ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
2
+ import { unsafeOverflowAutoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element';
3
+ import { dropTargetExtendedWidth } from '../../../ui/consts';
4
+ export var autoScrollerFactory = function autoScrollerFactory(_ref) {
5
+ var tableWrapper = _ref.tableWrapper,
6
+ getNode = _ref.getNode;
7
+ return [autoScrollForElements({
8
+ element: tableWrapper,
9
+ canScroll: function canScroll(_ref2) {
10
+ var source = _ref2.source;
11
+ var _ref3 = source.data,
12
+ localId = _ref3.localId,
13
+ type = _ref3.type;
14
+ var node = getNode();
15
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
16
+ }
17
+ }), unsafeOverflowAutoScrollForElements({
18
+ element: tableWrapper,
19
+ canScroll: function canScroll(_ref4) {
20
+ var source = _ref4.source;
21
+ var _ref5 = source.data,
22
+ localId = _ref5.localId,
23
+ type = _ref5.type;
24
+ var node = getNode();
25
+ return localId === (node === null || node === void 0 ? void 0 : node.attrs.localId) && type === 'table-column';
26
+ },
27
+ getOverflow: function getOverflow() {
28
+ return {
29
+ fromTopEdge: {
30
+ top: dropTargetExtendedWidth,
31
+ right: dropTargetExtendedWidth,
32
+ left: dropTargetExtendedWidth
33
+ },
34
+ fromRightEdge: {
35
+ right: dropTargetExtendedWidth,
36
+ top: dropTargetExtendedWidth,
37
+ bottom: dropTargetExtendedWidth
38
+ },
39
+ fromLeftEdge: {
40
+ top: dropTargetExtendedWidth,
41
+ left: dropTargetExtendedWidth,
42
+ bottom: dropTargetExtendedWidth
43
+ }
44
+ };
45
+ }
46
+ })];
47
+ };
@@ -1 +1,2 @@
1
- export { getDraggableDataFromEvent } from './monitor';
1
+ export { getDraggableDataFromEvent } from './monitor';
2
+ export { autoScrollerFactory } from './autoscrollers';
@@ -74,7 +74,7 @@ export var InsertButtonForDragAndDrop = function InsertButtonForDragAndDrop(_ref
74
74
  fill: "none",
75
75
  xmlns: "http://www.w3.org/2000/svg"
76
76
  }, /*#__PURE__*/React.createElement("path", {
77
- d: "M8.66667 7.33333V4.66667C8.66667 4.48986 8.59643 4.32029 8.47141 4.19526C8.34638 4.07024 8.17682 4 8 4C7.82318 4 7.65362 4.07024 7.52859 4.19526C7.40357 4.32029 7.33333 4.48986 7.33333 4.66667V7.33333H4.66667C4.48986 7.33333 4.32029 7.40357 4.19526 7.52859C4.07024 7.65362 4 7.82318 4 8C4 8.17682 4.07024 8.34638 4.19526 8.47141C4.32029 8.59643 4.48986 8.66667 4.66667 8.66667H7.33333V11.3333C7.33333 11.5101 7.40357 11.6797 7.52859 11.8047C7.65362 11.9298 7.82318 12 8 12C8.17682 12 8.34638 11.9298 8.47141 11.8047C8.59643 11.6797 8.66667 11.5101 8.66667 11.3333V8.66667H11.3333C11.5101 8.66667 11.6797 8.59643 11.8047 8.47141C11.9298 8.34638 12 8.17682 12 8C12 7.82318 11.9298 7.65362 11.8047 7.52859C11.6797 7.40357 11.5101 7.33333 11.3333 7.33333H8.66667Z",
77
+ d: "M8 4C7.44771 4 7 4.44771 7 5V7H5C4.44771 7 4 7.44771 4 8C4 8.55229 4.44771 9 5 9H7V11C7 11.5523 7.44771 12 8 12C8.55229 12 9 11.5523 9 11V9H11C11.5523 9 12 8.55229 12 8C12 7.44771 11.5523 7 11 7H9V5C9 4.44771 8.55229 4 8 4Z",
78
78
  fill: "currentColor"
79
79
  })))), /*#__PURE__*/React.createElement("div", {
80
80
  className: ClassName.CONTROLS_INSERT_LINE,
@@ -0,0 +1,7 @@
1
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
+ type AutoScrollerFactory = {
3
+ tableWrapper: HTMLElement;
4
+ getNode: () => PmNode;
5
+ };
6
+ export declare const autoScrollerFactory: ({ tableWrapper, getNode, }: AutoScrollerFactory) => import("@atlaskit/pragmatic-drag-and-drop/types").CleanupFn[];
7
+ export {};
@@ -1 +1,2 @@
1
1
  export { getDraggableDataFromEvent } from './monitor';
2
+ export { autoScrollerFactory } from './autoscrollers';
@@ -0,0 +1,7 @@
1
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
2
+ type AutoScrollerFactory = {
3
+ tableWrapper: HTMLElement;
4
+ getNode: () => PmNode;
5
+ };
6
+ export declare const autoScrollerFactory: ({ tableWrapper, getNode, }: AutoScrollerFactory) => import("@atlaskit/pragmatic-drag-and-drop/types").CleanupFn[];
7
+ export {};
@@ -1 +1,2 @@
1
1
  export { getDraggableDataFromEvent } from './monitor';
2
+ export { autoScrollerFactory } from './autoscrollers';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.8.1",
3
+ "version": "5.8.3",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -42,8 +42,7 @@ describe('Snapshot Test: Table', () => {
42
42
  });
43
43
 
44
44
  describe('sticky header', () => {
45
- // FIXME: This test was automatically skipped due to failure on 26/07/2023: https://product-fabric.atlassian.net/browse/ED-19223
46
- it.skip('should align with table cell when active', async () => {
45
+ it('should align with table cell when active', async () => {
47
46
  await initEditor(page, stickyHeaderWithHorizontalScroll);
48
47
 
49
48
  await clickFirstCell(page, true);
@@ -31,15 +31,11 @@ import {
31
31
  } from '@atlaskit/editor-shared-styles';
32
32
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
33
33
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
34
- import {
35
- autoScrollForElements,
36
- autoScrollWindowForElements,
37
- } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
38
- import { unsafeOverflowAutoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/element';
39
34
  import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
40
35
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
41
36
 
42
37
  import { autoSizeTable, clearHoverSelection } from '../commands';
38
+ import { autoScrollerFactory } from '../pm-plugins/drag-and-drop/utils';
43
39
  import { getPluginState } from '../pm-plugins/plugin-factory';
44
40
  import type {
45
41
  RowStickyState,
@@ -57,10 +53,9 @@ import {
57
53
  } from '../pm-plugins/table-resizing/utils';
58
54
  import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils/colgroup';
59
55
  import { updateControls } from '../pm-plugins/table-resizing/utils/dom';
60
- import type { DraggableSourceData, PluginInjectionAPI } from '../types';
56
+ import type { PluginInjectionAPI } from '../types';
61
57
  import { TableCssClassName as ClassName, ShadowEvent } from '../types';
62
58
  import {
63
- dropTargetExtendedWidth,
64
59
  tableOverflowShadowWidth,
65
60
  tableOverflowShadowWidthWide,
66
61
  } from '../ui/consts';
@@ -198,48 +193,9 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
198
193
 
199
194
  if (isDragAndDropEnabled) {
200
195
  this.dragAndDropCleanupFn = combine(
201
- autoScrollForElements({
202
- element: this.wrapper,
203
- canScroll: ({ source }) => {
204
- const { localId, type } =
205
- source.data as Partial<DraggableSourceData>;
206
- const node = getNode();
207
- return localId === node?.attrs.localId && type === 'table-column';
208
- },
209
- }),
210
- autoScrollWindowForElements({
211
- canScroll: ({ source }) => {
212
- const { localId, type } =
213
- source.data as Partial<DraggableSourceData>;
214
- const node = getNode();
215
- return localId === node?.attrs.localId && type === 'table-row';
216
- },
217
- }),
218
- unsafeOverflowAutoScrollForElements({
219
- element: this.wrapper,
220
- canScroll: ({ source }) => {
221
- const { localId, type } =
222
- source.data as Partial<DraggableSourceData>;
223
- const node = getNode();
224
- return localId === node?.attrs.localId && type === 'table-column';
225
- },
226
- getOverflow: () => ({
227
- fromTopEdge: {
228
- top: dropTargetExtendedWidth,
229
- right: dropTargetExtendedWidth,
230
- left: dropTargetExtendedWidth,
231
- },
232
- fromRightEdge: {
233
- right: dropTargetExtendedWidth,
234
- top: dropTargetExtendedWidth,
235
- bottom: dropTargetExtendedWidth,
236
- },
237
- fromLeftEdge: {
238
- top: dropTargetExtendedWidth,
239
- left: dropTargetExtendedWidth,
240
- bottom: dropTargetExtendedWidth,
241
- },
242
- }),
196
+ ...autoScrollerFactory({
197
+ tableWrapper: this.wrapper,
198
+ getNode,
243
199
  }),
244
200
  );
245
201
  }