@atlaskit/editor-plugin-table 5.3.8 → 5.3.10

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 (77) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/plugins/table/commands/hover.js +4 -2
  3. package/dist/cjs/plugins/table/event-handlers.js +7 -4
  4. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
  5. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +1 -1
  6. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +3 -2
  7. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +6 -1
  8. package/dist/cjs/plugins/table/ui/DragHandle/index.js +6 -4
  9. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +16 -25
  10. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +70 -0
  11. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +12 -77
  12. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +45 -20
  13. package/dist/cjs/plugins/table/ui/icons/index.js +19 -0
  14. package/dist/cjs/plugins/table/ui/ui-styles.js +1 -1
  15. package/dist/es2019/plugins/table/commands/hover.js +4 -2
  16. package/dist/es2019/plugins/table/event-handlers.js +7 -4
  17. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
  18. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +1 -1
  19. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +3 -2
  20. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +6 -1
  21. package/dist/es2019/plugins/table/ui/DragHandle/index.js +5 -3
  22. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +14 -21
  23. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +62 -0
  24. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +8 -74
  25. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +45 -19
  26. package/dist/es2019/plugins/table/ui/icons/index.js +2 -0
  27. package/dist/es2019/plugins/table/ui/ui-styles.js +0 -1
  28. package/dist/esm/plugins/table/commands/hover.js +4 -2
  29. package/dist/esm/plugins/table/event-handlers.js +7 -4
  30. package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
  31. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +1 -1
  32. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +3 -2
  33. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +6 -1
  34. package/dist/esm/plugins/table/ui/DragHandle/index.js +5 -3
  35. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +15 -22
  36. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +61 -0
  37. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +9 -72
  38. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +45 -20
  39. package/dist/esm/plugins/table/ui/icons/index.js +2 -0
  40. package/dist/esm/plugins/table/ui/ui-styles.js +1 -1
  41. package/dist/types/plugins/table/commands/hover.d.ts +1 -1
  42. package/dist/types/plugins/table/types.d.ts +9 -4
  43. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +4 -3
  44. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +9 -0
  45. package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -3
  46. package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +4 -2
  47. package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -2
  48. package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +2 -2
  49. package/dist/types/plugins/table/ui/icons/index.d.ts +2 -0
  50. package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +1 -1
  51. package/dist/types-ts4.5/plugins/table/types.d.ts +9 -4
  52. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +4 -3
  53. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +9 -0
  54. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -3
  55. package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +4 -2
  56. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +2 -2
  57. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +2 -2
  58. package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +2 -0
  59. package/package.json +2 -1
  60. package/src/__tests__/unit/event-handlers.ts +4 -1
  61. package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +58 -12
  62. package/src/plugins/table/commands/hover.ts +7 -2
  63. package/src/plugins/table/event-handlers.ts +18 -4
  64. package/src/plugins/table/nodeviews/TableComponent.tsx +2 -1
  65. package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +1 -4
  66. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +7 -2
  67. package/src/plugins/table/pm-plugins/drag-and-drop/utils/monitor.ts +5 -0
  68. package/src/plugins/table/types.ts +14 -4
  69. package/src/plugins/table/ui/DragHandle/index.tsx +3 -1
  70. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +36 -39
  71. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +74 -0
  72. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +12 -80
  73. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +62 -32
  74. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +2 -2
  75. package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -2
  76. package/src/plugins/table/ui/icons/index.ts +2 -0
  77. package/src/plugins/table/ui/ui-styles.ts +0 -1
@@ -1,35 +1,26 @@
1
- import React, { useMemo } from 'react';
1
+ import React from 'react';
2
2
  import { TableCssClassName as ClassName } from '../../../types';
3
- import { getColumnsWidths, getRowHeights } from '../../../utils';
4
3
  import { DragHandle } from '../../DragHandle';
5
4
  export var ColumnControls = function ColumnControls(_ref) {
6
- var _rowHeights$;
5
+ var _rowHeights$, _colWidths$map$join;
7
6
  var editorView = _ref.editorView,
8
7
  tableActive = _ref.tableActive,
9
8
  tableRef = _ref.tableRef,
10
9
  hoveredCell = _ref.hoveredCell,
11
10
  isResizing = _ref.isResizing,
12
- tableHeight = _ref.tableHeight,
13
11
  stickyTop = _ref.stickyTop,
14
- localId = _ref.localId;
15
- var rowHeights = useMemo(function () {
16
- // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
17
- if (tableRef && !!tableHeight) {
18
- return getRowHeights(tableRef);
19
- }
20
- return [0];
21
- }, [tableRef, tableHeight]);
12
+ localId = _ref.localId,
13
+ rowHeights = _ref.rowHeights,
14
+ colWidths = _ref.colWidths;
22
15
  if (!tableRef) {
23
16
  return null;
24
17
  }
25
18
  var firstRow = tableRef.querySelector('tr');
26
19
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
27
20
  var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
28
- var colWidths = getColumnsWidths(editorView);
29
- var widths = colWidths.map(function (width) {
21
+ var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
30
22
  return width ? "".concat(width - 1, "px") : '0px';
31
- }).join(' ');
32
- var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
23
+ }).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
33
24
  var _onClick = function onClick(index, event) {};
34
25
  var onMouseOver = function onMouseOver() {};
35
26
  var onMouseOut = function onMouseOut() {};
@@ -42,22 +33,24 @@ export var ColumnControls = function ColumnControls(_ref) {
42
33
  gridTemplateColumns: widths,
43
34
  marginTop: marginTop
44
35
  }
45
- }, tableActive && !isResizing && Number.isFinite(colIndex) && /*#__PURE__*/React.createElement("div", {
36
+ }, tableActive && !isResizing && !!hoveredCell && Number.isFinite(hoveredCell.colIndex) && /*#__PURE__*/React.createElement("div", {
46
37
  style: {
47
- gridColumn: "".concat(colIndex + 1, " / span 1"),
38
+ gridColumn: "".concat(hoveredCell.colIndex + 1, " / span 1"),
48
39
  marginTop: "-15px"
49
40
  },
50
- "data-column-control-index": colIndex,
41
+ "data-column-control-index": hoveredCell.colIndex,
51
42
  "data-testid": "table-floating-column-control"
52
43
  }, /*#__PURE__*/React.createElement(DragHandle, {
53
44
  direction: "column",
54
- indexes: [],
45
+ indexes: [hoveredCell.colIndex],
55
46
  onClick: function onClick(event) {
56
- return _onClick(colIndex, event);
47
+ return _onClick(hoveredCell.colIndex, event);
57
48
  },
58
49
  onMouseOver: onMouseOver,
59
50
  onMouseOut: onMouseOut,
60
- tableLocalId: localId || ''
51
+ tableLocalId: localId || '',
52
+ previewWidth: hoveredCell.colWidth,
53
+ previewHeight: hoveredCell.colHeight
61
54
  }))));
62
55
  };
63
56
  export default ColumnControls;
@@ -0,0 +1,61 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
3
+ import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
4
+ export var ColumnDropTarget = function ColumnDropTarget(_ref) {
5
+ var index = _ref.index,
6
+ localId = _ref.localId,
7
+ width = _ref.width,
8
+ height = _ref.height,
9
+ marginTop = _ref.marginTop;
10
+ var dropTargetRef = useRef(null);
11
+ useEffect(function () {
12
+ if (!dropTargetRef.current) {
13
+ return;
14
+ }
15
+ return dropTargetForElements({
16
+ element: dropTargetRef.current,
17
+ canDrop: function canDrop(_ref2) {
18
+ var _data$indexes, _data$indexes2;
19
+ var source = _ref2.source;
20
+ var data = source.data;
21
+ return (
22
+ // Only draggables of row type can be dropped on this target
23
+ data.type === 'table-column' &&
24
+ // Only draggables which came from the same table can be dropped on this target
25
+ data.localId === localId &&
26
+ // Only draggables which DO NOT include this drop targets index can be dropped
27
+ !!((_data$indexes = data.indexes) !== null && _data$indexes !== void 0 && _data$indexes.length) && ((_data$indexes2 = data.indexes) === null || _data$indexes2 === void 0 ? void 0 : _data$indexes2.indexOf(index)) === -1
28
+ );
29
+ },
30
+ getIsSticky: function getIsSticky() {
31
+ return true;
32
+ },
33
+ getData: function getData(_ref3) {
34
+ var input = _ref3.input,
35
+ element = _ref3.element;
36
+ var data = {
37
+ localId: localId,
38
+ type: 'table-column',
39
+ targetIndex: index
40
+ };
41
+ return attachClosestEdge(data, {
42
+ input: input,
43
+ element: element,
44
+ allowedEdges: ['left', 'right']
45
+ });
46
+ }
47
+ });
48
+ }, [index, localId]);
49
+ return /*#__PURE__*/React.createElement("div", {
50
+ ref: dropTargetRef,
51
+ style: {
52
+ width: width && "".concat(width - 1, "px"),
53
+ height: height && "".concat(height, "px"),
54
+ marginTop: marginTop && "".concat(marginTop, "px"),
55
+ pointerEvents: 'auto'
56
+ },
57
+ "data-drop-target-index": index,
58
+ "data-drop-target-localid": localId,
59
+ "data-testid": "table-floating-column-controls-drop-target"
60
+ });
61
+ };
@@ -1,23 +1,14 @@
1
- import React, { useEffect, useMemo, useRef } from 'react';
2
- import { attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
3
- import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
1
+ import React from 'react';
4
2
  import { TableCssClassName as ClassName } from '../../../types';
5
- import { getColumnsWidths, getRowHeights } from '../../../utils';
3
+ import { ColumnDropTarget } from './ColumnDropTarget';
6
4
  export var ColumnDropTargets = function ColumnDropTargets(_ref) {
7
5
  var _rowHeights$;
8
- var editorView = _ref.editorView,
9
- tableRef = _ref.tableRef,
6
+ var tableRef = _ref.tableRef,
10
7
  tableHeight = _ref.tableHeight,
11
8
  stickyTop = _ref.stickyTop,
12
- localId = _ref.localId;
13
- var colWidths = getColumnsWidths(editorView);
14
- var rowHeights = useMemo(function () {
15
- // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
16
- if (tableRef && !!tableHeight) {
17
- return getRowHeights(tableRef);
18
- }
19
- return [0];
20
- }, [tableRef, tableHeight]);
9
+ localId = _ref.localId,
10
+ rowHeights = _ref.rowHeights,
11
+ colWidths = _ref.colWidths;
21
12
  if (!tableRef) {
22
13
  return null;
23
14
  }
@@ -25,11 +16,12 @@ export var ColumnDropTargets = function ColumnDropTargets(_ref) {
25
16
  var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
26
17
  var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
27
18
  return /*#__PURE__*/React.createElement("div", {
28
- className: ClassName.COLUMN_DROP_TARGET_CONTROLS
19
+ className: ClassName.COLUMN_DROP_TARGET_CONTROLS,
20
+ contentEditable: false
29
21
  }, /*#__PURE__*/React.createElement("div", {
30
22
  className: ClassName.COLUMN_CONTROLS_INNER,
31
23
  "data-testid": "table-floating-column-controls-drop-targets"
32
- }, colWidths.map(function (width, index) {
24
+ }, colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width, index) {
33
25
  return /*#__PURE__*/React.createElement(ColumnDropTarget, {
34
26
  key: index,
35
27
  index: index,
@@ -39,59 +31,4 @@ export var ColumnDropTargets = function ColumnDropTargets(_ref) {
39
31
  marginTop: marginTop
40
32
  });
41
33
  })));
42
- };
43
- export default ColumnDropTargets;
44
- var ColumnDropTarget = function ColumnDropTarget(_ref2) {
45
- var index = _ref2.index,
46
- localId = _ref2.localId,
47
- width = _ref2.width,
48
- height = _ref2.height,
49
- marginTop = _ref2.marginTop;
50
- var dropTargetRef = useRef(null);
51
- useEffect(function () {
52
- if (!dropTargetRef.current) {
53
- return;
54
- }
55
- return dropTargetForElements({
56
- element: dropTargetRef.current,
57
- canDrop: function canDrop(_ref3) {
58
- var _data$indexes, _data$indexes2;
59
- var source = _ref3.source;
60
- var data = source.data;
61
- return (
62
- // Only draggables of row type can be dropped on this target
63
- data.type === 'table-column' &&
64
- // Only draggables which came from the same table can be dropped on this target
65
- data.localId === localId &&
66
- // Only draggables which DO NOT include this drop targets index can be dropped
67
- !!((_data$indexes = data.indexes) !== null && _data$indexes !== void 0 && _data$indexes.length) && ((_data$indexes2 = data.indexes) === null || _data$indexes2 === void 0 ? void 0 : _data$indexes2.indexOf(index)) === -1
68
- );
69
- },
70
- getData: function getData(_ref4) {
71
- var input = _ref4.input,
72
- element = _ref4.element;
73
- var data = {
74
- localId: localId,
75
- type: 'table-column',
76
- targetIndex: index
77
- };
78
- return attachClosestEdge(data, {
79
- input: input,
80
- element: element,
81
- allowedEdges: ['left', 'right']
82
- });
83
- }
84
- });
85
- }, [index, localId]);
86
- return /*#__PURE__*/React.createElement("div", {
87
- ref: dropTargetRef,
88
- style: {
89
- width: width && "".concat(width - 1, "px"),
90
- height: height && "".concat(height, "px"),
91
- marginTop: marginTop && "".concat(marginTop, "px")
92
- },
93
- "data-drop-target-index": index,
94
- "data-drop-target-localid": localId,
95
- "data-testid": "table-floating-column-controls-drop-target"
96
- });
97
34
  };
@@ -4,13 +4,15 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  import React, { useEffect, useMemo, useState } from 'react';
6
6
  import ReactDOM from 'react-dom';
7
- import { findTable } from '@atlaskit/editor-tables';
7
+ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
8
8
  import { TableCssClassName as ClassName } from '../../types';
9
+ import { getColumnsWidths, getRowHeights } from '../../utils';
9
10
  import { ColumnControls } from './ColumnControls';
10
11
  import { ColumnDropTargets } from './ColumnDropTargets';
11
12
  export var TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
12
13
  var editorView = _ref.editorView,
13
14
  tableRef = _ref.tableRef,
15
+ getNode = _ref.getNode,
14
16
  tableActive = _ref.tableActive,
15
17
  hasHeaderRow = _ref.hasHeaderRow,
16
18
  hoveredCell = _ref.hoveredCell,
@@ -24,6 +26,12 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
24
26
  _useState2 = _slicedToArray(_useState, 2),
25
27
  tableRect = _useState2[0],
26
28
  setTableRect = _useState2[1];
29
+ var _useState3 = useState(false),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ hasDropTargets = _useState4[0],
32
+ setHasDropTargets = _useState4[1];
33
+ var node = getNode();
34
+ var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
27
35
  useEffect(function () {
28
36
  var _window;
29
37
  if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
@@ -55,26 +63,41 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
55
63
  };
56
64
  }
57
65
  }, [tableRef]);
58
- var selectedLocalId = useMemo(function () {
59
- if (!selection) {
60
- return undefined;
61
- }
62
- var tableNode = findTable(selection);
63
- if (!tableNode) {
64
- return undefined;
66
+ useEffect(function () {
67
+ return monitorForElements({
68
+ canMonitor: function canMonitor(_ref2) {
69
+ var source = _ref2.source;
70
+ var _ref3 = source.data,
71
+ type = _ref3.type,
72
+ localId = _ref3.localId,
73
+ indexes = _ref3.indexes;
74
+ return type === 'table-column' && !!(indexes !== null && indexes !== void 0 && indexes.length) && localId === currentNodeLocalId;
75
+ },
76
+ onDragStart: function onDragStart() {
77
+ setHasDropTargets(true);
78
+ },
79
+ onDrop: function onDrop() {
80
+ setHasDropTargets(false);
81
+ }
82
+ });
83
+ }, [editorView, currentNodeLocalId]);
84
+ var rowHeights = useMemo(function () {
85
+ // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
86
+ if (tableRef && !!tableRect.height) {
87
+ return getRowHeights(tableRef);
65
88
  }
66
- return tableNode.node.attrs.localId;
67
- }, [selection]);
89
+ return [0];
90
+ }, [tableRef, tableRect.height]);
68
91
  if (!tableRef) {
69
92
  return null;
70
93
  }
94
+ var colWidths = getColumnsWidths(editorView);
71
95
  var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
72
96
  var mountTo = tableRef && (tableRef === null || tableRef === void 0 ? void 0 : tableRef.parentElement) || document.body;
73
97
  return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement("div", {
74
- className: ClassName.COLUMN_CONTROLS_WRAPPER
75
- }, /*#__PURE__*/React.createElement("div", {
76
- onMouseDown: function onMouseDown(e) {
77
- return e.preventDefault();
98
+ className: ClassName.COLUMN_CONTROLS_WRAPPER,
99
+ style: {
100
+ pointerEvents: 'none'
78
101
  },
79
102
  "data-testid": "table-floating-column-controls-wrapper"
80
103
  }, /*#__PURE__*/React.createElement(ColumnControls, {
@@ -84,14 +107,16 @@ export var TableFloatingColumnControls = function TableFloatingColumnControls(_r
84
107
  isResizing: isResizing,
85
108
  tableActive: tableActive,
86
109
  stickyTop: tableActive ? stickyTop : undefined,
87
- tableHeight: tableRect.height,
88
- localId: selectedLocalId
89
- }), /*#__PURE__*/React.createElement(ColumnDropTargets, {
90
- editorView: editorView,
110
+ localId: currentNodeLocalId,
111
+ rowHeights: rowHeights,
112
+ colWidths: colWidths
113
+ }), hasDropTargets && /*#__PURE__*/React.createElement(ColumnDropTargets, {
91
114
  tableRef: tableRef,
92
115
  stickyTop: tableActive ? stickyTop : undefined,
93
116
  tableHeight: tableRect.height,
94
- localId: selectedLocalId
95
- }))), mountTo);
117
+ localId: currentNodeLocalId,
118
+ rowHeights: rowHeights,
119
+ colWidths: colWidths
120
+ })), mountTo);
96
121
  };
97
122
  export default TableFloatingColumnControls;
@@ -0,0 +1,2 @@
1
+ export { DragHandleIcon } from './DragHandleIcon';
2
+ export { DragInMotionIcon } from './DragInMotionIcon';
@@ -64,7 +64,7 @@ var getFloatingDotOverrides = function getFloatingDotOverrides(props) {
64
64
  return getBooleanFF('platform.editor.custom-table-width') ? css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n tr\n th:last-child\n .", "::before,\n tr\n td:last-child\n .", "::before {\n content: '';\n background-color: ", ";\n position: absolute;\n height: ", "px;\n width: ", "px;\n border-radius: 50%;\n pointer-events: none;\n top: ", ";\n right: 0px;\n }\n "])), ClassName.COLUMN_CONTROLS_DECORATIONS, ClassName.COLUMN_CONTROLS_DECORATIONS, tableBorderColor(props), lineMarkerSize, lineMarkerSize, "var(--ds-space-025, 2px)") : '';
65
65
  };
66
66
  export var floatingColumnControls = function floatingColumnControls(props) {
67
- return css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n .", " {\n box-sizing: border-box;\n position: absolute;\n top: 0;\n z-index: -1;\n\n .", " {\n display: flex;\n flex-direction: row;\n }\n }\n\n .", " {\n box-sizing: border-box;\n\n .", " {\n display: grid;\n justify-items: center;\n }\n }\n "])), ClassName.COLUMN_DROP_TARGET_CONTROLS, ClassName.COLUMN_CONTROLS_INNER, ClassName.COLUMN_CONTROLS_WITH_DRAG, ClassName.COLUMN_CONTROLS_INNER);
67
+ return css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n .", " {\n box-sizing: border-box;\n position: absolute;\n top: 0;\n\n .", " {\n display: flex;\n flex-direction: row;\n }\n }\n\n .", " {\n box-sizing: border-box;\n\n .", " {\n display: grid;\n justify-items: center;\n }\n }\n "])), ClassName.COLUMN_DROP_TARGET_CONTROLS, ClassName.COLUMN_CONTROLS_INNER, ClassName.COLUMN_CONTROLS_WITH_DRAG, ClassName.COLUMN_CONTROLS_INNER);
68
68
  };
69
69
  export var rowControlsWrapperDotStyle = function rowControlsWrapperDotStyle(props) {
70
70
  if (getBooleanFF('platform.editor.table.drag-and-drop')) {
@@ -6,4 +6,4 @@ 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) => 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;
@@ -44,15 +44,17 @@ export interface PluginConfig {
44
44
  }
45
45
  export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
46
46
  export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
47
- export type CellHoverCoordinates = {
47
+ export interface CellHoverMeta {
48
48
  colIndex?: number;
49
49
  rowIndex?: number;
50
- };
50
+ colWidth?: number;
51
+ colHeight?: number;
52
+ }
51
53
  export interface TablePluginState {
52
54
  editorHasFocus?: boolean;
53
55
  hoveredColumns: number[];
54
56
  hoveredRows: number[];
55
- hoveredCell: CellHoverCoordinates;
57
+ hoveredCell: CellHoverMeta;
56
58
  pluginConfig: PluginConfig;
57
59
  isHeaderColumnEnabled: boolean;
58
60
  isHeaderRowEnabled: boolean;
@@ -170,7 +172,9 @@ export type TablePluginAction = {
170
172
  };
171
173
  } | {
172
174
  type: 'HOVER_CELL';
173
- data: CellHoverCoordinates;
175
+ data: {
176
+ hoveredCell: CellHoverMeta;
177
+ };
174
178
  } | {
175
179
  type: 'SET_TARGET_CELL_POSITION';
176
180
  data: {
@@ -392,4 +396,5 @@ export interface DraggableData {
392
396
  targetIndex: number;
393
397
  targetAdjustedIndex: number;
394
398
  targetClosestEdge: Edge;
399
+ direction: 1 | -1;
395
400
  }
@@ -1,15 +1,16 @@
1
1
  import React from 'react';
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- import type { CellHoverCoordinates } from '../../../types';
3
+ import type { CellHoverMeta } from '../../../types';
4
4
  export interface Props {
5
5
  editorView: EditorView;
6
6
  tableActive?: boolean;
7
7
  tableRef: HTMLTableElement;
8
- hoveredCell?: CellHoverCoordinates;
8
+ hoveredCell?: CellHoverMeta;
9
9
  isResizing?: boolean;
10
10
  stickyTop?: number;
11
- tableHeight?: number;
12
11
  localId?: string;
12
+ rowHeights?: number[];
13
+ colWidths?: (number | undefined)[];
13
14
  }
14
15
  export declare const ColumnControls: React.FC<Props>;
15
16
  export default ColumnControls;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface Props {
3
+ index: number;
4
+ localId?: string;
5
+ width?: number;
6
+ height?: number;
7
+ marginTop?: number;
8
+ }
9
+ export declare const ColumnDropTarget: React.FC<Props>;
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
2
  export interface Props {
4
- editorView: EditorView;
5
3
  tableRef: HTMLTableElement;
6
4
  stickyTop?: number;
7
5
  tableHeight?: number;
8
6
  localId?: string;
7
+ rowHeights?: number[];
8
+ colWidths?: (number | undefined)[];
9
9
  }
10
10
  export declare const ColumnDropTargets: React.FC<Props>;
11
- export default ColumnDropTargets;
@@ -1,20 +1,22 @@
1
1
  import React from 'react';
2
2
  import type { TableColumnOrdering } from '@atlaskit/custom-steps';
3
3
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
4
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
5
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
5
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
7
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
7
- import type { CellHoverCoordinates } from '../../types';
8
+ import type { CellHoverMeta } from '../../types';
8
9
  export interface Props {
9
10
  editorView: EditorView;
10
11
  getEditorFeatureFlags: GetEditorFeatureFlags;
11
12
  selection?: Selection;
12
13
  tableRef?: HTMLTableElement;
14
+ getNode: () => PmNode;
13
15
  tableActive?: boolean;
14
16
  hasHeaderRow?: boolean;
15
17
  headerRowHeight?: number;
16
18
  hoveredRows?: number[];
17
- hoveredCell?: CellHoverCoordinates;
19
+ hoveredCell?: CellHoverMeta;
18
20
  isResizing?: boolean;
19
21
  ordering?: TableColumnOrdering;
20
22
  stickyHeader?: RowStickyState;
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { CellHoverCoordinates } from '../../../types';
4
+ import type { CellHoverMeta } from '../../../types';
5
5
  type DragControlsProps = {
6
6
  editorView: EditorView;
7
7
  tableRef: HTMLTableElement;
8
8
  tableActive?: boolean;
9
- hoveredCell?: CellHoverCoordinates;
9
+ hoveredCell?: CellHoverMeta;
10
10
  hoverRows?: (rows: number[], danger?: boolean) => void;
11
11
  selectRow?: (row: number, expand: boolean) => void;
12
12
  };
@@ -3,7 +3,7 @@ import type { TableColumnOrdering } from '@atlaskit/custom-steps';
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 { CellHoverCoordinates } from '../../types';
6
+ import type { CellHoverMeta } from '../../types';
7
7
  export interface Props {
8
8
  editorView: EditorView;
9
9
  selection?: Selection;
@@ -18,7 +18,7 @@ export interface Props {
18
18
  hasHeaderRow?: boolean;
19
19
  headerRowHeight?: number;
20
20
  hoveredRows?: number[];
21
- hoveredCell?: CellHoverCoordinates;
21
+ hoveredCell?: CellHoverMeta;
22
22
  ordering?: TableColumnOrdering;
23
23
  stickyHeader?: RowStickyState;
24
24
  }
@@ -0,0 +1,2 @@
1
+ export { DragHandleIcon } from './DragHandleIcon';
2
+ export { DragInMotionIcon } from './DragInMotionIcon';
@@ -6,4 +6,4 @@ 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) => 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;
@@ -44,15 +44,17 @@ export interface PluginConfig {
44
44
  }
45
45
  export type { ColumnResizingPluginState } from '@atlaskit/editor-common/types';
46
46
  export type CellColumnPositioning = Pick<Rect, 'right' | 'left'>;
47
- export type CellHoverCoordinates = {
47
+ export interface CellHoverMeta {
48
48
  colIndex?: number;
49
49
  rowIndex?: number;
50
- };
50
+ colWidth?: number;
51
+ colHeight?: number;
52
+ }
51
53
  export interface TablePluginState {
52
54
  editorHasFocus?: boolean;
53
55
  hoveredColumns: number[];
54
56
  hoveredRows: number[];
55
- hoveredCell: CellHoverCoordinates;
57
+ hoveredCell: CellHoverMeta;
56
58
  pluginConfig: PluginConfig;
57
59
  isHeaderColumnEnabled: boolean;
58
60
  isHeaderRowEnabled: boolean;
@@ -170,7 +172,9 @@ export type TablePluginAction = {
170
172
  };
171
173
  } | {
172
174
  type: 'HOVER_CELL';
173
- data: CellHoverCoordinates;
175
+ data: {
176
+ hoveredCell: CellHoverMeta;
177
+ };
174
178
  } | {
175
179
  type: 'SET_TARGET_CELL_POSITION';
176
180
  data: {
@@ -392,4 +396,5 @@ export interface DraggableData {
392
396
  targetIndex: number;
393
397
  targetAdjustedIndex: number;
394
398
  targetClosestEdge: Edge;
399
+ direction: 1 | -1;
395
400
  }
@@ -1,15 +1,16 @@
1
1
  import React from 'react';
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
- import type { CellHoverCoordinates } from '../../../types';
3
+ import type { CellHoverMeta } from '../../../types';
4
4
  export interface Props {
5
5
  editorView: EditorView;
6
6
  tableActive?: boolean;
7
7
  tableRef: HTMLTableElement;
8
- hoveredCell?: CellHoverCoordinates;
8
+ hoveredCell?: CellHoverMeta;
9
9
  isResizing?: boolean;
10
10
  stickyTop?: number;
11
- tableHeight?: number;
12
11
  localId?: string;
12
+ rowHeights?: number[];
13
+ colWidths?: (number | undefined)[];
13
14
  }
14
15
  export declare const ColumnControls: React.FC<Props>;
15
16
  export default ColumnControls;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface Props {
3
+ index: number;
4
+ localId?: string;
5
+ width?: number;
6
+ height?: number;
7
+ marginTop?: number;
8
+ }
9
+ export declare const ColumnDropTarget: React.FC<Props>;
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
2
  export interface Props {
4
- editorView: EditorView;
5
3
  tableRef: HTMLTableElement;
6
4
  stickyTop?: number;
7
5
  tableHeight?: number;
8
6
  localId?: string;
7
+ rowHeights?: number[];
8
+ colWidths?: (number | undefined)[];
9
9
  }
10
10
  export declare const ColumnDropTargets: React.FC<Props>;
11
- export default ColumnDropTargets;
@@ -1,20 +1,22 @@
1
1
  import React from 'react';
2
2
  import type { TableColumnOrdering } from '@atlaskit/custom-steps';
3
3
  import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
4
+ import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
4
5
  import type { Selection } from '@atlaskit/editor-prosemirror/state';
5
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
7
  import type { RowStickyState } from '../../pm-plugins/sticky-headers';
7
- import type { CellHoverCoordinates } from '../../types';
8
+ import type { CellHoverMeta } from '../../types';
8
9
  export interface Props {
9
10
  editorView: EditorView;
10
11
  getEditorFeatureFlags: GetEditorFeatureFlags;
11
12
  selection?: Selection;
12
13
  tableRef?: HTMLTableElement;
14
+ getNode: () => PmNode;
13
15
  tableActive?: boolean;
14
16
  hasHeaderRow?: boolean;
15
17
  headerRowHeight?: number;
16
18
  hoveredRows?: number[];
17
- hoveredCell?: CellHoverCoordinates;
19
+ hoveredCell?: CellHoverMeta;
18
20
  isResizing?: boolean;
19
21
  ordering?: TableColumnOrdering;
20
22
  stickyHeader?: RowStickyState;
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { WrappedComponentProps } from 'react-intl-next';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { CellHoverCoordinates } from '../../../types';
4
+ import type { CellHoverMeta } from '../../../types';
5
5
  type DragControlsProps = {
6
6
  editorView: EditorView;
7
7
  tableRef: HTMLTableElement;
8
8
  tableActive?: boolean;
9
- hoveredCell?: CellHoverCoordinates;
9
+ hoveredCell?: CellHoverMeta;
10
10
  hoverRows?: (rows: number[], danger?: boolean) => void;
11
11
  selectRow?: (row: number, expand: boolean) => void;
12
12
  };