@atlaskit/editor-plugin-table 5.3.12 → 5.3.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 (105) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/plugins/table/index.js +15 -2
  3. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
  4. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
  5. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +22 -1
  6. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +43 -7
  7. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
  8. package/dist/cjs/plugins/table/ui/DragHandle/index.js +2 -0
  9. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +80 -0
  10. package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +60 -0
  11. package/dist/cjs/plugins/table/ui/FloatingInsertButton/InsertButton.js +5 -5
  12. package/dist/cjs/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +2 -2
  13. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +1 -1
  14. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +9 -7
  15. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +2 -0
  16. package/dist/cjs/plugins/table/ui/consts.js +3 -2
  17. package/dist/cjs/plugins/table/utils/drag-menu.js +59 -0
  18. package/dist/es2019/plugins/table/index.js +15 -2
  19. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
  20. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
  21. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +20 -0
  22. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +42 -3
  23. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/reducer.js +7 -0
  24. package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
  25. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +77 -0
  26. package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +54 -0
  27. package/dist/es2019/plugins/table/ui/FloatingInsertButton/InsertButton.js +5 -5
  28. package/dist/es2019/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +2 -2
  29. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -1
  30. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +10 -8
  31. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -0
  32. package/dist/es2019/plugins/table/ui/consts.js +2 -1
  33. package/dist/es2019/plugins/table/utils/drag-menu.js +44 -0
  34. package/dist/esm/plugins/table/index.js +15 -2
  35. package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
  36. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/actions.js +2 -1
  37. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +21 -0
  38. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +43 -7
  39. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/reducer.js +6 -0
  40. package/dist/esm/plugins/table/ui/DragHandle/index.js +2 -0
  41. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +73 -0
  42. package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +53 -0
  43. package/dist/esm/plugins/table/ui/FloatingInsertButton/InsertButton.js +5 -5
  44. package/dist/esm/plugins/table/ui/FloatingInsertButton/getPopupOptions.js +2 -2
  45. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -1
  46. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +10 -8
  47. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -0
  48. package/dist/esm/plugins/table/ui/consts.js +2 -1
  49. package/dist/esm/plugins/table/utils/drag-menu.js +52 -0
  50. package/dist/types/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
  51. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
  52. package/dist/types/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
  53. package/dist/types/plugins/table/types.d.ts +1 -0
  54. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +4 -2
  55. package/dist/types/plugins/table/ui/DragPreview/index.d.ts +2 -1
  56. package/dist/types/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
  57. package/dist/types/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
  58. package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
  59. package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
  60. package/dist/types/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +2 -1
  61. package/dist/types/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
  62. package/dist/types/plugins/table/ui/FloatingInsertButton/index.d.ts +4 -5
  63. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
  64. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
  65. package/dist/types/plugins/table/ui/consts.d.ts +1 -0
  66. package/dist/types/plugins/table/utils/drag-menu.d.ts +7 -0
  67. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/actions.d.ts +8 -1
  68. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +2 -1
  69. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/types.d.ts +4 -0
  70. package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
  71. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +4 -2
  72. package/dist/types-ts4.5/plugins/table/ui/DragPreview/index.d.ts +2 -1
  73. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +2 -1
  74. package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +2 -1
  75. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +19 -0
  76. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +21 -0
  77. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +2 -1
  78. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +2 -1
  79. package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +4 -5
  80. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -0
  81. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +3 -0
  82. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +1 -0
  83. package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +7 -0
  84. package/package.json +2 -2
  85. package/src/plugins/table/index.tsx +16 -0
  86. package/src/plugins/table/nodeviews/TableComponent.tsx +2 -1
  87. package/src/plugins/table/pm-plugins/drag-and-drop/actions.ts +14 -1
  88. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +32 -1
  89. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +41 -2
  90. package/src/plugins/table/pm-plugins/drag-and-drop/reducer.ts +7 -0
  91. package/src/plugins/table/pm-plugins/drag-and-drop/types.ts +5 -0
  92. package/src/plugins/table/types.ts +2 -0
  93. package/src/plugins/table/ui/DragHandle/index.tsx +5 -1
  94. package/src/plugins/table/ui/DragPreview/index.tsx +2 -1
  95. package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +2 -1
  96. package/src/plugins/table/ui/FloatingDeleteButton/types.ts +3 -1
  97. package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +99 -0
  98. package/src/plugins/table/ui/FloatingDragMenu/index.tsx +84 -0
  99. package/src/plugins/table/ui/FloatingInsertButton/InsertButton.tsx +8 -7
  100. package/src/plugins/table/ui/FloatingInsertButton/getPopupOptions.ts +3 -2
  101. package/src/plugins/table/ui/FloatingInsertButton/index.tsx +10 -7
  102. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +16 -7
  103. package/src/plugins/table/ui/TableFloatingControls/index.tsx +5 -0
  104. package/src/plugins/table/ui/consts.ts +2 -0
  105. package/src/plugins/table/utils/drag-menu.ts +65 -0
@@ -17,6 +17,12 @@ export default (function (pluginState, action) {
17
17
  dropTargetType: DropTargetType.NONE,
18
18
  dropTargetIndex: 0
19
19
  });
20
+ case DragAndDropActionType.TOGGLE_DRAG_MENU:
21
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
22
+ isDragMenuOpen: action.data.isDragMenuOpen,
23
+ dragMenuDirection: action.data.direction,
24
+ dragMenuIndex: action.data.index
25
+ });
20
26
  default:
21
27
  return pluginState;
22
28
  }
@@ -18,6 +18,7 @@ export var DragHandle = function DragHandle(_ref) {
18
18
  previewHeight = _ref.previewHeight,
19
19
  onMouseOver = _ref.onMouseOver,
20
20
  onMouseOut = _ref.onMouseOut,
21
+ onMouseUp = _ref.onMouseUp,
21
22
  onClick = _ref.onClick;
22
23
  var dragHandleDivRef = useRef(null);
23
24
  var _useState = useState(null),
@@ -77,6 +78,7 @@ export var DragHandle = function DragHandle(_ref) {
77
78
  "data-testid": "table-floating-column-controls-drag-handle",
78
79
  onMouseOver: onMouseOver,
79
80
  onMouseOut: onMouseOut,
81
+ onMouseUp: onMouseUp,
80
82
  onClick: onClick
81
83
  }, /*#__PURE__*/React.createElement(DragHandleIcon, null), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
82
84
  direction: direction,
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
3
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
4
+ import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
5
+ import { getDragMenuConfig } from '../../utils/drag-menu';
6
+ import { dragMenuDropdownWidth } from '../consts';
7
+ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
8
+ var menuItems = [];
9
+ var menuCallback = {};
10
+ dragMenuConfig.forEach(function (item) {
11
+ menuItems.push({
12
+ key: item.id,
13
+ content: item.title,
14
+ value: {
15
+ name: item.id
16
+ },
17
+ isDisabled: item.disabled
18
+ });
19
+ item.onClick && (menuCallback[item.id] = item.onClick);
20
+ });
21
+ return {
22
+ menuItems: menuItems,
23
+ menuCallback: menuCallback
24
+ };
25
+ };
26
+ export var DragMenu = function DragMenu(_ref) {
27
+ var _ref$direction = _ref.direction,
28
+ direction = _ref$direction === void 0 ? 'row' : _ref$direction,
29
+ index = _ref.index,
30
+ isOpen = _ref.isOpen,
31
+ editorView = _ref.editorView,
32
+ tableNode = _ref.tableNode,
33
+ mountPoint = _ref.mountPoint,
34
+ boundariesElement = _ref.boundariesElement,
35
+ scrollableElement = _ref.scrollableElement;
36
+ var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
37
+ var dragMenuConfig = getDragMenuConfig(direction, tableMap, index);
38
+ var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
39
+ menuItems = _convertToDropdownIte.menuItems,
40
+ menuCallback = _convertToDropdownIte.menuCallback;
41
+ var closeMenu = function closeMenu() {
42
+ var state = editorView.state,
43
+ dispatch = editorView.dispatch;
44
+ toggleDragMenu(false)(state, dispatch);
45
+ };
46
+ var onMenuItemActivated = function onMenuItemActivated(_ref2) {
47
+ var _menuCallback$item$va;
48
+ var item = _ref2.item;
49
+ (_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, editorView.state, editorView.dispatch);
50
+ closeMenu();
51
+ };
52
+ if (!menuItems) {
53
+ return null;
54
+ }
55
+ return /*#__PURE__*/React.createElement(DropdownMenu, {
56
+ mountTo: mountPoint
57
+ //This needs be removed when the a11y is completely handled
58
+ //Disabling key navigation now as it works only partially
59
+ ,
60
+ arrowKeyNavigationProviderOptions: {
61
+ type: ArrowKeyNavigationType.MENU,
62
+ disableArrowKeyNavigation: true
63
+ },
64
+ items: [{
65
+ items: menuItems
66
+ }],
67
+ isOpen: isOpen,
68
+ onOpenChange: closeMenu,
69
+ onItemActivated: onMenuItemActivated,
70
+ fitWidth: dragMenuDropdownWidth,
71
+ boundariesElement: boundariesElement
72
+ });
73
+ };
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { Popup } from '@atlaskit/editor-common/ui';
3
+ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
+ import { akEditorFloatingOverlapPanelZIndex } from '@atlaskit/editor-shared-styles';
5
+ import { dragMenuDropdownWidth } from '../consts';
6
+ import { DragMenu } from './DragMenu';
7
+ var FloatingDragMenu = function FloatingDragMenu(_ref) {
8
+ var mountPoint = _ref.mountPoint,
9
+ boundariesElement = _ref.boundariesElement,
10
+ scrollableElement = _ref.scrollableElement,
11
+ editorView = _ref.editorView,
12
+ isOpen = _ref.isOpen,
13
+ tableRef = _ref.tableRef,
14
+ tableNode = _ref.tableNode,
15
+ direction = _ref.direction,
16
+ index = _ref.index,
17
+ targetCellPosition = _ref.targetCellPosition;
18
+ if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
19
+ return null;
20
+ }
21
+ var domAtPos = editorView.domAtPos.bind(editorView);
22
+ var targetCellRef = findDomRefAtPos(targetCellPosition, domAtPos);
23
+ if (!targetCellRef) {
24
+ return null;
25
+ }
26
+
27
+ // TODO: we will need to adjust the alignment and offset values depending on whether this is a row or column menu.
28
+ return /*#__PURE__*/React.createElement(Popup, {
29
+ alignX: "left",
30
+ alignY: "top",
31
+ target: targetCellRef,
32
+ mountTo: mountPoint,
33
+ boundariesElement: boundariesElement,
34
+ scrollableElement: scrollableElement,
35
+ fitWidth: dragMenuDropdownWidth
36
+ // z-index value below is to ensure that this menu is above other floating menu
37
+ // in table, but below floating dialogs like typeaheads, pickers, etc.
38
+ ,
39
+ zIndex: akEditorFloatingOverlapPanelZIndex,
40
+ forcePlacement: true,
41
+ offset: [7, 0],
42
+ stick: true
43
+ }, /*#__PURE__*/React.createElement(DragMenu, {
44
+ editorView: editorView,
45
+ isOpen: isOpen,
46
+ boundariesElement: boundariesElement,
47
+ tableNode: tableNode,
48
+ direction: direction,
49
+ index: index
50
+ }));
51
+ };
52
+ FloatingDragMenu.displayName = 'FloatingDragMenu';
53
+ export default FloatingDragMenu;
@@ -43,13 +43,13 @@ var tooltipMessageByType = function tooltipMessageByType(type) {
43
43
  var InsertButton = function InsertButton(_ref2) {
44
44
  var onMouseDown = _ref2.onMouseDown,
45
45
  tableRef = _ref2.tableRef,
46
- type = _ref2.type,
46
+ direction = _ref2.direction,
47
47
  formatMessage = _ref2.intl.formatMessage,
48
48
  hasStickyHeaders = _ref2.hasStickyHeaders;
49
49
  var content = /*#__PURE__*/React.createElement(Tooltip, {
50
50
  content: /*#__PURE__*/React.createElement(ToolTipContent, {
51
- description: formatMessage(tooltipMessageByType(type)),
52
- keymap: type === 'row' ? addRowAfter : addColumnAfter
51
+ description: formatMessage(tooltipMessageByType(direction)),
52
+ keymap: direction === 'row' ? addRowAfter : addColumnAfter
53
53
  }),
54
54
  position: "top"
55
55
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -66,13 +66,13 @@ var InsertButton = function InsertButton(_ref2) {
66
66
  fillRule: "evenodd"
67
67
  })))), /*#__PURE__*/React.createElement("div", {
68
68
  className: ClassName.CONTROLS_INSERT_LINE,
69
- style: type === 'row' ? {
69
+ style: direction === 'row' ? {
70
70
  width: getInsertLineWidth(tableRef)
71
71
  } : {
72
72
  height: getInsertLineHeight(tableRef, hasStickyHeaders)
73
73
  }
74
74
  })));
75
- var floatingButtonClassName = type === 'column' ? ClassName.CONTROLS_FLOATING_BUTTON_COLUMN : ClassName.CONTROLS_FLOATING_BUTTON_ROW;
75
+ var floatingButtonClassName = direction === 'column' ? ClassName.CONTROLS_FLOATING_BUTTON_COLUMN : ClassName.CONTROLS_FLOATING_BUTTON_ROW;
76
76
  return /*#__PURE__*/React.createElement("div", {
77
77
  className: floatingButtonClassName
78
78
  }, /*#__PURE__*/React.createElement("div", {
@@ -70,8 +70,8 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns) {
70
70
  }
71
71
  return options;
72
72
  }
73
- function getPopupOptions(type, index, hasNumberedColumns, tableContainer) {
74
- switch (type) {
73
+ function getPopupOptions(direction, index, hasNumberedColumns, tableContainer) {
74
+ switch (direction) {
75
75
  case 'column':
76
76
  return getColumnOptions(index, tableContainer, hasNumberedColumns);
77
77
  case 'row':
@@ -124,7 +124,7 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
124
124
  }, getPopupOptions(type, index, hasNumberedColumns, tableContainerWrapper), {
125
125
  zIndex: zIndex
126
126
  }), /*#__PURE__*/React.createElement(InsertButton, {
127
- type: type,
127
+ direction: type,
128
128
  tableRef: tableRef,
129
129
  onMouseDown: type === 'column' ? this.insertColumn : this.insertRow,
130
130
  hasStickyHeaders: this.props.hasStickyHeaders || false
@@ -1,8 +1,9 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import { injectIntl } from 'react-intl-next';
3
3
  import { CellSelection } from '@atlaskit/editor-tables';
4
- import { findTable, getSelectionRect } from '@atlaskit/editor-tables/utils';
4
+ import { getSelectionRect } from '@atlaskit/editor-tables/utils';
5
5
  import { clearHoverSelection } from '../../../commands';
6
+ import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
6
7
  import { TableCssClassName as ClassName } from '../../../types';
7
8
  import { getRowHeights, getSelectedRowIndexes } from '../../../utils';
8
9
  import { DragHandle } from '../../DragHandle';
@@ -17,7 +18,9 @@ var getSelectedRows = function getSelectedRows(selection) {
17
18
  return [];
18
19
  };
19
20
  var DragControlsComponent = function DragControlsComponent(_ref) {
21
+ var _tableNode$attrs$loca, _tableNode$attrs;
20
22
  var tableRef = _ref.tableRef,
23
+ tableNode = _ref.tableNode,
21
24
  hoveredCell = _ref.hoveredCell,
22
25
  tableActive = _ref.tableActive,
23
26
  editorView = _ref.editorView,
@@ -31,6 +34,9 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
31
34
  }).join(' ');
32
35
  var selectedRowIndexes = getSelectedRows(editorView.state.selection);
33
36
  var rowWidth = tableRef.offsetWidth;
37
+ var onMouseUp = useCallback(function () {
38
+ toggleDragMenu(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
39
+ }, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
34
40
  var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
35
41
  var gridRowPosition = useMemo(function () {
36
42
  // if more than one row is selected, ensure the handle spans over the selected range
@@ -39,11 +45,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
39
45
  }
40
46
  return "".concat(rowIndex + 1, " / span 1");
41
47
  }, [rowIndex, selectedRowIndexes]);
42
- var getLocalId = function getLocalId() {
43
- var _tableNode$node;
44
- var tableNode = findTable(editorView.state.selection);
45
- return (tableNode === null || tableNode === void 0 || (_tableNode$node = tableNode.node) === null || _tableNode$node === void 0 || (_tableNode$node = _tableNode$node.attrs) === null || _tableNode$node === void 0 ? void 0 : _tableNode$node.localId) || '';
46
- };
47
48
  var handleMouseOut = useCallback(function () {
48
49
  if (tableActive) {
49
50
  var state = editorView.state,
@@ -85,14 +86,15 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
85
86
  justifyContent: 'center'
86
87
  }
87
88
  }, /*#__PURE__*/React.createElement(DragHandle, {
88
- tableLocalId: getLocalId(),
89
+ tableLocalId: (_tableNode$attrs$loca = tableNode === null || tableNode === void 0 || (_tableNode$attrs = tableNode.attrs) === null || _tableNode$attrs === void 0 ? void 0 : _tableNode$attrs.localId) !== null && _tableNode$attrs$loca !== void 0 ? _tableNode$attrs$loca : '',
89
90
  indexes: [rowIndex],
90
91
  previewWidth: rowWidth,
91
92
  previewHeight: rowHeights[rowIndex],
92
93
  appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
93
94
  onClick: handleClick,
94
95
  onMouseOver: handleMouseOver,
95
- onMouseOut: handleMouseOut
96
+ onMouseOut: handleMouseOut,
97
+ onMouseUp: onMouseUp
96
98
  })));
97
99
  };
98
100
  export var DragControls = injectIntl(DragControlsComponent);
@@ -134,6 +134,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
134
134
  var _this$props3 = this.props,
135
135
  editorView = _this$props3.editorView,
136
136
  tableRef = _this$props3.tableRef,
137
+ tableNode = _this$props3.tableNode,
137
138
  isInDanger = _this$props3.isInDanger,
138
139
  isResizing = _this$props3.isResizing,
139
140
  isNumberColumnEnabled = _this$props3.isNumberColumnEnabled,
@@ -168,6 +169,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
168
169
  isDragAndDropEnabled: isDragAndDropEnabled
169
170
  }) : null, tableActive && /*#__PURE__*/React.createElement(React.Fragment, null, isDragAndDropEnabled ? /*#__PURE__*/React.createElement(DragControls, {
170
171
  tableRef: tableRef,
172
+ tableNode: tableNode,
171
173
  hoveredCell: hoveredCell,
172
174
  editorView: editorView,
173
175
  tableActive: tableActive,
@@ -104,4 +104,5 @@ export var tableOverflowShadowWidthWide = 32;
104
104
  export var TABLE_SNAP_GAP = 9;
105
105
  export var TABLE_HIGHLIGHT_GAP = 10;
106
106
  export var TABLE_HIGHLIGHT_TOLERANCE = 2;
107
- export var STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
107
+ export var STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
108
+ export var dragMenuDropdownWidth = 240;
@@ -0,0 +1,52 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { moveSource } from '../pm-plugins/drag-and-drop/commands';
3
+ var canDecrease = function canDecrease(index) {
4
+ var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
5
+ return index !== undefined && index > min;
6
+ };
7
+ var canIncrease = function canIncrease(index) {
8
+ var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
9
+ return index !== undefined && index < max;
10
+ };
11
+ export var getDragMenuConfig = function getDragMenuConfig(direction, tableMap, index) {
12
+ var moveOptions = direction === 'row' ? [{
13
+ label: 'up',
14
+ offset: -1,
15
+ canMove: canDecrease
16
+ }, {
17
+ label: 'down',
18
+ offset: 1,
19
+ canMove: function canMove(index) {
20
+ var _tableMap$height;
21
+ return canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
22
+ }
23
+ }] : [{
24
+ label: 'left',
25
+ offset: -1,
26
+ canMove: canDecrease
27
+ }, {
28
+ label: 'right',
29
+ offset: 1,
30
+ canMove: function canMove(index) {
31
+ var _tableMap$width;
32
+ return canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
33
+ }
34
+ }];
35
+ return _toConsumableArray(moveOptions.map(function (_ref) {
36
+ var label = _ref.label,
37
+ offset = _ref.offset,
38
+ canMove = _ref.canMove;
39
+ return {
40
+ id: "move_".concat(direction, "_").concat(label),
41
+ title: "Move ".concat(direction, " ").concat(label),
42
+ disabled: !canMove(index),
43
+ onClick: function onClick(state, dispatch) {
44
+ if (canMove(index)) {
45
+ moveSource("table-".concat(direction), index, index + offset)(state, dispatch);
46
+ return true;
47
+ }
48
+ return false;
49
+ }
50
+ };
51
+ }));
52
+ };
@@ -1,4 +1,5 @@
1
1
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
+ import type { TableDirection } from '../../types';
2
3
  import type { DropTargetType } from './consts';
3
4
  export interface DragAndDropAction<T, D> {
4
5
  type: T;
@@ -7,6 +8,7 @@ export interface DragAndDropAction<T, D> {
7
8
  export declare const DragAndDropActionType: {
8
9
  readonly SET_DROP_TARGET: "SET_DROP_TARGET";
9
10
  readonly CLEAR_DROP_TARGET: "CLEAR_DROP_TARGET";
11
+ readonly TOGGLE_DRAG_MENU: "TOGGLE_DRAG_MENU";
10
12
  };
11
13
  export type DragAndDropSetDropTargetAction = DragAndDropAction<typeof DragAndDropActionType.SET_DROP_TARGET, {
12
14
  type: DropTargetType;
@@ -16,4 +18,9 @@ export type DragAndDropSetDropTargetAction = DragAndDropAction<typeof DragAndDro
16
18
  export type DragAndDropClearDropTargetAction = DragAndDropAction<typeof DragAndDropActionType.CLEAR_DROP_TARGET, {
17
19
  decorationSet: DecorationSet;
18
20
  }>;
19
- export type DragAndDropPluginAction = DragAndDropSetDropTargetAction | DragAndDropClearDropTargetAction;
21
+ export type DragAndDropToggleDragMenuAction = DragAndDropAction<typeof DragAndDropActionType.TOGGLE_DRAG_MENU, {
22
+ isDragMenuOpen: boolean;
23
+ direction: TableDirection;
24
+ index: number;
25
+ }>;
26
+ export type DragAndDropPluginAction = DragAndDropSetDropTargetAction | DragAndDropClearDropTargetAction | DragAndDropToggleDragMenuAction;
@@ -1,7 +1,7 @@
1
1
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import type { DraggableType } from '../../types';
4
+ import type { DraggableType, TableDirection } from '../../types';
5
5
  import { TableDecorations } from '../../types';
6
6
  import { DropTargetType } from './consts';
7
7
  export declare const getDecorations: (state: EditorState) => DecorationSet;
@@ -9,3 +9,4 @@ export declare const updatePluginStateDecorations: (state: EditorState, decorati
9
9
  export declare const setDropTarget: (type: DropTargetType, index: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
10
10
  export declare const clearDropTarget: (tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
11
11
  export declare const moveSource: (sourceType: DraggableType, sourceIndex: number, targetIndex: number) => import("@atlaskit/editor-common/types").Command;
12
+ export declare const toggleDragMenu: (isDragMenuOpen: boolean | undefined, direction?: TableDirection, index?: number) => import("@atlaskit/editor-common/types").Command;
@@ -1,7 +1,11 @@
1
1
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
+ import type { TableDirection } from '../../types';
2
3
  import type { DropTargetType } from './consts';
3
4
  export interface DragAndDropPluginState {
4
5
  decorationSet: DecorationSet;
5
6
  dropTargetType: DropTargetType;
6
7
  dropTargetIndex: number;
8
+ isDragMenuOpen: boolean;
9
+ dragMenuDirection?: TableDirection;
10
+ dragMenuIndex: number;
7
11
  }
@@ -373,6 +373,7 @@ export type InvalidNodeAttr = {
373
373
  spanValue: number;
374
374
  tableLocalId: string;
375
375
  };
376
+ export type TableDirection = 'row' | 'column';
376
377
  /**
377
378
  * Drag and Drop interfaces
378
379
  */
@@ -1,15 +1,17 @@
1
1
  import type { MouseEventHandler } from 'react';
2
+ import type { TableDirection } from '../../types';
2
3
  type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
3
4
  type DragHandleProps = {
4
5
  tableLocalId: string;
5
6
  indexes: number[];
6
7
  previewWidth?: number;
7
8
  previewHeight?: number;
8
- direction?: 'column' | 'row';
9
+ direction?: TableDirection;
9
10
  appearance?: DragHandleAppearance;
10
11
  onClick?: MouseEventHandler;
11
12
  onMouseOver?: MouseEventHandler;
12
13
  onMouseOut?: MouseEventHandler;
14
+ onMouseUp?: MouseEventHandler;
13
15
  };
14
- export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onClick, }: DragHandleProps) => JSX.Element;
16
+ export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, }: DragHandleProps) => JSX.Element;
15
17
  export {};
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
+ import type { TableDirection } from '../../types';
2
3
  export declare const DragPreview: ({ direction, width, height, }: {
3
- direction: 'column' | 'row';
4
+ direction: TableDirection;
4
5
  width: number;
5
6
  height: number;
6
7
  }) => JSX.Element;
@@ -3,6 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
6
+ import type { TableDirection } from '../../types';
6
7
  import type { CellSelectionType } from './types';
7
8
  export interface Props {
8
9
  editorView: EditorView;
@@ -23,7 +24,7 @@ export interface State {
23
24
  position?: string;
24
25
  scrollLeft: number;
25
26
  }
26
- export declare function getSelectionType(selection: Selection): 'column' | 'row' | undefined;
27
+ export declare function getSelectionType(selection: Selection): TableDirection | undefined;
27
28
  declare class FloatingDeleteButton extends Component<Props, State> {
28
29
  static displayName: string;
29
30
  wrapper: HTMLElement | null;
@@ -1 +1,2 @@
1
- export type CellSelectionType = 'column' | 'row' | undefined;
1
+ import type { TableDirection } from '../../types';
2
+ export type CellSelectionType = TableDirection | undefined;
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { PluginConfig, TableDirection } from '../../types';
5
+ type DragMenuProps = {
6
+ direction?: TableDirection;
7
+ index?: number;
8
+ tableRef?: HTMLTableElement;
9
+ tableNode?: PmNode;
10
+ editorView: EditorView;
11
+ isOpen?: boolean;
12
+ targetCellPosition?: number;
13
+ mountPoint?: HTMLElement;
14
+ boundariesElement?: HTMLElement;
15
+ scrollableElement?: HTMLElement;
16
+ pluginConfig?: PluginConfig;
17
+ };
18
+ export declare const DragMenu: ({ direction, index, isOpen, editorView, tableNode, mountPoint, boundariesElement, scrollableElement, }: DragMenuProps) => JSX.Element | null;
19
+ export {};
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { TableDirection } from '../../types';
5
+ export interface Props {
6
+ editorView: EditorView;
7
+ isOpen: boolean;
8
+ tableRef?: HTMLTableElement;
9
+ tableNode?: PmNode;
10
+ mountPoint?: HTMLElement;
11
+ boundariesElement?: HTMLElement;
12
+ scrollableElement?: HTMLElement;
13
+ direction?: TableDirection;
14
+ index?: number;
15
+ targetCellPosition?: number;
16
+ }
17
+ declare const FloatingDragMenu: {
18
+ ({ mountPoint, boundariesElement, scrollableElement, editorView, isOpen, tableRef, tableNode, direction, index, targetCellPosition, }: Props): JSX.Element | null;
19
+ displayName: string;
20
+ };
21
+ export default FloatingDragMenu;
@@ -1,8 +1,9 @@
1
1
  import type { SyntheticEvent } from 'react';
2
2
  import React from 'react';
3
3
  import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { TableDirection } from '../../types';
4
5
  export interface ButtonProps {
5
- type: 'row' | 'column';
6
+ direction: TableDirection;
6
7
  tableRef: HTMLElement;
7
8
  onMouseDown: (event: SyntheticEvent<HTMLButtonElement>) => void;
8
9
  hasStickyHeaders: boolean;
@@ -1,3 +1,4 @@
1
1
  import type { PopupProps } from '@atlaskit/editor-common/ui';
2
- declare function getPopupOptions(type: 'column' | 'row', index: number, hasNumberedColumns: boolean, tableContainer: HTMLElement | null): Partial<PopupProps>;
2
+ import type { TableDirection } from '../../types';
3
+ declare function getPopupOptions(direction: TableDirection, index: number, hasNumberedColumns: boolean, tableContainer: HTMLElement | null): Partial<PopupProps>;
3
4
  export default getPopupOptions;
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
- import { WrappedComponentProps } from 'react-intl-next';
3
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
- import { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { DispatchAnalyticsEvent, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
5
4
  import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
6
- import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
7
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
6
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
7
  export interface Props {
9
8
  editorView: EditorView;
10
9
  getEditorContainerWidth: GetEditorContainerWidth;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
5
  import type { CellHoverMeta } from '../../../types';
5
6
  type DragControlsProps = {
6
7
  editorView: EditorView;
7
8
  tableRef: HTMLTableElement;
9
+ tableNode?: PmNode;
8
10
  tableActive?: boolean;
9
11
  hoveredCell?: CellHoverMeta;
10
12
  isInDanger?: boolean;
@@ -1,5 +1,6 @@
1
1
  import { Component } from 'react';
2
2
  import type { TableColumnOrdering } from '@atlaskit/custom-steps';
3
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
6
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
@@ -8,6 +9,7 @@ export interface Props {
8
9
  editorView: EditorView;
9
10
  selection?: Selection;
10
11
  tableRef?: HTMLTableElement;
12
+ tableNode?: PmNode;
11
13
  tableActive?: boolean;
12
14
  isInDanger?: boolean;
13
15
  isResizing?: boolean;
@@ -21,6 +23,7 @@ export interface Props {
21
23
  hoveredCell?: CellHoverMeta;
22
24
  ordering?: TableColumnOrdering;
23
25
  stickyHeader?: RowStickyState;
26
+ insertRowButtonIndex?: number;
24
27
  }
25
28
  interface State {
26
29
  tableHeight: number;
@@ -50,3 +50,4 @@ export declare const TABLE_SNAP_GAP = 9;
50
50
  export declare const TABLE_HIGHLIGHT_GAP = 10;
51
51
  export declare const TABLE_HIGHLIGHT_TOLERANCE = 2;
52
52
  export declare const STICKY_HEADER_TOGGLE_TOLERANCE_MS = 5;
53
+ export declare const dragMenuDropdownWidth = 240;
@@ -0,0 +1,7 @@
1
+ import type { Command, DropdownOptionT } from '@atlaskit/editor-common/types';
2
+ import type { TableMap } from '@atlaskit/editor-tables/table-map';
3
+ import type { TableDirection } from '../types';
4
+ export interface DragMenuConfig extends DropdownOptionT<Command> {
5
+ id: string;
6
+ }
7
+ export declare const getDragMenuConfig: (direction: TableDirection, tableMap?: TableMap, index?: number) => DragMenuConfig[];
@@ -1,4 +1,5 @@
1
1
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
2
+ import type { TableDirection } from '../../types';
2
3
  import type { DropTargetType } from './consts';
3
4
  export interface DragAndDropAction<T, D> {
4
5
  type: T;
@@ -7,6 +8,7 @@ export interface DragAndDropAction<T, D> {
7
8
  export declare const DragAndDropActionType: {
8
9
  readonly SET_DROP_TARGET: "SET_DROP_TARGET";
9
10
  readonly CLEAR_DROP_TARGET: "CLEAR_DROP_TARGET";
11
+ readonly TOGGLE_DRAG_MENU: "TOGGLE_DRAG_MENU";
10
12
  };
11
13
  export type DragAndDropSetDropTargetAction = DragAndDropAction<typeof DragAndDropActionType.SET_DROP_TARGET, {
12
14
  type: DropTargetType;
@@ -16,4 +18,9 @@ export type DragAndDropSetDropTargetAction = DragAndDropAction<typeof DragAndDro
16
18
  export type DragAndDropClearDropTargetAction = DragAndDropAction<typeof DragAndDropActionType.CLEAR_DROP_TARGET, {
17
19
  decorationSet: DecorationSet;
18
20
  }>;
19
- export type DragAndDropPluginAction = DragAndDropSetDropTargetAction | DragAndDropClearDropTargetAction;
21
+ export type DragAndDropToggleDragMenuAction = DragAndDropAction<typeof DragAndDropActionType.TOGGLE_DRAG_MENU, {
22
+ isDragMenuOpen: boolean;
23
+ direction: TableDirection;
24
+ index: number;
25
+ }>;
26
+ export type DragAndDropPluginAction = DragAndDropSetDropTargetAction | DragAndDropClearDropTargetAction | DragAndDropToggleDragMenuAction;
@@ -1,7 +1,7 @@
1
1
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import type { DraggableType } from '../../types';
4
+ import type { DraggableType, TableDirection } from '../../types';
5
5
  import { TableDecorations } from '../../types';
6
6
  import { DropTargetType } from './consts';
7
7
  export declare const getDecorations: (state: EditorState) => DecorationSet;
@@ -9,3 +9,4 @@ export declare const updatePluginStateDecorations: (state: EditorState, decorati
9
9
  export declare const setDropTarget: (type: DropTargetType, index: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
10
10
  export declare const clearDropTarget: (tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
11
11
  export declare const moveSource: (sourceType: DraggableType, sourceIndex: number, targetIndex: number) => import("@atlaskit/editor-common/types").Command;
12
+ export declare const toggleDragMenu: (isDragMenuOpen: boolean | undefined, direction?: TableDirection, index?: number) => import("@atlaskit/editor-common/types").Command;