@atlaskit/editor-plugin-table 5.3.14 → 5.3.15

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 (54) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/table/index.js +2 -1
  3. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +49 -11
  4. package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +5 -2
  5. package/dist/cjs/plugins/table/ui/icons/AddColLeftIcon.js +44 -0
  6. package/dist/cjs/plugins/table/ui/icons/AddColRightIcon.js +44 -0
  7. package/dist/cjs/plugins/table/ui/icons/AddRowAboveIcon.js +45 -0
  8. package/dist/cjs/plugins/table/ui/icons/AddRowBelowIcon.js +40 -0
  9. package/dist/cjs/plugins/table/ui/icons/index.js +29 -1
  10. package/dist/cjs/plugins/table/utils/drag-menu.js +122 -10
  11. package/dist/es2019/plugins/table/index.js +2 -1
  12. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +52 -8
  13. package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +5 -2
  14. package/dist/es2019/plugins/table/ui/icons/AddColLeftIcon.js +35 -0
  15. package/dist/es2019/plugins/table/ui/icons/AddColRightIcon.js +35 -0
  16. package/dist/es2019/plugins/table/ui/icons/AddRowAboveIcon.js +36 -0
  17. package/dist/es2019/plugins/table/ui/icons/AddRowBelowIcon.js +31 -0
  18. package/dist/es2019/plugins/table/ui/icons/index.js +5 -1
  19. package/dist/es2019/plugins/table/utils/drag-menu.js +118 -8
  20. package/dist/esm/plugins/table/index.js +2 -1
  21. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +46 -8
  22. package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +5 -2
  23. package/dist/esm/plugins/table/ui/icons/AddColLeftIcon.js +37 -0
  24. package/dist/esm/plugins/table/ui/icons/AddColRightIcon.js +37 -0
  25. package/dist/esm/plugins/table/ui/icons/AddRowAboveIcon.js +38 -0
  26. package/dist/esm/plugins/table/ui/icons/AddRowBelowIcon.js +33 -0
  27. package/dist/esm/plugins/table/ui/icons/index.js +5 -1
  28. package/dist/esm/plugins/table/utils/drag-menu.js +120 -8
  29. package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
  30. package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
  31. package/dist/types/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
  32. package/dist/types/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
  33. package/dist/types/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
  34. package/dist/types/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
  35. package/dist/types/plugins/table/ui/icons/index.d.ts +4 -0
  36. package/dist/types/plugins/table/utils/drag-menu.d.ts +6 -3
  37. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
  38. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
  39. package/dist/types-ts4.5/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
  40. package/dist/types-ts4.5/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
  41. package/dist/types-ts4.5/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
  42. package/dist/types-ts4.5/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
  43. package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +4 -0
  44. package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +6 -3
  45. package/package.json +1 -1
  46. package/src/plugins/table/index.tsx +1 -0
  47. package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +73 -6
  48. package/src/plugins/table/ui/FloatingDragMenu/index.tsx +5 -0
  49. package/src/plugins/table/ui/icons/AddColLeftIcon.tsx +43 -0
  50. package/src/plugins/table/ui/icons/AddColRightIcon.tsx +43 -0
  51. package/src/plugins/table/ui/icons/AddRowAboveIcon.tsx +42 -0
  52. package/src/plugins/table/ui/icons/AddRowBelowIcon.tsx +36 -0
  53. package/src/plugins/table/ui/icons/index.ts +4 -0
  54. package/src/plugins/table/utils/drag-menu.ts +158 -5
@@ -15,7 +15,8 @@ const FloatingDragMenu = ({
15
15
  tableNode,
16
16
  direction,
17
17
  index,
18
- targetCellPosition
18
+ targetCellPosition,
19
+ getEditorContainerWidth
19
20
  }) => {
20
21
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
21
22
  return null;
@@ -49,7 +50,9 @@ const FloatingDragMenu = ({
49
50
  boundariesElement: boundariesElement,
50
51
  tableNode: tableNode,
51
52
  direction: direction,
52
- index: index
53
+ index: index,
54
+ targetCellPosition: targetCellPosition,
55
+ getEditorContainerWidth: getEditorContainerWidth
53
56
  }));
54
57
  };
55
58
  FloatingDragMenu.displayName = 'FloatingDragMenu';
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ export const AddColLeftIcon = () => /*#__PURE__*/React.createElement("svg", {
3
+ width: "24",
4
+ height: "24",
5
+ viewBox: "0 0 24 24",
6
+ fill: "currentColor",
7
+ xmlns: "http://www.w3.org/2000/svg"
8
+ }, /*#__PURE__*/React.createElement("rect", {
9
+ width: "24",
10
+ height: "24",
11
+ transform: "matrix(0 -1 1 0 0 24)",
12
+ fill: "none",
13
+ fillOpacity: "0.01"
14
+ }), /*#__PURE__*/React.createElement("rect", {
15
+ x: "12",
16
+ y: "18",
17
+ width: "12",
18
+ height: "3",
19
+ rx: "0.5",
20
+ transform: "rotate(-90 12 18)",
21
+ fill: "currentColor"
22
+ }), /*#__PURE__*/React.createElement("rect", {
23
+ x: "16",
24
+ y: "18",
25
+ width: "12",
26
+ height: "3",
27
+ rx: "0.5",
28
+ transform: "rotate(-90 16 18)",
29
+ fill: "currentColor"
30
+ }), /*#__PURE__*/React.createElement("path", {
31
+ fillRule: "evenodd",
32
+ clipRule: "evenodd",
33
+ d: "M7 11H5.99C5.72652 11.0026 5.47473 11.1092 5.28935 11.2964C5.10397 11.4837 4.99999 11.7365 5 12C5 12.556 5.444 13 5.99 13H7V14C7 14.2652 7.10536 14.5196 7.29289 14.7071C7.48043 14.8946 7.73478 15 8 15C8.26522 15 8.51957 14.8946 8.70711 14.7071C8.89464 14.5196 9 14.2652 9 14V13H10.01C10.2735 12.9974 10.5253 12.8908 10.7107 12.7036C10.896 12.5163 11 12.2635 11 12C11 11.444 10.556 11 10.01 11H9V10C9 9.73478 8.89464 9.48043 8.70711 9.29289C8.51957 9.10536 8.26522 9 8 9C7.73478 9 7.48043 9.10536 7.29289 9.29289C7.10536 9.48043 7 9.73478 7 10V11Z",
34
+ fill: "currentColor"
35
+ }));
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ export const AddColRightIcon = () => /*#__PURE__*/React.createElement("svg", {
3
+ width: "24",
4
+ height: "24",
5
+ viewBox: "0 0 24 24",
6
+ fill: "none",
7
+ xmlns: "http://www.w3.org/2000/svg"
8
+ }, /*#__PURE__*/React.createElement("rect", {
9
+ width: "24",
10
+ height: "24",
11
+ transform: "translate(0 24) rotate(-90)",
12
+ fill: "none",
13
+ fillOpacity: "0.01"
14
+ }), /*#__PURE__*/React.createElement("rect", {
15
+ x: "9",
16
+ y: "18",
17
+ width: "12",
18
+ height: "3",
19
+ rx: "0.5",
20
+ transform: "rotate(-90 9 18)",
21
+ fill: "currentColor"
22
+ }), /*#__PURE__*/React.createElement("rect", {
23
+ x: "5",
24
+ y: "18",
25
+ width: "12",
26
+ height: "3",
27
+ rx: "0.5",
28
+ transform: "rotate(-90 5 18)",
29
+ fill: "currentColor"
30
+ }), /*#__PURE__*/React.createElement("path", {
31
+ fillRule: "evenodd",
32
+ clipRule: "evenodd",
33
+ d: "M15 11L13.99 11C13.7265 11.0026 13.4747 11.1092 13.2893 11.2964C13.104 11.4837 13 11.7365 13 12C13 12.556 13.444 13 13.99 13L15 13L15 14C15 14.2652 15.1054 14.5196 15.2929 14.7071C15.4804 14.8946 15.7348 15 16 15C16.2652 15 16.5196 14.8946 16.7071 14.7071C16.8946 14.5196 17 14.2652 17 14L17 13L18.01 13C18.2735 12.9974 18.5253 12.8908 18.7107 12.7036C18.896 12.5163 19 12.2635 19 12C19 11.444 18.556 11 18.01 11L17 11L17 10C17 9.73478 16.8946 9.48043 16.7071 9.29289C16.5196 9.10536 16.2652 9 16 9C15.7348 9 15.4804 9.10536 15.2929 9.29289C15.1054 9.48043 15 9.73478 15 10L15 11Z",
34
+ fill: "currentColor"
35
+ }));
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ export const AddRowAboveIcon = () => /*#__PURE__*/React.createElement("svg", {
3
+ width: "24",
4
+ height: "24",
5
+ viewBox: "0 0 24 24",
6
+ fill: "none",
7
+ xmlns: "http://www.w3.org/2000/svg"
8
+ }, /*#__PURE__*/React.createElement("rect", {
9
+ width: "24",
10
+ height: "24",
11
+ fill: "var(--ds-border-inverse, #FFFFFF)",
12
+ fillOpacity: "0.01"
13
+ }), /*#__PURE__*/React.createElement("mask", {
14
+ id: "path-1-inside-1_896_17822",
15
+ fill: "var(--ds-border-inverse, #FFFFFF)"
16
+ }, /*#__PURE__*/React.createElement("rect", {
17
+ x: "6",
18
+ y: "12",
19
+ width: "12",
20
+ height: "8",
21
+ rx: "0.5"
22
+ })), /*#__PURE__*/React.createElement("rect", {
23
+ x: "6",
24
+ y: "12",
25
+ width: "12",
26
+ height: "8",
27
+ rx: "0.5",
28
+ stroke: "currentColor",
29
+ strokeWidth: "4",
30
+ mask: "url(#path-1-inside-1_896_17822)"
31
+ }), /*#__PURE__*/React.createElement("path", {
32
+ fillRule: "evenodd",
33
+ clipRule: "evenodd",
34
+ d: "M13 7V5.99C12.9974 5.72652 12.8908 5.47473 12.7036 5.28935C12.5163 5.10397 12.2635 4.99999 12 5C11.444 5 11 5.444 11 5.99V7H10C9.73478 7 9.48043 7.10536 9.29289 7.29289C9.10536 7.48043 9 7.73478 9 8C9 8.26522 9.10536 8.51957 9.29289 8.70711C9.48043 8.89464 9.73478 9 10 9H11V10.01C11.0026 10.2735 11.1092 10.5253 11.2964 10.7107C11.4837 10.896 11.7365 11 12 11C12.556 11 13 10.556 13 10.01V9H14C14.2652 9 14.5196 8.89464 14.7071 8.70711C14.8946 8.51957 15 8.26522 15 8C15 7.73478 14.8946 7.48043 14.7071 7.29289C14.5196 7.10536 14.2652 7 14 7H13Z",
35
+ fill: "currentColor"
36
+ }));
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ export const AddRowBelowIcon = () => /*#__PURE__*/React.createElement("svg", {
3
+ width: "24",
4
+ height: "24",
5
+ viewBox: "0 0 24 24",
6
+ fill: "none",
7
+ xmlns: "http://www.w3.org/2000/svg"
8
+ }, /*#__PURE__*/React.createElement("mask", {
9
+ id: "path-1-inside-1_920_47112",
10
+ fill: "var(--ds-border-inverse, #FFFFFF)"
11
+ }, /*#__PURE__*/React.createElement("rect", {
12
+ x: "6",
13
+ y: "4",
14
+ width: "12",
15
+ height: "8",
16
+ rx: "0.5"
17
+ })), /*#__PURE__*/React.createElement("rect", {
18
+ x: "6",
19
+ y: "4",
20
+ width: "12",
21
+ height: "8",
22
+ rx: "0.5",
23
+ stroke: "currentColor",
24
+ strokeWidth: "4",
25
+ mask: "url(#path-1-inside-1_920_47112)"
26
+ }), /*#__PURE__*/React.createElement("path", {
27
+ fillRule: "evenodd",
28
+ clipRule: "evenodd",
29
+ d: "M13 15V13.99C12.9974 13.7265 12.8908 13.4747 12.7036 13.2893C12.5163 13.104 12.2635 13 12 13C11.444 13 11 13.444 11 13.99V15H10C9.73478 15 9.48043 15.1054 9.29289 15.2929C9.10536 15.4804 9 15.7348 9 16C9 16.2652 9.10536 16.5196 9.29289 16.7071C9.48043 16.8946 9.73478 17 10 17H11V18.01C11.0026 18.2735 11.1092 18.5253 11.2964 18.7107C11.4837 18.896 11.7365 19 12 19C12.556 19 13 18.556 13 18.01V17H14C14.2652 17 14.5196 16.8946 14.7071 16.7071C14.8946 16.5196 15 16.2652 15 16C15 15.7348 14.8946 15.4804 14.7071 15.2929C14.5196 15.1054 14.2652 15 14 15H13Z",
30
+ fill: "currentColor"
31
+ }));
@@ -1,2 +1,6 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
- export { DragInMotionIcon } from './DragInMotionIcon';
2
+ export { DragInMotionIcon } from './DragInMotionIcon';
3
+ export { AddRowAboveIcon } from './AddRowAboveIcon';
4
+ export { AddRowBelowIcon } from './AddRowBelowIcon';
5
+ export { AddColLeftIcon } from './AddColLeftIcon';
6
+ export { AddColRightIcon } from './AddColRightIcon';
@@ -1,38 +1,136 @@
1
+ import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
2
+ import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
3
+ import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
4
+ import ArrowLeftIcon from '@atlaskit/icon/glyph/arrow-left';
5
+ import ArrowRightIcon from '@atlaskit/icon/glyph/arrow-right';
6
+ import ArrowUpIcon from '@atlaskit/icon/glyph/arrow-up';
7
+ import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
8
+ import EditorLayoutThreeEqualIcon from '@atlaskit/icon/glyph/editor/layout-three-equal';
9
+ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
10
+ import HipchatChevronDoubleDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-down';
11
+ import HipchatChevronDoubleUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-double-up';
12
+ import { clearMultipleCells, insertColumn, insertRow, sortByColumn } from '../commands';
13
+ import { deleteColumnsCommand } from '../commands/delete';
1
14
  import { moveSource } from '../pm-plugins/drag-and-drop/commands';
15
+ import { deleteRows } from '../transforms';
16
+ import { AddColLeftIcon, AddColRightIcon, AddRowAboveIcon, AddRowBelowIcon } from '../ui/icons';
2
17
  const canDecrease = (index, min = 0) => index !== undefined && index > min;
3
18
  const canIncrease = (index, max = 0) => index !== undefined && index < max;
4
- export const getDragMenuConfig = (direction, tableMap, index) => {
19
+ export const getDragMenuConfig = (direction, getEditorContainerWidth, tableMap, index, targetCellPosition, selectionRect) => {
20
+ const addOptions = direction === 'row' ? [{
21
+ label: 'above',
22
+ offset: 0,
23
+ icon: AddRowAboveIcon,
24
+ keymap: addRowBefore
25
+ }, {
26
+ label: 'below',
27
+ offset: 1,
28
+ icon: AddRowBelowIcon,
29
+ keymap: addRowAfter
30
+ }] : [{
31
+ label: 'left',
32
+ offset: 0,
33
+ icon: AddColLeftIcon,
34
+ keymap: addColumnBefore
35
+ }, {
36
+ label: 'right',
37
+ offset: 1,
38
+ icon: AddColRightIcon,
39
+ keymap: addColumnAfter
40
+ }];
5
41
  const moveOptions = direction === 'row' ? [{
6
42
  label: 'up',
7
43
  offset: -1,
8
- canMove: canDecrease
44
+ canMove: canDecrease,
45
+ icon: ArrowUpIcon
9
46
  }, {
10
47
  label: 'down',
11
48
  offset: 1,
12
49
  canMove: index => {
13
50
  var _tableMap$height;
14
51
  return canIncrease(index, ((_tableMap$height = tableMap === null || tableMap === void 0 ? void 0 : tableMap.height) !== null && _tableMap$height !== void 0 ? _tableMap$height : 0) - 1);
15
- }
52
+ },
53
+ icon: ArrowDownIcon
16
54
  }] : [{
17
55
  label: 'left',
18
56
  offset: -1,
19
- canMove: canDecrease
57
+ canMove: canDecrease,
58
+ icon: ArrowLeftIcon
20
59
  }, {
21
60
  label: 'right',
22
61
  offset: 1,
23
62
  canMove: index => {
24
63
  var _tableMap$width;
25
64
  return canIncrease(index, ((_tableMap$width = tableMap === null || tableMap === void 0 ? void 0 : tableMap.width) !== null && _tableMap$width !== void 0 ? _tableMap$width : 0) - 1);
26
- }
65
+ },
66
+ icon: ArrowRightIcon
27
67
  }];
28
- return [...moveOptions.map(({
68
+ const sortOptions = direction === 'column' ? [{
69
+ label: 'increasing',
70
+ order: SortOrder.ASC,
71
+ icon: HipchatChevronDoubleUpIcon
72
+ }, {
73
+ label: 'decreasing',
74
+ order: SortOrder.DESC,
75
+ icon: HipchatChevronDoubleDownIcon
76
+ }] : [];
77
+ return [...addOptions.map(({
29
78
  label,
30
79
  offset,
31
- canMove
80
+ icon,
81
+ keymap
82
+ }) => ({
83
+ id: `add_${direction}_${label}`,
84
+ title: `Add ${direction} ${label}`,
85
+ icon,
86
+ onClick: (state, dispatch) => {
87
+ if (direction === 'row') {
88
+ insertRow(index + offset, true)(state, dispatch);
89
+ } else {
90
+ insertColumn(getEditorContainerWidth)(index + offset)(state, dispatch);
91
+ }
92
+ return true;
93
+ },
94
+ keymap: keymap && tooltip(keymap)
95
+ })), direction === 'column' ? {
96
+ id: 'distribute_columns',
97
+ title: 'Distribute columns',
98
+ disabled: true,
99
+ onClick: () => {
100
+ return false;
101
+ },
102
+ icon: EditorLayoutThreeEqualIcon
103
+ } : undefined, {
104
+ id: 'clear_cells',
105
+ title: 'Clear cells',
106
+ onClick: (state, dispatch) => {
107
+ clearMultipleCells(targetCellPosition)(state, dispatch);
108
+ return true;
109
+ },
110
+ icon: CrossCircleIcon,
111
+ keymap: tooltip(backspace)
112
+ }, {
113
+ id: `delete_${direction}`,
114
+ title: `Delete ${direction}`,
115
+ onClick: (state, dispatch) => {
116
+ if (direction === 'row') {
117
+ dispatch === null || dispatch === void 0 ? void 0 : dispatch(deleteRows(selectionRect, false)(state.tr));
118
+ } else {
119
+ deleteColumnsCommand(selectionRect)(state, dispatch);
120
+ }
121
+ return true;
122
+ },
123
+ icon: RemoveIcon
124
+ }, ...moveOptions.map(({
125
+ label,
126
+ offset,
127
+ canMove,
128
+ icon
32
129
  }) => ({
33
130
  id: `move_${direction}_${label}`,
34
131
  title: `Move ${direction} ${label}`,
35
132
  disabled: !canMove(index),
133
+ icon,
36
134
  onClick: (state, dispatch) => {
37
135
  if (canMove(index)) {
38
136
  moveSource(`table-${direction}`, index, index + offset)(state, dispatch);
@@ -40,5 +138,17 @@ export const getDragMenuConfig = (direction, tableMap, index) => {
40
138
  }
41
139
  return false;
42
140
  }
43
- }))];
141
+ })), ...sortOptions.map(({
142
+ label,
143
+ order,
144
+ icon
145
+ }) => ({
146
+ id: `sort_column_${order}`,
147
+ title: `Sort ${label}`,
148
+ icon,
149
+ onClick: (state, dispatch) => {
150
+ sortByColumn(index, order)(state, dispatch);
151
+ return true;
152
+ }
153
+ }))].filter(Boolean);
44
154
  };
@@ -330,7 +330,8 @@ var tablesPlugin = function tablesPlugin(_ref) {
330
330
  targetCellPosition: targetCellPosition,
331
331
  direction: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuDirection,
332
332
  index: dragAndDropState === null || dragAndDropState === void 0 ? void 0 : dragAndDropState.dragMenuIndex,
333
- isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing
333
+ isOpen: !!(dragAndDropState !== null && dragAndDropState !== void 0 && dragAndDropState.isDragMenuOpen) && !isResizing,
334
+ getEditorContainerWidth: defaultGetEditorContainerWidth
334
335
  }), allowControls && !isDragAndDropEnabled && !isResizing && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
335
336
  editorView: editorView,
336
337
  selection: editorView.state.selection,
@@ -1,7 +1,12 @@
1
- import React from 'react';
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
2
3
  import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
4
+ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
3
5
  import { TableMap } from '@atlaskit/editor-tables/table-map';
6
+ import { findCellRectClosestToPos, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
7
+ import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
4
8
  import { toggleDragMenu } from '../../pm-plugins/drag-and-drop/commands';
9
+ import { getSelectedColumnIndexes, getSelectedRowIndexes } from '../../utils';
5
10
  import { getDragMenuConfig } from '../../utils/drag-menu';
6
11
  import { dragMenuDropdownWidth } from '../consts';
7
12
  var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
@@ -14,7 +19,18 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
14
19
  value: {
15
20
  name: item.id
16
21
  },
17
- isDisabled: item.disabled
22
+ isDisabled: item.disabled,
23
+ elemBefore: item.icon ? jsx("div", {
24
+ style: {
25
+ marginRight: "var(--ds-space-negative-075, -6px)",
26
+ display: 'flex'
27
+ }
28
+ }, jsx(item.icon, {
29
+ label: item.title
30
+ })) : undefined,
31
+ elemAfter: item.keymap ? jsx("div", {
32
+ css: shortcutStyle
33
+ }, item.keymap) : undefined
18
34
  });
19
35
  item.onClick && (menuCallback[item.id] = item.onClick);
20
36
  });
@@ -32,9 +48,15 @@ export var DragMenu = function DragMenu(_ref) {
32
48
  tableNode = _ref.tableNode,
33
49
  mountPoint = _ref.mountPoint,
34
50
  boundariesElement = _ref.boundariesElement,
35
- scrollableElement = _ref.scrollableElement;
51
+ scrollableElement = _ref.scrollableElement,
52
+ targetCellPosition = _ref.targetCellPosition,
53
+ getEditorContainerWidth = _ref.getEditorContainerWidth;
36
54
  var tableMap = tableNode ? TableMap.get(tableNode) : undefined;
37
- var dragMenuConfig = getDragMenuConfig(direction, tableMap, index);
55
+ var state = editorView.state,
56
+ dispatch = editorView.dispatch;
57
+ var selection = state.selection;
58
+ var selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
59
+ var dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, tableMap, index, targetCellPosition, selectionRect);
38
60
  var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
39
61
  menuItems = _convertToDropdownIte.menuItems,
40
62
  menuCallback = _convertToDropdownIte.menuCallback;
@@ -43,16 +65,30 @@ export var DragMenu = function DragMenu(_ref) {
43
65
  dispatch = editorView.dispatch;
44
66
  toggleDragMenu(false)(state, dispatch);
45
67
  };
46
- var onMenuItemActivated = function onMenuItemActivated(_ref2) {
68
+ var handleMenuItemActivated = function handleMenuItemActivated(_ref2) {
47
69
  var _menuCallback$item$va;
48
70
  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);
71
+ (_menuCallback$item$va = menuCallback[item.value.name]) === null || _menuCallback$item$va === void 0 || _menuCallback$item$va.call(menuCallback, state, dispatch);
50
72
  closeMenu();
51
73
  };
74
+ var handleItemMouseEnter = function handleItemMouseEnter(_ref3) {
75
+ var _item$value$name;
76
+ var item = _ref3.item;
77
+ if (!selectionRect || !((_item$value$name = item.value.name) !== null && _item$value$name !== void 0 && _item$value$name.startsWith('delete'))) {
78
+ return;
79
+ }
80
+ (item.value.name === 'delete_column' ? hoverColumns(getSelectedColumnIndexes(selectionRect), true) : hoverRows(getSelectedRowIndexes(selectionRect), true))(state, dispatch);
81
+ };
82
+ var handleItemMouseLeave = function handleItemMouseLeave(_ref4) {
83
+ var item = _ref4.item;
84
+ if (['sort_column_asc', 'sort_column_desc', 'delete_column', 'delete_row'].indexOf(item.value.name) > -1) {
85
+ clearHoverSelection()(state, dispatch);
86
+ }
87
+ };
52
88
  if (!menuItems) {
53
89
  return null;
54
90
  }
55
- return /*#__PURE__*/React.createElement(DropdownMenu, {
91
+ return jsx(DropdownMenu, {
56
92
  mountTo: mountPoint
57
93
  //This needs be removed when the a11y is completely handled
58
94
  //Disabling key navigation now as it works only partially
@@ -66,7 +102,9 @@ export var DragMenu = function DragMenu(_ref) {
66
102
  }],
67
103
  isOpen: isOpen,
68
104
  onOpenChange: closeMenu,
69
- onItemActivated: onMenuItemActivated,
105
+ onItemActivated: handleMenuItemActivated,
106
+ onMouseEnter: handleItemMouseEnter,
107
+ onMouseLeave: handleItemMouseLeave,
70
108
  fitWidth: dragMenuDropdownWidth,
71
109
  boundariesElement: boundariesElement
72
110
  });
@@ -15,7 +15,8 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
15
15
  tableNode = _ref.tableNode,
16
16
  direction = _ref.direction,
17
17
  index = _ref.index,
18
- targetCellPosition = _ref.targetCellPosition;
18
+ targetCellPosition = _ref.targetCellPosition,
19
+ getEditorContainerWidth = _ref.getEditorContainerWidth;
19
20
  if (!isOpen || !targetCellPosition || editorView.state.doc.nodeSize <= targetCellPosition) {
20
21
  return null;
21
22
  }
@@ -48,7 +49,9 @@ var FloatingDragMenu = function FloatingDragMenu(_ref) {
48
49
  boundariesElement: boundariesElement,
49
50
  tableNode: tableNode,
50
51
  direction: direction,
51
- index: index
52
+ index: index,
53
+ targetCellPosition: targetCellPosition,
54
+ getEditorContainerWidth: getEditorContainerWidth
52
55
  }));
53
56
  };
54
57
  FloatingDragMenu.displayName = 'FloatingDragMenu';
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ export var AddColLeftIcon = function AddColLeftIcon() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "24",
5
+ height: "24",
6
+ viewBox: "0 0 24 24",
7
+ fill: "currentColor",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("rect", {
10
+ width: "24",
11
+ height: "24",
12
+ transform: "matrix(0 -1 1 0 0 24)",
13
+ fill: "none",
14
+ fillOpacity: "0.01"
15
+ }), /*#__PURE__*/React.createElement("rect", {
16
+ x: "12",
17
+ y: "18",
18
+ width: "12",
19
+ height: "3",
20
+ rx: "0.5",
21
+ transform: "rotate(-90 12 18)",
22
+ fill: "currentColor"
23
+ }), /*#__PURE__*/React.createElement("rect", {
24
+ x: "16",
25
+ y: "18",
26
+ width: "12",
27
+ height: "3",
28
+ rx: "0.5",
29
+ transform: "rotate(-90 16 18)",
30
+ fill: "currentColor"
31
+ }), /*#__PURE__*/React.createElement("path", {
32
+ fillRule: "evenodd",
33
+ clipRule: "evenodd",
34
+ d: "M7 11H5.99C5.72652 11.0026 5.47473 11.1092 5.28935 11.2964C5.10397 11.4837 4.99999 11.7365 5 12C5 12.556 5.444 13 5.99 13H7V14C7 14.2652 7.10536 14.5196 7.29289 14.7071C7.48043 14.8946 7.73478 15 8 15C8.26522 15 8.51957 14.8946 8.70711 14.7071C8.89464 14.5196 9 14.2652 9 14V13H10.01C10.2735 12.9974 10.5253 12.8908 10.7107 12.7036C10.896 12.5163 11 12.2635 11 12C11 11.444 10.556 11 10.01 11H9V10C9 9.73478 8.89464 9.48043 8.70711 9.29289C8.51957 9.10536 8.26522 9 8 9C7.73478 9 7.48043 9.10536 7.29289 9.29289C7.10536 9.48043 7 9.73478 7 10V11Z",
35
+ fill: "currentColor"
36
+ }));
37
+ };
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ export var AddColRightIcon = function AddColRightIcon() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "24",
5
+ height: "24",
6
+ viewBox: "0 0 24 24",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("rect", {
10
+ width: "24",
11
+ height: "24",
12
+ transform: "translate(0 24) rotate(-90)",
13
+ fill: "none",
14
+ fillOpacity: "0.01"
15
+ }), /*#__PURE__*/React.createElement("rect", {
16
+ x: "9",
17
+ y: "18",
18
+ width: "12",
19
+ height: "3",
20
+ rx: "0.5",
21
+ transform: "rotate(-90 9 18)",
22
+ fill: "currentColor"
23
+ }), /*#__PURE__*/React.createElement("rect", {
24
+ x: "5",
25
+ y: "18",
26
+ width: "12",
27
+ height: "3",
28
+ rx: "0.5",
29
+ transform: "rotate(-90 5 18)",
30
+ fill: "currentColor"
31
+ }), /*#__PURE__*/React.createElement("path", {
32
+ fillRule: "evenodd",
33
+ clipRule: "evenodd",
34
+ d: "M15 11L13.99 11C13.7265 11.0026 13.4747 11.1092 13.2893 11.2964C13.104 11.4837 13 11.7365 13 12C13 12.556 13.444 13 13.99 13L15 13L15 14C15 14.2652 15.1054 14.5196 15.2929 14.7071C15.4804 14.8946 15.7348 15 16 15C16.2652 15 16.5196 14.8946 16.7071 14.7071C16.8946 14.5196 17 14.2652 17 14L17 13L18.01 13C18.2735 12.9974 18.5253 12.8908 18.7107 12.7036C18.896 12.5163 19 12.2635 19 12C19 11.444 18.556 11 18.01 11L17 11L17 10C17 9.73478 16.8946 9.48043 16.7071 9.29289C16.5196 9.10536 16.2652 9 16 9C15.7348 9 15.4804 9.10536 15.2929 9.29289C15.1054 9.48043 15 9.73478 15 10L15 11Z",
35
+ fill: "currentColor"
36
+ }));
37
+ };
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ export var AddRowAboveIcon = function AddRowAboveIcon() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "24",
5
+ height: "24",
6
+ viewBox: "0 0 24 24",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("rect", {
10
+ width: "24",
11
+ height: "24",
12
+ fill: "var(--ds-border-inverse, #FFFFFF)",
13
+ fillOpacity: "0.01"
14
+ }), /*#__PURE__*/React.createElement("mask", {
15
+ id: "path-1-inside-1_896_17822",
16
+ fill: "var(--ds-border-inverse, #FFFFFF)"
17
+ }, /*#__PURE__*/React.createElement("rect", {
18
+ x: "6",
19
+ y: "12",
20
+ width: "12",
21
+ height: "8",
22
+ rx: "0.5"
23
+ })), /*#__PURE__*/React.createElement("rect", {
24
+ x: "6",
25
+ y: "12",
26
+ width: "12",
27
+ height: "8",
28
+ rx: "0.5",
29
+ stroke: "currentColor",
30
+ strokeWidth: "4",
31
+ mask: "url(#path-1-inside-1_896_17822)"
32
+ }), /*#__PURE__*/React.createElement("path", {
33
+ fillRule: "evenodd",
34
+ clipRule: "evenodd",
35
+ d: "M13 7V5.99C12.9974 5.72652 12.8908 5.47473 12.7036 5.28935C12.5163 5.10397 12.2635 4.99999 12 5C11.444 5 11 5.444 11 5.99V7H10C9.73478 7 9.48043 7.10536 9.29289 7.29289C9.10536 7.48043 9 7.73478 9 8C9 8.26522 9.10536 8.51957 9.29289 8.70711C9.48043 8.89464 9.73478 9 10 9H11V10.01C11.0026 10.2735 11.1092 10.5253 11.2964 10.7107C11.4837 10.896 11.7365 11 12 11C12.556 11 13 10.556 13 10.01V9H14C14.2652 9 14.5196 8.89464 14.7071 8.70711C14.8946 8.51957 15 8.26522 15 8C15 7.73478 14.8946 7.48043 14.7071 7.29289C14.5196 7.10536 14.2652 7 14 7H13Z",
36
+ fill: "currentColor"
37
+ }));
38
+ };
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ export var AddRowBelowIcon = function AddRowBelowIcon() {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ width: "24",
5
+ height: "24",
6
+ viewBox: "0 0 24 24",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg"
9
+ }, /*#__PURE__*/React.createElement("mask", {
10
+ id: "path-1-inside-1_920_47112",
11
+ fill: "var(--ds-border-inverse, #FFFFFF)"
12
+ }, /*#__PURE__*/React.createElement("rect", {
13
+ x: "6",
14
+ y: "4",
15
+ width: "12",
16
+ height: "8",
17
+ rx: "0.5"
18
+ })), /*#__PURE__*/React.createElement("rect", {
19
+ x: "6",
20
+ y: "4",
21
+ width: "12",
22
+ height: "8",
23
+ rx: "0.5",
24
+ stroke: "currentColor",
25
+ strokeWidth: "4",
26
+ mask: "url(#path-1-inside-1_920_47112)"
27
+ }), /*#__PURE__*/React.createElement("path", {
28
+ fillRule: "evenodd",
29
+ clipRule: "evenodd",
30
+ d: "M13 15V13.99C12.9974 13.7265 12.8908 13.4747 12.7036 13.2893C12.5163 13.104 12.2635 13 12 13C11.444 13 11 13.444 11 13.99V15H10C9.73478 15 9.48043 15.1054 9.29289 15.2929C9.10536 15.4804 9 15.7348 9 16C9 16.2652 9.10536 16.5196 9.29289 16.7071C9.48043 16.8946 9.73478 17 10 17H11V18.01C11.0026 18.2735 11.1092 18.5253 11.2964 18.7107C11.4837 18.896 11.7365 19 12 19C12.556 19 13 18.556 13 18.01V17H14C14.2652 17 14.5196 16.8946 14.7071 16.7071C14.8946 16.5196 15 16.2652 15 16C15 15.7348 14.8946 15.4804 14.7071 15.2929C14.5196 15.1054 14.2652 15 14 15H13Z",
31
+ fill: "currentColor"
32
+ }));
33
+ };
@@ -1,2 +1,6 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
- export { DragInMotionIcon } from './DragInMotionIcon';
2
+ export { DragInMotionIcon } from './DragInMotionIcon';
3
+ export { AddRowAboveIcon } from './AddRowAboveIcon';
4
+ export { AddRowBelowIcon } from './AddRowBelowIcon';
5
+ export { AddColLeftIcon } from './AddColLeftIcon';
6
+ export { AddColRightIcon } from './AddColRightIcon';