@atlaskit/editor-plugin-table 5.5.12 → 5.5.13

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 (23) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/table/ui/DragHandle/index.js +4 -1
  3. package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +8 -11
  4. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  5. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  6. package/dist/es2019/plugins/table/ui/DragHandle/index.js +3 -0
  7. package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +8 -11
  8. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  9. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  10. package/dist/esm/plugins/table/ui/DragHandle/index.js +4 -1
  11. package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +8 -11
  12. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -1
  13. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +2 -1
  14. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
  15. package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +1 -1
  16. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
  17. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +1 -1
  18. package/package.json +1 -1
  19. package/src/__tests__/unit/ui/FloatingDragMenu.tsx +10 -13
  20. package/src/plugins/table/ui/DragHandle/index.tsx +8 -0
  21. package/src/plugins/table/ui/FloatingDragMenu/index.tsx +16 -16
  22. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +2 -5
  23. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +2 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 5.5.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
3
9
  ## 5.5.12
4
10
 
5
11
  ### Patch Changes
@@ -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 tableLocalId = _ref.tableLocalId,
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: {
@@ -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 _tableMap = require("@atlaskit/editor-tables/table-map");
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,7 +17,6 @@ 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,
@@ -28,18 +26,17 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
28
26
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
29
27
  return null;
30
28
  }
31
- var domAtPos = editorView.domAtPos.bind(editorView);
32
- var targetCellRef = (0, _utils.findDomRefAtPos)(targetCellPosition, domAtPos);
33
- if (!targetCellRef) {
29
+ var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
30
+ if (!targetHandleRef || !(editorView.state.selection instanceof _cellSelection.CellSelection)) {
34
31
  return null;
35
32
  }
36
- var tableMap = tableNode ? _tableMap.TableMap.get(tableNode) : undefined;
37
- var offset = direction === 'row' ? [7, 0] : index === ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) || 1) - 1 ? [14, 0] : [-14, 0];
33
+ var offset = direction === 'row' ? [-9, 6] : [0, -7];
34
+
38
35
  // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
39
36
  return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
40
- alignX: direction === 'row' ? 'left' : 'center',
41
- alignY: "top",
42
- target: targetCellRef,
37
+ alignX: direction === 'row' ? 'right' : undefined,
38
+ alignY: direction === 'row' ? 'start' : undefined,
39
+ target: targetHandleRef,
43
40
  mountTo: mountPoint,
44
41
  boundariesElement: boundariesElement,
45
42
  scrollableElement: scrollableElement,
@@ -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": isHover ? 'table-floating-column-control-hover' : 'table-floating-column-control'
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": isHover ? 'table-floating-row-drag-handle-hover' : 'table-floating-row-drag-handle'
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,
@@ -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
  }),
@@ -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
  const FloatingDragMenu = ({
@@ -11,7 +10,6 @@ const FloatingDragMenu = ({
11
10
  scrollableElement,
12
11
  editorView,
13
12
  isOpen,
14
- tableRef,
15
13
  tableNode,
16
14
  direction,
17
15
  index,
@@ -22,18 +20,17 @@ const FloatingDragMenu = ({
22
20
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
23
21
  return null;
24
22
  }
25
- const domAtPos = editorView.domAtPos.bind(editorView);
26
- const targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
27
- if (!targetCellRef) {
23
+ const targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
24
+ if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
28
25
  return null;
29
26
  }
30
- const tableMap = tableNode ? TableMap.get(tableNode) : undefined;
31
- const offset = direction === 'row' ? [7, 0] : index === ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) || 1) - 1 ? [14, 0] : [-14, 0];
27
+ const offset = direction === 'row' ? [-9, 6] : [0, -7];
28
+
32
29
  // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
33
30
  return /*#__PURE__*/React.createElement(Popup, {
34
- alignX: direction === 'row' ? 'left' : 'center',
35
- alignY: "top",
36
- target: targetCellRef,
31
+ alignX: direction === 'row' ? 'right' : undefined,
32
+ alignY: direction === 'row' ? 'start' : undefined,
33
+ target: targetHandleRef,
37
34
  mountTo: mountPoint,
38
35
  boundariesElement: boundariesElement,
39
36
  scrollableElement: scrollableElement,
@@ -136,8 +136,9 @@ export const ColumnControls = ({
136
136
  zIndex: 99
137
137
  },
138
138
  "data-column-control-index": hoveredCell.colIndex,
139
- "data-testid": isHover ? 'table-floating-column-control-hover' : 'table-floating-column-control'
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": 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,
@@ -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: {
@@ -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,7 +10,6 @@ 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,
@@ -21,18 +19,17 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
21
19
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
22
20
  return null;
23
21
  }
24
- var domAtPos = editorView.domAtPos.bind(editorView);
25
- var targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
26
- if (!targetCellRef) {
22
+ var targetHandleRef = direction === 'row' ? document.querySelector('#drag-handle-button-row') : document.querySelector('#drag-handle-button-column');
23
+ if (!targetHandleRef || !(editorView.state.selection instanceof CellSelection)) {
27
24
  return null;
28
25
  }
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];
26
+ var offset = direction === 'row' ? [-9, 6] : [0, -7];
27
+
31
28
  // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
32
29
  return /*#__PURE__*/React.createElement(Popup, {
33
- alignX: direction === 'row' ? 'left' : 'center',
34
- alignY: "top",
35
- target: targetCellRef,
30
+ alignX: direction === 'row' ? 'right' : undefined,
31
+ alignY: direction === 'row' ? 'start' : undefined,
32
+ target: targetHandleRef,
36
33
  mountTo: mountPoint,
37
34
  boundariesElement: boundariesElement,
38
35
  scrollableElement: scrollableElement,
@@ -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,
@@ -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 {};
@@ -18,7 +18,7 @@ export interface Props {
18
18
  canDrag?: boolean;
19
19
  }
20
20
  declare const FloatingDragMenu: {
21
- ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableRef, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
21
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
22
22
  displayName: string;
23
23
  };
24
24
  export default FloatingDragMenu;
@@ -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 {};
@@ -18,7 +18,7 @@ export interface Props {
18
18
  canDrag?: boolean;
19
19
  }
20
20
  declare const FloatingDragMenu: {
21
- ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableRef, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
21
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableNode, direction, index, targetCellPosition, getEditorContainerWidth, canDrag, }: Props): JSX.Element | null;
22
22
  displayName: string;
23
23
  };
24
24
  export default FloatingDragMenu;
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.5.13",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,7 @@ import {
33
33
  import { ffTest } from '@atlassian/feature-flags-test-utils';
34
34
 
35
35
  import tablePlugin from '../../../plugins/table-plugin';
36
- import FloatingDragMenu from '../../../plugins/table/ui/FloatingDragMenu';
36
+ import { DragMenu } from '../../../plugins/table/ui/FloatingDragMenu/DragMenu';
37
37
 
38
38
  describe('FloatingDragMenu', () => {
39
39
  const createEditor = createProsemirrorEditorFactory();
@@ -72,14 +72,13 @@ describe('FloatingDragMenu', () => {
72
72
  editorRef,
73
73
  }}
74
74
  >
75
- <FloatingDragMenu
75
+ <DragMenu
76
76
  editorView={editorView}
77
- isOpen
77
+ isOpen={true}
78
78
  getEditorContainerWidth={jest.fn()}
79
79
  tableRef={tableRef as HTMLTableElement}
80
80
  tableNode={tableNode?.node}
81
81
  direction="row"
82
- targetCellPosition={1}
83
82
  />
84
83
  </ReactEditorViewContext.Provider>,
85
84
  );
@@ -98,14 +97,13 @@ describe('FloatingDragMenu', () => {
98
97
  editorRef,
99
98
  }}
100
99
  >
101
- <FloatingDragMenu
100
+ <DragMenu
102
101
  editorView={editorView}
103
- isOpen
102
+ isOpen={true}
104
103
  getEditorContainerWidth={jest.fn()}
105
104
  tableRef={tableRef as HTMLTableElement}
106
105
  tableNode={tableNode?.node}
107
106
  direction="row"
108
- targetCellPosition={1}
109
107
  />
110
108
  </ReactEditorViewContext.Provider>,
111
109
  );
@@ -127,14 +125,14 @@ describe('FloatingDragMenu', () => {
127
125
  editorRef,
128
126
  }}
129
127
  >
130
- <FloatingDragMenu
128
+ <div id="drag-handle-button-row">dragmenu anchor</div>
129
+ <DragMenu
131
130
  editorView={editorView}
132
- isOpen
131
+ isOpen={true}
133
132
  getEditorContainerWidth={jest.fn()}
134
133
  tableRef={tableRef as HTMLTableElement}
135
134
  tableNode={tableNode?.node}
136
135
  direction="row"
137
- targetCellPosition={1}
138
136
  />
139
137
  </ReactEditorViewContext.Provider>,
140
138
  );
@@ -163,14 +161,13 @@ describe('FloatingDragMenu', () => {
163
161
  editorRef,
164
162
  }}
165
163
  >
166
- <FloatingDragMenu
164
+ <DragMenu
167
165
  editorView={editorView}
168
- isOpen
166
+ isOpen={true}
169
167
  getEditorContainerWidth={jest.fn()}
170
168
  tableRef={tableRef as HTMLTableElement}
171
169
  tableNode={tableNode?.node}
172
170
  direction="column"
173
- targetCellPosition={1}
174
171
  />
175
172
  </ReactEditorViewContext.Provider>,
176
173
  );
@@ -33,9 +33,11 @@ type DragHandleProps = {
33
33
  onMouseUp?: MouseEventHandler;
34
34
  editorView: EditorView;
35
35
  canDrag?: boolean;
36
+ isDragMenuTarget: boolean; // this is identify which current handle component is
36
37
  };
37
38
 
38
39
  export const DragHandle = ({
40
+ isDragMenuTarget,
39
41
  tableLocalId,
40
42
  direction = 'row',
41
43
  appearance = 'default',
@@ -131,9 +133,15 @@ export const DragHandle = ({
131
133
  canDrag,
132
134
  ]);
133
135
 
136
+ const showDragMenuAnchorId =
137
+ direction === 'row'
138
+ ? 'drag-handle-button-row'
139
+ : 'drag-handle-button-column';
140
+
134
141
  return (
135
142
  <>
136
143
  <button
144
+ id={isDragMenuTarget ? showDragMenuAnchorId : undefined}
137
145
  className={classnames(
138
146
  ClassName.DRAG_HANDLE_BUTTON_CONTAINER,
139
147
  appearance,
@@ -3,10 +3,9 @@ import React from 'react';
3
3
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
4
4
  import { Popup } from '@atlaskit/editor-common/ui';
5
5
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
6
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
7
  import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
9
- import { TableMap } from '@atlaskit/editor-tables/table-map';
8
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
10
9
 
11
10
  import type { TableDirection } from '../../types';
12
11
  import { dragMenuDropdownWidth } from '../consts';
@@ -34,7 +33,6 @@ const FloatingDragMenu = ({
34
33
  scrollableElement,
35
34
  editorView,
36
35
  isOpen,
37
- tableRef,
38
36
  tableNode,
39
37
  direction,
40
38
  index,
@@ -50,24 +48,26 @@ const FloatingDragMenu = ({
50
48
  return null;
51
49
  }
52
50
 
53
- const domAtPos = editorView.domAtPos.bind(editorView);
54
- const targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
55
- if (!targetCellRef) {
51
+ const targetHandleRef =
52
+ direction === 'row'
53
+ ? document.querySelector('#drag-handle-button-row')
54
+ : document.querySelector('#drag-handle-button-column');
55
+
56
+ if (
57
+ !targetHandleRef ||
58
+ !(editorView.state.selection instanceof CellSelection)
59
+ ) {
56
60
  return null;
57
61
  }
58
- const tableMap = tableNode ? TableMap.get(tableNode) : undefined;
59
- const offset =
60
- direction === 'row'
61
- ? [7, 0]
62
- : index === (tableMap?.width || 1) - 1
63
- ? [14, 0]
64
- : [-14, 0];
62
+
63
+ const offset = direction === 'row' ? [-9, 6] : [0, -7];
64
+
65
65
  // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
66
66
  return (
67
67
  <Popup
68
- alignX={direction === 'row' ? 'left' : 'center'}
69
- alignY="top"
70
- target={targetCellRef as HTMLElement}
68
+ alignX={direction === 'row' ? 'right' : undefined}
69
+ alignY={direction === 'row' ? 'start' : undefined}
70
+ target={targetHandleRef as HTMLElement}
71
71
  mountTo={mountPoint}
72
72
  boundariesElement={boundariesElement}
73
73
  scrollableElement={scrollableElement}
@@ -217,13 +217,10 @@ export const ColumnControls = ({
217
217
  zIndex: 99,
218
218
  }}
219
219
  data-column-control-index={hoveredCell.colIndex}
220
- data-testid={
221
- isHover
222
- ? 'table-floating-column-control-hover'
223
- : 'table-floating-column-control'
224
- }
220
+ data-testid={'table-floating-column-control'}
225
221
  >
226
222
  <DragHandle
223
+ isDragMenuTarget={!isHover}
227
224
  direction="column"
228
225
  tableLocalId={localId || ''}
229
226
  indexes={indexes}
@@ -239,13 +239,10 @@ const DragControlsComponent = ({
239
239
  position: 'relative',
240
240
  right: '-0.5px',
241
241
  }}
242
- data-testid={
243
- isHover
244
- ? 'table-floating-row-drag-handle-hover'
245
- : 'table-floating-row-drag-handle'
246
- }
242
+ data-testid={'table-floating-row-drag-handle'}
247
243
  >
248
244
  <DragHandle
245
+ isDragMenuTarget={!isHover}
249
246
  direction="row"
250
247
  tableLocalId={currentNodeLocalId}
251
248
  indexes={indexes}