@atlaskit/editor-plugin-table 5.4.14 → 5.4.16

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 (123) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/afm-cc/tsconfig.json +70 -0
  3. package/dist/cjs/plugins/table/commands/hover.js +26 -6
  4. package/dist/cjs/plugins/table/commands/index.js +6 -0
  5. package/dist/cjs/plugins/table/commands/misc.js +8 -3
  6. package/dist/cjs/plugins/table/event-handlers.js +56 -34
  7. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -1
  8. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  9. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +39 -7
  10. package/dist/cjs/plugins/table/pm-plugins/main.js +5 -3
  11. package/dist/cjs/plugins/table/reducer.js +1 -0
  12. package/dist/cjs/plugins/table/toolbar.js +6 -3
  13. package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +6 -3
  14. package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
  15. package/dist/cjs/plugins/table/ui/DragHandle/index.js +3 -0
  16. package/dist/cjs/plugins/table/ui/DragPreview/index.js +0 -2
  17. package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -7
  18. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -10
  19. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
  20. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +7 -4
  21. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +74 -37
  22. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  23. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +63 -31
  24. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +12 -8
  25. package/dist/cjs/plugins/table/utils/dom.js +16 -1
  26. package/dist/cjs/plugins/table/utils/index.js +6 -0
  27. package/dist/es2019/plugins/table/commands/hover.js +22 -5
  28. package/dist/es2019/plugins/table/commands/index.js +1 -1
  29. package/dist/es2019/plugins/table/commands/misc.js +8 -3
  30. package/dist/es2019/plugins/table/event-handlers.js +45 -20
  31. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -1
  32. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  33. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +36 -3
  34. package/dist/es2019/plugins/table/pm-plugins/main.js +6 -4
  35. package/dist/es2019/plugins/table/reducer.js +1 -0
  36. package/dist/es2019/plugins/table/toolbar.js +5 -3
  37. package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
  38. package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
  39. package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
  40. package/dist/es2019/plugins/table/ui/DragPreview/index.js +0 -2
  41. package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +9 -7
  42. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
  43. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
  44. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
  45. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +73 -37
  46. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  47. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -29
  48. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +12 -9
  49. package/dist/es2019/plugins/table/utils/dom.js +13 -0
  50. package/dist/es2019/plugins/table/utils/index.js +1 -1
  51. package/dist/esm/plugins/table/commands/hover.js +25 -5
  52. package/dist/esm/plugins/table/commands/index.js +1 -1
  53. package/dist/esm/plugins/table/commands/misc.js +8 -3
  54. package/dist/esm/plugins/table/event-handlers.js +55 -33
  55. package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -1
  56. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
  57. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +35 -3
  58. package/dist/esm/plugins/table/pm-plugins/main.js +6 -4
  59. package/dist/esm/plugins/table/reducer.js +1 -0
  60. package/dist/esm/plugins/table/toolbar.js +5 -3
  61. package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
  62. package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
  63. package/dist/esm/plugins/table/ui/DragHandle/index.js +3 -0
  64. package/dist/esm/plugins/table/ui/DragPreview/index.js +0 -2
  65. package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +9 -7
  66. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
  67. package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
  68. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
  69. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +74 -37
  70. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
  71. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +61 -29
  72. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -8
  73. package/dist/esm/plugins/table/utils/dom.js +15 -0
  74. package/dist/esm/plugins/table/utils/index.js +1 -1
  75. package/dist/types/plugins/table/commands/hover.d.ts +2 -1
  76. package/dist/types/plugins/table/commands/index.d.ts +1 -1
  77. package/dist/types/plugins/table/commands/misc.d.ts +1 -1
  78. package/dist/types/plugins/table/event-handlers.d.ts +2 -0
  79. package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  80. package/dist/types/plugins/table/types.d.ts +7 -2
  81. package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
  82. package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
  83. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  84. package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
  85. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  86. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  87. package/dist/types/plugins/table/utils/dom.d.ts +4 -0
  88. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  89. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
  90. package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
  91. package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +1 -1
  92. package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +2 -0
  93. package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
  94. package/dist/types-ts4.5/plugins/table/types.d.ts +7 -2
  95. package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
  96. package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
  97. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
  98. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
  99. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
  100. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
  101. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -0
  102. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  103. package/package.json +2 -2
  104. package/src/__tests__/unit/event-handlers.ts +2 -2
  105. package/src/__tests__/unit/ui/RowDragControls.tsx +1 -0
  106. package/src/plugins/table/commands/hover.ts +37 -7
  107. package/src/plugins/table/commands/index.ts +1 -0
  108. package/src/plugins/table/commands/misc.ts +9 -3
  109. package/src/plugins/table/event-handlers.ts +47 -29
  110. package/src/plugins/table/nodeviews/TableComponent.tsx +4 -1
  111. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +7 -5
  112. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +37 -2
  113. package/src/plugins/table/pm-plugins/main.ts +6 -3
  114. package/src/plugins/table/reducer.ts +1 -0
  115. package/src/plugins/table/types.ts +9 -2
  116. package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +10 -9
  117. package/src/plugins/table/ui/DragHandle/index.tsx +4 -0
  118. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +129 -50
  119. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +3 -0
  120. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +128 -41
  121. package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -5
  122. package/src/plugins/table/utils/dom.ts +22 -0
  123. package/src/plugins/table/utils/index.ts +1 -0
@@ -1,4 +1,6 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ /** @jsx jsx */
3
+ import { jsx } from '@emotion/react';
2
4
  import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
3
5
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
4
6
  import { TableMap } from '@atlaskit/editor-tables/table-map';
@@ -29,15 +31,15 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
29
31
  name: item.id
30
32
  },
31
33
  isDisabled: item.disabled,
32
- elemBefore: item.icon ? /*#__PURE__*/React.createElement("div", {
34
+ elemBefore: item.icon ? jsx("div", {
33
35
  style: {
34
36
  marginRight: "var(--ds-space-negative-075, -6px)",
35
37
  display: 'flex'
36
38
  }
37
- }, /*#__PURE__*/React.createElement(item.icon, {
39
+ }, jsx(item.icon, {
38
40
  label: item.title
39
41
  })) : undefined,
40
- elemAfter: item.keymap ? /*#__PURE__*/React.createElement("div", {
42
+ elemAfter: item.keymap ? jsx("div", {
41
43
  css: shortcutStyle
42
44
  }, item.keymap) : undefined
43
45
  });
@@ -129,7 +131,7 @@ export var DragMenu = function DragMenu(_ref) {
129
131
  if (!menuItems) {
130
132
  return null;
131
133
  }
132
- return /*#__PURE__*/React.createElement(DropdownMenu, {
134
+ return jsx(DropdownMenu, {
133
135
  mountTo: mountPoint
134
136
  //This needs be removed when the a11y is completely handled
135
137
  //Disabling key navigation now as it works only partially
@@ -1,8 +1,11 @@
1
+ /* eslint-disable @atlaskit/design-system/prefer-primitives */
2
+
1
3
  import React, { useCallback, useMemo } from 'react';
2
4
  import { CellSelection } from '@atlaskit/editor-tables';
3
5
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
4
6
  import { clearHoverSelection, hoverCell, hoverColumns, selectColumn } from '../../../commands';
5
7
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
8
+ import { getPluginState as getDragDropPluginState } from '../../../pm-plugins/drag-and-drop/plugin-factory';
6
9
  import { TableCssClassName as ClassName } from '../../../types';
7
10
  import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
8
11
  import { DragHandle } from '../../DragHandle';
@@ -17,7 +20,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
17
20
  return [];
18
21
  };
19
22
  export var ColumnControls = function ColumnControls(_ref) {
20
- var _colWidths$map$join, _rowHeights$;
23
+ var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
21
24
  var editorView = _ref.editorView,
22
25
  tableActive = _ref.tableActive,
23
26
  tableRef = _ref.tableRef,
@@ -28,7 +31,8 @@ export var ColumnControls = function ColumnControls(_ref) {
28
31
  isInDanger = _ref.isInDanger,
29
32
  rowHeights = _ref.rowHeights,
30
33
  colWidths = _ref.colWidths,
31
- hasHeaderColumn = _ref.hasHeaderColumn;
34
+ hasHeaderColumn = _ref.hasHeaderColumn,
35
+ isTableHovered = _ref.isTableHovered;
32
36
  var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
33
37
  return width ? "".concat(width - 1, "px") : '0px';
34
38
  }).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
@@ -36,13 +40,6 @@ export var ColumnControls = function ColumnControls(_ref) {
36
40
  var columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
37
41
  var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
38
42
  var selectedColIndexes = getSelectedColumns(editorView.state.selection);
39
- var gridColumnPosition = useMemo(function () {
40
- // if more than one row is selected, ensure the handle spans over the selected range
41
- if (selectedColIndexes.includes(colIndex)) {
42
- return "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
43
- }
44
- return "".concat(colIndex + 1, " / span 1");
45
- }, [colIndex, selectedColIndexes]);
46
43
  var firstRow = tableRef.querySelector('tr');
47
44
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
48
45
  var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
@@ -68,10 +65,14 @@ export var ColumnControls = function ColumnControls(_ref) {
68
65
  // update hovered cell location
69
66
  var state = editorView.state,
70
67
  dispatch = editorView.dispatch;
71
- if (tableActive && (hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) !== Number(colIndex)) {
72
- hoverCell(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, Number(colIndex))(state, dispatch);
68
+ if (tableActive) {
69
+ // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
70
+ // of the opposite dimension. For example; here when we mouse over the column drag handle then we're technically
71
+ // also hovering over row 0 index. And vice-versa with rows. This means we don't need to worry about knowing the
72
+ // current row index. We can just force it to 0.
73
+ hoverCell(0, Number(colIndex))(state, dispatch);
73
74
  }
74
- }, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex, tableActive]);
75
+ }, [editorView, tableActive]);
75
76
  var handleMouseOut = useCallback(function () {
76
77
  if (tableActive) {
77
78
  var state = editorView.state,
@@ -87,6 +88,66 @@ export var ColumnControls = function ColumnControls(_ref) {
87
88
  var colIndexes = useMemo(function () {
88
89
  return [colIndex];
89
90
  }, [colIndex]);
91
+ var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
92
+ return sum + cur;
93
+ }, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
94
+ var generateHandleByType = useCallback(function (type) {
95
+ var _colWidths;
96
+ if (!hoveredCell) {
97
+ return null;
98
+ }
99
+ var _getDragDropPluginSta = getDragDropPluginState(editorView.state),
100
+ isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
101
+ dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
102
+ dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
103
+ var isHover = type === 'hover';
104
+ var isHoveredOnSelectedColumn = isDragMenuOpen && dragMenuDirection === 'column' && dragMenuIndex === colIndex;
105
+ var showCondition = isHover ? !isHoveredOnSelectedColumn && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'column';
106
+ if (!showCondition) {
107
+ return null;
108
+ }
109
+ var selectedColumnPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedColIndexes.length);
110
+ var gridColumnPosition = selectedColIndexes.includes(colIndex) ? "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length) : "".concat(colIndex + 1, " / span 1");
111
+ var selectedApprearance = isInDanger ? 'danger' : 'selected';
112
+ var hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
113
+ return showCondition && /*#__PURE__*/React.createElement("div", {
114
+ key: type,
115
+ style: {
116
+ gridColumn: isHover ? gridColumnPosition : selectedColumnPosition,
117
+ display: 'flex',
118
+ justifyContent: 'center',
119
+ alignItems: 'center',
120
+ height: 'fit-content',
121
+ placeSelf: 'center',
122
+ zIndex: 99
123
+ },
124
+ "data-column-control-index": hoveredCell.colIndex,
125
+ "data-testid": isHover ? 'table-floating-column-control' : 'table-floating-column-control-selected'
126
+ }, /*#__PURE__*/React.createElement(DragHandle, {
127
+ direction: "column",
128
+ tableLocalId: localId || '',
129
+ indexes: isHover ? colIndexes : selectedColIndexes,
130
+ forceDefaultHandle: !isHover,
131
+ previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
132
+ previewHeight: previewHeight,
133
+ appearance: isHover ? hoveredAppearance : selectedApprearance,
134
+ onClick: handleClick,
135
+ onMouseOver: handleMouseOver,
136
+ onMouseOut: handleMouseOut,
137
+ onMouseUp: handleMouseUp,
138
+ editorView: editorView
139
+ }));
140
+ }, [colIndex, previewHeight, colWidths, colIndexes, editorView, handleClick, handleMouseOut, handleMouseOver, handleMouseUp, hoveredCell, isInDanger, localId, selectedColIndexes]);
141
+ var columnHandles = useCallback(function (hoveredCell) {
142
+ if (!hoveredCell) {
143
+ return null;
144
+ }
145
+ if (hoveredCell.colIndex === undefined) {
146
+ return generateHandleByType('selected');
147
+ }
148
+ var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
149
+ return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
150
+ }, [generateHandleByType, selectedColIndexes]);
90
151
  return /*#__PURE__*/React.createElement("div", {
91
152
  className: ClassName.DRAG_COLUMN_CONTROLS,
92
153
  onMouseMove: handleMouseMove
@@ -115,30 +176,6 @@ export var ColumnControls = function ColumnControls(_ref) {
115
176
  right: '0'
116
177
  } : {}
117
178
  }));
118
- }), tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
119
- style: {
120
- gridColumn: gridColumnPosition,
121
- display: 'flex',
122
- justifyContent: 'center',
123
- alignItems: 'center',
124
- height: 'fit-content',
125
- placeSelf: 'center',
126
- zIndex: 99
127
- },
128
- "data-column-control-index": hoveredCell.colIndex,
129
- "data-testid": "table-floating-column-control"
130
- }, /*#__PURE__*/React.createElement(DragHandle, {
131
- direction: "column",
132
- tableLocalId: localId || '',
133
- indexes: colIndexes,
134
- previewWidth: hoveredCell.colWidth,
135
- previewHeight: hoveredCell.colHeight,
136
- appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
137
- onClick: handleClick,
138
- onMouseOver: handleMouseOver,
139
- onMouseOut: handleMouseOut,
140
- onMouseUp: handleMouseUp,
141
- editorView: editorView
142
- }))));
179
+ }), tableActive && !isResizing && columnHandles(hoveredCell)));
143
180
  };
144
181
  export default ColumnControls;
@@ -18,7 +18,8 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
18
18
  isResizing = _ref.isResizing,
19
19
  stickyHeader = _ref.stickyHeader,
20
20
  selection = _ref.selection,
21
- isInDanger = _ref.isInDanger;
21
+ isInDanger = _ref.isInDanger,
22
+ isTableHovered = _ref.isTableHovered;
22
23
  var _useState = useState({
23
24
  width: 0,
24
25
  height: 0
@@ -103,6 +104,7 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
103
104
  tableRef: tableRef,
104
105
  isResizing: isResizing,
105
106
  tableActive: tableActive,
107
+ isTableHovered: isTableHovered,
106
108
  stickyTop: tableActive ? stickyTop : undefined,
107
109
  localId: currentNodeLocalId,
108
110
  isInDanger: isInDanger,
@@ -1,4 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /* eslint-disable @atlaskit/design-system/prefer-primitives */
3
+
2
4
  import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
3
5
  import { injectIntl } from 'react-intl-next';
4
6
  import { CellSelection } from '@atlaskit/editor-tables';
@@ -6,6 +8,7 @@ import { getSelectionRect } from '@atlaskit/editor-tables/utils';
6
8
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
7
9
  import { clearHoverSelection } from '../../../commands';
8
10
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
11
+ import { getPluginState as getDragDropPluginState } from '../../../pm-plugins/drag-and-drop/plugin-factory';
9
12
  import { getPluginState as getTablePluginState } from '../../../pm-plugins/plugin-factory';
10
13
  import { TableCssClassName as ClassName } from '../../../types';
11
14
  import { getRowHeights, getRowsParams, getSelectedRowIndexes } from '../../../utils';
@@ -32,6 +35,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
32
35
  editorView = _ref.editorView,
33
36
  isInDanger = _ref.isInDanger,
34
37
  isResizing = _ref.isResizing,
38
+ isTableHovered = _ref.isTableHovered,
35
39
  hoverRows = _ref.hoverRows,
36
40
  selectRow = _ref.selectRow,
37
41
  updateCellHoverLocation = _ref.updateCellHoverLocation;
@@ -75,13 +79,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
75
79
  toggleDragMenu(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
76
80
  }, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
77
81
  var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
78
- var gridRowPosition = useMemo(function () {
79
- // if more than one row is selected, ensure the handle spans over the selected range
80
- if (selectedRowIndexes.includes(rowIndex)) {
81
- return "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
82
- }
83
- return "".concat(rowIndex + 1, " / span 1");
84
- }, [rowIndex, selectedRowIndexes]);
85
82
  var handleMouseOut = useCallback(function () {
86
83
  if (tableActive) {
87
84
  var state = editorView.state,
@@ -108,6 +105,62 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
108
105
  var handleClick = useCallback(function (e) {
109
106
  selectRow(rowIndex, e === null || e === void 0 ? void 0 : e.shiftKey);
110
107
  }, [rowIndex, selectRow]);
108
+ var generateHandleByType = useCallback(function (type) {
109
+ if (!hoveredCell) {
110
+ return null;
111
+ }
112
+ var _getDragDropPluginSta = getDragDropPluginState(editorView.state),
113
+ isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
114
+ dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
115
+ dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
116
+ var isHover = type === 'hover';
117
+ var isHoveredOnSelectedRow = isDragMenuOpen && dragMenuDirection === 'row' && dragMenuIndex === rowIndex;
118
+ var showCondition = isHover ? !isHoveredOnSelectedRow && !selectedRowIndexes.includes(rowIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'row' && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
119
+ if (!showCondition) {
120
+ return null;
121
+ }
122
+ var gridRowPosition =
123
+ // if more than one row is selected, ensure the handle spans over the selected range
124
+ selectedRowIndexes.includes(rowIndex) ? "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length) : "".concat(rowIndex + 1, " / span 1");
125
+ var selectedRowPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedRowIndexes.length);
126
+ var selectedApprearance = isInDanger ? 'danger' : 'selected';
127
+ var hoveredAppearance = selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
128
+ return showCondition && /*#__PURE__*/React.createElement("div", {
129
+ key: type,
130
+ style: {
131
+ gridRow: isHover ? gridRowPosition : selectedRowPosition,
132
+ gridColumn: '2',
133
+ display: 'flex',
134
+ height: '100%',
135
+ alignItems: 'center',
136
+ justifyContent: 'center'
137
+ },
138
+ "data-testid": isHover ? 'table-floating-row-drag-handle' : 'table-floating-row-control-selected'
139
+ }, /*#__PURE__*/React.createElement(DragHandle, {
140
+ direction: "row",
141
+ tableLocalId: currentNodeLocalId,
142
+ indexes: isHover ? rowIndexes : selectedRowIndexes,
143
+ forceDefaultHandle: !isHover,
144
+ previewWidth: tableWidth,
145
+ previewHeight: rowHeights[rowIndex],
146
+ appearance: isHover ? hoveredAppearance : selectedApprearance,
147
+ onClick: handleClick,
148
+ onMouseOver: handleMouseOver,
149
+ onMouseOut: handleMouseOut,
150
+ onMouseUp: onMouseUp,
151
+ editorView: editorView
152
+ }));
153
+ }, [currentNodeLocalId, editorView, handleClick, handleMouseOut, handleMouseOver, hoveredCell, isInDanger, onMouseUp, rowHeights, rowIndex, rowIndexes, selectedRowIndexes, tableWidth]);
154
+ var rowHandles = useCallback(function (hoveredCell) {
155
+ if (!hoveredCell) {
156
+ return null;
157
+ }
158
+ if (hoveredCell.rowIndex === undefined) {
159
+ return generateHandleByType('selected');
160
+ }
161
+ var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
162
+ return hoveredCell.rowIndex < selectedRowIndexes[0] ? sortedHandles : sortedHandles.reverse();
163
+ }, [generateHandleByType, selectedRowIndexes]);
111
164
  return /*#__PURE__*/React.createElement("div", {
112
165
  className: ClassName.DRAG_ROW_CONTROLS,
113
166
  style: {
@@ -147,27 +200,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
147
200
  left: "var(--ds-space-negative-100, -8px)"
148
201
  }
149
202
  }));
150
- }), !isResizing && Number.isFinite(rowIndex) && /*#__PURE__*/React.createElement("div", {
151
- style: {
152
- gridRow: gridRowPosition,
153
- gridColumn: '2',
154
- display: 'flex',
155
- height: '100%',
156
- alignItems: 'center',
157
- justifyContent: 'center'
158
- },
159
- "data-testid": "table-floating-row-drag-handle"
160
- }, /*#__PURE__*/React.createElement(DragHandle, {
161
- tableLocalId: currentNodeLocalId,
162
- indexes: rowIndexes,
163
- previewWidth: tableWidth,
164
- previewHeight: rowHeights[rowIndex],
165
- appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
166
- onClick: handleClick,
167
- onMouseOver: handleMouseOver,
168
- onMouseOut: handleMouseOut,
169
- onMouseUp: onMouseUp,
170
- editorView: editorView
171
- })));
203
+ }), !isResizing && Number.isFinite(rowIndex) && rowHandles(hoveredCell));
172
204
  };
173
205
  export var DragControls = injectIntl(DragControlsComponent);
@@ -13,7 +13,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
13
13
  import React, { Component } from 'react';
14
14
  import { browser } from '@atlaskit/editor-common/utils';
15
15
  import { hoverCell, hoverRows, selectRow } from '../../commands';
16
- import { getPluginState } from '../../pm-plugins/plugin-factory';
17
16
  import { TableCssClassName as ClassName } from '../../types';
18
17
  import { isSelectionUpdated } from '../../utils';
19
18
  import { CornerControls, DragCornerControls } from './CornerControls';
@@ -49,10 +48,12 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
49
48
  tableActive = _this$props.tableActive;
50
49
  var state = editorView.state,
51
50
  dispatch = editorView.dispatch;
52
- var _getPluginState = getPluginState(state),
53
- hoveredCell = _getPluginState.hoveredCell;
54
- if (tableActive && hoveredCell.rowIndex !== rowIndex) {
55
- hoverCell(rowIndex, hoveredCell.colIndex)(state, dispatch);
51
+ if (tableActive) {
52
+ // For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
53
+ // of the opposite dimension. For example; here when we mouse over the row drag handle then we're technically
54
+ // also hovering over column 0 index. And vice-versa with columns. This means we don't need to worry about knowing the
55
+ // current column index. We can just force it to 0.
56
+ hoverCell(rowIndex, 0)(state, dispatch);
56
57
  }
57
58
  });
58
59
  _this.state = {
@@ -124,8 +125,9 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
124
125
  ordering = _this$props2.ordering,
125
126
  headerRowHeight = _this$props2.headerRowHeight,
126
127
  stickyHeader = _this$props2.stickyHeader,
127
- hoveredCell = _this$props2.hoveredCell;
128
- return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || isSelectionUpdated(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell;
128
+ hoveredCell = _this$props2.hoveredCell,
129
+ isTableHovered = _this$props2.isTableHovered;
130
+ return this.state.tableWrapperWidth !== nextState.tableWrapperWidth || this.state.tableWrapperHeight !== nextState.tableWrapperHeight || ordering !== nextProps.ordering || tableRef !== nextProps.tableRef || tableActive !== nextProps.tableActive || isInDanger !== nextProps.isInDanger || isResizing !== nextProps.isResizing || hoveredRows !== nextProps.hoveredRows || isHeaderRowEnabled !== nextProps.isHeaderRowEnabled || isHeaderColumnEnabled !== nextProps.isHeaderColumnEnabled || isNumberColumnEnabled !== nextProps.isNumberColumnEnabled || isSelectionUpdated(selection, nextProps.selection) || headerRowHeight !== nextProps.headerRowHeight || stickyHeader !== nextProps.stickyHeader || hoveredCell !== nextProps.hoveredCell || isTableHovered !== nextProps.isTableHovered;
129
131
  }
130
132
  }, {
131
133
  key: "componentWillUnmount",
@@ -151,7 +153,8 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
151
153
  hoveredRows = _this$props3.hoveredRows,
152
154
  stickyHeader = _this$props3.stickyHeader,
153
155
  isDragAndDropEnabled = _this$props3.isDragAndDropEnabled,
154
- hoveredCell = _this$props3.hoveredCell;
156
+ hoveredCell = _this$props3.hoveredCell,
157
+ isTableHovered = _this$props3.isTableHovered;
155
158
  if (!tableRef) {
156
159
  return null;
157
160
  }
@@ -185,6 +188,7 @@ var TableFloatingControls = /*#__PURE__*/function (_Component) {
185
188
  tableRef: tableRef,
186
189
  tableNode: tableNode,
187
190
  hoveredCell: hoveredCell,
191
+ isTableHovered: isTableHovered,
188
192
  editorView: editorView,
189
193
  tableActive: tableActive,
190
194
  isInDanger: isInDanger,
@@ -200,4 +200,19 @@ export var getTop = function getTop(element) {
200
200
  return 0;
201
201
  }
202
202
  return (_element$getBoundingC = element === null || element === void 0 || (_element$getBoundingC2 = element.getBoundingClientRect) === null || _element$getBoundingC2 === void 0 || (_element$getBoundingC2 = _element$getBoundingC2.call(element)) === null || _element$getBoundingC2 === void 0 ? void 0 : _element$getBoundingC2.top) !== null && _element$getBoundingC !== void 0 ? _element$getBoundingC : 0;
203
+ };
204
+ export var findNearestCellIndexToPoint = function findNearestCellIndexToPoint(x, y) {
205
+ var _cell$parentElement;
206
+ var elements = document.elementsFromPoint(x, y);
207
+ var cell = elements.find(function (el) {
208
+ return el.nodeName.toUpperCase() === 'TD' || el.nodeName.toUpperCase() === 'TH';
209
+ });
210
+ var row = (_cell$parentElement = cell === null || cell === void 0 ? void 0 : cell.parentElement) !== null && _cell$parentElement !== void 0 ? _cell$parentElement : undefined;
211
+ if (!Number.isFinite(row === null || row === void 0 ? void 0 : row.rowIndex) || !Number.isFinite(cell === null || cell === void 0 ? void 0 : cell.cellIndex)) {
212
+ return undefined;
213
+ }
214
+ return {
215
+ row: row.rowIndex,
216
+ col: cell.cellIndex
217
+ };
203
218
  };
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine } from './decoration';
3
3
  export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell } from './paste';
5
- export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler } from './dom';
5
+ export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow } from './row-controls';
8
8
  export { getSelectedTableInfo, getSelectedCellInfo } from './analytics';
@@ -6,4 +6,5 @@ export declare const hoverTable: (isInDanger?: boolean, isSelected?: boolean) =>
6
6
  export declare const clearHoverSelection: () => import("@atlaskit/editor-common/types").Command;
7
7
  export declare const showResizeHandleLine: (cellColumnPositioning: CellColumnPositioning) => import("@atlaskit/editor-common/types").Command;
8
8
  export declare const hideResizeHandleLine: () => import("@atlaskit/editor-common/types").Command;
9
- export declare const hoverCell: (rowIndex?: number, colIndex?: number, colWidth?: number, colHeight?: number) => import("@atlaskit/editor-common/types").Command;
9
+ export declare const setTableHovered: (hovered: boolean) => import("@atlaskit/editor-common/types").Command;
10
+ export declare const hoverCell: (rowIndex?: number, colIndex?: number) => import("@atlaskit/editor-common/types").Command;
@@ -1,4 +1,4 @@
1
- export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, } from './hover';
1
+ export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, setTableHovered, } from './hover';
2
2
  export { insertColumn, insertRow, createTable } from './insert';
3
3
  export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout, } from './toggle';
4
4
  export { clearMultipleCells } from './clear';
@@ -13,7 +13,7 @@ export declare const transformSliceToRemoveColumnsWidths: (slice: Slice, schema:
13
13
  export declare const countCellsInSlice: (slice: Slice, schema: Schema, type?: 'row' | 'column') => number;
14
14
  export declare const getTableSelectionType: (selection: Selection) => "row" | "column" | undefined;
15
15
  export declare const getTableElementMoveTypeBySlice: (slice: Slice, state: EditorState) => "row" | "column" | undefined;
16
- export declare const isInsideFirstCellOfRowOrColumn: (selection: Selection, type?: 'row' | 'column') => boolean | undefined;
16
+ export declare const isInsideFirstCellOfRowOrColumn: (selection: Selection, type?: 'row' | 'column') => boolean;
17
17
  export declare const deleteTable: Command;
18
18
  export declare const deleteTableIfSelected: Command;
19
19
  export declare const convertFirstRowToHeader: (schema: Schema) => (tr: Transaction) => Transaction;
@@ -8,9 +8,11 @@ export declare const handleClick: (view: EditorView, event: Event) => boolean;
8
8
  export declare const handleMouseOver: (view: EditorView, mouseEvent: Event) => boolean;
9
9
  export declare const handleMouseDown: (_: EditorView, event: Event) => boolean;
10
10
  export declare const handleMouseOut: (view: EditorView, mouseEvent: Event) => boolean;
11
+ export declare const handleMouseEnter: (view: EditorView, mouseEvent: Event) => boolean;
11
12
  export declare const handleMouseLeave: (view: EditorView, event: Event) => boolean;
12
13
  export declare const handleMouseMove: (view: EditorView, event: Event, elementContentRects?: ElementContentRects) => boolean;
13
14
  export declare function handleTripleClick(view: EditorView, pos: number): boolean;
14
15
  export declare const handleCut: (oldTr: Transaction, oldState: EditorState, newState: EditorState, editorAnalyticsAPI?: EditorAnalyticsAPI, editorView?: EditorView) => Transaction;
16
+ export declare const isTableInFocus: (view: EditorView) => boolean;
15
17
  export declare const whenTableInFocus: (eventHandler: (view: EditorView, mouseEvent: Event, elementContentRects?: ElementContentRects) => boolean, elementContentRects?: ElementContentRects) => (view: EditorView, mouseEvent: Event) => boolean;
16
18
  export declare const withCellTracking: (eventHandler: (view: EditorView, mouseEvent: Event, elementContentRects?: ElementContentRects) => boolean, elementContentRects?: ElementContentRects) => (view: EditorView, mouseEvent: Event) => boolean;
@@ -8,5 +8,5 @@ export declare const getDecorations: (state: EditorState) => DecorationSet;
8
8
  export declare const updatePluginStateDecorations: (state: EditorState, decorations: Decoration[], key: TableDecorations) => DecorationSet;
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
- export declare const moveSource: (sourceType: DraggableType, sourceIndex: number, targetIndex: number) => import("@atlaskit/editor-common/types").Command;
11
+ export declare const moveSource: (sourceType: DraggableType, sourceIndex: number, targetIndex: number, tr?: Transaction) => import("@atlaskit/editor-common/types").Command;
12
12
  export declare const toggleDragMenu: (isDragMenuOpen: boolean | undefined, direction?: TableDirection, index?: number) => import("@atlaskit/editor-common/types").Command;
@@ -47,8 +47,6 @@ export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
47
47
  export interface CellHoverMeta {
48
48
  colIndex?: number;
49
49
  rowIndex?: number;
50
- colWidth?: number;
51
- colHeight?: number;
52
50
  }
53
51
  export interface TablePluginState {
54
52
  editorHasFocus?: boolean;
@@ -82,6 +80,7 @@ export interface TablePluginState {
82
80
  wasFullWidthModeEnabled?: boolean;
83
81
  isTableResizingEnabled?: boolean;
84
82
  isDragAndDropEnabled?: boolean;
83
+ isTableHovered?: boolean;
85
84
  }
86
85
  export type TablePluginAction = {
87
86
  type: 'SET_EDITOR_FOCUS';
@@ -175,6 +174,11 @@ export type TablePluginAction = {
175
174
  data: {
176
175
  hoveredCell: CellHoverMeta;
177
176
  };
177
+ } | {
178
+ type: 'TABLE_HOVERED';
179
+ data: {
180
+ isTableHovered: boolean;
181
+ };
178
182
  } | {
179
183
  type: 'SET_TARGET_CELL_POSITION';
180
184
  data: {
@@ -416,3 +420,4 @@ export interface DraggableData {
416
420
  targetClosestEdge: Edge;
417
421
  direction: 1 | -1;
418
422
  }
423
+ export type HandleTypes = 'hover' | 'selected';
@@ -2,6 +2,7 @@
2
2
  type HandleIconProps = {
3
3
  hasMergedCells: boolean;
4
4
  direction: 'row' | 'column';
5
+ forceDefaultHandle: boolean;
5
6
  isDragMenuOpen: boolean | undefined;
6
7
  isRowHandleHovered: boolean;
7
8
  isColumnHandleHovered: boolean;
@@ -5,6 +5,7 @@ type DragHandleAppearance = 'default' | 'selected' | 'disabled' | 'danger';
5
5
  type DragHandleProps = {
6
6
  tableLocalId: string;
7
7
  indexes: number[];
8
+ forceDefaultHandle?: boolean;
8
9
  previewWidth?: number;
9
10
  previewHeight?: number;
10
11
  direction?: TableDirection;
@@ -15,5 +16,5 @@ type DragHandleProps = {
15
16
  onMouseUp?: MouseEventHandler;
16
17
  editorView: EditorView;
17
18
  };
18
- export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, }: DragHandleProps) => JSX.Element;
19
+ export declare const DragHandle: ({ tableLocalId, direction, appearance, indexes, forceDefaultHandle, previewWidth, previewHeight, onMouseOver, onMouseOut, onMouseUp, onClick, editorView, }: DragHandleProps) => JSX.Element;
19
20
  export {};
@@ -13,6 +13,7 @@ export interface ColumnControlsProps {
13
13
  rowHeights?: number[];
14
14
  colWidths?: (number | undefined)[];
15
15
  hasHeaderColumn?: boolean;
16
+ isTableHovered?: boolean;
16
17
  }
17
- export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, }: ColumnControlsProps) => JSX.Element;
18
+ export declare const ColumnControls: ({ editorView, tableActive, tableRef, hoveredCell, isResizing, stickyTop, localId, isInDanger, rowHeights, colWidths, hasHeaderColumn, isTableHovered, }: ColumnControlsProps) => JSX.Element;
18
19
  export default ColumnControls;
@@ -21,6 +21,7 @@ export interface Props {
21
21
  isResizing?: boolean;
22
22
  ordering?: TableColumnOrdering;
23
23
  stickyHeader?: RowStickyState;
24
+ isTableHovered?: boolean;
24
25
  }
25
26
  export declare const TableFloatingColumnControls: React.FC<Props>;
26
27
  export default TableFloatingColumnControls;
@@ -12,6 +12,7 @@ type DragControlsProps = {
12
12
  hoveredCell?: CellHoverMeta;
13
13
  isInDanger?: boolean;
14
14
  isResizing?: boolean;
15
+ isTableHovered?: boolean;
15
16
  hoverRows: (rows: number[], danger?: boolean) => void;
16
17
  selectRow: (row: number, expand: boolean) => void;
17
18
  updateCellHoverLocation: (rowIndex: number) => void;
@@ -12,6 +12,7 @@ export interface Props {
12
12
  tableNode?: PmNode;
13
13
  tableActive?: boolean;
14
14
  isInDanger?: boolean;
15
+ isTableHovered?: boolean;
15
16
  isResizing?: boolean;
16
17
  isHeaderRowEnabled?: boolean;
17
18
  isHeaderColumnEnabled?: boolean;
@@ -26,3 +26,7 @@ export type TableDOMElements = {
26
26
  };
27
27
  export declare const getTree: (tr: HTMLTableRowElement) => TableDOMElements | null;
28
28
  export declare const getTop: (element: HTMLElement | Window | undefined) => number;
29
+ export declare const findNearestCellIndexToPoint: (x: number, y: number) => {
30
+ row: number;
31
+ col: number;
32
+ } | undefined;
@@ -2,7 +2,7 @@ export { getSelectedColumnIndexes, getSelectedRowIndexes, normalizeSelection, is
2
2
  export { findControlsHoverDecoration, createControlsHoverDecoration, createColumnControlsDecoration, createColumnSelectedDecoration, createCellHoverDecoration, updateDecorations, createResizeHandleDecoration, createColumnInsertLine, createColumnLineResize, createRowInsertLine, } from './decoration';
3
3
  export { isIsolating, containsHeaderColumn, containsHeaderRow, checkIfHeaderColumnEnabled, checkIfHeaderRowEnabled, checkIfNumberColumnEnabled, isLayoutSupported, getTableWidth, tablesHaveDifferentColumnWidths, tablesHaveDifferentNoOfColumns, isTableNested, anyChildCellMergedAcrossRow, supportedHeaderRow, } from './nodes';
4
4
  export { unwrapContentFromTable, removeTableFromFirstChild, removeTableFromLastChild, transformSliceToRemoveOpenTable, transformSliceToCorrectEmptyTableCells, transformSliceToFixHardBreakProblemOnCopyFromCell, } from './paste';
5
- export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, } from './dom';
5
+ export { isCell, isCornerButton, isInsertRowButton, isColumnControlsDecorations, isTableControlsButton, isTableContainerOrWrapper, isRowControlsButton, isDragRowControlsButton, isDragColumnFloatingInsertDot, isDragRowFloatingInsertDot, isDragCornerButton, getColumnOrRowIndex, getMousePositionHorizontalRelativeByElement, getMousePositionVerticalRelativeByElement, updateResizeHandles, isResizeHandleDecoration, hasResizeHandler, findNearestCellIndexToPoint, } from './dom';
6
6
  export { convertHTMLCellIndexToColumnIndex, getColumnsWidths, isColumnDeleteButtonVisible, getColumnDeleteButtonParams, getColumnClassNames, getColumnIndexMappedToColumnIndexInFirstRow, } from './column-controls';
7
7
  export { getRowHeights, isRowDeleteButtonVisible, getRowDeleteButtonParams, getRowsParams, getRowClassNames, copyPreviousRow, } from './row-controls';
8
8
  export type { RowParams } from './row-controls';
@@ -6,4 +6,5 @@ export declare const hoverTable: (isInDanger?: boolean, isSelected?: boolean) =>
6
6
  export declare const clearHoverSelection: () => import("@atlaskit/editor-common/types").Command;
7
7
  export declare const showResizeHandleLine: (cellColumnPositioning: CellColumnPositioning) => import("@atlaskit/editor-common/types").Command;
8
8
  export declare const hideResizeHandleLine: () => import("@atlaskit/editor-common/types").Command;
9
- export declare const hoverCell: (rowIndex?: number, colIndex?: number, colWidth?: number, colHeight?: number) => import("@atlaskit/editor-common/types").Command;
9
+ export declare const setTableHovered: (hovered: boolean) => import("@atlaskit/editor-common/types").Command;
10
+ export declare const hoverCell: (rowIndex?: number, colIndex?: number) => import("@atlaskit/editor-common/types").Command;
@@ -1,4 +1,4 @@
1
- export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, } from './hover';
1
+ export { hoverColumns, hoverRows, hoverTable, hoverCell, hoverMergedCells, clearHoverSelection, showResizeHandleLine, hideResizeHandleLine, setTableHovered, } from './hover';
2
2
  export { insertColumn, insertRow, createTable } from './insert';
3
3
  export { getNextLayout, toggleContextualMenu, toggleHeaderColumn, toggleHeaderRow, toggleNumberColumn, toggleTableLayout, } from './toggle';
4
4
  export { clearMultipleCells } from './clear';
@@ -13,7 +13,7 @@ export declare const transformSliceToRemoveColumnsWidths: (slice: Slice, schema:
13
13
  export declare const countCellsInSlice: (slice: Slice, schema: Schema, type?: 'row' | 'column') => number;
14
14
  export declare const getTableSelectionType: (selection: Selection) => "row" | "column" | undefined;
15
15
  export declare const getTableElementMoveTypeBySlice: (slice: Slice, state: EditorState) => "row" | "column" | undefined;
16
- export declare const isInsideFirstCellOfRowOrColumn: (selection: Selection, type?: 'row' | 'column') => boolean | undefined;
16
+ export declare const isInsideFirstCellOfRowOrColumn: (selection: Selection, type?: 'row' | 'column') => boolean;
17
17
  export declare const deleteTable: Command;
18
18
  export declare const deleteTableIfSelected: Command;
19
19
  export declare const convertFirstRowToHeader: (schema: Schema) => (tr: Transaction) => Transaction;