@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/table/index.js +5 -3
  3. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.js +72 -0
  4. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +14 -5
  5. package/dist/cjs/plugins/table/ui/DragHandle/index.js +4 -1
  6. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
  7. package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +12 -13
  8. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  9. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  10. package/dist/cjs/plugins/table/utils/drag-menu.js +6 -5
  11. package/dist/es2019/plugins/table/index.js +5 -3
  12. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.js +66 -0
  13. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +15 -6
  14. package/dist/es2019/plugins/table/ui/DragHandle/index.js +3 -0
  15. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
  16. package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +12 -13
  17. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  18. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  19. package/dist/es2019/plugins/table/utils/drag-menu.js +4 -3
  20. package/dist/esm/plugins/table/index.js +5 -3
  21. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.js +66 -0
  22. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +15 -6
  23. package/dist/esm/plugins/table/ui/DragHandle/index.js +4 -1
  24. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +3 -2
  25. package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +12 -13
  26. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  27. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  28. package/dist/esm/plugins/table/utils/drag-menu.js +4 -3
  29. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +6 -0
  30. package/dist/types/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +2 -1
  31. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
  32. package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
  33. package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
  34. package/dist/types/plugins/table/utils/drag-menu.d.ts +2 -1
  35. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.d.ts +6 -0
  36. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/plugin.d.ts +2 -1
  37. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
  38. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +3 -1
  39. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
  40. package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +2 -1
  41. package/package.json +2 -2
  42. package/src/__tests__/unit/analytics.ts +107 -3
  43. package/src/__tests__/unit/ui/FloatingDragMenu.tsx +10 -13
  44. package/src/plugins/table/index.tsx +7 -2
  45. package/src/plugins/table/pm-plugins/drag-and-drop/commands-with-analytics.ts +100 -0
  46. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +30 -9
  47. package/src/plugins/table/ui/DragHandle/index.tsx +8 -0
  48. package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +4 -0
  49. package/src/plugins/table/ui/FloatingDragMenu/index.tsx +20 -16
  50. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -5
  51. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +2 -5
  52. package/src/plugins/table/utils/drag-menu.ts +7 -3
@@ -1,4 +1,5 @@
1
1
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
3
4
  import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
4
5
  import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
@@ -11,7 +12,7 @@ import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-d
11
12
  import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
12
13
  import { clearMultipleCells, insertColumn, insertRow, sortByColumn } from '../commands';
13
14
  import { deleteColumnsCommand } from '../commands/delete';
14
- import { moveSource } from '../pm-plugins/drag-and-drop/commands';
15
+ import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
15
16
  import { distributeColumnsWidths } from '../pm-plugins/table-resizing/commands';
16
17
  import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
17
18
  import { getClosestSelectionRect } from '../toolbar';
@@ -28,7 +29,7 @@ const isDistributeColumnsEnabled = state => {
28
29
  }
29
30
  return false;
30
31
  };
31
- export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect) => {
32
+ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI) => {
32
33
  const addOptions = direction === 'row' ? [{
33
34
  label: 'above',
34
35
  offset: 0,
@@ -159,7 +160,7 @@ export const getDragMenuConfig = (direction, getEditorContainerWidth, canDrag, h
159
160
  onClick: (state, dispatch) => {
160
161
  if (canMove(index)) {
161
162
  requestAnimationFrame(() => {
162
- moveSource(`table-${direction}`, index, index + offset)(state, dispatch);
163
+ moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, `table-${direction}`, index, index + offset)(editorView.state, editorView.dispatch);
163
164
  });
164
165
  return true;
165
166
  }
@@ -183,8 +183,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
183
183
  name: 'tableDragAndDrop',
184
184
  plugin: function plugin(_ref9) {
185
185
  var dispatch = _ref9.dispatch,
186
- eventDispatcher = _ref9.eventDispatcher;
187
- return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, eventDispatcher) : undefined;
186
+ eventDispatcher = _ref9.eventDispatcher,
187
+ dispatchAnalyticsEvent = _ref9.dispatchAnalyticsEvent;
188
+ return options !== null && options !== void 0 && options.dragAndDropEnabled ? createDragAndDropPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) : undefined;
188
189
  }
189
190
  }, {
190
191
  name: 'tableLocalId',
@@ -350,7 +351,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
350
351
  index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
351
352
  isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
352
353
  canDrag: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.canDrag,
353
- getEditorContainerWidth: defaultGetEditorContainerWidth
354
+ getEditorContainerWidth: defaultGetEditorContainerWidth,
355
+ editorAnalyticsAPI: editorAnalyticsAPI
354
356
  }), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
355
357
  editorView: editorView,
356
358
  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 var clearDropTargetWithAnalytics = function clearDropTargetWithAnalytics(editorAnalyticsAPI) {
6
+ return function (inputMethod, sourceType, status, tr) {
7
+ return withEditorAnalyticsAPI(function (_ref) {
8
+ var selection = _ref.selection;
9
+ var _getSelectedTableInfo = getSelectedTableInfo(selection),
10
+ totalRowCount = _getSelectedTableInfo.totalRowCount,
11
+ totalColumnCount = _getSelectedTableInfo.totalColumnCount;
12
+ return {
13
+ action: sourceType === 'table-row' ? TABLE_ACTION.MOVED_ROW : TABLE_ACTION.MOVED_COLUMN,
14
+ actionSubject: ACTION_SUBJECT.TABLE,
15
+ actionSubjectId: null,
16
+ attributes: {
17
+ inputMethod: inputMethod,
18
+ // TODO: When multiple sources can be moved we need to update this count to be the amount of sources which are being moved.
19
+ count: 1,
20
+ distance: 0,
21
+ status: status,
22
+ totalRowCount: totalRowCount,
23
+ totalColumnCount: totalColumnCount
24
+ },
25
+ eventType: EVENT_TYPE.TRACK
26
+ };
27
+ })(editorAnalyticsAPI)(function (state, dispatch) {
28
+ if (dispatch) {
29
+ clearDropTarget(tr)(state, dispatch);
30
+ }
31
+ return true;
32
+ });
33
+ };
34
+ };
35
+ export var moveSourceWithAnalytics = function moveSourceWithAnalytics(editorAnalyticsAPI) {
36
+ return function (inputMethod, sourceType, sourceIndex, targetIndex, tr) {
37
+ return withEditorAnalyticsAPI(function (_ref2) {
38
+ var selection = _ref2.selection;
39
+ var _getSelectedTableInfo2 = getSelectedTableInfo(selection),
40
+ totalRowCount = _getSelectedTableInfo2.totalRowCount,
41
+ totalColumnCount = _getSelectedTableInfo2.totalColumnCount;
42
+ return {
43
+ action: sourceType === 'table-row' ? TABLE_ACTION.MOVED_ROW : TABLE_ACTION.MOVED_COLUMN,
44
+ actionSubject: ACTION_SUBJECT.TABLE,
45
+ actionSubjectId: null,
46
+ attributes: {
47
+ inputMethod: inputMethod,
48
+ // TODO: When multiple sources can be moved we need to update this count to be the amount of sources which are being moved.
49
+ count: 1,
50
+ // This identifies the total amount of row/cols the move operation covered
51
+ distance: targetIndex - sourceIndex,
52
+ // If a drop doesn't actually change anything then we're going to mark the event as cancelled.
53
+ status: sourceIndex === targetIndex ? TABLE_STATUS.CANCELLED : TABLE_STATUS.SUCCESS,
54
+ totalRowCount: totalRowCount,
55
+ totalColumnCount: totalColumnCount
56
+ },
57
+ eventType: EVENT_TYPE.TRACK
58
+ };
59
+ })(editorAnalyticsAPI)(function (state, dispatch) {
60
+ if (dispatch) {
61
+ moveSource(sourceType, sourceIndex, targetIndex, tr)(state, dispatch);
62
+ }
63
+ return true;
64
+ });
65
+ };
66
+ };
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
+ import { INPUT_METHOD, TABLE_STATUS } from '@atlaskit/editor-common/analytics';
5
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
8
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
@@ -12,12 +13,13 @@ import { getPluginState as getTablePluginState } from '../plugin-factory';
12
13
  import { pluginKey as tablePluginKey } from '../plugin-key';
13
14
  import { insertColgroupFromNode } from '../table-resizing/utils';
14
15
  import { DragAndDropActionType } from './actions';
15
- import { clearDropTarget, moveSource, setDropTarget, toggleDragMenu } from './commands';
16
+ import { clearDropTarget, setDropTarget, toggleDragMenu } from './commands';
17
+ import { clearDropTargetWithAnalytics, moveSourceWithAnalytics } from './commands-with-analytics';
16
18
  import { DRAGGABLE_TABLE_NODE_SIZE_LIMIT, DropTargetType } from './consts';
17
19
  import { createPluginState, getPluginState } from './plugin-factory';
18
20
  import { pluginKey } from './plugin-key';
19
21
  import { getDraggableDataFromEvent } from './utils/monitor';
20
- export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
22
+ export var createPlugin = function createPlugin(dispatch, eventDispatcher, editorAnalyticsAPI) {
21
23
  return new SafePlugin({
22
24
  state: createPluginState(dispatch, function (state) {
23
25
  return {
@@ -158,8 +160,13 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
158
160
 
159
161
  // If no data can be found then it's most like we do not want to perform any drop action
160
162
  if (!data) {
161
- clearDropTarget(tr)(editorView.state, editorView.dispatch);
162
- return;
163
+ var _event$source, _event$source2;
164
+ // If we're able to determine the source type of the dropped element then we should report to analytics that
165
+ // the drop event was cancelled. Otherwise we will cancel silently.
166
+ 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') {
167
+ return clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, event.source.data.type, TABLE_STATUS.CANCELLED, tr)(editorView.state, editorView.dispatch);
168
+ }
169
+ return clearDropTarget(tr)(editorView.state, editorView.dispatch);
163
170
  }
164
171
  var sourceType = data.sourceType,
165
172
  sourceIndexes = data.sourceIndexes,
@@ -176,13 +183,15 @@ export var createPlugin = function createPlugin(dispatch, eventDispatcher) {
176
183
 
177
184
  // If the drop target index contains merged cells then we should not allow the drop to occur.
178
185
  if (hasMergedCellsInBetween([targetAdjustedIndex - 1, targetAdjustedIndex], sourceType === 'table-row' ? DropTargetType.ROW : DropTargetType.COLUMN)(editorView.state.selection)) {
179
- clearDropTarget(tr)(editorView.state, editorView.dispatch);
186
+ clearDropTargetWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType,
187
+ // This event is mrked as invalid because the user is attempting to drop an element in an area which has merged cells.
188
+ TABLE_STATUS.INVALID, tr)(editorView.state, editorView.dispatch);
180
189
  return;
181
190
  }
182
191
  var _sourceIndexes = _slicedToArray(sourceIndexes, 1),
183
192
  sourceIndex = _sourceIndexes[0];
184
193
  requestAnimationFrame(function () {
185
- moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
194
+ moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.DRAG_AND_DROP, sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1), tr)(editorView.state, editorView.dispatch);
186
195
 
187
196
  // force a colgroup update here, otherwise dropped columns don't have
188
197
  // the correct width immediately after the drop
@@ -12,7 +12,8 @@ import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
12
12
  import { DragPreview } from '../DragPreview';
13
13
  import { HandleIconComponent } from './HandleIconComponent';
14
14
  export var DragHandle = function DragHandle(_ref) {
15
- var tableLocalId = _ref.tableLocalId,
15
+ var isDragMenuTarget = _ref.isDragMenuTarget,
16
+ tableLocalId = _ref.tableLocalId,
16
17
  _ref$direction = _ref.direction,
17
18
  direction = _ref$direction === void 0 ? 'row' : _ref$direction,
18
19
  _ref$appearance = _ref.appearance,
@@ -104,7 +105,9 @@ export var DragHandle = function DragHandle(_ref) {
104
105
  });
105
106
  }
106
107
  }, [tableLocalId, direction, indexes, editorView.state.selection, hasMergedCells, _canDrag]);
108
+ var showDragMenuAnchorId = direction === 'row' ? 'drag-handle-button-row' : 'drag-handle-button-column';
107
109
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
110
+ id: isDragMenuTarget ? showDragMenuAnchorId : undefined,
108
111
  className: classnames(ClassName.DRAG_HANDLE_BUTTON_CONTAINER, appearance, _defineProperty({}, ClassName.DRAG_HANDLE_DISABLED, !_canDrag || hasMergedCells)),
109
112
  ref: dragHandleDivRef,
110
113
  style: {
@@ -68,7 +68,8 @@ export var DragMenu = function DragMenu(_ref) {
68
68
  scrollableElement = _ref.scrollableElement,
69
69
  targetCellPosition = _ref.targetCellPosition,
70
70
  getEditorContainerWidth = _ref.getEditorContainerWidth,
71
- canDrag = _ref.canDrag;
71
+ canDrag = _ref.canDrag,
72
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI;
72
73
  var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
73
74
  var state = editorView.state,
74
75
  dispatch = editorView.dispatch;
@@ -77,7 +78,7 @@ export var DragMenu = function DragMenu(_ref) {
77
78
  var hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
78
79
  var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
79
80
  var hasMergedCellsInTable = getMergedCellsPositions(state.tr).length > 0;
80
- var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect);
81
+ var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, !!canDrag && !shouldMoveDisabled, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI);
81
82
  var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
82
83
  menuItems = _convertToDropdownIte.menuItems,
83
84
  menuCallback = _convertToDropdownIte.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 { TableMap } from '@atlaskit/editor-tables/table-map';
4
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
5
  import { dragMenuDropdownWidth } from '../consts';
7
6
  import { DragMenu } from './DragMenu';
8
7
  var FloatingDragMenu = function FloatingDragMenu(_ref) {
@@ -11,28 +10,27 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
11
10
  scrollableElement = _ref.scrollableElement,
12
11
  editorView = _ref.editorView,
13
12
  isOpen = _ref.isOpen,
14
- tableRef = _ref.tableRef,
15
13
  tableNode = _ref.tableNode,
16
14
  direction = _ref.direction,
17
15
  index = _ref.index,
18
16
  targetCellPosition = _ref.targetCellPosition,
19
17
  getEditorContainerWidth = _ref.getEditorContainerWidth,
20
- canDrag = _ref.canDrag;
18
+ canDrag = _ref.canDrag,
19
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI;
21
20
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
22
21
  return null;
23
22
  }
24
- var domAtPos = editorView.domAtPos.bind(editorView);
25
- var targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
26
- if (!targetCellRef) {
23
+ var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
24
+ if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
27
25
  return null;
28
26
  }
29
- var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
30
- var offset = direction === 'row' ? [7, 0] : index === ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) || 1) - 1 ? [14, 0] : [-14, 0];
27
+ var offset = direction === 'row' ? [-9, 6] : [0, -7];
28
+
31
29
  // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
32
30
  return /*#__PURE__*/React.createElement(Popup, {
33
- alignX: direction === 'row' ? 'left' : 'center',
34
- alignY: "top",
35
- target: targetCellRef,
31
+ alignX: direction === 'row' ? 'right' : undefined,
32
+ alignY: direction === 'row' ? 'start' : undefined,
33
+ target: targetHandleRef,
36
34
  mountTo: mountPoint,
37
35
  boundariesElement: boundariesElement,
38
36
  scrollableElement: scrollableElement,
@@ -53,7 +51,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
53
51
  index: index,
54
52
  targetCellPosition: targetCellPosition,
55
53
  getEditorContainerWidth: getEditorContainerWidth,
56
- canDrag: canDrag
54
+ canDrag: canDrag,
55
+ editorAnalyticsAPI: editorAnalyticsAPI
57
56
  }));
58
57
  };
59
58
  FloatingDragMenu.displayName = 'FloatingDragMenu';
@@ -129,8 +129,9 @@ export var ColumnControls = function ColumnControls(_ref) {
129
129
  zIndex: 99
130
130
  },
131
131
  "data-column-control-index": hoveredCell.colIndex,
132
- "data-testid": isHover ? 'table-floating-column-control-hover' : 'table-floating-column-control'
132
+ "data-testid": 'table-floating-column-control'
133
133
  }, /*#__PURE__*/React.createElement(DragHandle, {
134
+ isDragMenuTarget: !isHover,
134
135
  direction: "column",
135
136
  tableLocalId: localId || '',
136
137
  indexes: indexes,
@@ -140,8 +140,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
140
140
  position: 'relative',
141
141
  right: '-0.5px'
142
142
  },
143
- "data-testid": isHover ? 'table-floating-row-drag-handle-hover' : 'table-floating-row-drag-handle'
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,
@@ -1,5 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
4
5
  import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
5
6
  import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
@@ -12,7 +13,7 @@ import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-d
12
13
  import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
13
14
  import { clearMultipleCells, insertColumn, insertRow, sortByColumn } from '../commands';
14
15
  import { deleteColumnsCommand } from '../commands/delete';
15
- import { moveSource } from '../pm-plugins/drag-and-drop/commands';
16
+ import { moveSourceWithAnalytics } from '../pm-plugins/drag-and-drop/commands-with-analytics';
16
17
  import { distributeColumnsWidths } from '../pm-plugins/table-resizing/commands';
17
18
  import { getNewResizeStateFromSelectedColumns } from '../pm-plugins/table-resizing/utils/resize-state';
18
19
  import { getClosestSelectionRect } from '../toolbar';
@@ -35,7 +36,7 @@ var isDistributeColumnsEnabled = function isDistributeColumnsEnabled(state) {
35
36
  }
36
37
  return false;
37
38
  };
38
- export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect) {
39
+ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorContainerWidth, canDrag, hasMergedCellsInTable, editorView, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI) {
39
40
  var addOptions = direction === 'row' ? [{
40
41
  label: 'above',
41
42
  offset: 0,
@@ -169,7 +170,7 @@ export var getDragMenuConfig = function getDragMenuConfig(direction, getEditorCo
169
170
  onClick: function onClick(state, dispatch) {
170
171
  if (canMove(index)) {
171
172
  requestAnimationFrame(function () {
172
- moveSource("table-".concat(direction), index, index + offset)(state, dispatch);
173
+ moveSourceWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.TABLE_CONTEXT_MENU, "table-".concat(direction), index, index + offset)(editorView.state, editorView.dispatch);
173
174
  });
174
175
  return true;
175
176
  }
@@ -0,0 +1,6 @@
1
+ import { TABLE_STATUS } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { DraggableType } from '../../types';
5
+ export declare const clearDropTargetWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.TABLE_CONTEXT_MENU | INPUT_METHOD.DRAG_AND_DROP, sourceType: DraggableType, status: TABLE_STATUS.CANCELLED | TABLE_STATUS.INVALID, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
6
+ export declare const moveSourceWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.TABLE_CONTEXT_MENU | INPUT_METHOD.DRAG_AND_DROP, sourceType: DraggableType, sourceIndex: number, targetIndex: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
@@ -1,4 +1,5 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
1
2
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
4
  import type { DragAndDropPluginState } from './types';
4
- export declare const createPlugin: (dispatch: Dispatch, eventDispatcher: EventDispatcher) => SafePlugin<DragAndDropPluginState>;
5
+ export declare const createPlugin: (dispatch: Dispatch, eventDispatcher: EventDispatcher, editorAnalyticsAPI?: EditorAnalyticsAPI) => SafePlugin<DragAndDropPluginState>;
@@ -16,6 +16,7 @@ type DragHandleProps = {
16
16
  onMouseUp?: MouseEventHandler;
17
17
  editorView: EditorView;
18
18
  canDrag?: boolean;
19
+ isDragMenuTarget: boolean;
19
20
  };
20
- export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
21
+ export declare const DragHandle: ({ isDragMenuTarget, tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
21
22
  export {};
@@ -1,5 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
4
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
5
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
5
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -18,6 +19,7 @@ type DragMenuProps = {
18
19
  pluginConfig?: PluginConfig;
19
20
  getEditorContainerWidth: GetEditorContainerWidth;
20
21
  canDrag?: boolean;
22
+ editorAnalyticsAPI?: EditorAnalyticsAPI;
21
23
  };
22
- export declare const DragMenu: ({ direction, index, isOpen, editorView, tableNode, mountPoint, boundariesElement, scrollableElement, targetCellPosition, getEditorContainerWidth, canDrag, }: DragMenuProps) => jsx.JSX.Element | null;
24
+ export declare const DragMenu: ({ direction, index, isOpen, editorView, tableNode, mountPoint, boundariesElement, scrollableElement, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: DragMenuProps) => jsx.JSX.Element | null;
23
25
  export {};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
4
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -16,9 +17,10 @@ export interface Props {
16
17
  targetCellPosition?: number;
17
18
  getEditorContainerWidth: GetEditorContainerWidth;
18
19
  canDrag?: boolean;
20
+ editorAnalyticsAPI?: EditorAnalyticsAPI;
19
21
  }
20
22
  declare const FloatingDragMenu: {
21
- ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableRef, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
23
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: Props): JSX.Element | null;
22
24
  displayName: string;
23
25
  };
24
26
  export default FloatingDragMenu;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { Command, DropdownOptionT, GetEditorContainerWidth, IconProps } from '@atlaskit/editor-common/types';
3
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
5
  import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
@@ -8,4 +9,4 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
8
9
  icon?: React.ComponentType<IconProps>;
9
10
  keymap?: string;
10
11
  }
11
- export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect) => DragMenuConfig[];
12
+ export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI) => DragMenuConfig[];
@@ -0,0 +1,6 @@
1
+ import { TABLE_STATUS } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ import type { DraggableType } from '../../types';
5
+ export declare const clearDropTargetWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.TABLE_CONTEXT_MENU | INPUT_METHOD.DRAG_AND_DROP, sourceType: DraggableType, status: TABLE_STATUS.CANCELLED | TABLE_STATUS.INVALID, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
6
+ export declare const moveSourceWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null) => (inputMethod: INPUT_METHOD.TABLE_CONTEXT_MENU | INPUT_METHOD.DRAG_AND_DROP, sourceType: DraggableType, sourceIndex: number, targetIndex: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
@@ -1,4 +1,5 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
1
2
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
4
  import type { DragAndDropPluginState } from './types';
4
- export declare const createPlugin: (dispatch: Dispatch, eventDispatcher: EventDispatcher) => SafePlugin<DragAndDropPluginState>;
5
+ export declare const createPlugin: (dispatch: Dispatch, eventDispatcher: EventDispatcher, editorAnalyticsAPI?: EditorAnalyticsAPI) => SafePlugin<DragAndDropPluginState>;
@@ -16,6 +16,7 @@ type DragHandleProps = {
16
16
  onMouseUp?: MouseEventHandler;
17
17
  editorView: EditorView;
18
18
  canDrag?: boolean;
19
+ isDragMenuTarget: boolean;
19
20
  };
20
- export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
21
+ export declare const DragHandle: ({ isDragMenuTarget, tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, canDrag, }: DragHandleProps) => JSX.Element;
21
22
  export {};
@@ -1,5 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
4
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
5
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
5
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -18,6 +19,7 @@ type DragMenuProps = {
18
19
  pluginConfig?: PluginConfig;
19
20
  getEditorContainerWidth: GetEditorContainerWidth;
20
21
  canDrag?: boolean;
22
+ editorAnalyticsAPI?: EditorAnalyticsAPI;
21
23
  };
22
- export declare const DragMenu: ({ direction, index, isOpen, editorView, tableNode, mountPoint, boundariesElement, scrollableElement, targetCellPosition, getEditorContainerWidth, canDrag, }: DragMenuProps) => jsx.JSX.Element | null;
24
+ export declare const DragMenu: ({ direction, index, isOpen, editorView, tableNode, mountPoint, boundariesElement, scrollableElement, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: DragMenuProps) => jsx.JSX.Element | null;
23
25
  export {};
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
3
4
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -16,9 +17,10 @@ export interface Props {
16
17
  targetCellPosition?: number;
17
18
  getEditorContainerWidth: GetEditorContainerWidth;
18
19
  canDrag?: boolean;
20
+ editorAnalyticsAPI?: EditorAnalyticsAPI;
19
21
  }
20
22
  declare const FloatingDragMenu: {
21
- ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableRef, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
23
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, editorAnalyticsAPI, }: Props): JSX.Element | null;
22
24
  displayName: string;
23
25
  };
24
26
  export default FloatingDragMenu;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
3
  import type { Command, DropdownOptionT, GetEditorContainerWidth, IconProps } from '@atlaskit/editor-common/types';
3
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
5
  import type { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
@@ -8,4 +9,4 @@ export interface DragMenuConfig extends DropdownOptionT<Command> {
8
9
  icon?: React.ComponentType<IconProps>;
9
10
  keymap?: string;
10
11
  }
11
- export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect) => DragMenuConfig[];
12
+ export declare const getDragMenuConfig: (direction: TableDirection, getEditorContainerWidth: GetEditorContainerWidth, canDrag: boolean, hasMergedCellsInTable: boolean, editorView: EditorView, tableMap?: TableMap, index?: number, targetCellPosition?: number, selectionRect?: Rect, editorAnalyticsAPI?: EditorAnalyticsAPI) => DragMenuConfig[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "5.5.12",
3
+ "version": "5.6.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^35.1.1",
31
31
  "@atlaskit/custom-steps": "^0.0.9",
32
- "@atlaskit/editor-common": "^76.26.0",
32
+ "@atlaskit/editor-common": "^76.27.0",
33
33
  "@atlaskit/editor-palette": "1.5.2",
34
34
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
35
35
  "@atlaskit/editor-plugin-content-insertion": "^0.1.0",