@atlaskit/editor-plugin-table 5.5.12 → 5.6.0
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/plugins/table/index.js +5 -3
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.js +72 -0
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +14 -5
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +4 -1
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +12 -13
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/cjs/plugins/table/utils/drag-menu.js +6 -5
- package/dist/es2019/plugins/table/index.js +5 -3
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.js +66 -0
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +15 -6
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +12 -13
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/es2019/plugins/table/utils/drag-menu.js +4 -3
- package/dist/esm/plugins/table/index.js +5 -3
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.js +66 -0
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +15 -6
- package/dist/esm/plugins/table/ui/DragHandle/index.js +4 -1
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
- package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +12 -13
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
- package/dist/esm/plugins/table/utils/drag-menu.js +4 -3
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +6 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +2 -1
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
- package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types/plugins/table/utils/drag-menu.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +2 -1
- package/package.json +2 -2
- package/src/__tests__/unit/analytics.ts +107 -3
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +10 -13
- package/src/plugins/table/index.tsx +7 -2
- package/src/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.ts +100 -0
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +30 -9
- package/src/plugins/table/ui/DragHandle/index.tsx +8 -0
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +4 -0
- package/src/plugins/table/ui/FloatingDragMenu/index.tsx +20 -16
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -5
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +2 -5
- package/src/plugins/table/utils/drag-menu.ts +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#60937](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60937) [`fd6ea5aa5a6e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fd6ea5aa5a6e) - Added new table analytics to cover moving row/column scenarios
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 5.5.13
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#60425](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60425) [`0caaaa7105f9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0caaaa7105f9) - [ux] Fix drag menu position and anchor element
|
|
18
|
+
|
|
3
19
|
## 5.5.12
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -190,8 +190,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
190
190
|
name: 'tableDragAndDrop',
|
|
191
191
|
plugin: function plugin(_ref9) {
|
|
192
192
|
var dispatch = _ref9.dispatch,
|
|
193
|
-
eventDispatcher = _ref9.eventDispatcher
|
|
194
|
-
|
|
193
|
+
eventDispatcher = _ref9.eventDispatcher,
|
|
194
|
+
dispatchAnalyticsEvent = _ref9.dispatchAnalyticsEvent;
|
|
195
|
+
return options !== null && options !== void 0 && options.dragAndDropEnabled ? (0, _dragAndDrop.createPlugin)(dispatch, eventDispatcher, editorAnalyticsAPI) : undefined;
|
|
195
196
|
}
|
|
196
197
|
}, {
|
|
197
198
|
name: 'tableLocalId',
|
|
@@ -357,7 +358,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
357
358
|
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
358
359
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
|
|
359
360
|
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
360
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
361
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
362
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
361
363
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/_react.default.createElement(_FloatingDeleteButton.default, {
|
|
362
364
|
editorView: editorView,
|
|
363
365
|
selection: editorView.state.selection,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.moveSourceWithAnalytics = exports.clearDropTargetWithAnalytics = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
|
+
var _analytics2 = require("../../utils/analytics");
|
|
10
|
+
var _commands = require("./commands");
|
|
11
|
+
var clearDropTargetWithAnalytics = exports.clearDropTargetWithAnalytics = function clearDropTargetWithAnalytics(editorAnalyticsAPI) {
|
|
12
|
+
return function (inputMethod, sourceType, status, tr) {
|
|
13
|
+
return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref) {
|
|
14
|
+
var selection = _ref.selection;
|
|
15
|
+
var _getSelectedTableInfo = (0, _utils.getSelectedTableInfo)(selection),
|
|
16
|
+
totalRowCount = _getSelectedTableInfo.totalRowCount,
|
|
17
|
+
totalColumnCount = _getSelectedTableInfo.totalColumnCount;
|
|
18
|
+
return {
|
|
19
|
+
action: sourceType === 'table-row' ? _analytics.TABLE_ACTION.MOVED_ROW : _analytics.TABLE_ACTION.MOVED_COLUMN,
|
|
20
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
21
|
+
actionSubjectId: null,
|
|
22
|
+
attributes: {
|
|
23
|
+
inputMethod: inputMethod,
|
|
24
|
+
// TODO: When multiple sources can be moved we need to update this count to be the amount of sources which are being moved.
|
|
25
|
+
count: 1,
|
|
26
|
+
distance: 0,
|
|
27
|
+
status: status,
|
|
28
|
+
totalRowCount: totalRowCount,
|
|
29
|
+
totalColumnCount: totalColumnCount
|
|
30
|
+
},
|
|
31
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
32
|
+
};
|
|
33
|
+
})(editorAnalyticsAPI)(function (state, dispatch) {
|
|
34
|
+
if (dispatch) {
|
|
35
|
+
(0, _commands.clearDropTarget)(tr)(state, dispatch);
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
var moveSourceWithAnalytics = exports.moveSourceWithAnalytics = function moveSourceWithAnalytics(editorAnalyticsAPI) {
|
|
42
|
+
return function (inputMethod, sourceType, sourceIndex, targetIndex, tr) {
|
|
43
|
+
return (0, _analytics2.withEditorAnalyticsAPI)(function (_ref2) {
|
|
44
|
+
var selection = _ref2.selection;
|
|
45
|
+
var _getSelectedTableInfo2 = (0, _utils.getSelectedTableInfo)(selection),
|
|
46
|
+
totalRowCount = _getSelectedTableInfo2.totalRowCount,
|
|
47
|
+
totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
|
|
48
|
+
return {
|
|
49
|
+
action: sourceType === 'table-row' ? _analytics.TABLE_ACTION.MOVED_ROW : _analytics.TABLE_ACTION.MOVED_COLUMN,
|
|
50
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
51
|
+
actionSubjectId: null,
|
|
52
|
+
attributes: {
|
|
53
|
+
inputMethod: inputMethod,
|
|
54
|
+
// TODO: When multiple sources can be moved we need to update this count to be the amount of sources which are being moved.
|
|
55
|
+
count: 1,
|
|
56
|
+
// This identifies the total amount of row/cols the move operation covered
|
|
57
|
+
distance: targetIndex - sourceIndex,
|
|
58
|
+
// If a drop doesn't actually change anything then we're going to mark the event as cancelled.
|
|
59
|
+
status: sourceIndex === targetIndex ? _analytics.TABLE_STATUS.CANCELLED : _analytics.TABLE_STATUS.SUCCESS,
|
|
60
|
+
totalRowCount: totalRowCount,
|
|
61
|
+
totalColumnCount: totalColumnCount
|
|
62
|
+
},
|
|
63
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
64
|
+
};
|
|
65
|
+
})(editorAnalyticsAPI)(function (state, dispatch) {
|
|
66
|
+
if (dispatch) {
|
|
67
|
+
(0, _commands.moveSource)(sourceType, sourceIndex, targetIndex, tr)(state, dispatch);
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createPlugin = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
12
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
13
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
@@ -18,13 +19,14 @@ var _pluginKey = require("../plugin-key");
|
|
|
18
19
|
var _utils3 = require("../table-resizing/utils");
|
|
19
20
|
var _actions = require("./actions");
|
|
20
21
|
var _commands = require("./commands");
|
|
22
|
+
var _commandsWithAnalytics = require("./commands-with-analytics");
|
|
21
23
|
var _consts = require("./consts");
|
|
22
24
|
var _pluginFactory2 = require("./plugin-factory");
|
|
23
25
|
var _pluginKey2 = require("./plugin-key");
|
|
24
26
|
var _monitor = require("./utils/monitor");
|
|
25
27
|
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; }
|
|
26
28
|
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) { (0, _defineProperty2.default)(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; }
|
|
27
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
29
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) {
|
|
28
30
|
return new _safePlugin.SafePlugin({
|
|
29
31
|
state: (0, _pluginFactory2.createPluginState)(dispatch, function (state) {
|
|
30
32
|
return {
|
|
@@ -165,8 +167,13 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
165
167
|
|
|
166
168
|
// If no data can be found then it's most like we do not want to perform any drop action
|
|
167
169
|
if (!data) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
var _event$source, _event$source2;
|
|
171
|
+
// If we're able to determine the source type of the dropped element then we should report to analytics that
|
|
172
|
+
// the drop event was cancelled. Otherwise we will cancel silently.
|
|
173
|
+
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') {
|
|
174
|
+
return (0, _commandsWithAnalytics.clearDropTargetWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, _analytics.TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
|
|
175
|
+
}
|
|
176
|
+
return (0, _commands.clearDropTarget)(tr)(editorView.state, editorView.dispatch);
|
|
170
177
|
}
|
|
171
178
|
var sourceType = data.sourceType,
|
|
172
179
|
sourceIndexes = data.sourceIndexes,
|
|
@@ -183,13 +190,15 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
183
190
|
|
|
184
191
|
// If the drop target index contains merged cells then we should not allow the drop to occur.
|
|
185
192
|
if ((0, _utils2.hasMergedCellsInBetween)([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? _consts.DropTargetType.ROW : _consts.DropTargetType.COLUMN)(editorView.state.selection)) {
|
|
186
|
-
(0,
|
|
193
|
+
(0, _commandsWithAnalytics.clearDropTargetWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType,
|
|
194
|
+
// This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
|
|
195
|
+
_analytics.TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
|
|
187
196
|
return;
|
|
188
197
|
}
|
|
189
198
|
var _sourceIndexes = (0, _slicedToArray2.default)(sourceIndexes, 1),
|
|
190
199
|
sourceIndex = _sourceIndexes[0];
|
|
191
200
|
requestAnimationFrame(function () {
|
|
192
|
-
(0,
|
|
201
|
+
(0, _commandsWithAnalytics.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
193
202
|
|
|
194
203
|
// force a colgroup update here, otherwise dropped columns don't have
|
|
195
204
|
// the correct width immediately after the drop
|
|
@@ -22,7 +22,8 @@ var _HandleIconComponent = require("./HandleIconComponent");
|
|
|
22
22
|
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); }
|
|
23
23
|
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; }
|
|
24
24
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
25
|
-
var
|
|
25
|
+
var isDragMenuTarget = _ref.isDragMenuTarget,
|
|
26
|
+
tableLocalId = _ref.tableLocalId,
|
|
26
27
|
_ref$direction = _ref.direction,
|
|
27
28
|
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
28
29
|
_ref$appearance = _ref.appearance,
|
|
@@ -114,7 +115,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, _canDrag]);
|
|
118
|
+
var showDragMenuAnchorId = direction === 'row' ? 'drag-handle-button-row' : 'drag-handle-button-column';
|
|
117
119
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
120
|
+
id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
|
|
118
121
|
className: (0, _classnames2.default)(_types.TableCssClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, (0, _defineProperty2.default)({}, _types.TableCssClassName.DRAG_HANDLE_DISABLED, !_canDrag || hasMergedCells)),
|
|
119
122
|
ref: dragHandleDivRef,
|
|
120
123
|
style: {
|
|
@@ -76,7 +76,8 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
76
76
|
scrollableElement = _ref.scrollableElement,
|
|
77
77
|
targetCellPosition = _ref.targetCellPosition,
|
|
78
78
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
79
|
-
canDrag = _ref.canDrag
|
|
79
|
+
canDrag = _ref.canDrag,
|
|
80
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
80
81
|
var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
|
|
81
82
|
var state = editorView.state,
|
|
82
83
|
dispatch = editorView.dispatch;
|
|
@@ -85,7 +86,7 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
85
86
|
var hasMergedCells = direction === 'row' ? _utils2.hasMergedCellsInRow : _utils2.hasMergedCellsInColumn;
|
|
86
87
|
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
87
88
|
var hasMergedCellsInTable = (0, _utils2.getMergedCellsPositions)(state.tr).length > 0;
|
|
88
|
-
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect);
|
|
89
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
89
90
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
90
91
|
menuItems = _convertToDropdownIte.menuItems,
|
|
91
92
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -7,9 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
10
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
|
-
var
|
|
11
|
+
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
12
|
var _consts = require("../consts");
|
|
14
13
|
var _DragMenu = require("./DragMenu");
|
|
15
14
|
var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
@@ -18,28 +17,27 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
18
17
|
scrollableElement = _ref.scrollableElement,
|
|
19
18
|
editorView = _ref.editorView,
|
|
20
19
|
isOpen = _ref.isOpen,
|
|
21
|
-
tableRef = _ref.tableRef,
|
|
22
20
|
tableNode = _ref.tableNode,
|
|
23
21
|
direction = _ref.direction,
|
|
24
22
|
index = _ref.index,
|
|
25
23
|
targetCellPosition = _ref.targetCellPosition,
|
|
26
24
|
getEditorContainerWidth = _ref.getEditorContainerWidth,
|
|
27
|
-
canDrag = _ref.canDrag
|
|
25
|
+
canDrag = _ref.canDrag,
|
|
26
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
28
27
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
29
28
|
return null;
|
|
30
29
|
}
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
if (!targetCellRef) {
|
|
30
|
+
var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
31
|
+
if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
|
|
34
32
|
return null;
|
|
35
33
|
}
|
|
36
|
-
var
|
|
37
|
-
|
|
34
|
+
var offset = direction === 'row' ? [-9, 6] : [0, -7];
|
|
35
|
+
|
|
38
36
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
39
37
|
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
40
|
-
alignX: direction === 'row' ? '
|
|
41
|
-
alignY:
|
|
42
|
-
target:
|
|
38
|
+
alignX: direction === 'row' ? 'right' : undefined,
|
|
39
|
+
alignY: direction === 'row' ? 'start' : undefined,
|
|
40
|
+
target: targetHandleRef,
|
|
43
41
|
mountTo: mountPoint,
|
|
44
42
|
boundariesElement: boundariesElement,
|
|
45
43
|
scrollableElement: scrollableElement,
|
|
@@ -60,7 +58,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
|
|
|
60
58
|
index: index,
|
|
61
59
|
targetCellPosition: targetCellPosition,
|
|
62
60
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
63
|
-
canDrag: canDrag
|
|
61
|
+
canDrag: canDrag,
|
|
62
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
64
63
|
}));
|
|
65
64
|
};
|
|
66
65
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -138,8 +138,9 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
138
138
|
zIndex: 99
|
|
139
139
|
},
|
|
140
140
|
"data-column-control-index": hoveredCell.colIndex,
|
|
141
|
-
"data-testid":
|
|
141
|
+
"data-testid": 'table-floating-column-control'
|
|
142
142
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
143
|
+
isDragMenuTarget: !isHover,
|
|
143
144
|
direction: "column",
|
|
144
145
|
tableLocalId: localId || '',
|
|
145
146
|
indexes: indexes,
|
|
@@ -150,8 +150,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
150
150
|
position: 'relative',
|
|
151
151
|
right: '-0.5px'
|
|
152
152
|
},
|
|
153
|
-
"data-testid":
|
|
153
|
+
"data-testid": 'table-floating-row-drag-handle'
|
|
154
154
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
155
|
+
isDragMenuTarget: !isHover,
|
|
155
156
|
direction: "row",
|
|
156
157
|
tableLocalId: currentNodeLocalId,
|
|
157
158
|
indexes: indexes,
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getDragMenuConfig = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
12
|
var _arrowDown = _interopRequireDefault(require("@atlaskit/icon/glyph/arrow-down"));
|
|
12
13
|
var _arrowLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/arrow-left"));
|
|
@@ -19,8 +20,8 @@ var _chevronDoubleDown = _interopRequireDefault(require("@atlaskit/icon/glyph/hi
|
|
|
19
20
|
var _chevronDoubleUp = _interopRequireDefault(require("@atlaskit/icon/glyph/hipchat/chevron-double-up"));
|
|
20
21
|
var _commands = require("../commands");
|
|
21
22
|
var _delete = require("../commands/delete");
|
|
22
|
-
var
|
|
23
|
-
var
|
|
23
|
+
var _commandsWithAnalytics = require("../pm-plugins/drag-and-drop/commands-with-analytics");
|
|
24
|
+
var _commands2 = require("../pm-plugins/table-resizing/commands");
|
|
24
25
|
var _resizeState = require("../pm-plugins/table-resizing/utils/resize-state");
|
|
25
26
|
var _toolbar = require("../toolbar");
|
|
26
27
|
var _transforms = require("../transforms");
|
|
@@ -42,7 +43,7 @@ var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
|
|
|
42
43
|
}
|
|
43
44
|
return false;
|
|
44
45
|
};
|
|
45
|
-
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect) {
|
|
46
|
+
var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI) {
|
|
46
47
|
var addOptions = direction === 'row' ? [{
|
|
47
48
|
label: 'above',
|
|
48
49
|
offset: 0,
|
|
@@ -134,7 +135,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
134
135
|
if (newResizeState) {
|
|
135
136
|
var resizeState = newResizeState.resizeState,
|
|
136
137
|
table = newResizeState.table;
|
|
137
|
-
(0,
|
|
138
|
+
(0, _commands2.distributeColumnsWidths)(resizeState, table)(state, dispatch);
|
|
138
139
|
return true;
|
|
139
140
|
}
|
|
140
141
|
return false;
|
|
@@ -176,7 +177,7 @@ var getDragMenuConfig = exports.getDragMenuConfig = function getDragMenuConfig(d
|
|
|
176
177
|
onClick: function onClick(state, dispatch) {
|
|
177
178
|
if (canMove(index)) {
|
|
178
179
|
requestAnimationFrame(function () {
|
|
179
|
-
(0,
|
|
180
|
+
(0, _commandsWithAnalytics.moveSourceWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction), index, index + offset)(editorView.state, editorView.dispatch);
|
|
180
181
|
});
|
|
181
182
|
return true;
|
|
182
183
|
}
|
|
@@ -178,8 +178,9 @@ const tablesPlugin = ({
|
|
|
178
178
|
name: 'tableDragAndDrop',
|
|
179
179
|
plugin: ({
|
|
180
180
|
dispatch,
|
|
181
|
-
eventDispatcher
|
|
182
|
-
|
|
181
|
+
eventDispatcher,
|
|
182
|
+
dispatchAnalyticsEvent
|
|
183
|
+
}) => options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) : undefined
|
|
183
184
|
}, {
|
|
184
185
|
name: 'tableLocalId',
|
|
185
186
|
plugin: ({
|
|
@@ -351,7 +352,8 @@ const tablesPlugin = ({
|
|
|
351
352
|
index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
|
|
352
353
|
isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
|
|
353
354
|
canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
|
|
354
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
355
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
356
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
355
357
|
}), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
356
358
|
editorView: editorView,
|
|
357
359
|
selection: editorView.state.selection,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { getSelectedTableInfo } from '../../utils';
|
|
3
|
+
import { withEditorAnalyticsAPI } from '../../utils/analytics';
|
|
4
|
+
import { clearDropTarget, moveSource } from './commands';
|
|
5
|
+
export const clearDropTargetWithAnalytics = editorAnalyticsAPI => (inputMethod, sourceType, status, tr) => {
|
|
6
|
+
return withEditorAnalyticsAPI(({
|
|
7
|
+
selection
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
totalRowCount,
|
|
11
|
+
totalColumnCount
|
|
12
|
+
} = getSelectedTableInfo(selection);
|
|
13
|
+
return {
|
|
14
|
+
action: sourceType === 'table-row' ? TABLE_ACTION.MOVED_ROW : TABLE_ACTION.MOVED_COLUMN,
|
|
15
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
16
|
+
actionSubjectId: null,
|
|
17
|
+
attributes: {
|
|
18
|
+
inputMethod,
|
|
19
|
+
// TODO: When multiple sources can be moved we need to update this count to be the amount of sources which are being moved.
|
|
20
|
+
count: 1,
|
|
21
|
+
distance: 0,
|
|
22
|
+
status,
|
|
23
|
+
totalRowCount,
|
|
24
|
+
totalColumnCount
|
|
25
|
+
},
|
|
26
|
+
eventType: EVENT_TYPE.TRACK
|
|
27
|
+
};
|
|
28
|
+
})(editorAnalyticsAPI)((state, dispatch) => {
|
|
29
|
+
if (dispatch) {
|
|
30
|
+
clearDropTarget(tr)(state, dispatch);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export const moveSourceWithAnalytics = editorAnalyticsAPI => (inputMethod, sourceType, sourceIndex, targetIndex, tr) => {
|
|
36
|
+
return withEditorAnalyticsAPI(({
|
|
37
|
+
selection
|
|
38
|
+
}) => {
|
|
39
|
+
const {
|
|
40
|
+
totalRowCount,
|
|
41
|
+
totalColumnCount
|
|
42
|
+
} = getSelectedTableInfo(selection);
|
|
43
|
+
return {
|
|
44
|
+
action: sourceType === 'table-row' ? TABLE_ACTION.MOVED_ROW : TABLE_ACTION.MOVED_COLUMN,
|
|
45
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
46
|
+
actionSubjectId: null,
|
|
47
|
+
attributes: {
|
|
48
|
+
inputMethod,
|
|
49
|
+
// TODO: When multiple sources can be moved we need to update this count to be the amount of sources which are being moved.
|
|
50
|
+
count: 1,
|
|
51
|
+
// This identifies the total amount of row/cols the move operation covered
|
|
52
|
+
distance: targetIndex - sourceIndex,
|
|
53
|
+
// If a drop doesn't actually change anything then we're going to mark the event as cancelled.
|
|
54
|
+
status: sourceIndex === targetIndex ? TABLE_STATUS.CANCELLED : TABLE_STATUS.SUCCESS,
|
|
55
|
+
totalRowCount,
|
|
56
|
+
totalColumnCount
|
|
57
|
+
},
|
|
58
|
+
eventType: EVENT_TYPE.TRACK
|
|
59
|
+
};
|
|
60
|
+
})(editorAnalyticsAPI)((state, dispatch) => {
|
|
61
|
+
if (dispatch) {
|
|
62
|
+
moveSource(sourceType, sourceIndex, targetIndex, tr)(state, dispatch);
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { INPUT_METHOD, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
@@ -8,12 +9,13 @@ import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
|
8
9
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
9
10
|
import { insertColgroupFromNode } from '../table-resizing/utils';
|
|
10
11
|
import { DragAndDropActionType } from './actions';
|
|
11
|
-
import { clearDropTarget,
|
|
12
|
+
import { clearDropTarget, setDropTarget, toggleDragMenu } from './commands';
|
|
13
|
+
import { clearDropTargetWithAnalytics, moveSourceWithAnalytics } from './commands-with-analytics';
|
|
12
14
|
import { DRAGGABLE_TABLE_NODE_SIZE_LIMIT, DropTargetType } from './consts';
|
|
13
15
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
14
16
|
import { pluginKey } from './plugin-key';
|
|
15
17
|
import { getDraggableDataFromEvent } from './utils/monitor';
|
|
16
|
-
export const createPlugin = (dispatch, eventDispatcher) => {
|
|
18
|
+
export const createPlugin = (dispatch, eventDispatcher, editorAnalyticsAPI) => {
|
|
17
19
|
return new SafePlugin({
|
|
18
20
|
state: createPluginState(dispatch, state => ({
|
|
19
21
|
decorationSet: DecorationSet.empty,
|
|
@@ -165,8 +167,13 @@ export const createPlugin = (dispatch, eventDispatcher) => {
|
|
|
165
167
|
|
|
166
168
|
// If no data can be found then it's most like we do not want to perform any drop action
|
|
167
169
|
if (!data) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
var _event$source, _event$source$data, _event$source2, _event$source2$data;
|
|
171
|
+
// If we're able to determine the source type of the dropped element then we should report to analytics that
|
|
172
|
+
// the drop event was cancelled. Otherwise we will cancel silently.
|
|
173
|
+
if ((event === null || event === void 0 ? void 0 : (_event$source = event.source) === null || _event$source === void 0 ? void 0 : (_event$source$data = _event$source.data) === null || _event$source$data === void 0 ? void 0 : _event$source$data.type) === 'table-row' || (event === null || event === void 0 ? void 0 : (_event$source2 = event.source) === null || _event$source2 === void 0 ? void 0 : (_event$source2$data = _event$source2.data) === null || _event$source2$data === void 0 ? void 0 : _event$source2$data.type) === 'table-column') {
|
|
174
|
+
return clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
|
|
175
|
+
}
|
|
176
|
+
return clearDropTarget(tr)(editorView.state, editorView.dispatch);
|
|
170
177
|
}
|
|
171
178
|
const {
|
|
172
179
|
sourceType,
|
|
@@ -185,12 +192,14 @@ export const createPlugin = (dispatch, eventDispatcher) => {
|
|
|
185
192
|
|
|
186
193
|
// If the drop target index contains merged cells then we should not allow the drop to occur.
|
|
187
194
|
if (hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN)(editorView.state.selection)) {
|
|
188
|
-
|
|
195
|
+
clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType,
|
|
196
|
+
// This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
|
|
197
|
+
TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
|
|
189
198
|
return;
|
|
190
199
|
}
|
|
191
200
|
const [sourceIndex] = sourceIndexes;
|
|
192
201
|
requestAnimationFrame(() => {
|
|
193
|
-
|
|
202
|
+
moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
|
|
194
203
|
|
|
195
204
|
// force a colgroup update here, otherwise dropped columns don't have
|
|
196
205
|
// the correct width immediately after the drop
|
|
@@ -10,6 +10,7 @@ import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
|
10
10
|
import { DragPreview } from '../DragPreview';
|
|
11
11
|
import { HandleIconComponent } from './HandleIconComponent';
|
|
12
12
|
export const DragHandle = ({
|
|
13
|
+
isDragMenuTarget,
|
|
13
14
|
tableLocalId,
|
|
14
15
|
direction = 'row',
|
|
15
16
|
appearance = 'default',
|
|
@@ -98,7 +99,9 @@ export const DragHandle = ({
|
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
}, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, canDrag]);
|
|
102
|
+
const showDragMenuAnchorId = direction === 'row' ? 'drag-handle-button-row' : 'drag-handle-button-column';
|
|
101
103
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
104
|
+
id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
|
|
102
105
|
className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, {
|
|
103
106
|
[ClassName.DRAG_HANDLE_DISABLED]: !canDrag || hasMergedCells
|
|
104
107
|
}),
|
|
@@ -62,7 +62,8 @@ export const DragMenu = ({
|
|
|
62
62
|
scrollableElement,
|
|
63
63
|
targetCellPosition,
|
|
64
64
|
getEditorContainerWidth,
|
|
65
|
-
canDrag
|
|
65
|
+
canDrag,
|
|
66
|
+
editorAnalyticsAPI
|
|
66
67
|
}) => {
|
|
67
68
|
const tableMap = tableNode ? TableMap.get(tableNode) : undefined;
|
|
68
69
|
const {
|
|
@@ -76,7 +77,7 @@ export const DragMenu = ({
|
|
|
76
77
|
const hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
77
78
|
const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
78
79
|
const hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
|
|
79
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect);
|
|
80
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
|
|
80
81
|
const {
|
|
81
82
|
menuItems,
|
|
82
83
|
menuCallback
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
-
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
5
|
-
import {
|
|
4
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
5
|
import { dragMenuDropdownWidth } from '../consts';
|
|
7
6
|
import { DragMenu } from './DragMenu';
|
|
8
7
|
const FloatingDragMenu = ({
|
|
@@ -11,29 +10,28 @@ const FloatingDragMenu = ({
|
|
|
11
10
|
scrollableElement,
|
|
12
11
|
editorView,
|
|
13
12
|
isOpen,
|
|
14
|
-
tableRef,
|
|
15
13
|
tableNode,
|
|
16
14
|
direction,
|
|
17
15
|
index,
|
|
18
16
|
targetCellPosition,
|
|
19
17
|
getEditorContainerWidth,
|
|
20
|
-
canDrag
|
|
18
|
+
canDrag,
|
|
19
|
+
editorAnalyticsAPI
|
|
21
20
|
}) => {
|
|
22
21
|
if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
|
|
23
22
|
return null;
|
|
24
23
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
if (!targetCellRef) {
|
|
24
|
+
const targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
|
|
25
|
+
if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
|
|
28
26
|
return null;
|
|
29
27
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
28
|
+
const offset = direction === 'row' ? [-9, 6] : [0, -7];
|
|
29
|
+
|
|
32
30
|
// TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
|
|
33
31
|
return /*#__PURE__*/React.createElement(Popup, {
|
|
34
|
-
alignX: direction === 'row' ? '
|
|
35
|
-
alignY:
|
|
36
|
-
target:
|
|
32
|
+
alignX: direction === 'row' ? 'right' : undefined,
|
|
33
|
+
alignY: direction === 'row' ? 'start' : undefined,
|
|
34
|
+
target: targetHandleRef,
|
|
37
35
|
mountTo: mountPoint,
|
|
38
36
|
boundariesElement: boundariesElement,
|
|
39
37
|
scrollableElement: scrollableElement,
|
|
@@ -54,7 +52,8 @@ const FloatingDragMenu = ({
|
|
|
54
52
|
index: index,
|
|
55
53
|
targetCellPosition: targetCellPosition,
|
|
56
54
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
57
|
-
canDrag: canDrag
|
|
55
|
+
canDrag: canDrag,
|
|
56
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
58
57
|
}));
|
|
59
58
|
};
|
|
60
59
|
FloatingDragMenu.displayName = 'FloatingDragMenu';
|
|
@@ -136,8 +136,9 @@ export const ColumnControls = ({
|
|
|
136
136
|
zIndex: 99
|
|
137
137
|
},
|
|
138
138
|
"data-column-control-index": hoveredCell.colIndex,
|
|
139
|
-
"data-testid":
|
|
139
|
+
"data-testid": 'table-floating-column-control'
|
|
140
140
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
141
|
+
isDragMenuTarget: !isHover,
|
|
141
142
|
direction: "column",
|
|
142
143
|
tableLocalId: localId || '',
|
|
143
144
|
indexes: indexes,
|
|
@@ -140,8 +140,9 @@ const DragControlsComponent = ({
|
|
|
140
140
|
position: 'relative',
|
|
141
141
|
right: '-0.5px'
|
|
142
142
|
},
|
|
143
|
-
"data-testid":
|
|
143
|
+
"data-testid": 'table-floating-row-drag-handle'
|
|
144
144
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
145
|
+
isDragMenuTarget: !isHover,
|
|
145
146
|
direction: "row",
|
|
146
147
|
tableLocalId: currentNodeLocalId,
|
|
147
148
|
indexes: indexes,
|