@atlaskit/editor-plugin-block-controls 1.4.13 → 1.4.14
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 +8 -0
- package/dist/cjs/ui/drag-handle.js +6 -1
- package/dist/cjs/ui/global-styles.js +3 -0
- package/dist/cjs/ui/mouse-move-wrapper.js +40 -24
- package/dist/es2019/ui/drag-handle.js +6 -1
- package/dist/es2019/ui/global-styles.js +3 -0
- package/dist/es2019/ui/mouse-move-wrapper.js +34 -21
- package/dist/esm/ui/drag-handle.js +6 -1
- package/dist/esm/ui/global-styles.js +3 -0
- package/dist/esm/ui/mouse-move-wrapper.js +41 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.4.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#109040](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109040)
|
|
8
|
+
[`5c5824e70db23`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c5824e70db23) -
|
|
9
|
+
ED-23629 Improve performance of mousemoveWrapper hiding on hover
|
|
10
|
+
|
|
3
11
|
## 1.4.13
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -27,10 +27,13 @@ var dragHandleButtonStyles = (0, _react2.css)({
|
|
|
27
27
|
flexDirection: 'column',
|
|
28
28
|
justifyContent: 'center',
|
|
29
29
|
alignItems: 'center',
|
|
30
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
30
31
|
height: _consts.DRAG_HANDLE_HEIGHT,
|
|
32
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
31
33
|
width: _consts.DRAG_HANDLE_WIDTH,
|
|
32
34
|
border: 'none',
|
|
33
35
|
background: 'transparent',
|
|
36
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
34
37
|
borderRadius: _consts.DRAG_HANDLE_BORDER_RADIUS,
|
|
35
38
|
color: "var(--ds-icon, #44546F)",
|
|
36
39
|
cursor: 'grab',
|
|
@@ -159,7 +162,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
159
162
|
return (0, _react2.jsx)("button", {
|
|
160
163
|
type: "button",
|
|
161
164
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
162
|
-
ref: buttonRef
|
|
165
|
+
ref: buttonRef
|
|
166
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
167
|
+
,
|
|
163
168
|
style: positionStyles,
|
|
164
169
|
onClick: handleOnClick,
|
|
165
170
|
onMouseDown: handleMouseDown,
|
|
@@ -6,9 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.GlobalStylesWrapper = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
/** @jsx jsx */
|
|
9
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles -- Ignored via go/DSP-18766
|
|
9
10
|
|
|
10
11
|
var globalStyles = (0, _react.css)({
|
|
12
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
11
13
|
'.ProseMirror-widget:first-child + *': {
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
12
15
|
marginTop: '0 !important'
|
|
13
16
|
}
|
|
14
17
|
});
|
|
@@ -8,7 +8,6 @@ exports.MouseMoveWrapper = void 0;
|
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
11
|
var _dragHandlePositions = require("../utils/drag-handle-positions");
|
|
13
12
|
/** @jsx jsx */
|
|
14
13
|
|
|
@@ -28,39 +27,54 @@ var MouseMoveWrapper = exports.MouseMoveWrapper = function MouseMoveWrapper(_ref
|
|
|
28
27
|
anchorName = _ref.anchorName,
|
|
29
28
|
nodeType = _ref.nodeType,
|
|
30
29
|
getPos = _ref.getPos;
|
|
31
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockControls']),
|
|
32
|
-
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
33
|
-
var activeNode = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.activeNode;
|
|
34
|
-
var isDragging = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging;
|
|
35
30
|
var _useState = (0, _react.useState)(false),
|
|
36
31
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var _useState3 = (0, _react.useState)(),
|
|
32
|
+
isDragging = _useState2[0],
|
|
33
|
+
setIsDragging = _useState2[1];
|
|
34
|
+
var _useState3 = (0, _react.useState)(false),
|
|
40
35
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
hideWrapper = _useState4[0],
|
|
37
|
+
setHideWrapper = _useState4[1];
|
|
38
|
+
var _useState5 = (0, _react.useState)(),
|
|
39
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
40
|
+
pos = _useState6[0],
|
|
41
|
+
setPos = _useState6[1];
|
|
43
42
|
var onMouseEnter = (0, _react.useCallback)(function () {
|
|
43
|
+
if (!isDragging) {
|
|
44
|
+
setHideWrapper(true);
|
|
45
|
+
}
|
|
44
46
|
var pos = getPos();
|
|
45
47
|
if (pos === undefined) {
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
|
-
if (api && api.blockControls &&
|
|
50
|
+
if (api && api.blockControls && !isDragging) {
|
|
49
51
|
var _api$core;
|
|
50
52
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api.blockControls.commands.showDragHandleAt(pos, anchorName, nodeType));
|
|
51
53
|
}
|
|
52
|
-
}, [
|
|
53
|
-
(0, _react.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
}, [setHideWrapper, isDragging, api, getPos, anchorName, nodeType]);
|
|
55
|
+
(0, _react.useEffect)(function () {
|
|
56
|
+
var _api$blockControls;
|
|
57
|
+
var unbind = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.onChange(function (_ref2) {
|
|
58
|
+
var _nextSharedState$acti;
|
|
59
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
60
|
+
var pos = getPos();
|
|
61
|
+
setIsDragging(Boolean(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging));
|
|
62
|
+
if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.activeNode)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if ((nextSharedState === null || nextSharedState === void 0 || (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !== pos && !(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging)) {
|
|
66
|
+
setHideWrapper(false);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging) {
|
|
70
|
+
setHideWrapper(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return function () {
|
|
75
|
+
unbind === null || unbind === void 0 || unbind();
|
|
76
|
+
};
|
|
77
|
+
}, [getPos, api]);
|
|
64
78
|
(0, _react.useLayoutEffect)(function () {
|
|
65
79
|
var supportsAnchor = CSS.supports('height', "anchor-size(".concat(anchorName, " height)")) && CSS.supports('top', "anchor(".concat(anchorName, " start)"));
|
|
66
80
|
if (supportsAnchor) {
|
|
@@ -86,7 +100,9 @@ var MouseMoveWrapper = exports.MouseMoveWrapper = function MouseMoveWrapper(_ref
|
|
|
86
100
|
}, [view, anchorName]);
|
|
87
101
|
return (0, _react2.jsx)("div", {
|
|
88
102
|
onMouseEnter: onMouseEnter,
|
|
89
|
-
css: [basicStyles, !hideWrapper && mouseMoveWrapperStyles]
|
|
103
|
+
css: [basicStyles, !hideWrapper && mouseMoveWrapperStyles]
|
|
104
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
105
|
+
,
|
|
90
106
|
style: pos
|
|
91
107
|
});
|
|
92
108
|
};
|
|
@@ -18,10 +18,13 @@ const dragHandleButtonStyles = css({
|
|
|
18
18
|
flexDirection: 'column',
|
|
19
19
|
justifyContent: 'center',
|
|
20
20
|
alignItems: 'center',
|
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
21
22
|
height: DRAG_HANDLE_HEIGHT,
|
|
23
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
22
24
|
width: DRAG_HANDLE_WIDTH,
|
|
23
25
|
border: 'none',
|
|
24
26
|
background: 'transparent',
|
|
27
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
25
28
|
borderRadius: DRAG_HANDLE_BORDER_RADIUS,
|
|
26
29
|
color: "var(--ds-icon, #44546F)",
|
|
27
30
|
cursor: 'grab',
|
|
@@ -154,7 +157,9 @@ export const DragHandle = ({
|
|
|
154
157
|
return jsx("button", {
|
|
155
158
|
type: "button",
|
|
156
159
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
157
|
-
ref: buttonRef
|
|
160
|
+
ref: buttonRef
|
|
161
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
162
|
+
,
|
|
158
163
|
style: positionStyles,
|
|
159
164
|
onClick: handleOnClick,
|
|
160
165
|
onMouseDown: handleMouseDown,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles -- Ignored via go/DSP-18766
|
|
2
3
|
import { css, Global, jsx } from '@emotion/react';
|
|
3
4
|
const globalStyles = css({
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
4
6
|
'.ProseMirror-widget:first-child + *': {
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
5
8
|
marginTop: '0 !important'
|
|
6
9
|
}
|
|
7
10
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { useCallback, useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
4
|
import { getTopPosition } from '../utils/drag-handle-positions';
|
|
6
5
|
const basicStyles = css({
|
|
7
6
|
position: 'absolute',
|
|
@@ -20,34 +19,46 @@ export const MouseMoveWrapper = ({
|
|
|
20
19
|
nodeType,
|
|
21
20
|
getPos
|
|
22
21
|
}) => {
|
|
23
|
-
const
|
|
24
|
-
blockControlsState
|
|
25
|
-
} = useSharedPluginState(api, ['blockControls']);
|
|
26
|
-
const activeNode = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.activeNode;
|
|
27
|
-
const isDragging = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging;
|
|
22
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
28
23
|
const [hideWrapper, setHideWrapper] = useState(false);
|
|
29
24
|
const [pos, setPos] = useState();
|
|
30
25
|
const onMouseEnter = useCallback(() => {
|
|
26
|
+
if (!isDragging) {
|
|
27
|
+
setHideWrapper(true);
|
|
28
|
+
}
|
|
31
29
|
const pos = getPos();
|
|
32
30
|
if (pos === undefined) {
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
|
-
if (api && api.blockControls &&
|
|
33
|
+
if (api && api.blockControls && !isDragging) {
|
|
36
34
|
var _api$core;
|
|
37
35
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api.blockControls.commands.showDragHandleAt(pos, anchorName, nodeType));
|
|
38
36
|
}
|
|
39
|
-
}, [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
}, [setHideWrapper, isDragging, api, getPos, anchorName, nodeType]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
var _api$blockControls;
|
|
40
|
+
const unbind = api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.onChange(({
|
|
41
|
+
nextSharedState
|
|
42
|
+
}) => {
|
|
43
|
+
var _nextSharedState$acti;
|
|
44
|
+
const pos = getPos();
|
|
45
|
+
setIsDragging(Boolean(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging));
|
|
46
|
+
if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.activeNode)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if ((nextSharedState === null || nextSharedState === void 0 ? void 0 : (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !== pos && !(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging)) {
|
|
50
|
+
setHideWrapper(false);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging) {
|
|
54
|
+
setHideWrapper(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
unbind === null || unbind === void 0 ? void 0 : unbind();
|
|
60
|
+
};
|
|
61
|
+
}, [getPos, api]);
|
|
51
62
|
useLayoutEffect(() => {
|
|
52
63
|
const supportsAnchor = CSS.supports('height', `anchor-size(${anchorName} height)`) && CSS.supports('top', `anchor(${anchorName} start)`);
|
|
53
64
|
if (supportsAnchor) {
|
|
@@ -71,7 +82,9 @@ export const MouseMoveWrapper = ({
|
|
|
71
82
|
}, [view, anchorName]);
|
|
72
83
|
return jsx("div", {
|
|
73
84
|
onMouseEnter: onMouseEnter,
|
|
74
|
-
css: [basicStyles, !hideWrapper && mouseMoveWrapperStyles]
|
|
85
|
+
css: [basicStyles, !hideWrapper && mouseMoveWrapperStyles]
|
|
86
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
87
|
+
,
|
|
75
88
|
style: pos
|
|
76
89
|
});
|
|
77
90
|
};
|
|
@@ -19,10 +19,13 @@ var dragHandleButtonStyles = css({
|
|
|
19
19
|
flexDirection: 'column',
|
|
20
20
|
justifyContent: 'center',
|
|
21
21
|
alignItems: 'center',
|
|
22
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
22
23
|
height: DRAG_HANDLE_HEIGHT,
|
|
24
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
23
25
|
width: DRAG_HANDLE_WIDTH,
|
|
24
26
|
border: 'none',
|
|
25
27
|
background: 'transparent',
|
|
28
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
26
29
|
borderRadius: DRAG_HANDLE_BORDER_RADIUS,
|
|
27
30
|
color: "var(--ds-icon, #44546F)",
|
|
28
31
|
cursor: 'grab',
|
|
@@ -151,7 +154,9 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
151
154
|
return jsx("button", {
|
|
152
155
|
type: "button",
|
|
153
156
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
154
|
-
ref: buttonRef
|
|
157
|
+
ref: buttonRef
|
|
158
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
159
|
+
,
|
|
155
160
|
style: positionStyles,
|
|
156
161
|
onClick: handleOnClick,
|
|
157
162
|
onMouseDown: handleMouseDown,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles -- Ignored via go/DSP-18766
|
|
2
3
|
import { css, Global, jsx } from '@emotion/react';
|
|
3
4
|
var globalStyles = css({
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
4
6
|
'.ProseMirror-widget:first-child + *': {
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
5
8
|
marginTop: '0 !important'
|
|
6
9
|
}
|
|
7
10
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import { useCallback, useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
5
|
import { getTopPosition } from '../utils/drag-handle-positions';
|
|
7
6
|
var basicStyles = css({
|
|
8
7
|
position: 'absolute',
|
|
@@ -20,39 +19,54 @@ export var MouseMoveWrapper = function MouseMoveWrapper(_ref) {
|
|
|
20
19
|
anchorName = _ref.anchorName,
|
|
21
20
|
nodeType = _ref.nodeType,
|
|
22
21
|
getPos = _ref.getPos;
|
|
23
|
-
var _useSharedPluginState = useSharedPluginState(api, ['blockControls']),
|
|
24
|
-
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
25
|
-
var activeNode = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.activeNode;
|
|
26
|
-
var isDragging = blockControlsState === null || blockControlsState === void 0 ? void 0 : blockControlsState.isDragging;
|
|
27
22
|
var _useState = useState(false),
|
|
28
23
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _useState3 = useState(),
|
|
24
|
+
isDragging = _useState2[0],
|
|
25
|
+
setIsDragging = _useState2[1];
|
|
26
|
+
var _useState3 = useState(false),
|
|
32
27
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
hideWrapper = _useState4[0],
|
|
29
|
+
setHideWrapper = _useState4[1];
|
|
30
|
+
var _useState5 = useState(),
|
|
31
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
32
|
+
pos = _useState6[0],
|
|
33
|
+
setPos = _useState6[1];
|
|
35
34
|
var onMouseEnter = useCallback(function () {
|
|
35
|
+
if (!isDragging) {
|
|
36
|
+
setHideWrapper(true);
|
|
37
|
+
}
|
|
36
38
|
var pos = getPos();
|
|
37
39
|
if (pos === undefined) {
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
|
-
if (api && api.blockControls &&
|
|
42
|
+
if (api && api.blockControls && !isDragging) {
|
|
41
43
|
var _api$core;
|
|
42
44
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api.blockControls.commands.showDragHandleAt(pos, anchorName, nodeType));
|
|
43
45
|
}
|
|
44
|
-
}, [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
}, [setHideWrapper, isDragging, api, getPos, anchorName, nodeType]);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
var _api$blockControls;
|
|
49
|
+
var unbind = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.onChange(function (_ref2) {
|
|
50
|
+
var _nextSharedState$acti;
|
|
51
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
52
|
+
var pos = getPos();
|
|
53
|
+
setIsDragging(Boolean(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging));
|
|
54
|
+
if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.activeNode)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if ((nextSharedState === null || nextSharedState === void 0 || (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !== pos && !(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging)) {
|
|
58
|
+
setHideWrapper(false);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging) {
|
|
62
|
+
setHideWrapper(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return function () {
|
|
67
|
+
unbind === null || unbind === void 0 || unbind();
|
|
68
|
+
};
|
|
69
|
+
}, [getPos, api]);
|
|
56
70
|
useLayoutEffect(function () {
|
|
57
71
|
var supportsAnchor = CSS.supports('height', "anchor-size(".concat(anchorName, " height)")) && CSS.supports('top', "anchor(".concat(anchorName, " start)"));
|
|
58
72
|
if (supportsAnchor) {
|
|
@@ -78,7 +92,9 @@ export var MouseMoveWrapper = function MouseMoveWrapper(_ref) {
|
|
|
78
92
|
}, [view, anchorName]);
|
|
79
93
|
return jsx("div", {
|
|
80
94
|
onMouseEnter: onMouseEnter,
|
|
81
|
-
css: [basicStyles, !hideWrapper && mouseMoveWrapperStyles]
|
|
95
|
+
css: [basicStyles, !hideWrapper && mouseMoveWrapperStyles]
|
|
96
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
97
|
+
,
|
|
82
98
|
style: pos
|
|
83
99
|
});
|
|
84
100
|
};
|