@atlaskit/editor-plugin-table 7.5.16 → 7.6.1
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.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +36 -1
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +17 -1
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +8 -2
- package/dist/cjs/pm-plugins/drag-and-drop/utils/getDragBehaviour.js +13 -0
- package/dist/cjs/pm-plugins/drag-and-drop/utils/monitor.js +11 -4
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +31 -6
- package/dist/cjs/ui/TableFloatingControls/RowDropTarget/index.js +31 -6
- package/dist/cjs/ui/consts.js +3 -2
- package/dist/cjs/utils/snapping.js +2 -1
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +34 -1
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +15 -1
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +9 -3
- package/dist/es2019/pm-plugins/drag-and-drop/utils/getDragBehaviour.js +8 -0
- package/dist/es2019/pm-plugins/drag-and-drop/utils/monitor.js +9 -4
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +27 -3
- package/dist/es2019/ui/TableFloatingControls/RowDropTarget/index.js +27 -3
- package/dist/es2019/ui/consts.js +2 -1
- package/dist/es2019/utils/snapping.js +3 -2
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +36 -1
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +17 -1
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +9 -3
- package/dist/esm/pm-plugins/drag-and-drop/utils/getDragBehaviour.js +7 -0
- package/dist/esm/pm-plugins/drag-and-drop/utils/monitor.js +10 -4
- package/dist/esm/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +31 -6
- package/dist/esm/ui/TableFloatingControls/RowDropTarget/index.js +31 -6
- package/dist/esm/ui/consts.js +2 -1
- package/dist/esm/utils/snapping.js +3 -2
- package/dist/types/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/commands.d.ts +1 -0
- package/dist/types/pm-plugins/drag-and-drop/utils/getDragBehaviour.d.ts +3 -0
- package/dist/types/types.d.ts +12 -1
- package/dist/types/ui/consts.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/commands.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/utils/getDragBehaviour.d.ts +3 -0
- package/dist/types-ts4.5/types.d.ts +12 -1
- package/dist/types-ts4.5/ui/consts.d.ts +1 -0
- package/package.json +3 -3
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +56 -1
- package/src/pm-plugins/drag-and-drop/commands.ts +31 -2
- package/src/pm-plugins/drag-and-drop/plugin.ts +21 -7
- package/src/pm-plugins/drag-and-drop/utils/getDragBehaviour.ts +12 -0
- package/src/pm-plugins/drag-and-drop/utils/monitor.ts +17 -3
- package/src/types.ts +13 -1
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +39 -5
- package/src/ui/TableFloatingControls/RowDropTarget/index.tsx +40 -5
- package/src/ui/consts.ts +2 -0
- package/src/utils/snapping.ts +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 7.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#83158](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83158) [`5a0749bf19ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5a0749bf19ec) - Fix incorrect full width guideline snapping
|
|
8
|
+
|
|
9
|
+
## 7.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#83612](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83612) [`25b32cbfbb7e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/25b32cbfbb7e) - [ux] Added new clone row/column behaviour to tables drag N drop. When the user holds the alt modifier during the operation the row/column will be duplicated rather then moved.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 7.5.16
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.moveSourceWithAnalyticsViaShortcut = exports.moveSourceWithAnalytics = exports.clearDropTargetWithAnalytics = void 0;
|
|
7
|
+
exports.moveSourceWithAnalyticsViaShortcut = exports.moveSourceWithAnalytics = exports.cloneSourceWithAnalytics = exports.clearDropTargetWithAnalytics = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
@@ -102,4 +102,39 @@ var moveSourceWithAnalyticsViaShortcut = exports.moveSourceWithAnalyticsViaShort
|
|
|
102
102
|
return moveSourceWithAnalytics(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
|
+
};
|
|
106
|
+
var cloneSourceWithAnalytics = exports.cloneSourceWithAnalytics = function cloneSourceWithAnalytics(editorAnalyticsAPI) {
|
|
107
|
+
return function (inputMethod, sourceType, sourceIndexes, targetIndex, targetDirection, tr) {
|
|
108
|
+
return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref3) {
|
|
109
|
+
var selection = _ref3.selection;
|
|
110
|
+
var direction = sourceIndexes[0] > targetIndex ? -1 : 1;
|
|
111
|
+
var _getSelectedTableInfo4 = (0, _utils2.getSelectedTableInfo)(selection),
|
|
112
|
+
totalRowCount = _getSelectedTableInfo4.totalRowCount,
|
|
113
|
+
totalColumnCount = _getSelectedTableInfo4.totalColumnCount;
|
|
114
|
+
return {
|
|
115
|
+
action: sourceType === 'table-row' ? _analytics.TABLE_ACTION.CLONED_ROW : _analytics.TABLE_ACTION.CLONED_COLUMN,
|
|
116
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
117
|
+
actionSubjectId: null,
|
|
118
|
+
attributes: {
|
|
119
|
+
inputMethod: inputMethod,
|
|
120
|
+
count: sourceIndexes.length,
|
|
121
|
+
// This identifies the total amount of row/cols the move operation covered. The distance covered should be a representaion
|
|
122
|
+
// of the minimum distance. This will account for large selection being moved causing a large distance travelled value.
|
|
123
|
+
distance: Math.min.apply(Math, (0, _toConsumableArray2.default)(sourceIndexes.map(function (v) {
|
|
124
|
+
return Math.abs(targetIndex - v);
|
|
125
|
+
}))) * direction,
|
|
126
|
+
// If a drop doesn't actually change anything then we're going to mark the event as cancelled.
|
|
127
|
+
status: sourceIndexes.includes(targetIndex) ? _analytics.TABLE_STATUS.CANCELLED : _analytics.TABLE_STATUS.SUCCESS,
|
|
128
|
+
totalRowCount: totalRowCount,
|
|
129
|
+
totalColumnCount: totalColumnCount
|
|
130
|
+
},
|
|
131
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
132
|
+
};
|
|
133
|
+
})(editorAnalyticsAPI)(function (state, dispatch) {
|
|
134
|
+
if (dispatch) {
|
|
135
|
+
(0, _commands.cloneSource)(sourceType, sourceIndexes, targetIndex, targetDirection, tr)(state, dispatch);
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
});
|
|
139
|
+
};
|
|
105
140
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.updatePluginStateDecorations = exports.toggleDragMenu = exports.setDropTarget = exports.moveSource = exports.getDecorations = exports.clearDropTarget = void 0;
|
|
6
|
+
exports.updatePluginStateDecorations = exports.toggleDragMenu = exports.setDropTarget = exports.moveSource = exports.getDecorations = exports.cloneSource = exports.clearDropTarget = void 0;
|
|
7
7
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
8
8
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
9
9
|
var _types = require("../../types");
|
|
@@ -118,4 +118,20 @@ var toggleDragMenu = exports.toggleDragMenu = function toggleDragMenu(isDragMenu
|
|
|
118
118
|
}, function (tr) {
|
|
119
119
|
return tr.setMeta('addToHistory', false);
|
|
120
120
|
});
|
|
121
|
+
};
|
|
122
|
+
var cloneSource = exports.cloneSource = function cloneSource(sourceType, sourceIndexes, targetIndex, targetDirection, tr) {
|
|
123
|
+
return (0, _pluginFactory.createCommand)(function (state) {
|
|
124
|
+
return {
|
|
125
|
+
type: _actions.DragAndDropActionType.CLEAR_DROP_TARGET,
|
|
126
|
+
data: {
|
|
127
|
+
decorationSet: _view.DecorationSet.empty
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}, function (originalTr, state) {
|
|
131
|
+
var nextTr = tr || originalTr;
|
|
132
|
+
var clone = sourceType === 'table-row' ? _utils.cloneRow : _utils.cloneColumn;
|
|
133
|
+
return clone(state, sourceIndexes, targetIndex, targetDirection, {
|
|
134
|
+
selectAfterClone: true
|
|
135
|
+
})(nextTr);
|
|
136
|
+
});
|
|
121
137
|
};
|
|
@@ -127,7 +127,9 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
|
127
127
|
sourceIndexes = data.sourceIndexes,
|
|
128
128
|
targetIndex = data.targetIndex,
|
|
129
129
|
targetAdjustedIndex = data.targetAdjustedIndex,
|
|
130
|
-
|
|
130
|
+
targetDirection = data.targetDirection,
|
|
131
|
+
direction = data.direction,
|
|
132
|
+
behaviour = data.behaviour;
|
|
131
133
|
|
|
132
134
|
// When we drop on a target we will know the targets row/col index for certain,
|
|
133
135
|
if (sourceType === 'table-row') {
|
|
@@ -144,7 +146,11 @@ var destroyFn = function destroyFn(editorView, editorAnalyticsAPI) {
|
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
146
148
|
requestAnimationFrame(function () {
|
|
147
|
-
|
|
149
|
+
if (behaviour === 'clone') {
|
|
150
|
+
(0, _commandsWithAnalytics.cloneSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndexes, targetIndex, targetDirection, tr)(editorView.state, editorView.dispatch);
|
|
151
|
+
} else {
|
|
152
|
+
(0, _commandsWithAnalytics.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndexes, targetAdjustedIndex + (direction === 1 ? -1 : 0), tr)(editorView.state, editorView.dispatch);
|
|
153
|
+
}
|
|
148
154
|
|
|
149
155
|
// force a colgroup update here, otherwise dropped columns don't have
|
|
150
156
|
// the correct width immediately after the drop
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDragBehaviour = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var getDragBehaviour = exports.getDragBehaviour = function getDragBehaviour(_ref) {
|
|
9
|
+
var altKey = _ref.altKey,
|
|
10
|
+
ctrlKey = _ref.ctrlKey;
|
|
11
|
+
var isCloneModifierKeyPressed = _utils.browser.mac ? altKey : ctrlKey;
|
|
12
|
+
return isCloneModifierKeyPressed ? 'clone' : 'move';
|
|
13
|
+
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getDraggableDataFromEvent = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
9
|
var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
10
|
+
var _getDragBehaviour = require("./getDragBehaviour");
|
|
8
11
|
var getDraggableDataFromEvent = exports.getDraggableDataFromEvent = function getDraggableDataFromEvent(_ref) {
|
|
9
12
|
var _extractClosestEdge;
|
|
10
13
|
var location = _ref.location,
|
|
@@ -42,9 +45,11 @@ var getDraggableDataFromEvent = exports.getDraggableDataFromEvent = function get
|
|
|
42
45
|
// the new target index to be 1 index higher.
|
|
43
46
|
var targetOffset = targetClosestEdge === 'right' || targetClosestEdge === 'bottom' ? 1 : 0;
|
|
44
47
|
|
|
45
|
-
//
|
|
46
|
-
// the target
|
|
47
|
-
var
|
|
48
|
+
// if the min index is greater then the target index, the then the direction of the DnD is decreasing
|
|
49
|
+
// if the target is within the min/max index then we can assume that no direction exists so it will be 0.
|
|
50
|
+
var srcMin = Math.min.apply(Math, (0, _toConsumableArray2.default)(sourceIndexes));
|
|
51
|
+
var srcMax = Math.max.apply(Math, (0, _toConsumableArray2.default)(sourceIndexes));
|
|
52
|
+
var direction = targetIndex >= srcMin && targetIndex <= srcMax ? 0 : srcMin >= targetIndex ? -1 : 1;
|
|
48
53
|
return {
|
|
49
54
|
sourceType: sourceType,
|
|
50
55
|
sourceLocalId: sourceLocalId,
|
|
@@ -54,6 +59,8 @@ var getDraggableDataFromEvent = exports.getDraggableDataFromEvent = function get
|
|
|
54
59
|
targetIndex: targetIndex,
|
|
55
60
|
targetAdjustedIndex: targetIndex + targetOffset,
|
|
56
61
|
targetClosestEdge: targetClosestEdge,
|
|
57
|
-
|
|
62
|
+
targetDirection: targetClosestEdge === 'top' || targetClosestEdge === 'left' ? 'start' : 'end',
|
|
63
|
+
direction: direction,
|
|
64
|
+
behaviour: (0, _getDragBehaviour.getDragBehaviour)(location.current.input)
|
|
58
65
|
};
|
|
59
66
|
};
|
|
@@ -8,6 +8,7 @@ exports.ColumnDropTarget = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
10
10
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
11
|
+
var _getDragBehaviour = require("../../../pm-plugins/drag-and-drop/utils/getDragBehaviour");
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
14
|
var ColumnDropTarget = exports.ColumnDropTarget = function ColumnDropTarget(_ref) {
|
|
@@ -25,32 +26,56 @@ var ColumnDropTarget = exports.ColumnDropTarget = function ColumnDropTarget(_ref
|
|
|
25
26
|
element: dropTargetRef.current,
|
|
26
27
|
canDrop: function canDrop(_ref2) {
|
|
27
28
|
var _data$indexes, _data$indexes2;
|
|
28
|
-
var source = _ref2.source
|
|
29
|
+
var source = _ref2.source,
|
|
30
|
+
input = _ref2.input;
|
|
29
31
|
var data = source.data;
|
|
32
|
+
var behaviour = (0, _getDragBehaviour.getDragBehaviour)(input);
|
|
33
|
+
|
|
34
|
+
// A move drop is limited too where it can go, however a clone can drop can go anywhere.
|
|
35
|
+
var isDropValid = behaviour === 'move' ? ((_data$indexes = data.indexes) === null || _data$indexes === void 0 ? void 0 : _data$indexes.indexOf(index)) === -1 : behaviour === 'clone';
|
|
30
36
|
return (
|
|
31
37
|
// Only draggables of row type can be dropped on this target
|
|
32
38
|
data.type === 'table-column' &&
|
|
33
39
|
// Only draggables which came from the same table can be dropped on this target
|
|
34
40
|
data.localId === localId &&
|
|
35
41
|
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
36
|
-
!!((_data$
|
|
42
|
+
!!((_data$indexes2 = data.indexes) !== null && _data$indexes2 !== void 0 && _data$indexes2.length) && isDropValid
|
|
37
43
|
);
|
|
38
44
|
},
|
|
45
|
+
getDropEffect: function getDropEffect(_ref3) {
|
|
46
|
+
var input = _ref3.input;
|
|
47
|
+
return (0, _getDragBehaviour.getDragBehaviour)(input) === 'clone' ? 'copy' : 'move';
|
|
48
|
+
},
|
|
39
49
|
getIsSticky: function getIsSticky() {
|
|
40
50
|
return true;
|
|
41
51
|
},
|
|
42
|
-
getData: function getData(
|
|
43
|
-
var
|
|
44
|
-
|
|
52
|
+
getData: function getData(_ref4) {
|
|
53
|
+
var _srcData$indexes;
|
|
54
|
+
var source = _ref4.source,
|
|
55
|
+
input = _ref4.input,
|
|
56
|
+
element = _ref4.element;
|
|
45
57
|
var data = {
|
|
46
58
|
localId: localId,
|
|
47
59
|
type: 'table-column',
|
|
48
60
|
targetIndex: index
|
|
49
61
|
};
|
|
62
|
+
var srcData = source.data;
|
|
63
|
+
var behaviour = (0, _getDragBehaviour.getDragBehaviour)(input);
|
|
64
|
+
|
|
65
|
+
// During a move op there's no point in allowing edges to be dropped on which result in no change/move to occur.
|
|
66
|
+
var allowedEdges = behaviour === 'move' ? (_srcData$indexes = srcData.indexes) === null || _srcData$indexes === void 0 ? void 0 : _srcData$indexes.reduce(function (acc, v) {
|
|
67
|
+
if (v - index === -1) {
|
|
68
|
+
acc.shift();
|
|
69
|
+
}
|
|
70
|
+
if (v - index === 1) {
|
|
71
|
+
acc.pop();
|
|
72
|
+
}
|
|
73
|
+
return acc;
|
|
74
|
+
}, ['left', 'right']) : ['left', 'right'];
|
|
50
75
|
return (0, _closestEdge.attachClosestEdge)(data, {
|
|
51
76
|
input: input,
|
|
52
77
|
element: element,
|
|
53
|
-
allowedEdges:
|
|
78
|
+
allowedEdges: allowedEdges
|
|
54
79
|
});
|
|
55
80
|
}
|
|
56
81
|
});
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
10
10
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
11
|
+
var _getDragBehaviour = require("../../../pm-plugins/drag-and-drop/utils/getDragBehaviour");
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
14
|
var RowDropTarget = function RowDropTarget(_ref) {
|
|
@@ -23,32 +24,56 @@ var RowDropTarget = function RowDropTarget(_ref) {
|
|
|
23
24
|
element: dropTargetRef.current,
|
|
24
25
|
canDrop: function canDrop(_ref2) {
|
|
25
26
|
var _data$indexes, _data$indexes2;
|
|
26
|
-
var source = _ref2.source
|
|
27
|
+
var source = _ref2.source,
|
|
28
|
+
input = _ref2.input;
|
|
27
29
|
var data = source.data;
|
|
30
|
+
var behaviour = (0, _getDragBehaviour.getDragBehaviour)(input);
|
|
31
|
+
|
|
32
|
+
// A move drop is limited too where it can go, however a clone can drop can go anywhere.
|
|
33
|
+
var isDropValid = behaviour === 'move' ? ((_data$indexes = data.indexes) === null || _data$indexes === void 0 ? void 0 : _data$indexes.indexOf(index)) === -1 : behaviour === 'clone';
|
|
28
34
|
return (
|
|
29
35
|
// Only draggables of row type can be dropped on this target
|
|
30
36
|
data.type === 'table-row' &&
|
|
31
37
|
// Only draggables which came from the same table can be dropped on this target
|
|
32
38
|
data.localId === localId &&
|
|
33
39
|
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
34
|
-
!!((_data$
|
|
40
|
+
!!((_data$indexes2 = data.indexes) !== null && _data$indexes2 !== void 0 && _data$indexes2.length) && isDropValid
|
|
35
41
|
);
|
|
36
42
|
},
|
|
43
|
+
getDropEffect: function getDropEffect(_ref3) {
|
|
44
|
+
var input = _ref3.input;
|
|
45
|
+
return (0, _getDragBehaviour.getDragBehaviour)(input) === 'clone' ? 'copy' : 'move';
|
|
46
|
+
},
|
|
37
47
|
getIsSticky: function getIsSticky() {
|
|
38
48
|
return true;
|
|
39
49
|
},
|
|
40
|
-
getData: function getData(
|
|
41
|
-
var
|
|
42
|
-
|
|
50
|
+
getData: function getData(_ref4) {
|
|
51
|
+
var _srcData$indexes;
|
|
52
|
+
var source = _ref4.source,
|
|
53
|
+
input = _ref4.input,
|
|
54
|
+
element = _ref4.element;
|
|
43
55
|
var data = {
|
|
44
56
|
localId: localId,
|
|
45
57
|
type: 'table-row',
|
|
46
58
|
targetIndex: index
|
|
47
59
|
};
|
|
60
|
+
var srcData = source.data;
|
|
61
|
+
var behaviour = (0, _getDragBehaviour.getDragBehaviour)(input);
|
|
62
|
+
|
|
63
|
+
// During a move op there's no point in allowing edges to be dropped on which result in no change/move to occur.
|
|
64
|
+
var allowedEdges = behaviour === 'move' ? (_srcData$indexes = srcData.indexes) === null || _srcData$indexes === void 0 ? void 0 : _srcData$indexes.reduce(function (acc, v) {
|
|
65
|
+
if (v - index === -1) {
|
|
66
|
+
acc.shift();
|
|
67
|
+
}
|
|
68
|
+
if (v - index === 1) {
|
|
69
|
+
acc.pop();
|
|
70
|
+
}
|
|
71
|
+
return acc;
|
|
72
|
+
}, ['top', 'bottom']) : ['top', 'bottom'];
|
|
48
73
|
return (0, _closestEdge.attachClosestEdge)(data, {
|
|
49
74
|
input: input,
|
|
50
75
|
element: element,
|
|
51
|
-
allowedEdges:
|
|
76
|
+
allowedEdges: allowedEdges
|
|
52
77
|
});
|
|
53
78
|
}
|
|
54
79
|
});
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tablePopupMenuFitHeight = exports.tablePadding = exports.tableOverflowShadowWidthWide = exports.tableOverflowShadowWidth = exports.tableMarginFullWidthMode = exports.tableInsertColumnButtonSize = exports.tableInsertColumnButtonOffset = exports.tableHeaderCellBackgroundColor = exports.tableFloatingControlsColor = exports.tableDeleteButtonSize = exports.tableDeleteButtonOffset = exports.tableControlsSpacing = exports.tableCellSelectedDeleteIconColor = exports.tableCellSelectedDeleteIconBackground = exports.tableCellSelectedColor = exports.tableCellHoverDeleteIconColor = exports.tableCellHoverDeleteIconBackground = exports.tableCellDeleteColor = exports.tableCellBackgroundColor = exports.tableBorderSelectedColor = exports.tableBorderRadiusSize = exports.tableBorderDeleteColor = exports.tableBorderColor = exports.stickyRowZIndex = exports.stickyRowOffsetTop = exports.stickyHeaderBorderBottomWidth = exports.rowControlsZIndex = exports.resizeLineWidth = exports.resizeHandlerZIndex = exports.resizeHandlerAreaWidth = exports.lineMarkerSize = exports.lineMarkerOffsetFromColumnControls = exports.layoutButtonSize = exports.insertLineWidth = exports.dropTargetsZIndex = exports.dropTargetExtendedWidth = exports.dragTableInsertColumnButtonSize = exports.dragMenuDropdownWidth = exports.contextualMenuTriggerSize = exports.contextualMenuDropdownWidthDnD = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.colorPalletteColumns = exports.TABLE_SNAP_GAP = exports.TABLE_HIGHLIGHT_TOLERANCE = exports.TABLE_HIGHLIGHT_GAP = exports.TABLE_GUIDELINE_VISIBLE_ADJUSTMENT = exports.STICKY_HEADER_TOGGLE_TOLERANCE_MS = void 0;
|
|
6
|
+
exports.tableToolbarSize = exports.tableToolbarSelectedColor = exports.tableToolbarDeleteColor = exports.tableToolbarColor = exports.tableTextColor = exports.tableScrollbarOffset = exports.tableResizerWidth = exports.tablePopupMenuFitHeight = exports.tablePadding = exports.tableOverflowShadowWidthWide = exports.tableOverflowShadowWidth = exports.tableMarginFullWidthMode = exports.tableInsertColumnButtonSize = exports.tableInsertColumnButtonOffset = exports.tableHeaderCellBackgroundColor = exports.tableFloatingControlsColor = exports.tableDeleteButtonSize = exports.tableDeleteButtonOffset = exports.tableControlsSpacing = exports.tableCellSelectedDeleteIconColor = exports.tableCellSelectedDeleteIconBackground = exports.tableCellSelectedColor = exports.tableCellHoverDeleteIconColor = exports.tableCellHoverDeleteIconBackground = exports.tableCellDeleteColor = exports.tableCellBackgroundColor = exports.tableBorderSelectedColor = exports.tableBorderRadiusSize = exports.tableBorderDeleteColor = exports.tableBorderColor = exports.stickyRowZIndex = exports.stickyRowOffsetTop = exports.stickyHeaderBorderBottomWidth = exports.rowControlsZIndex = exports.resizeLineWidth = exports.resizeHandlerZIndex = exports.resizeHandlerAreaWidth = exports.lineMarkerSize = exports.lineMarkerOffsetFromColumnControls = exports.layoutButtonSize = exports.insertLineWidth = exports.dropTargetsZIndex = exports.dropTargetExtendedWidth = exports.dragTableInsertColumnButtonSize = exports.dragMenuDropdownWidth = exports.contextualMenuTriggerSize = exports.contextualMenuDropdownWidthDnD = exports.contextualMenuDropdownWidth = exports.columnResizeHandleZIndex = exports.columnControlsZIndex = exports.columnControlsSelectedZIndex = exports.columnControlsDecorationHeight = exports.colorPalletteColumns = exports.TABLE_SNAP_GAP = exports.TABLE_HIGHLIGHT_TOLERANCE = exports.TABLE_HIGHLIGHT_GAP = exports.TABLE_GUIDELINE_VISIBLE_ADJUSTMENT = exports.STICKY_HEADER_TOGGLE_TOLERANCE_MS = void 0;
|
|
7
7
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
8
8
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
9
|
var _colors = require("@atlaskit/theme/colors");
|
|
@@ -75,4 +75,5 @@ var TABLE_GUIDELINE_VISIBLE_ADJUSTMENT = exports.TABLE_GUIDELINE_VISIBLE_ADJUSTM
|
|
|
75
75
|
var dragMenuDropdownWidth = exports.dragMenuDropdownWidth = 250;
|
|
76
76
|
var dragTableInsertColumnButtonSize = exports.dragTableInsertColumnButtonSize = 16;
|
|
77
77
|
var dropTargetExtendedWidth = exports.dropTargetExtendedWidth = 150;
|
|
78
|
-
var colorPalletteColumns = exports.colorPalletteColumns = 7;
|
|
78
|
+
var colorPalletteColumns = exports.colorPalletteColumns = 7;
|
|
79
|
+
var tableResizerWidth = exports.tableResizerWidth = 8;
|
|
@@ -8,6 +8,7 @@ exports.findClosestSnap = exports.defaultTablePreserveSnappingWidths = exports.d
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _guideline = require("@atlaskit/editor-common/guideline");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
|
+
var _consts = require("../ui/consts");
|
|
11
12
|
var numberOfLanesInDefaultLayoutWidth = 12;
|
|
12
13
|
var calculateSubSnappingWidths = function calculateSubSnappingWidths(totalLanes, totalWidth) {
|
|
13
14
|
return new Array(Math.round(totalLanes / 2) - 1).fill(totalWidth / totalLanes).map(function (v, i) {
|
|
@@ -23,7 +24,7 @@ var calculateDefaultSnappings = exports.calculateDefaultSnappings = function cal
|
|
|
23
24
|
var calculateDefaultTablePreserveSnappings = exports.calculateDefaultTablePreserveSnappings = function calculateDefaultTablePreserveSnappings() {
|
|
24
25
|
var lengthOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
25
26
|
var editorContainerWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
26
|
-
var dynamicFullWidthLine = editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 >= _editorSharedStyles.akEditorFullWidthLayoutWidth ? _editorSharedStyles.akEditorFullWidthLayoutWidth : editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 -
|
|
27
|
+
var dynamicFullWidthLine = editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 >= _editorSharedStyles.akEditorFullWidthLayoutWidth ? _editorSharedStyles.akEditorFullWidthLayoutWidth : editorContainerWith - _editorSharedStyles.akEditorGutterPadding * 2 - _consts.tableResizerWidth;
|
|
27
28
|
return [].concat((0, _toConsumableArray2.default)(calculateSubSnappingWidths(numberOfLanesInDefaultLayoutWidth, _editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset)), [_editorSharedStyles.akEditorDefaultLayoutWidth + lengthOffset, _editorSharedStyles.akEditorCalculatedWideLayoutWidth + lengthOffset, dynamicFullWidthLine - lengthOffset]);
|
|
28
29
|
};
|
|
29
30
|
var defaultSnappingWidths = exports.defaultSnappingWidths = calculateDefaultSnappings();
|
|
@@ -4,7 +4,7 @@ import { findCellRectClosestToPos, getSelectionRect } from '@atlaskit/editor-tab
|
|
|
4
4
|
import { getSelectedColumnIndexes, getSelectedRowIndexes, getSelectedTableInfo } from '../../utils';
|
|
5
5
|
import { withEditorAnalyticsAPI } from '../../utils/analytics';
|
|
6
6
|
import { canMove, getTargetIndex } from '../../utils/drag-menu';
|
|
7
|
-
import { clearDropTarget, moveSource } from './commands';
|
|
7
|
+
import { clearDropTarget, cloneSource, moveSource } from './commands';
|
|
8
8
|
export const clearDropTargetWithAnalytics = editorAnalyticsAPI => (inputMethod, sourceType, sourceIndexes, status, tr) => {
|
|
9
9
|
return withEditorAnalyticsAPI(({
|
|
10
10
|
selection
|
|
@@ -91,4 +91,37 @@ export const moveSourceWithAnalyticsViaShortcut = editorAnalyticsAPI => (sourceT
|
|
|
91
91
|
}
|
|
92
92
|
const targetIndex = getTargetIndex(selectedIndexes, direction);
|
|
93
93
|
return moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT, sourceType, selectedIndexes, targetIndex)(state, dispatch);
|
|
94
|
+
};
|
|
95
|
+
export const cloneSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sourceType, sourceIndexes, targetIndex, targetDirection, tr) => {
|
|
96
|
+
return withEditorAnalyticsAPI(({
|
|
97
|
+
selection
|
|
98
|
+
}) => {
|
|
99
|
+
const direction = sourceIndexes[0] > targetIndex ? -1 : 1;
|
|
100
|
+
const {
|
|
101
|
+
totalRowCount,
|
|
102
|
+
totalColumnCount
|
|
103
|
+
} = getSelectedTableInfo(selection);
|
|
104
|
+
return {
|
|
105
|
+
action: sourceType === 'table-row' ? TABLE_ACTION.CLONED_ROW : TABLE_ACTION.CLONED_COLUMN,
|
|
106
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
107
|
+
actionSubjectId: null,
|
|
108
|
+
attributes: {
|
|
109
|
+
inputMethod,
|
|
110
|
+
count: sourceIndexes.length,
|
|
111
|
+
// This identifies the total amount of row/cols the move operation covered. The distance covered should be a representaion
|
|
112
|
+
// of the minimum distance. This will account for large selection being moved causing a large distance travelled value.
|
|
113
|
+
distance: Math.min(...sourceIndexes.map(v => Math.abs(targetIndex - v))) * direction,
|
|
114
|
+
// If a drop doesn't actually change anything then we're going to mark the event as cancelled.
|
|
115
|
+
status: sourceIndexes.includes(targetIndex) ? TABLE_STATUS.CANCELLED : TABLE_STATUS.SUCCESS,
|
|
116
|
+
totalRowCount,
|
|
117
|
+
totalColumnCount
|
|
118
|
+
},
|
|
119
|
+
eventType: EVENT_TYPE.TRACK
|
|
120
|
+
};
|
|
121
|
+
})(editorAnalyticsAPI)((state, dispatch) => {
|
|
122
|
+
if (dispatch) {
|
|
123
|
+
cloneSource(sourceType, sourceIndexes, targetIndex, targetDirection, tr)(state, dispatch);
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
});
|
|
94
127
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import { moveColumn, moveRow } from '@atlaskit/editor-tables/utils';
|
|
2
|
+
import { cloneColumn, cloneRow, moveColumn, moveRow } from '@atlaskit/editor-tables/utils';
|
|
3
3
|
import { TableDecorations } from '../../types';
|
|
4
4
|
import { createColumnInsertLine, createRowInsertLine, updateDecorations } from '../../utils';
|
|
5
5
|
import { DragAndDropActionType } from './actions';
|
|
@@ -100,4 +100,18 @@ export const toggleDragMenu = (isDragMenuOpen, direction, index, trigger = 'mous
|
|
|
100
100
|
};
|
|
101
101
|
}, tr => {
|
|
102
102
|
return tr.setMeta('addToHistory', false);
|
|
103
|
+
});
|
|
104
|
+
export const cloneSource = (sourceType, sourceIndexes, targetIndex, targetDirection, tr) => createCommand(state => {
|
|
105
|
+
return {
|
|
106
|
+
type: DragAndDropActionType.CLEAR_DROP_TARGET,
|
|
107
|
+
data: {
|
|
108
|
+
decorationSet: DecorationSet.empty
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, (originalTr, state) => {
|
|
112
|
+
const nextTr = tr || originalTr;
|
|
113
|
+
const clone = sourceType === 'table-row' ? cloneRow : cloneColumn;
|
|
114
|
+
return clone(state, sourceIndexes, targetIndex, targetDirection, {
|
|
115
|
+
selectAfterClone: true
|
|
116
|
+
})(nextTr);
|
|
103
117
|
});
|
|
@@ -12,7 +12,7 @@ import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
|
12
12
|
import { insertColgroupFromNode } from '../table-resizing/utils';
|
|
13
13
|
import { DragAndDropActionType } from './actions';
|
|
14
14
|
import { clearDropTarget, setDropTarget, toggleDragMenu } from './commands';
|
|
15
|
-
import { clearDropTargetWithAnalytics, moveSourceWithAnalytics } from './commands-with-analytics';
|
|
15
|
+
import { clearDropTargetWithAnalytics, cloneSourceWithAnalytics, moveSourceWithAnalytics } from './commands-with-analytics';
|
|
16
16
|
import { DropTargetType } from './consts';
|
|
17
17
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
18
18
|
import { pluginKey } from './plugin-key';
|
|
@@ -133,7 +133,9 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
133
133
|
sourceIndexes,
|
|
134
134
|
targetIndex,
|
|
135
135
|
targetAdjustedIndex,
|
|
136
|
-
|
|
136
|
+
targetDirection,
|
|
137
|
+
direction,
|
|
138
|
+
behaviour
|
|
137
139
|
} = data;
|
|
138
140
|
|
|
139
141
|
// When we drop on a target we will know the targets row/col index for certain,
|
|
@@ -151,7 +153,11 @@ const destroyFn = (editorView, editorAnalyticsAPI) => {
|
|
|
151
153
|
return;
|
|
152
154
|
}
|
|
153
155
|
requestAnimationFrame(() => {
|
|
154
|
-
|
|
156
|
+
if (behaviour === 'clone') {
|
|
157
|
+
cloneSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndexes, targetIndex, targetDirection, tr)(editorView.state, editorView.dispatch);
|
|
158
|
+
} else {
|
|
159
|
+
moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndexes, targetAdjustedIndex + (direction === 1 ? -1 : 0), tr)(editorView.state, editorView.dispatch);
|
|
160
|
+
}
|
|
155
161
|
|
|
156
162
|
// force a colgroup update here, otherwise dropped columns don't have
|
|
157
163
|
// the correct width immediately after the drop
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
2
|
+
import { getDragBehaviour } from './getDragBehaviour';
|
|
2
3
|
export const getDraggableDataFromEvent = ({
|
|
3
4
|
location,
|
|
4
5
|
source
|
|
@@ -39,9 +40,11 @@ export const getDraggableDataFromEvent = ({
|
|
|
39
40
|
// the new target index to be 1 index higher.
|
|
40
41
|
const targetOffset = targetClosestEdge === 'right' || targetClosestEdge === 'bottom' ? 1 : 0;
|
|
41
42
|
|
|
42
|
-
//
|
|
43
|
-
// the target
|
|
44
|
-
const
|
|
43
|
+
// if the min index is greater then the target index, the then the direction of the DnD is decreasing
|
|
44
|
+
// if the target is within the min/max index then we can assume that no direction exists so it will be 0.
|
|
45
|
+
const srcMin = Math.min(...sourceIndexes);
|
|
46
|
+
const srcMax = Math.max(...sourceIndexes);
|
|
47
|
+
const direction = targetIndex >= srcMin && targetIndex <= srcMax ? 0 : srcMin >= targetIndex ? -1 : 1;
|
|
45
48
|
return {
|
|
46
49
|
sourceType,
|
|
47
50
|
sourceLocalId,
|
|
@@ -51,6 +54,8 @@ export const getDraggableDataFromEvent = ({
|
|
|
51
54
|
targetIndex,
|
|
52
55
|
targetAdjustedIndex: targetIndex + targetOffset,
|
|
53
56
|
targetClosestEdge,
|
|
54
|
-
|
|
57
|
+
targetDirection: targetClosestEdge === 'top' || targetClosestEdge === 'left' ? 'start' : 'end',
|
|
58
|
+
direction,
|
|
59
|
+
behaviour: getDragBehaviour(location.current.input)
|
|
55
60
|
};
|
|
56
61
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
3
3
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
4
|
+
import { getDragBehaviour } from '../../../pm-plugins/drag-and-drop/utils/getDragBehaviour';
|
|
4
5
|
export const ColumnDropTarget = ({
|
|
5
6
|
index,
|
|
6
7
|
localId,
|
|
@@ -16,33 +17,56 @@ export const ColumnDropTarget = ({
|
|
|
16
17
|
return dropTargetForElements({
|
|
17
18
|
element: dropTargetRef.current,
|
|
18
19
|
canDrop({
|
|
19
|
-
source
|
|
20
|
+
source,
|
|
21
|
+
input
|
|
20
22
|
}) {
|
|
21
23
|
var _data$indexes, _data$indexes2;
|
|
22
24
|
const data = source.data;
|
|
25
|
+
const behaviour = getDragBehaviour(input);
|
|
26
|
+
|
|
27
|
+
// A move drop is limited too where it can go, however a clone can drop can go anywhere.
|
|
28
|
+
const isDropValid = behaviour === 'move' ? ((_data$indexes = data.indexes) === null || _data$indexes === void 0 ? void 0 : _data$indexes.indexOf(index)) === -1 : behaviour === 'clone';
|
|
23
29
|
return (
|
|
24
30
|
// Only draggables of row type can be dropped on this target
|
|
25
31
|
data.type === 'table-column' &&
|
|
26
32
|
// Only draggables which came from the same table can be dropped on this target
|
|
27
33
|
data.localId === localId &&
|
|
28
34
|
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
29
|
-
!!((_data$
|
|
35
|
+
!!((_data$indexes2 = data.indexes) !== null && _data$indexes2 !== void 0 && _data$indexes2.length) && isDropValid
|
|
30
36
|
);
|
|
31
37
|
},
|
|
38
|
+
getDropEffect: ({
|
|
39
|
+
input
|
|
40
|
+
}) => getDragBehaviour(input) === 'clone' ? 'copy' : 'move',
|
|
32
41
|
getIsSticky: () => true,
|
|
33
42
|
getData({
|
|
43
|
+
source,
|
|
34
44
|
input,
|
|
35
45
|
element
|
|
36
46
|
}) {
|
|
47
|
+
var _srcData$indexes;
|
|
37
48
|
const data = {
|
|
38
49
|
localId,
|
|
39
50
|
type: 'table-column',
|
|
40
51
|
targetIndex: index
|
|
41
52
|
};
|
|
53
|
+
const srcData = source.data;
|
|
54
|
+
const behaviour = getDragBehaviour(input);
|
|
55
|
+
|
|
56
|
+
// During a move op there's no point in allowing edges to be dropped on which result in no change/move to occur.
|
|
57
|
+
const allowedEdges = behaviour === 'move' ? (_srcData$indexes = srcData.indexes) === null || _srcData$indexes === void 0 ? void 0 : _srcData$indexes.reduce((acc, v) => {
|
|
58
|
+
if (v - index === -1) {
|
|
59
|
+
acc.shift();
|
|
60
|
+
}
|
|
61
|
+
if (v - index === 1) {
|
|
62
|
+
acc.pop();
|
|
63
|
+
}
|
|
64
|
+
return acc;
|
|
65
|
+
}, ['left', 'right']) : ['left', 'right'];
|
|
42
66
|
return attachClosestEdge(data, {
|
|
43
67
|
input,
|
|
44
68
|
element,
|
|
45
|
-
allowedEdges
|
|
69
|
+
allowedEdges
|
|
46
70
|
});
|
|
47
71
|
}
|
|
48
72
|
});
|