@atlaskit/editor-plugin-table 5.5.2 → 5.5.3
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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/plugins/table/index.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +8 -19
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +62 -34
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +58 -30
- package/dist/es2019/plugins/table/index.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +25 -29
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +5 -18
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +62 -34
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +58 -30
- package/dist/esm/plugins/table/index.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +22 -26
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +5 -7
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +4 -15
- package/dist/esm/plugins/table/ui/DragHandle/index.js +6 -17
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +62 -34
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +58 -30
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +2 -7
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/package.json +1 -4
- package/src/plugins/table/index.tsx +5 -7
- package/src/plugins/table/nodeviews/TableComponent.tsx +31 -38
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +5 -7
- package/src/plugins/table/types.ts +2 -0
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +5 -30
- package/src/plugins/table/ui/DragHandle/index.tsx +6 -23
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +112 -47
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +3 -3
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +116 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#59569](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59569) [`dffa156814cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dffa156814cd) - [ux] re-implement feature with fixed handle when drag menu off and fix issue when numbered column enabled.
|
|
8
|
+
- [#60153](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60153) [`5764d44cc93b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5764d44cc93b) - Cleaned references for feature flag: platform.editor.table.overflow-state-analytics
|
|
9
|
+
|
|
3
10
|
## 5.5.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -211,7 +211,7 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
211
211
|
var _options$tableResizin;
|
|
212
212
|
var dispatch = _ref12.dispatch,
|
|
213
213
|
dispatchAnalyticsEvent = _ref12.dispatchAnalyticsEvent;
|
|
214
|
-
return (0,
|
|
214
|
+
return (0, _tableAnalytics.createPlugin)(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false);
|
|
215
215
|
}
|
|
216
216
|
}, {
|
|
217
217
|
name: 'tableAnalyticsPlugin',
|
|
@@ -393,10 +393,8 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
393
393
|
this.onStickyState(currentStickyState);
|
|
394
394
|
}
|
|
395
395
|
eventDispatcher.on(_stickyHeaders.pluginKey.key, this.onStickyState);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
399
|
-
}
|
|
396
|
+
var initialIsOveflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
397
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
400
398
|
}
|
|
401
399
|
}, {
|
|
402
400
|
key: "componentWillUnmount",
|
|
@@ -483,28 +481,26 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
483
481
|
}
|
|
484
482
|
this.handleTableResizingDebounced();
|
|
485
483
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}));
|
|
507
|
-
}
|
|
484
|
+
var newIsOverflowing = this.state[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
485
|
+
var prevIsOverflowing = prevState[_types.ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[_types.ShadowEvent.SHOW_AFTER_SHADOW];
|
|
486
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
487
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
488
|
+
}
|
|
489
|
+
if (!this.isInitialOverflowSent) {
|
|
490
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
491
|
+
}
|
|
492
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
493
|
+
var _this$state2;
|
|
494
|
+
var _this$props$view = this.props.view,
|
|
495
|
+
dispatch = _this$props$view.dispatch,
|
|
496
|
+
tr = _this$props$view.state.tr;
|
|
497
|
+
dispatch(tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
498
|
+
isOverflowing: newIsOverflowing,
|
|
499
|
+
wasOverflowing: prevIsOverflowing,
|
|
500
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
501
|
+
width: this.node.attrs.width || 0,
|
|
502
|
+
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
503
|
+
}));
|
|
508
504
|
}
|
|
509
505
|
}
|
|
510
506
|
}, {
|
|
@@ -27,13 +27,11 @@ var handleMouseDown = exports.handleMouseDown = function handleMouseDown(view, e
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
event.preventDefault();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
dispatch(tr);
|
|
36
|
-
}
|
|
30
|
+
var tr = view.state.tr;
|
|
31
|
+
tr.setMeta(_tableAnalytics.META_KEYS.OVERFLOW_TRIGGER, {
|
|
32
|
+
name: _analytics.TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
|
|
33
|
+
});
|
|
34
|
+
dispatch(tr);
|
|
37
35
|
var mouseDownTime = event.timeStamp;
|
|
38
36
|
var cell = state.doc.nodeAt(localResizeHandlePos);
|
|
39
37
|
var $cell = state.doc.resolve(localResizeHandlePos);
|
|
@@ -8,24 +8,13 @@ exports.HandleIconComponent = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _icons = require("../icons");
|
|
10
10
|
var HandleIconComponent = exports.HandleIconComponent = function HandleIconComponent(props) {
|
|
11
|
-
var
|
|
12
|
-
direction = props.direction,
|
|
13
|
-
isDragMenuOpen = props.isDragMenuOpen,
|
|
11
|
+
var forceDefaultHandle = props.forceDefaultHandle,
|
|
14
12
|
isRowHandleHovered = props.isRowHandleHovered,
|
|
15
13
|
isColumnHandleHovered = props.isColumnHandleHovered,
|
|
16
|
-
hasMergedCells = props.hasMergedCells
|
|
17
|
-
isCurrentRowSelected = props.isCurrentRowSelected,
|
|
18
|
-
isCurrentColumnSelected = props.isCurrentColumnSelected,
|
|
19
|
-
dragMenuDirection = props.dragMenuDirection;
|
|
14
|
+
hasMergedCells = props.hasMergedCells;
|
|
20
15
|
var isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var isDragPossible = canDrag && !hasMergedCells;
|
|
24
|
-
var showNormalHandle = !isDragPossible ? /*#__PURE__*/_react.default.createElement(_icons.DragHandleDisabledIcon, null) : /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null);
|
|
25
|
-
|
|
26
|
-
// hoverred handle or open drag menu
|
|
27
|
-
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
28
|
-
return showNormalHandle;
|
|
16
|
+
if (isHandleHovered || forceDefaultHandle) {
|
|
17
|
+
return hasMergedCells ? /*#__PURE__*/_react.default.createElement(_icons.DragHandleDisabledIcon, null) : /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null);
|
|
29
18
|
}
|
|
30
19
|
return /*#__PURE__*/_react.default.createElement(_icons.MinimisedHandleIcon, null);
|
|
31
20
|
};
|
|
@@ -14,8 +14,7 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
14
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
15
|
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
16
16
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview");
|
|
17
|
-
var _pluginFactory = require("../../pm-plugins/
|
|
18
|
-
var _pluginFactory2 = require("../../pm-plugins/plugin-factory");
|
|
17
|
+
var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
19
18
|
var _types = require("../../types");
|
|
20
19
|
var _utils2 = require("../../utils");
|
|
21
20
|
var _DragPreview = require("../DragPreview");
|
|
@@ -29,6 +28,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
29
28
|
_ref$appearance = _ref.appearance,
|
|
30
29
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
31
30
|
indexes = _ref.indexes,
|
|
31
|
+
_ref$forceDefaultHand = _ref.forceDefaultHandle,
|
|
32
|
+
forceDefaultHandle = _ref$forceDefaultHand === void 0 ? false : _ref$forceDefaultHand,
|
|
32
33
|
previewWidth = _ref.previewWidth,
|
|
33
34
|
previewHeight = _ref.previewHeight,
|
|
34
35
|
onMouseOver = _ref.onMouseOver,
|
|
@@ -43,32 +44,20 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
43
44
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
44
45
|
previewContainer = _useState2[0],
|
|
45
46
|
setPreviewContainer = _useState2[1];
|
|
46
|
-
var _getPluginState = (0,
|
|
47
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
47
48
|
hoveredColumns = _getPluginState.hoveredColumns,
|
|
48
|
-
hoveredRows = _getPluginState.hoveredRows
|
|
49
|
-
hoveredCell = _getPluginState.hoveredCell;
|
|
50
|
-
var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
51
|
-
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection,
|
|
52
|
-
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
53
|
-
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex;
|
|
49
|
+
hoveredRows = _getPluginState.hoveredRows;
|
|
54
50
|
var selection = editorView.state.selection;
|
|
55
|
-
var isCurrentRowSelected = isDragMenuOpen && direction === 'row' && hoveredCell.rowIndex === dragMenuIndex;
|
|
56
|
-
var isCurrentColumnSelected = isDragMenuOpen && direction === 'column' && hoveredCell.colIndex === dragMenuIndex;
|
|
57
51
|
var isRowHandleHovered = direction === 'row' && hoveredRows.length > 0;
|
|
58
52
|
var isColumnHandleHovered = direction === 'column' && hoveredColumns.length > 0;
|
|
59
53
|
var hasMergedCells = (0, _react.useMemo)(function () {
|
|
60
54
|
return direction === 'row' ? (0, _utils2.hasMergedCellsInRow)(indexes[0])(selection) : (0, _utils2.hasMergedCellsInColumn)(indexes[0])(selection);
|
|
61
55
|
}, [indexes, direction, selection]);
|
|
62
56
|
var handleIconProps = {
|
|
63
|
-
|
|
64
|
-
hasMergedCells: hasMergedCells,
|
|
65
|
-
direction: direction,
|
|
66
|
-
isDragMenuOpen: isDragMenuOpen,
|
|
67
|
-
isRowHandleHovered: isRowHandleHovered,
|
|
57
|
+
forceDefaultHandle: forceDefaultHandle,
|
|
68
58
|
isColumnHandleHovered: isColumnHandleHovered,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
dragMenuDirection: dragMenuDirection
|
|
59
|
+
isRowHandleHovered: isRowHandleHovered,
|
|
60
|
+
hasMergedCells: hasMergedCells
|
|
72
61
|
};
|
|
73
62
|
(0, _react.useEffect)(function () {
|
|
74
63
|
var dragHandleDivRefCurrent = dragHandleDivRef.current;
|
|
@@ -16,6 +16,8 @@ var _utils2 = require("../../../utils");
|
|
|
16
16
|
var _DragHandle = require("../../DragHandle");
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
20
|
+
|
|
19
21
|
var getSelectedColumns = function getSelectedColumns(selection) {
|
|
20
22
|
if (selection instanceof _editorTables.CellSelection && selection.isColSelection()) {
|
|
21
23
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -27,7 +29,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
|
|
|
27
29
|
return [];
|
|
28
30
|
};
|
|
29
31
|
var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
30
|
-
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce
|
|
32
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
|
|
31
33
|
var editorView = _ref.editorView,
|
|
32
34
|
tableActive = _ref.tableActive,
|
|
33
35
|
tableRef = _ref.tableRef,
|
|
@@ -48,13 +50,6 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
48
50
|
var columnParams = (0, _utils2.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
49
51
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
50
52
|
var selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
51
|
-
var gridColumnPosition = (0, _react.useMemo)(function () {
|
|
52
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
53
|
-
if (selectedColIndexes.includes(colIndex)) {
|
|
54
|
-
return "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
55
|
-
}
|
|
56
|
-
return "".concat(colIndex + 1, " / span 1");
|
|
57
|
-
}, [colIndex, selectedColIndexes]);
|
|
58
53
|
var firstRow = tableRef.querySelector('tr');
|
|
59
54
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
60
55
|
var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
@@ -106,6 +101,64 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
106
101
|
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
107
102
|
return sum + cur;
|
|
108
103
|
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
104
|
+
var generateHandleByType = function generateHandleByType(type) {
|
|
105
|
+
var _colWidths;
|
|
106
|
+
if (!hoveredCell || !(colWidths !== null && colWidths !== void 0 && colWidths.length)) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
var isHover = type === 'hover';
|
|
110
|
+
var isColumnsSelected = selectedColIndexes.length > 0;
|
|
111
|
+
var showCondition = isHover ? isColumnsSelected && !selectedColIndexes.includes(colIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : selectedColIndexes.length < (colWidths === null || colWidths === void 0 ? void 0 : colWidths.length) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
112
|
+
if (!showCondition) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
var gridColumnPosition = "".concat(colIndex + 1, " / span 1");
|
|
116
|
+
var selectedColumnPosition = "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
117
|
+
var hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
118
|
+
var currentSelectionApprearance = isColumnsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
119
|
+
var istSelecting = isColumnsSelected && !isHover;
|
|
120
|
+
|
|
121
|
+
// this indexes are used to calculate the drag and drop source
|
|
122
|
+
var indexes = isColumnsSelected ? isHover ? colIndexes : selectedColIndexes : colIndexes;
|
|
123
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
124
|
+
key: type,
|
|
125
|
+
style: {
|
|
126
|
+
gridColumn: istSelecting ? selectedColumnPosition : gridColumnPosition,
|
|
127
|
+
display: 'flex',
|
|
128
|
+
justifyContent: 'center',
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
height: 'fit-content',
|
|
131
|
+
placeSelf: 'center',
|
|
132
|
+
zIndex: 99
|
|
133
|
+
},
|
|
134
|
+
"data-column-control-index": hoveredCell.colIndex,
|
|
135
|
+
"data-testid": isHover ? 'table-floating-column-control-hover' : 'table-floating-column-control'
|
|
136
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
137
|
+
direction: "column",
|
|
138
|
+
tableLocalId: localId || '',
|
|
139
|
+
indexes: indexes,
|
|
140
|
+
forceDefaultHandle: isHover ? false : isColumnsSelected,
|
|
141
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : _styles.tableCellMinWidth,
|
|
142
|
+
previewHeight: previewHeight,
|
|
143
|
+
appearance: istSelecting ? currentSelectionApprearance : hoveredAppearance,
|
|
144
|
+
onClick: handleClick,
|
|
145
|
+
onMouseOver: handleMouseOver,
|
|
146
|
+
onMouseOut: handleMouseOut,
|
|
147
|
+
onMouseUp: handleMouseUp,
|
|
148
|
+
editorView: editorView,
|
|
149
|
+
canDrag: canDrag
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
var columnHandles = function columnHandles(hoveredCell) {
|
|
153
|
+
if (!hoveredCell) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
if (hoveredCell.colIndex === undefined) {
|
|
157
|
+
return generateHandleByType('selected');
|
|
158
|
+
}
|
|
159
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
160
|
+
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
161
|
+
};
|
|
109
162
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
110
163
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS,
|
|
111
164
|
onMouseMove: handleMouseMove
|
|
@@ -134,31 +187,6 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
134
187
|
right: '0'
|
|
135
188
|
} : {}
|
|
136
189
|
}));
|
|
137
|
-
}), tableActive &&
|
|
138
|
-
style: {
|
|
139
|
-
gridColumn: gridColumnPosition,
|
|
140
|
-
display: 'flex',
|
|
141
|
-
justifyContent: 'center',
|
|
142
|
-
alignItems: 'center',
|
|
143
|
-
height: 'fit-content',
|
|
144
|
-
placeSelf: 'center',
|
|
145
|
-
zIndex: 99
|
|
146
|
-
},
|
|
147
|
-
"data-column-control-index": hoveredCell.colIndex,
|
|
148
|
-
"data-testid": "table-floating-column-control"
|
|
149
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
150
|
-
direction: "column",
|
|
151
|
-
tableLocalId: localId || '',
|
|
152
|
-
indexes: colIndexes,
|
|
153
|
-
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : _styles.tableCellMinWidth,
|
|
154
|
-
previewHeight: previewHeight,
|
|
155
|
-
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
156
|
-
onClick: handleClick,
|
|
157
|
-
onMouseOver: handleMouseOver,
|
|
158
|
-
onMouseOut: handleMouseOut,
|
|
159
|
-
onMouseUp: handleMouseUp,
|
|
160
|
-
editorView: editorView,
|
|
161
|
-
canDrag: canDrag
|
|
162
|
-
}))));
|
|
190
|
+
}), tableActive && isTableHovered && !isResizing && columnHandles(hoveredCell)));
|
|
163
191
|
};
|
|
164
192
|
var _default = exports.default = ColumnControls;
|
|
@@ -22,6 +22,8 @@ var _DragHandle = require("../../DragHandle");
|
|
|
22
22
|
var _RowDropTarget = _interopRequireDefault(require("../RowDropTarget"));
|
|
23
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
26
|
+
|
|
25
27
|
var getSelectedRows = function getSelectedRows(selection) {
|
|
26
28
|
if (selection instanceof _editorTables.CellSelection && selection.isRowSelection()) {
|
|
27
29
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -87,13 +89,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
87
89
|
(0, _commands2.toggleDragMenu)(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
88
90
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
89
91
|
var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
90
|
-
var gridRowPosition = (0, _react.useMemo)(function () {
|
|
91
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
92
|
-
if (selectedRowIndexes.includes(rowIndex)) {
|
|
93
|
-
return "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
|
|
94
|
-
}
|
|
95
|
-
return "".concat(rowIndex + 1, " / span 1");
|
|
96
|
-
}, [rowIndex, selectedRowIndexes]);
|
|
97
92
|
var handleMouseOut = (0, _react.useCallback)(function () {
|
|
98
93
|
if (tableActive) {
|
|
99
94
|
var state = editorView.state,
|
|
@@ -120,6 +115,61 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
120
115
|
var handleClick = (0, _react.useCallback)(function (e) {
|
|
121
116
|
selectRow(rowIndex, e === null || e === void 0 ? void 0 : e.shiftKey);
|
|
122
117
|
}, [rowIndex, selectRow]);
|
|
118
|
+
var generateHandleByType = function generateHandleByType(type) {
|
|
119
|
+
if (!hoveredCell) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
var isHover = type === 'hover';
|
|
123
|
+
var isRowsSelected = selectedRowIndexes.length > 0;
|
|
124
|
+
var showCondition = isHover ? isRowsSelected && !selectedRowIndexes.includes(rowIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : selectedRowIndexes.length < rowHeights.length && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
125
|
+
if (!showCondition) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
var gridRowPosition = "".concat(rowIndex + 1, " / span 1");
|
|
129
|
+
|
|
130
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
131
|
+
var selectedRowPosition = "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
|
|
132
|
+
var hoveredAppearance = selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
133
|
+
var currentSelectionAppearance = isRowsSelected ? isInDanger ? 'danger' : 'selected' : hoveredAppearance;
|
|
134
|
+
var isSelecting = isRowsSelected && !isHover;
|
|
135
|
+
var indexes = isRowsSelected ? isHover ? rowIndexes : selectedRowIndexes : rowIndexes;
|
|
136
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
137
|
+
key: type,
|
|
138
|
+
style: {
|
|
139
|
+
gridRow: isSelecting ? selectedRowPosition : gridRowPosition,
|
|
140
|
+
gridColumn: '2',
|
|
141
|
+
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
142
|
+
width: '9px',
|
|
143
|
+
position: 'relative',
|
|
144
|
+
right: '-0.5px'
|
|
145
|
+
},
|
|
146
|
+
"data-testid": isHover ? 'table-floating-row-drag-handle-hover' : 'table-floating-row-drag-handle'
|
|
147
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
148
|
+
direction: "row",
|
|
149
|
+
tableLocalId: currentNodeLocalId,
|
|
150
|
+
indexes: indexes,
|
|
151
|
+
forceDefaultHandle: isHover ? false : isRowsSelected,
|
|
152
|
+
previewWidth: tableWidth,
|
|
153
|
+
previewHeight: rowHeights[rowIndex],
|
|
154
|
+
appearance: isSelecting ? currentSelectionAppearance : hoveredAppearance,
|
|
155
|
+
onClick: handleClick,
|
|
156
|
+
onMouseOver: handleMouseOver,
|
|
157
|
+
onMouseOut: handleMouseOut,
|
|
158
|
+
onMouseUp: onMouseUp,
|
|
159
|
+
editorView: editorView,
|
|
160
|
+
canDrag: canDrag
|
|
161
|
+
}));
|
|
162
|
+
};
|
|
163
|
+
var rowHandles = function rowHandles(hoveredCell) {
|
|
164
|
+
if (!hoveredCell) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
if (hoveredCell.rowIndex === undefined) {
|
|
168
|
+
return generateHandleByType('selected');
|
|
169
|
+
}
|
|
170
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
171
|
+
return hoveredCell.rowIndex < selectedRowIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
172
|
+
};
|
|
123
173
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
124
174
|
className: _types.TableCssClassName.DRAG_ROW_CONTROLS,
|
|
125
175
|
style: {
|
|
@@ -159,28 +209,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
159
209
|
left: "var(--ds-space-negative-100, -8px)"
|
|
160
210
|
}
|
|
161
211
|
}));
|
|
162
|
-
}),
|
|
163
|
-
style: {
|
|
164
|
-
gridRow: gridRowPosition,
|
|
165
|
-
gridColumn: '2',
|
|
166
|
-
// DragHandle uses `transform: rotate(90)`, which doesn't affect its parent (this div) causing the width of this element to be the true height of the drag handle
|
|
167
|
-
width: '9px',
|
|
168
|
-
position: 'relative',
|
|
169
|
-
right: '-0.5px'
|
|
170
|
-
},
|
|
171
|
-
"data-testid": "table-floating-row-drag-handle"
|
|
172
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
173
|
-
tableLocalId: currentNodeLocalId,
|
|
174
|
-
indexes: rowIndexes,
|
|
175
|
-
previewWidth: tableWidth,
|
|
176
|
-
previewHeight: rowHeights[rowIndex],
|
|
177
|
-
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
178
|
-
onClick: handleClick,
|
|
179
|
-
onMouseOver: handleMouseOver,
|
|
180
|
-
onMouseOut: handleMouseOut,
|
|
181
|
-
onMouseUp: onMouseUp,
|
|
182
|
-
editorView: editorView,
|
|
183
|
-
canDrag: canDrag
|
|
184
|
-
})));
|
|
212
|
+
}), tableActive && isTableHovered && !isResizing && Number.isFinite(rowIndex) && rowHandles(hoveredCell));
|
|
185
213
|
};
|
|
186
214
|
var DragControls = exports.DragControls = (0, _reactIntlNext.injectIntl)(DragControlsComponent);
|
|
@@ -199,7 +199,7 @@ const tablesPlugin = ({
|
|
|
199
199
|
dispatchAnalyticsEvent
|
|
200
200
|
}) => {
|
|
201
201
|
var _options$tableResizin;
|
|
202
|
-
return
|
|
202
|
+
return createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableResizin = options === null || options === void 0 ? void 0 : options.tableResizingEnabled) !== null && _options$tableResizin !== void 0 ? _options$tableResizin : false);
|
|
203
203
|
}
|
|
204
204
|
}, {
|
|
205
205
|
name: 'tableAnalyticsPlugin',
|
|
@@ -395,10 +395,8 @@ class TableComponent extends React.Component {
|
|
|
395
395
|
this.onStickyState(currentStickyState);
|
|
396
396
|
}
|
|
397
397
|
eventDispatcher.on(stickyHeadersPluginKey.key, this.onStickyState);
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
401
|
-
}
|
|
398
|
+
const initialIsOveflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
399
|
+
this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
|
|
402
400
|
}
|
|
403
401
|
componentWillUnmount() {
|
|
404
402
|
const {
|
|
@@ -487,31 +485,29 @@ class TableComponent extends React.Component {
|
|
|
487
485
|
}
|
|
488
486
|
this.handleTableResizingDebounced();
|
|
489
487
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}));
|
|
514
|
-
}
|
|
488
|
+
const newIsOverflowing = this.state[ShadowEvent.SHOW_BEFORE_SHADOW] || this.state[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
489
|
+
const prevIsOverflowing = prevState[ShadowEvent.SHOW_BEFORE_SHADOW] || prevState[ShadowEvent.SHOW_AFTER_SHADOW];
|
|
490
|
+
if (this.initialOverflowCaptureTimerId) {
|
|
491
|
+
clearTimeout(this.initialOverflowCaptureTimerId);
|
|
492
|
+
}
|
|
493
|
+
if (!this.isInitialOverflowSent) {
|
|
494
|
+
this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
|
|
495
|
+
}
|
|
496
|
+
if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
|
|
497
|
+
var _this$state2;
|
|
498
|
+
const {
|
|
499
|
+
dispatch,
|
|
500
|
+
state: {
|
|
501
|
+
tr
|
|
502
|
+
}
|
|
503
|
+
} = this.props.view;
|
|
504
|
+
dispatch(tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
|
|
505
|
+
isOverflowing: newIsOverflowing,
|
|
506
|
+
wasOverflowing: prevIsOverflowing,
|
|
507
|
+
editorWidth: this.props.containerWidth.width || 0,
|
|
508
|
+
width: this.node.attrs.width || 0,
|
|
509
|
+
parentWidth: ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.parentWidth) || 0
|
|
510
|
+
}));
|
|
515
511
|
}
|
|
516
512
|
}
|
|
517
513
|
render() {
|
|
@@ -23,13 +23,11 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
25
|
event.preventDefault();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
dispatch(tr);
|
|
32
|
-
}
|
|
26
|
+
const tr = view.state.tr;
|
|
27
|
+
tr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
28
|
+
name: TABLE_OVERFLOW_CHANGE_TRIGGER.RESIZED_COLUMN
|
|
29
|
+
});
|
|
30
|
+
dispatch(tr);
|
|
33
31
|
const mouseDownTime = event.timeStamp;
|
|
34
32
|
const cell = state.doc.nodeAt(localResizeHandlePos);
|
|
35
33
|
const $cell = state.doc.resolve(localResizeHandlePos);
|
|
@@ -2,25 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { DragHandleDisabledIcon, DragHandleIcon, MinimisedHandleIcon } from '../icons';
|
|
3
3
|
export const HandleIconComponent = props => {
|
|
4
4
|
const {
|
|
5
|
-
|
|
6
|
-
direction,
|
|
7
|
-
isDragMenuOpen,
|
|
5
|
+
forceDefaultHandle,
|
|
8
6
|
isRowHandleHovered,
|
|
9
7
|
isColumnHandleHovered,
|
|
10
|
-
hasMergedCells
|
|
11
|
-
isCurrentRowSelected,
|
|
12
|
-
isCurrentColumnSelected,
|
|
13
|
-
dragMenuDirection
|
|
8
|
+
hasMergedCells
|
|
14
9
|
} = props;
|
|
15
10
|
const isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const isDragPossible = canDrag && !hasMergedCells;
|
|
19
|
-
const showNormalHandle = !isDragPossible ? /*#__PURE__*/React.createElement(DragHandleDisabledIcon, null) : /*#__PURE__*/React.createElement(DragHandleIcon, null);
|
|
20
|
-
|
|
21
|
-
// hoverred handle or open drag menu
|
|
22
|
-
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
23
|
-
return showNormalHandle;
|
|
11
|
+
if (isHandleHovered || forceDefaultHandle) {
|
|
12
|
+
return hasMergedCells ? /*#__PURE__*/React.createElement(DragHandleDisabledIcon, null) : /*#__PURE__*/React.createElement(DragHandleIcon, null);
|
|
24
13
|
}
|
|
25
14
|
return /*#__PURE__*/React.createElement(MinimisedHandleIcon, null);
|
|
26
15
|
};
|
|
@@ -4,7 +4,6 @@ import ReactDOM from 'react-dom';
|
|
|
4
4
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
6
6
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
7
|
-
import { getPluginState as getDragDropPluginState } from '../../pm-plugins/drag-and-drop/plugin-factory';
|
|
8
7
|
import { getPluginState } from '../../pm-plugins/plugin-factory';
|
|
9
8
|
import { TableCssClassName as ClassName } from '../../types';
|
|
10
9
|
import { hasMergedCellsInColumn, hasMergedCellsInRow } from '../../utils';
|
|
@@ -15,6 +14,7 @@ export const DragHandle = ({
|
|
|
15
14
|
direction = 'row',
|
|
16
15
|
appearance = 'default',
|
|
17
16
|
indexes,
|
|
17
|
+
forceDefaultHandle = false,
|
|
18
18
|
previewWidth,
|
|
19
19
|
previewHeight,
|
|
20
20
|
onMouseOver,
|
|
@@ -28,32 +28,19 @@ export const DragHandle = ({
|
|
|
28
28
|
const [previewContainer, setPreviewContainer] = useState(null);
|
|
29
29
|
const {
|
|
30
30
|
hoveredColumns,
|
|
31
|
-
hoveredRows
|
|
32
|
-
hoveredCell
|
|
31
|
+
hoveredRows
|
|
33
32
|
} = getPluginState(editorView.state);
|
|
34
|
-
const {
|
|
35
|
-
dragMenuDirection,
|
|
36
|
-
isDragMenuOpen,
|
|
37
|
-
dragMenuIndex
|
|
38
|
-
} = getDragDropPluginState(editorView.state);
|
|
39
33
|
const {
|
|
40
34
|
selection
|
|
41
35
|
} = editorView.state;
|
|
42
|
-
const isCurrentRowSelected = isDragMenuOpen && direction === 'row' && hoveredCell.rowIndex === dragMenuIndex;
|
|
43
|
-
const isCurrentColumnSelected = isDragMenuOpen && direction === 'column' && hoveredCell.colIndex === dragMenuIndex;
|
|
44
36
|
const isRowHandleHovered = direction === 'row' && hoveredRows.length > 0;
|
|
45
37
|
const isColumnHandleHovered = direction === 'column' && hoveredColumns.length > 0;
|
|
46
38
|
const hasMergedCells = useMemo(() => direction === 'row' ? hasMergedCellsInRow(indexes[0])(selection) : hasMergedCellsInColumn(indexes[0])(selection), [indexes, direction, selection]);
|
|
47
39
|
const handleIconProps = {
|
|
48
|
-
|
|
49
|
-
hasMergedCells,
|
|
50
|
-
direction,
|
|
51
|
-
isDragMenuOpen,
|
|
52
|
-
isRowHandleHovered,
|
|
40
|
+
forceDefaultHandle,
|
|
53
41
|
isColumnHandleHovered,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
dragMenuDirection
|
|
42
|
+
isRowHandleHovered,
|
|
43
|
+
hasMergedCells
|
|
57
44
|
};
|
|
58
45
|
useEffect(() => {
|
|
59
46
|
const dragHandleDivRefCurrent = dragHandleDivRef.current;
|