@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.
- package/CHANGELOG.md +16 -0
- package/afm-cc/tsconfig.json +70 -0
- package/dist/cjs/plugins/table/commands/hover.js +26 -6
- package/dist/cjs/plugins/table/commands/index.js +6 -0
- package/dist/cjs/plugins/table/commands/misc.js +8 -3
- package/dist/cjs/plugins/table/event-handlers.js +56 -34
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +39 -7
- package/dist/cjs/plugins/table/pm-plugins/main.js +5 -3
- package/dist/cjs/plugins/table/reducer.js +1 -0
- package/dist/cjs/plugins/table/toolbar.js +6 -3
- package/dist/cjs/plugins/table/ui/ColumnResizeWidget/index.js +6 -3
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/cjs/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +10 -7
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -10
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +7 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +74 -37
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +63 -31
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +12 -8
- package/dist/cjs/plugins/table/utils/dom.js +16 -1
- package/dist/cjs/plugins/table/utils/index.js +6 -0
- package/dist/es2019/plugins/table/commands/hover.js +22 -5
- package/dist/es2019/plugins/table/commands/index.js +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +8 -3
- package/dist/es2019/plugins/table/event-handlers.js +45 -20
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +36 -3
- package/dist/es2019/plugins/table/pm-plugins/main.js +6 -4
- package/dist/es2019/plugins/table/reducer.js +1 -0
- package/dist/es2019/plugins/table/toolbar.js +5 -3
- package/dist/es2019/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/es2019/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +9 -7
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +73 -37
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -29
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +12 -9
- package/dist/es2019/plugins/table/utils/dom.js +13 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/commands/hover.js +25 -5
- package/dist/esm/plugins/table/commands/index.js +1 -1
- package/dist/esm/plugins/table/commands/misc.js +8 -3
- package/dist/esm/plugins/table/event-handlers.js +55 -33
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +7 -6
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +35 -3
- package/dist/esm/plugins/table/pm-plugins/main.js +6 -4
- package/dist/esm/plugins/table/reducer.js +1 -0
- package/dist/esm/plugins/table/toolbar.js +5 -3
- package/dist/esm/plugins/table/ui/ColumnResizeWidget/index.js +5 -3
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/esm/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/esm/plugins/table/ui/DragPreview/index.js +0 -2
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +9 -7
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +11 -9
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +5 -3
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +6 -4
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +74 -37
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +3 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +61 -29
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +12 -8
- package/dist/esm/plugins/table/utils/dom.js +15 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/types/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types/plugins/table/commands/index.d.ts +1 -1
- package/dist/types/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types/plugins/table/event-handlers.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +7 -2
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +4 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/drag-and-drop/commands.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +7 -2
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/DragControls.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/unit/event-handlers.ts +2 -2
- package/src/__tests__/unit/ui/RowDragControls.tsx +1 -0
- package/src/plugins/table/commands/hover.ts +37 -7
- package/src/plugins/table/commands/index.ts +1 -0
- package/src/plugins/table/commands/misc.ts +9 -3
- package/src/plugins/table/event-handlers.ts +47 -29
- package/src/plugins/table/nodeviews/TableComponent.tsx +4 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +7 -5
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +37 -2
- package/src/plugins/table/pm-plugins/main.ts +6 -3
- package/src/plugins/table/reducer.ts +1 -0
- package/src/plugins/table/types.ts +9 -2
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +10 -9
- package/src/plugins/table/ui/DragHandle/index.tsx +4 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +129 -50
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +3 -0
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +128 -41
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +12 -5
- package/src/plugins/table/utils/dom.ts +22 -0
- package/src/plugins/table/utils/index.ts +1 -0
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _icons = require("../icons");
|
|
10
10
|
var HandleIconComponent = exports.HandleIconComponent = function HandleIconComponent(props) {
|
|
11
11
|
var direction = props.direction,
|
|
12
|
+
forceDefaultHandle = props.forceDefaultHandle,
|
|
12
13
|
isDragMenuOpen = props.isDragMenuOpen,
|
|
13
14
|
isRowHandleHovered = props.isRowHandleHovered,
|
|
14
15
|
isColumnHandleHovered = props.isColumnHandleHovered,
|
|
@@ -19,11 +20,8 @@ var HandleIconComponent = exports.HandleIconComponent = function HandleIconCompo
|
|
|
19
20
|
var isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
20
21
|
var isCurrentRowOrColumnSelected = isCurrentRowSelected || isCurrentColumnSelected;
|
|
21
22
|
var isDragMenuOpenOnCurrentRowOrColumn = isDragMenuOpen && dragMenuDirection === direction && isCurrentRowOrColumnSelected;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// hoverred handle or open drag menu
|
|
25
|
-
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
26
|
-
return showNormalHandle;
|
|
23
|
+
if (forceDefaultHandle || isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
24
|
+
return hasMergedCells ? /*#__PURE__*/_react.default.createElement(_icons.DragHandleDisabledIcon, null) : /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null);
|
|
27
25
|
}
|
|
28
26
|
return /*#__PURE__*/_react.default.createElement(_icons.MinimisedHandleIcon, null);
|
|
29
27
|
};
|
|
@@ -28,6 +28,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
28
28
|
_ref$appearance = _ref.appearance,
|
|
29
29
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
30
30
|
indexes = _ref.indexes,
|
|
31
|
+
_ref$forceDefaultHand = _ref.forceDefaultHandle,
|
|
32
|
+
forceDefaultHandle = _ref$forceDefaultHand === void 0 ? false : _ref$forceDefaultHand,
|
|
31
33
|
previewWidth = _ref.previewWidth,
|
|
32
34
|
previewHeight = _ref.previewHeight,
|
|
33
35
|
onMouseOver = _ref.onMouseOver,
|
|
@@ -59,6 +61,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
59
61
|
var handleIconProps = {
|
|
60
62
|
hasMergedCells: hasMergedCells,
|
|
61
63
|
direction: direction,
|
|
64
|
+
forceDefaultHandle: forceDefaultHandle,
|
|
62
65
|
isDragMenuOpen: isDragMenuOpen,
|
|
63
66
|
isRowHandleHovered: isRowHandleHovered,
|
|
64
67
|
isColumnHandleHovered: isColumnHandleHovered,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* index.tsx generated by @compiled/babel-plugin v0.26.1 */
|
|
2
1
|
"use strict";
|
|
3
2
|
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -6,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.DragPreview = void 0;
|
|
9
|
-
var _runtime = require("@compiled/react/runtime");
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
var _primitives = require("@atlaskit/primitives");
|
|
12
10
|
var _DragInMotionIcon = require("../icons/DragInMotionIcon");
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = _default;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _react2 = require("@emotion/react");
|
|
9
10
|
var _reactIntlNext = require("react-intl-next");
|
|
10
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
12
|
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
@@ -19,6 +20,8 @@ var _commands = require("../../commands");
|
|
|
19
20
|
var _types = require("../../types");
|
|
20
21
|
var _FixedButton = _interopRequireDefault(require("./FixedButton"));
|
|
21
22
|
var _styles = require("./styles");
|
|
23
|
+
/** @jsx jsx */
|
|
24
|
+
|
|
22
25
|
var BUTTON_OFFSET = 3;
|
|
23
26
|
var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (props) {
|
|
24
27
|
var editorView = props.editorView,
|
|
@@ -49,7 +52,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
49
52
|
return null;
|
|
50
53
|
}
|
|
51
54
|
var labelCellOptions = formatMessage(_messages.tableMessages.cellOptions);
|
|
52
|
-
var button =
|
|
55
|
+
var button = (0, _react2.jsx)("div", {
|
|
53
56
|
css: function css(theme) {
|
|
54
57
|
return [(0, _styles.tableFloatingCellButtonStyles)({
|
|
55
58
|
theme: theme
|
|
@@ -57,19 +60,19 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
57
60
|
theme: theme
|
|
58
61
|
})];
|
|
59
62
|
}
|
|
60
|
-
},
|
|
63
|
+
}, (0, _react2.jsx)(_uiMenu.ToolbarButton, {
|
|
61
64
|
className: _types.TableCssClassName.CONTEXTUAL_MENU_BUTTON,
|
|
62
65
|
selected: isContextualMenuOpen,
|
|
63
66
|
title: labelCellOptions,
|
|
64
67
|
onClick: handleClick,
|
|
65
|
-
iconBefore:
|
|
68
|
+
iconBefore: (0, _react2.jsx)(_chevronDown.default, {
|
|
66
69
|
label: ""
|
|
67
70
|
}),
|
|
68
71
|
"aria-label": labelCellOptions
|
|
69
72
|
}));
|
|
70
73
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
71
74
|
if (stickyHeader && parentSticky && tableWrapper) {
|
|
72
|
-
return
|
|
75
|
+
return (0, _react2.jsx)(_FixedButton.default, {
|
|
73
76
|
offset: BUTTON_OFFSET,
|
|
74
77
|
stickyHeader: stickyHeader,
|
|
75
78
|
tableWrapper: tableWrapper,
|
|
@@ -79,7 +82,7 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
79
82
|
isContextualMenuOpen: isContextualMenuOpen
|
|
80
83
|
}, button);
|
|
81
84
|
}
|
|
82
|
-
return
|
|
85
|
+
return (0, _react2.jsx)(_ui.Popup, {
|
|
83
86
|
alignX: "right",
|
|
84
87
|
alignY: "start",
|
|
85
88
|
target: targetCellRef,
|
|
@@ -94,9 +97,9 @@ var FloatingContextualButtonInner = /*#__PURE__*/_react.default.memo(function (p
|
|
|
94
97
|
});
|
|
95
98
|
var FloatingContextualButton = (0, _reactIntlNext.injectIntl)(FloatingContextualButtonInner);
|
|
96
99
|
function _default(props) {
|
|
97
|
-
return
|
|
100
|
+
return (0, _react2.jsx)(_errorBoundary.ErrorBoundary, {
|
|
98
101
|
component: _analytics.ACTION_SUBJECT.FLOATING_CONTEXTUAL_BUTTON,
|
|
99
102
|
dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
|
|
100
103
|
fallbackComponent: null
|
|
101
|
-
},
|
|
104
|
+
}, (0, _react2.jsx)(FloatingContextualButton, props));
|
|
102
105
|
}
|
|
@@ -13,6 +13,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
13
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
15
|
var _react = require("react");
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
16
17
|
var _reactIntlNext = require("react-intl-next");
|
|
17
18
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
18
19
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -37,7 +38,7 @@ var _styles2 = require("./styles");
|
|
|
37
38
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
39
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
39
40
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
41
42
|
var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
42
43
|
(0, _inherits2.default)(ContextualMenu, _Component);
|
|
43
44
|
var _super = _createSuper(ContextualMenu);
|
|
@@ -87,15 +88,15 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
87
88
|
value: {
|
|
88
89
|
name: 'background'
|
|
89
90
|
},
|
|
90
|
-
elemAfter:
|
|
91
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
91
92
|
className: _styles.DropdownMenuSharedCssClassName.SUBMENU
|
|
92
|
-
},
|
|
93
|
+
}, (0, _react2.jsx)("div", {
|
|
93
94
|
css: (0, _styles2.cellColourPreviewStyles)(background),
|
|
94
95
|
className: _types.TableCssClassName.CONTEXTUAL_MENU_ICON
|
|
95
|
-
}), isSubmenuOpen &&
|
|
96
|
+
}), isSubmenuOpen && (0, _react2.jsx)("div", {
|
|
96
97
|
className: _types.TableCssClassName.CONTEXTUAL_SUBMENU,
|
|
97
98
|
ref: _this.handleSubMenuRef
|
|
98
|
-
},
|
|
99
|
+
}, (0, _react2.jsx)(_uiColor.ColorPalette, {
|
|
99
100
|
cols: 7,
|
|
100
101
|
onClick: _this.setColor,
|
|
101
102
|
selectedColor: background,
|
|
@@ -112,7 +113,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
112
113
|
value: {
|
|
113
114
|
name: 'insert_column'
|
|
114
115
|
},
|
|
115
|
-
elemAfter:
|
|
116
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
116
117
|
css: _shortcut.shortcutStyle
|
|
117
118
|
}, (0, _keymaps.tooltip)(_keymaps.addColumnAfter))
|
|
118
119
|
});
|
|
@@ -121,7 +122,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
121
122
|
value: {
|
|
122
123
|
name: 'insert_row'
|
|
123
124
|
},
|
|
124
|
-
elemAfter:
|
|
125
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
125
126
|
css: _shortcut.shortcutStyle
|
|
126
127
|
}, (0, _keymaps.tooltip)(_keymaps.addRowAfter))
|
|
127
128
|
});
|
|
@@ -201,7 +202,7 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
201
202
|
value: {
|
|
202
203
|
name: 'clear'
|
|
203
204
|
},
|
|
204
|
-
elemAfter:
|
|
205
|
+
elemAfter: (0, _react2.jsx)("div", {
|
|
205
206
|
css: _shortcut.shortcutStyle
|
|
206
207
|
}, (0, _keymaps.tooltip)(_keymaps.backspace))
|
|
207
208
|
});
|
|
@@ -363,10 +364,10 @@ var ContextualMenu = exports.ContextualMenu = /*#__PURE__*/function (_Component)
|
|
|
363
364
|
if (!items) {
|
|
364
365
|
return null;
|
|
365
366
|
}
|
|
366
|
-
return
|
|
367
|
+
return (0, _react2.jsx)("div", {
|
|
367
368
|
"data-testid": "table-cell-contextual-menu",
|
|
368
369
|
onMouseLeave: this.closeSubmenu
|
|
369
|
-
},
|
|
370
|
+
}, (0, _react2.jsx)(_uiMenu.DropdownMenu, {
|
|
370
371
|
mountTo: mountPoint
|
|
371
372
|
//This needs be removed when the a11y is completely handled
|
|
372
373
|
//Disabling key navigation now as it works only partially
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _react = require("@emotion/react");
|
|
8
9
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
9
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
11
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -13,6 +14,8 @@ var _pluginFactory = require("../../pm-plugins/plugin-factory");
|
|
|
13
14
|
var _consts = require("../consts");
|
|
14
15
|
var _ContextualMenu = _interopRequireDefault(require("./ContextualMenu"));
|
|
15
16
|
var _styles = require("./styles");
|
|
17
|
+
/** @jsx jsx */
|
|
18
|
+
|
|
16
19
|
var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
17
20
|
var mountPoint = _ref.mountPoint,
|
|
18
21
|
boundariesElement = _ref.boundariesElement,
|
|
@@ -39,7 +42,7 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
39
42
|
return null;
|
|
40
43
|
}
|
|
41
44
|
var parentSticky = targetCellRef.parentElement && targetCellRef.parentElement.className.indexOf('sticky') > -1;
|
|
42
|
-
return
|
|
45
|
+
return (0, _react.jsx)(_ui.Popup, {
|
|
43
46
|
alignX: "right",
|
|
44
47
|
alignY: "top",
|
|
45
48
|
target: targetCellRef,
|
|
@@ -55,9 +58,9 @@ var FloatingContextualMenu = function FloatingContextualMenu(_ref) {
|
|
|
55
58
|
forcePlacement: true,
|
|
56
59
|
offset: [-7, 0],
|
|
57
60
|
stick: true
|
|
58
|
-
},
|
|
61
|
+
}, (0, _react.jsx)("div", {
|
|
59
62
|
css: _styles.tablePopupStyles
|
|
60
|
-
},
|
|
63
|
+
}, (0, _react.jsx)(_ContextualMenu.default, {
|
|
61
64
|
editorView: editorView,
|
|
62
65
|
offset: [_consts.contextualMenuTriggerSize / 2, -_consts.contextualMenuTriggerSize],
|
|
63
66
|
isOpen: isOpen,
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.DragMenu = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _react = require("@emotion/react");
|
|
9
10
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
10
11
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
11
12
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
@@ -16,6 +17,8 @@ var _pluginFactory = require("../../pm-plugins/drag-and-drop/plugin-factory");
|
|
|
16
17
|
var _utils2 = require("../../utils");
|
|
17
18
|
var _dragMenu = require("../../utils/drag-menu");
|
|
18
19
|
var _consts = require("../consts");
|
|
20
|
+
/** @jsx jsx */
|
|
21
|
+
|
|
19
22
|
var groupedDragMenuConfig = [['add_row_above', 'add_row_below', 'add_column_left', 'add_column_right', 'distribute_columns', 'clear_cells', 'delete_row', 'delete_column'], ['move_column_left', 'move_column_right', 'move_row_up', 'move_row_down'], ['sort_column_asc', 'sort_column_desc']];
|
|
20
23
|
var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
21
24
|
var menuItemsArr = (0, _toConsumableArray2.default)(Array(groupedDragMenuConfig.length)).map(function () {
|
|
@@ -36,15 +39,15 @@ var convertToDropdownItems = function convertToDropdownItems(dragMenuConfig) {
|
|
|
36
39
|
name: item.id
|
|
37
40
|
},
|
|
38
41
|
isDisabled: item.disabled,
|
|
39
|
-
elemBefore: item.icon ?
|
|
42
|
+
elemBefore: item.icon ? (0, _react.jsx)("div", {
|
|
40
43
|
style: {
|
|
41
44
|
marginRight: "var(--ds-space-negative-075, -6px)",
|
|
42
45
|
display: 'flex'
|
|
43
46
|
}
|
|
44
|
-
},
|
|
47
|
+
}, (0, _react.jsx)(item.icon, {
|
|
45
48
|
label: item.title
|
|
46
49
|
})) : undefined,
|
|
47
|
-
elemAfter: item.keymap ?
|
|
50
|
+
elemAfter: item.keymap ? (0, _react.jsx)("div", {
|
|
48
51
|
css: _shortcut.shortcutStyle
|
|
49
52
|
}, item.keymap) : undefined
|
|
50
53
|
});
|
|
@@ -136,7 +139,7 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
136
139
|
if (!menuItems) {
|
|
137
140
|
return null;
|
|
138
141
|
}
|
|
139
|
-
return
|
|
142
|
+
return (0, _react.jsx)(_uiMenu.DropdownMenu, {
|
|
140
143
|
mountTo: mountPoint
|
|
141
144
|
//This needs be removed when the a11y is completely handled
|
|
142
145
|
//Disabling key navigation now as it works only partially
|
|
@@ -10,11 +10,14 @@ var _editorTables = require("@atlaskit/editor-tables");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
11
|
var _commands = require("../../../commands");
|
|
12
12
|
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
13
|
+
var _pluginFactory = require("../../../pm-plugins/drag-and-drop/plugin-factory");
|
|
13
14
|
var _types = require("../../../types");
|
|
14
15
|
var _utils2 = require("../../../utils");
|
|
15
16
|
var _DragHandle = require("../../DragHandle");
|
|
16
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); }
|
|
17
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
|
+
|
|
18
21
|
var getSelectedColumns = function getSelectedColumns(selection) {
|
|
19
22
|
if (selection instanceof _editorTables.CellSelection && selection.isColSelection()) {
|
|
20
23
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -26,7 +29,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
|
|
|
26
29
|
return [];
|
|
27
30
|
};
|
|
28
31
|
var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
29
|
-
var _colWidths$map$join, _rowHeights
|
|
32
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
|
|
30
33
|
var editorView = _ref.editorView,
|
|
31
34
|
tableActive = _ref.tableActive,
|
|
32
35
|
tableRef = _ref.tableRef,
|
|
@@ -37,7 +40,8 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
37
40
|
isInDanger = _ref.isInDanger,
|
|
38
41
|
rowHeights = _ref.rowHeights,
|
|
39
42
|
colWidths = _ref.colWidths,
|
|
40
|
-
hasHeaderColumn = _ref.hasHeaderColumn
|
|
43
|
+
hasHeaderColumn = _ref.hasHeaderColumn,
|
|
44
|
+
isTableHovered = _ref.isTableHovered;
|
|
41
45
|
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
42
46
|
return width ? "".concat(width - 1, "px") : '0px';
|
|
43
47
|
}).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
@@ -45,13 +49,6 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
45
49
|
var columnParams = (0, _utils2.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
46
50
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
47
51
|
var selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
48
|
-
var gridColumnPosition = (0, _react.useMemo)(function () {
|
|
49
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
50
|
-
if (selectedColIndexes.includes(colIndex)) {
|
|
51
|
-
return "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
52
|
-
}
|
|
53
|
-
return "".concat(colIndex + 1, " / span 1");
|
|
54
|
-
}, [colIndex, selectedColIndexes]);
|
|
55
52
|
var firstRow = tableRef.querySelector('tr');
|
|
56
53
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
57
54
|
var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
@@ -77,10 +74,14 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
77
74
|
// update hovered cell location
|
|
78
75
|
var state = editorView.state,
|
|
79
76
|
dispatch = editorView.dispatch;
|
|
80
|
-
if (tableActive
|
|
81
|
-
|
|
77
|
+
if (tableActive) {
|
|
78
|
+
// For context: Whenever we mouse over a column or row drag handle, we will ALWAYS be hovering over the 0 index
|
|
79
|
+
// of the opposite dimension. For example; here when we mouse over the column drag handle then we're technically
|
|
80
|
+
// also hovering over row 0 index. And vice-versa with rows. This means we don't need to worry about knowing the
|
|
81
|
+
// current row index. We can just force it to 0.
|
|
82
|
+
(0, _commands.hoverCell)(0, Number(colIndex))(state, dispatch);
|
|
82
83
|
}
|
|
83
|
-
}, [editorView,
|
|
84
|
+
}, [editorView, tableActive]);
|
|
84
85
|
var handleMouseOut = (0, _react.useCallback)(function () {
|
|
85
86
|
if (tableActive) {
|
|
86
87
|
var state = editorView.state,
|
|
@@ -96,6 +97,66 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
96
97
|
var colIndexes = (0, _react.useMemo)(function () {
|
|
97
98
|
return [colIndex];
|
|
98
99
|
}, [colIndex]);
|
|
100
|
+
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
101
|
+
return sum + cur;
|
|
102
|
+
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
103
|
+
var generateHandleByType = (0, _react.useCallback)(function (type) {
|
|
104
|
+
var _colWidths;
|
|
105
|
+
if (!hoveredCell) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
109
|
+
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
110
|
+
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
|
|
111
|
+
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
|
|
112
|
+
var isHover = type === 'hover';
|
|
113
|
+
var isHoveredOnSelectedColumn = isDragMenuOpen && dragMenuDirection === 'column' && dragMenuIndex === colIndex;
|
|
114
|
+
var showCondition = isHover ? !isHoveredOnSelectedColumn && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'column';
|
|
115
|
+
if (!showCondition) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
var selectedColumnPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedColIndexes.length);
|
|
119
|
+
var gridColumnPosition = selectedColIndexes.includes(colIndex) ? "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length) : "".concat(colIndex + 1, " / span 1");
|
|
120
|
+
var selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
121
|
+
var hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
122
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
key: type,
|
|
124
|
+
style: {
|
|
125
|
+
gridColumn: isHover ? gridColumnPosition : selectedColumnPosition,
|
|
126
|
+
display: 'flex',
|
|
127
|
+
justifyContent: 'center',
|
|
128
|
+
alignItems: 'center',
|
|
129
|
+
height: 'fit-content',
|
|
130
|
+
placeSelf: 'center',
|
|
131
|
+
zIndex: 99
|
|
132
|
+
},
|
|
133
|
+
"data-column-control-index": hoveredCell.colIndex,
|
|
134
|
+
"data-testid": isHover ? 'table-floating-column-control' : 'table-floating-column-control-selected'
|
|
135
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
136
|
+
direction: "column",
|
|
137
|
+
tableLocalId: localId || '',
|
|
138
|
+
indexes: isHover ? colIndexes : selectedColIndexes,
|
|
139
|
+
forceDefaultHandle: !isHover,
|
|
140
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
141
|
+
previewHeight: previewHeight,
|
|
142
|
+
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
143
|
+
onClick: handleClick,
|
|
144
|
+
onMouseOver: handleMouseOver,
|
|
145
|
+
onMouseOut: handleMouseOut,
|
|
146
|
+
onMouseUp: handleMouseUp,
|
|
147
|
+
editorView: editorView
|
|
148
|
+
}));
|
|
149
|
+
}, [colIndex, previewHeight, colWidths, colIndexes, editorView, handleClick, handleMouseOut, handleMouseOver, handleMouseUp, hoveredCell, isInDanger, localId, selectedColIndexes]);
|
|
150
|
+
var columnHandles = (0, _react.useCallback)(function (hoveredCell) {
|
|
151
|
+
if (!hoveredCell) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (hoveredCell.colIndex === undefined) {
|
|
155
|
+
return generateHandleByType('selected');
|
|
156
|
+
}
|
|
157
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
158
|
+
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
159
|
+
}, [generateHandleByType, selectedColIndexes]);
|
|
99
160
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
100
161
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS,
|
|
101
162
|
onMouseMove: handleMouseMove
|
|
@@ -124,30 +185,6 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
124
185
|
right: '0'
|
|
125
186
|
} : {}
|
|
126
187
|
}));
|
|
127
|
-
}), tableActive && !isResizing &&
|
|
128
|
-
style: {
|
|
129
|
-
gridColumn: gridColumnPosition,
|
|
130
|
-
display: 'flex',
|
|
131
|
-
justifyContent: 'center',
|
|
132
|
-
alignItems: 'center',
|
|
133
|
-
height: 'fit-content',
|
|
134
|
-
placeSelf: 'center',
|
|
135
|
-
zIndex: 99
|
|
136
|
-
},
|
|
137
|
-
"data-column-control-index": hoveredCell.colIndex,
|
|
138
|
-
"data-testid": "table-floating-column-control"
|
|
139
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
140
|
-
direction: "column",
|
|
141
|
-
tableLocalId: localId || '',
|
|
142
|
-
indexes: colIndexes,
|
|
143
|
-
previewWidth: hoveredCell.colWidth,
|
|
144
|
-
previewHeight: hoveredCell.colHeight,
|
|
145
|
-
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
146
|
-
onClick: handleClick,
|
|
147
|
-
onMouseOver: handleMouseOver,
|
|
148
|
-
onMouseOut: handleMouseOut,
|
|
149
|
-
onMouseUp: handleMouseUp,
|
|
150
|
-
editorView: editorView
|
|
151
|
-
}))));
|
|
188
|
+
}), tableActive && !isResizing && columnHandles(hoveredCell)));
|
|
152
189
|
};
|
|
153
190
|
var _default = exports.default = ColumnControls;
|
|
@@ -28,7 +28,8 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
28
28
|
isResizing = _ref.isResizing,
|
|
29
29
|
stickyHeader = _ref.stickyHeader,
|
|
30
30
|
selection = _ref.selection,
|
|
31
|
-
isInDanger = _ref.isInDanger
|
|
31
|
+
isInDanger = _ref.isInDanger,
|
|
32
|
+
isTableHovered = _ref.isTableHovered;
|
|
32
33
|
var _useState = (0, _react.useState)({
|
|
33
34
|
width: 0,
|
|
34
35
|
height: 0
|
|
@@ -113,6 +114,7 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
113
114
|
tableRef: tableRef,
|
|
114
115
|
isResizing: isResizing,
|
|
115
116
|
tableActive: tableActive,
|
|
117
|
+
isTableHovered: isTableHovered,
|
|
116
118
|
stickyTop: tableActive ? stickyTop : undefined,
|
|
117
119
|
localId: currentNodeLocalId,
|
|
118
120
|
isInDanger: isInDanger,
|
|
@@ -14,7 +14,8 @@ var _utils = require("@atlaskit/editor-tables/utils");
|
|
|
14
14
|
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
15
15
|
var _commands = require("../../../commands");
|
|
16
16
|
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
17
|
-
var _pluginFactory = require("../../../pm-plugins/plugin-factory");
|
|
17
|
+
var _pluginFactory = require("../../../pm-plugins/drag-and-drop/plugin-factory");
|
|
18
|
+
var _pluginFactory2 = require("../../../pm-plugins/plugin-factory");
|
|
18
19
|
var _types = require("../../../types");
|
|
19
20
|
var _utils2 = require("../../../utils");
|
|
20
21
|
var _consts = require("../../consts");
|
|
@@ -22,6 +23,8 @@ var _DragHandle = require("../../DragHandle");
|
|
|
22
23
|
var _RowDropTarget = _interopRequireDefault(require("../RowDropTarget"));
|
|
23
24
|
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
25
|
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; }
|
|
26
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
27
|
+
|
|
25
28
|
var getSelectedRows = function getSelectedRows(selection) {
|
|
26
29
|
if (selection instanceof _editorTables.CellSelection && selection.isRowSelection()) {
|
|
27
30
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -42,6 +45,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
42
45
|
editorView = _ref.editorView,
|
|
43
46
|
isInDanger = _ref.isInDanger,
|
|
44
47
|
isResizing = _ref.isResizing,
|
|
48
|
+
isTableHovered = _ref.isTableHovered,
|
|
45
49
|
hoverRows = _ref.hoverRows,
|
|
46
50
|
selectRow = _ref.selectRow,
|
|
47
51
|
updateCellHoverLocation = _ref.updateCellHoverLocation;
|
|
@@ -67,7 +71,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
67
71
|
if (!indexes || !localId || type !== 'table-row') {
|
|
68
72
|
return false;
|
|
69
73
|
}
|
|
70
|
-
var _getTablePluginState = (0,
|
|
74
|
+
var _getTablePluginState = (0, _pluginFactory2.getPluginState)(editorView.state),
|
|
71
75
|
tableNode = _getTablePluginState.tableNode;
|
|
72
76
|
// If the draggable localId is the same as the current selected table localId then we will allow the monitor
|
|
73
77
|
// watch for changes
|
|
@@ -85,13 +89,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
85
89
|
(0, _commands2.toggleDragMenu)(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
86
90
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
87
91
|
var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
88
|
-
var gridRowPosition = (0, _react.useMemo)(function () {
|
|
89
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
90
|
-
if (selectedRowIndexes.includes(rowIndex)) {
|
|
91
|
-
return "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
|
|
92
|
-
}
|
|
93
|
-
return "".concat(rowIndex + 1, " / span 1");
|
|
94
|
-
}, [rowIndex, selectedRowIndexes]);
|
|
95
92
|
var handleMouseOut = (0, _react.useCallback)(function () {
|
|
96
93
|
if (tableActive) {
|
|
97
94
|
var state = editorView.state,
|
|
@@ -118,6 +115,62 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
118
115
|
var handleClick = (0, _react.useCallback)(function (e) {
|
|
119
116
|
selectRow(rowIndex, e === null || e === void 0 ? void 0 : e.shiftKey);
|
|
120
117
|
}, [rowIndex, selectRow]);
|
|
118
|
+
var generateHandleByType = (0, _react.useCallback)(function (type) {
|
|
119
|
+
if (!hoveredCell) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
123
|
+
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
124
|
+
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
|
|
125
|
+
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
|
|
126
|
+
var isHover = type === 'hover';
|
|
127
|
+
var isHoveredOnSelectedRow = isDragMenuOpen && dragMenuDirection === 'row' && dragMenuIndex === rowIndex;
|
|
128
|
+
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);
|
|
129
|
+
if (!showCondition) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
var gridRowPosition =
|
|
133
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
134
|
+
selectedRowIndexes.includes(rowIndex) ? "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length) : "".concat(rowIndex + 1, " / span 1");
|
|
135
|
+
var selectedRowPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedRowIndexes.length);
|
|
136
|
+
var selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
137
|
+
var hoveredAppearance = selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
138
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
139
|
+
key: type,
|
|
140
|
+
style: {
|
|
141
|
+
gridRow: isHover ? gridRowPosition : selectedRowPosition,
|
|
142
|
+
gridColumn: '2',
|
|
143
|
+
display: 'flex',
|
|
144
|
+
height: '100%',
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
justifyContent: 'center'
|
|
147
|
+
},
|
|
148
|
+
"data-testid": isHover ? 'table-floating-row-drag-handle' : 'table-floating-row-control-selected'
|
|
149
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
150
|
+
direction: "row",
|
|
151
|
+
tableLocalId: currentNodeLocalId,
|
|
152
|
+
indexes: isHover ? rowIndexes : selectedRowIndexes,
|
|
153
|
+
forceDefaultHandle: !isHover,
|
|
154
|
+
previewWidth: tableWidth,
|
|
155
|
+
previewHeight: rowHeights[rowIndex],
|
|
156
|
+
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
157
|
+
onClick: handleClick,
|
|
158
|
+
onMouseOver: handleMouseOver,
|
|
159
|
+
onMouseOut: handleMouseOut,
|
|
160
|
+
onMouseUp: onMouseUp,
|
|
161
|
+
editorView: editorView
|
|
162
|
+
}));
|
|
163
|
+
}, [currentNodeLocalId, editorView, handleClick, handleMouseOut, handleMouseOver, hoveredCell, isInDanger, onMouseUp, rowHeights, rowIndex, rowIndexes, selectedRowIndexes, tableWidth]);
|
|
164
|
+
var rowHandles = (0, _react.useCallback)(function (hoveredCell) {
|
|
165
|
+
if (!hoveredCell) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
if (hoveredCell.rowIndex === undefined) {
|
|
169
|
+
return generateHandleByType('selected');
|
|
170
|
+
}
|
|
171
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
172
|
+
return hoveredCell.rowIndex < selectedRowIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
173
|
+
}, [generateHandleByType, selectedRowIndexes]);
|
|
121
174
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
122
175
|
className: _types.TableCssClassName.DRAG_ROW_CONTROLS,
|
|
123
176
|
style: {
|
|
@@ -157,27 +210,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
157
210
|
left: "var(--ds-space-negative-100, -8px)"
|
|
158
211
|
}
|
|
159
212
|
}));
|
|
160
|
-
}), !isResizing && Number.isFinite(rowIndex) &&
|
|
161
|
-
style: {
|
|
162
|
-
gridRow: gridRowPosition,
|
|
163
|
-
gridColumn: '2',
|
|
164
|
-
display: 'flex',
|
|
165
|
-
height: '100%',
|
|
166
|
-
alignItems: 'center',
|
|
167
|
-
justifyContent: 'center'
|
|
168
|
-
},
|
|
169
|
-
"data-testid": "table-floating-row-drag-handle"
|
|
170
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
171
|
-
tableLocalId: currentNodeLocalId,
|
|
172
|
-
indexes: rowIndexes,
|
|
173
|
-
previewWidth: tableWidth,
|
|
174
|
-
previewHeight: rowHeights[rowIndex],
|
|
175
|
-
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
176
|
-
onClick: handleClick,
|
|
177
|
-
onMouseOver: handleMouseOver,
|
|
178
|
-
onMouseOut: handleMouseOut,
|
|
179
|
-
onMouseUp: onMouseUp,
|
|
180
|
-
editorView: editorView
|
|
181
|
-
})));
|
|
213
|
+
}), !isResizing && Number.isFinite(rowIndex) && rowHandles(hoveredCell));
|
|
182
214
|
};
|
|
183
215
|
var DragControls = exports.DragControls = (0, _reactIntlNext.injectIntl)(DragControlsComponent);
|