@atlaskit/editor-plugin-block-controls 1.4.16 → 1.4.18
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 +20 -0
- package/dist/cjs/pm-plugins/main.js +8 -1
- package/dist/cjs/ui/drag-preview.js +3 -3
- package/dist/cjs/ui/mouse-move-wrapper.js +14 -9
- package/dist/es2019/pm-plugins/main.js +8 -1
- package/dist/es2019/ui/drag-preview.js +3 -3
- package/dist/es2019/ui/mouse-move-wrapper.js +14 -10
- package/dist/esm/pm-plugins/main.js +8 -1
- package/dist/esm/ui/drag-preview.js +3 -3
- package/dist/esm/ui/mouse-move-wrapper.js +15 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.4.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#110975](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110975)
|
|
8
|
+
[`1b910ab971427`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1b910ab971427) -
|
|
9
|
+
[ux] Generate generic drag preview for extension nodes
|
|
10
|
+
- [#110819](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110819)
|
|
11
|
+
[`c81b4e2254428`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c81b4e2254428) -
|
|
12
|
+
Fix cursor and handle position when changing node type
|
|
13
|
+
|
|
14
|
+
## 1.4.17
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#110808](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110808)
|
|
19
|
+
[`3ae32439b454c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3ae32439b454c) -
|
|
20
|
+
ED-23725 Fix issue where drag and drop breaks after node type changes and when text selection is
|
|
21
|
+
not allowed if user moves mouse to node before page finishes loading
|
|
22
|
+
|
|
3
23
|
## 1.4.16
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -82,7 +82,14 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
82
82
|
var mouseWrapperDecs = (0, _decorations.mouseMoveWrapperDecorations)(newState, api);
|
|
83
83
|
decorations = decorations.add(newState.doc, [].concat((0, _toConsumableArray2.default)(nodeDecs), (0, _toConsumableArray2.default)(mouseWrapperDecs)));
|
|
84
84
|
if (activeNode) {
|
|
85
|
-
var
|
|
85
|
+
var newActiveNode = activeNode && tr.doc.nodeAt(activeNode.pos);
|
|
86
|
+
var nodeType = activeNode.nodeType;
|
|
87
|
+
var anchorName = activeNode.anchorName;
|
|
88
|
+
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType && !(meta !== null && meta !== void 0 && meta.nodeMoved)) {
|
|
89
|
+
nodeType = newActiveNode.type.name;
|
|
90
|
+
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
91
|
+
}
|
|
92
|
+
var draghandleDec = (0, _decorations.dragHandleDecoration)(activeNode.pos, anchorName, nodeType, api);
|
|
86
93
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
87
94
|
}
|
|
88
95
|
}
|
|
@@ -20,8 +20,8 @@ var dragPreview = exports.dragPreview = function dragPreview(container, dom, nod
|
|
|
20
20
|
var parent = document.createElement('div');
|
|
21
21
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
22
22
|
parent.classList.add('ProseMirror');
|
|
23
|
-
var
|
|
24
|
-
if (
|
|
23
|
+
var shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension';
|
|
24
|
+
if (shouldBeGenericPreview) {
|
|
25
25
|
parent.style.border = "".concat(previewStyle.borderWidth, " ").concat(previewStyle.borderStyle, " ").concat(previewStyle.borderColor);
|
|
26
26
|
parent.style.borderRadius = previewStyle.borderRadius;
|
|
27
27
|
parent.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -29,7 +29,7 @@ var dragPreview = exports.dragPreview = function dragPreview(container, dom, nod
|
|
|
29
29
|
parent.setAttribute('data-testid', 'block-ctrl-generic-drag-preview');
|
|
30
30
|
}
|
|
31
31
|
var resizer = dom.querySelector('.resizer-item');
|
|
32
|
-
var clonedDom = resizer ? resizer.cloneNode(true) : dom.cloneNode(!
|
|
32
|
+
var clonedDom = resizer ? resizer.cloneNode(true) : dom.cloneNode(!shouldBeGenericPreview);
|
|
33
33
|
|
|
34
34
|
// Remove any margin from the cloned element to ensure is doesn't position incorrectly
|
|
35
35
|
clonedDom.style.marginLeft = '0';
|
|
@@ -8,6 +8,7 @@ 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");
|
|
11
12
|
var _dragHandlePositions = require("../utils/drag-handle-positions");
|
|
12
13
|
/** @jsx jsx */
|
|
13
14
|
|
|
@@ -22,16 +23,22 @@ var mouseMoveWrapperStyles = (0, _react2.css)({
|
|
|
22
23
|
zIndex: 1
|
|
23
24
|
});
|
|
24
25
|
var MouseMoveWrapper = exports.MouseMoveWrapper = function MouseMoveWrapper(_ref) {
|
|
26
|
+
var _blockControlsState$a;
|
|
25
27
|
var view = _ref.view,
|
|
26
28
|
api = _ref.api,
|
|
27
29
|
anchorName = _ref.anchorName,
|
|
28
30
|
nodeType = _ref.nodeType,
|
|
29
31
|
getPos = _ref.getPos;
|
|
32
|
+
var nodePos = (0, _react.useMemo)(function () {
|
|
33
|
+
return getPos();
|
|
34
|
+
}, [getPos]);
|
|
35
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockControls']),
|
|
36
|
+
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
30
37
|
var _useState = (0, _react.useState)(false),
|
|
31
38
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
32
39
|
isDragging = _useState2[0],
|
|
33
40
|
setIsDragging = _useState2[1];
|
|
34
|
-
var _useState3 = (0, _react.useState)(
|
|
41
|
+
var _useState3 = (0, _react.useState)((blockControlsState === null || blockControlsState === void 0 || (_blockControlsState$a = blockControlsState.activeNode) === null || _blockControlsState$a === void 0 ? void 0 : _blockControlsState$a.pos) === nodePos),
|
|
35
42
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
36
43
|
hideWrapper = _useState4[0],
|
|
37
44
|
setHideWrapper = _useState4[1];
|
|
@@ -43,38 +50,36 @@ var MouseMoveWrapper = exports.MouseMoveWrapper = function MouseMoveWrapper(_ref
|
|
|
43
50
|
if (!isDragging) {
|
|
44
51
|
setHideWrapper(true);
|
|
45
52
|
}
|
|
46
|
-
|
|
47
|
-
if (pos === undefined) {
|
|
53
|
+
if (nodePos === undefined) {
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
50
56
|
if (api && api.blockControls && !isDragging) {
|
|
51
57
|
var _api$core;
|
|
52
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api.blockControls.commands.showDragHandleAt(
|
|
58
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api.blockControls.commands.showDragHandleAt(nodePos, anchorName, nodeType));
|
|
53
59
|
}
|
|
54
|
-
}, [setHideWrapper, isDragging, api,
|
|
60
|
+
}, [setHideWrapper, isDragging, api, nodePos, anchorName, nodeType]);
|
|
55
61
|
(0, _react.useEffect)(function () {
|
|
56
62
|
var _api$blockControls;
|
|
57
63
|
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
64
|
var _nextSharedState$acti;
|
|
59
65
|
var nextSharedState = _ref2.nextSharedState;
|
|
60
|
-
var pos = getPos();
|
|
61
66
|
setIsDragging(Boolean(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging));
|
|
62
67
|
if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.activeNode)) {
|
|
63
68
|
return;
|
|
64
69
|
}
|
|
65
|
-
if ((nextSharedState === null || nextSharedState === void 0 || (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !==
|
|
70
|
+
if ((nextSharedState === null || nextSharedState === void 0 || (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !== nodePos && !(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging)) {
|
|
66
71
|
setHideWrapper(false);
|
|
67
72
|
return;
|
|
68
73
|
}
|
|
69
74
|
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging) {
|
|
70
|
-
setHideWrapper(
|
|
75
|
+
setHideWrapper(true);
|
|
71
76
|
return;
|
|
72
77
|
}
|
|
73
78
|
});
|
|
74
79
|
return function () {
|
|
75
80
|
unbind === null || unbind === void 0 || unbind();
|
|
76
81
|
};
|
|
77
|
-
}, [
|
|
82
|
+
}, [nodePos, api]);
|
|
78
83
|
(0, _react.useLayoutEffect)(function () {
|
|
79
84
|
var supportsAnchor = CSS.supports('height', "anchor-size(".concat(anchorName, " height)")) && CSS.supports('top', "anchor(".concat(anchorName, " start)"));
|
|
80
85
|
if (supportsAnchor) {
|
|
@@ -78,7 +78,14 @@ export const createPlugin = api => {
|
|
|
78
78
|
const mouseWrapperDecs = mouseMoveWrapperDecorations(newState, api);
|
|
79
79
|
decorations = decorations.add(newState.doc, [...nodeDecs, ...mouseWrapperDecs]);
|
|
80
80
|
if (activeNode) {
|
|
81
|
-
const
|
|
81
|
+
const newActiveNode = activeNode && tr.doc.nodeAt(activeNode.pos);
|
|
82
|
+
let nodeType = activeNode.nodeType;
|
|
83
|
+
let anchorName = activeNode.anchorName;
|
|
84
|
+
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType && !(meta !== null && meta !== void 0 && meta.nodeMoved)) {
|
|
85
|
+
nodeType = newActiveNode.type.name;
|
|
86
|
+
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
87
|
+
}
|
|
88
|
+
const draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api);
|
|
82
89
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
83
90
|
}
|
|
84
91
|
}
|
|
@@ -14,8 +14,8 @@ export const dragPreview = (container, dom, nodeType) => {
|
|
|
14
14
|
const parent = document.createElement('div');
|
|
15
15
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
16
16
|
parent.classList.add('ProseMirror');
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
17
|
+
const shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension';
|
|
18
|
+
if (shouldBeGenericPreview) {
|
|
19
19
|
parent.style.border = `${previewStyle.borderWidth} ${previewStyle.borderStyle} ${previewStyle.borderColor}`;
|
|
20
20
|
parent.style.borderRadius = previewStyle.borderRadius;
|
|
21
21
|
parent.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -23,7 +23,7 @@ export const dragPreview = (container, dom, nodeType) => {
|
|
|
23
23
|
parent.setAttribute('data-testid', 'block-ctrl-generic-drag-preview');
|
|
24
24
|
}
|
|
25
25
|
const resizer = dom.querySelector('.resizer-item');
|
|
26
|
-
const clonedDom = resizer ? resizer.cloneNode(true) : dom.cloneNode(!
|
|
26
|
+
const clonedDom = resizer ? resizer.cloneNode(true) : dom.cloneNode(!shouldBeGenericPreview);
|
|
27
27
|
|
|
28
28
|
// Remove any margin from the cloned element to ensure is doesn't position incorrectly
|
|
29
29
|
clonedDom.style.marginLeft = '0';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { getTopPosition } from '../utils/drag-handle-positions';
|
|
5
6
|
const basicStyles = css({
|
|
6
7
|
position: 'absolute',
|
|
@@ -19,46 +20,49 @@ export const MouseMoveWrapper = ({
|
|
|
19
20
|
nodeType,
|
|
20
21
|
getPos
|
|
21
22
|
}) => {
|
|
23
|
+
var _blockControlsState$a;
|
|
24
|
+
const nodePos = useMemo(() => getPos(), [getPos]);
|
|
25
|
+
const {
|
|
26
|
+
blockControlsState
|
|
27
|
+
} = useSharedPluginState(api, ['blockControls']);
|
|
22
28
|
const [isDragging, setIsDragging] = useState(false);
|
|
23
|
-
const [hideWrapper, setHideWrapper] = useState(
|
|
29
|
+
const [hideWrapper, setHideWrapper] = useState((blockControlsState === null || blockControlsState === void 0 ? void 0 : (_blockControlsState$a = blockControlsState.activeNode) === null || _blockControlsState$a === void 0 ? void 0 : _blockControlsState$a.pos) === nodePos);
|
|
24
30
|
const [pos, setPos] = useState();
|
|
25
31
|
const onMouseEnter = useCallback(() => {
|
|
26
32
|
if (!isDragging) {
|
|
27
33
|
setHideWrapper(true);
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
if (pos === undefined) {
|
|
35
|
+
if (nodePos === undefined) {
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
38
|
if (api && api.blockControls && !isDragging) {
|
|
34
39
|
var _api$core;
|
|
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(
|
|
40
|
+
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(nodePos, anchorName, nodeType));
|
|
36
41
|
}
|
|
37
|
-
}, [setHideWrapper, isDragging, api,
|
|
42
|
+
}, [setHideWrapper, isDragging, api, nodePos, anchorName, nodeType]);
|
|
38
43
|
useEffect(() => {
|
|
39
44
|
var _api$blockControls;
|
|
40
45
|
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
46
|
nextSharedState
|
|
42
47
|
}) => {
|
|
43
48
|
var _nextSharedState$acti;
|
|
44
|
-
const pos = getPos();
|
|
45
49
|
setIsDragging(Boolean(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging));
|
|
46
50
|
if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.activeNode)) {
|
|
47
51
|
return;
|
|
48
52
|
}
|
|
49
|
-
if ((nextSharedState === null || nextSharedState === void 0 ? void 0 : (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !==
|
|
53
|
+
if ((nextSharedState === null || nextSharedState === void 0 ? void 0 : (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !== nodePos && !(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging)) {
|
|
50
54
|
setHideWrapper(false);
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
57
|
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging) {
|
|
54
|
-
setHideWrapper(
|
|
58
|
+
setHideWrapper(true);
|
|
55
59
|
return;
|
|
56
60
|
}
|
|
57
61
|
});
|
|
58
62
|
return () => {
|
|
59
63
|
unbind === null || unbind === void 0 ? void 0 : unbind();
|
|
60
64
|
};
|
|
61
|
-
}, [
|
|
65
|
+
}, [nodePos, api]);
|
|
62
66
|
useLayoutEffect(() => {
|
|
63
67
|
const supportsAnchor = CSS.supports('height', `anchor-size(${anchorName} height)`) && CSS.supports('top', `anchor(${anchorName} start)`);
|
|
64
68
|
if (supportsAnchor) {
|
|
@@ -75,7 +75,14 @@ export var createPlugin = function createPlugin(api) {
|
|
|
75
75
|
var mouseWrapperDecs = mouseMoveWrapperDecorations(newState, api);
|
|
76
76
|
decorations = decorations.add(newState.doc, [].concat(_toConsumableArray(nodeDecs), _toConsumableArray(mouseWrapperDecs)));
|
|
77
77
|
if (activeNode) {
|
|
78
|
-
var
|
|
78
|
+
var newActiveNode = activeNode && tr.doc.nodeAt(activeNode.pos);
|
|
79
|
+
var nodeType = activeNode.nodeType;
|
|
80
|
+
var anchorName = activeNode.anchorName;
|
|
81
|
+
if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType && !(meta !== null && meta !== void 0 && meta.nodeMoved)) {
|
|
82
|
+
nodeType = newActiveNode.type.name;
|
|
83
|
+
anchorName = activeNode.anchorName.replace(activeNode.nodeType, nodeType);
|
|
84
|
+
}
|
|
85
|
+
var draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api);
|
|
79
86
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
80
87
|
}
|
|
81
88
|
}
|
|
@@ -14,8 +14,8 @@ export var dragPreview = function dragPreview(container, dom, nodeType) {
|
|
|
14
14
|
var parent = document.createElement('div');
|
|
15
15
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
16
16
|
parent.classList.add('ProseMirror');
|
|
17
|
-
var
|
|
18
|
-
if (
|
|
17
|
+
var shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension';
|
|
18
|
+
if (shouldBeGenericPreview) {
|
|
19
19
|
parent.style.border = "".concat(previewStyle.borderWidth, " ").concat(previewStyle.borderStyle, " ").concat(previewStyle.borderColor);
|
|
20
20
|
parent.style.borderRadius = previewStyle.borderRadius;
|
|
21
21
|
parent.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -23,7 +23,7 @@ export var dragPreview = function dragPreview(container, dom, nodeType) {
|
|
|
23
23
|
parent.setAttribute('data-testid', 'block-ctrl-generic-drag-preview');
|
|
24
24
|
}
|
|
25
25
|
var resizer = dom.querySelector('.resizer-item');
|
|
26
|
-
var clonedDom = resizer ? resizer.cloneNode(true) : dom.cloneNode(!
|
|
26
|
+
var clonedDom = resizer ? resizer.cloneNode(true) : dom.cloneNode(!shouldBeGenericPreview);
|
|
27
27
|
|
|
28
28
|
// Remove any margin from the cloned element to ensure is doesn't position incorrectly
|
|
29
29
|
clonedDom.style.marginLeft = '0';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import { useCallback, useEffect, useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
6
|
import { getTopPosition } from '../utils/drag-handle-positions';
|
|
6
7
|
var basicStyles = css({
|
|
7
8
|
position: 'absolute',
|
|
@@ -14,16 +15,22 @@ var mouseMoveWrapperStyles = css({
|
|
|
14
15
|
zIndex: 1
|
|
15
16
|
});
|
|
16
17
|
export var MouseMoveWrapper = function MouseMoveWrapper(_ref) {
|
|
18
|
+
var _blockControlsState$a;
|
|
17
19
|
var view = _ref.view,
|
|
18
20
|
api = _ref.api,
|
|
19
21
|
anchorName = _ref.anchorName,
|
|
20
22
|
nodeType = _ref.nodeType,
|
|
21
23
|
getPos = _ref.getPos;
|
|
24
|
+
var nodePos = useMemo(function () {
|
|
25
|
+
return getPos();
|
|
26
|
+
}, [getPos]);
|
|
27
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockControls']),
|
|
28
|
+
blockControlsState = _useSharedPluginState.blockControlsState;
|
|
22
29
|
var _useState = useState(false),
|
|
23
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
24
31
|
isDragging = _useState2[0],
|
|
25
32
|
setIsDragging = _useState2[1];
|
|
26
|
-
var _useState3 = useState(
|
|
33
|
+
var _useState3 = useState((blockControlsState === null || blockControlsState === void 0 || (_blockControlsState$a = blockControlsState.activeNode) === null || _blockControlsState$a === void 0 ? void 0 : _blockControlsState$a.pos) === nodePos),
|
|
27
34
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
28
35
|
hideWrapper = _useState4[0],
|
|
29
36
|
setHideWrapper = _useState4[1];
|
|
@@ -35,38 +42,36 @@ export var MouseMoveWrapper = function MouseMoveWrapper(_ref) {
|
|
|
35
42
|
if (!isDragging) {
|
|
36
43
|
setHideWrapper(true);
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
if (pos === undefined) {
|
|
45
|
+
if (nodePos === undefined) {
|
|
40
46
|
return;
|
|
41
47
|
}
|
|
42
48
|
if (api && api.blockControls && !isDragging) {
|
|
43
49
|
var _api$core;
|
|
44
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api.blockControls.commands.showDragHandleAt(
|
|
50
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api.blockControls.commands.showDragHandleAt(nodePos, anchorName, nodeType));
|
|
45
51
|
}
|
|
46
|
-
}, [setHideWrapper, isDragging, api,
|
|
52
|
+
}, [setHideWrapper, isDragging, api, nodePos, anchorName, nodeType]);
|
|
47
53
|
useEffect(function () {
|
|
48
54
|
var _api$blockControls;
|
|
49
55
|
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
56
|
var _nextSharedState$acti;
|
|
51
57
|
var nextSharedState = _ref2.nextSharedState;
|
|
52
|
-
var pos = getPos();
|
|
53
58
|
setIsDragging(Boolean(nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isDragging));
|
|
54
59
|
if (!(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.activeNode)) {
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
57
|
-
if ((nextSharedState === null || nextSharedState === void 0 || (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !==
|
|
62
|
+
if ((nextSharedState === null || nextSharedState === void 0 || (_nextSharedState$acti = nextSharedState.activeNode) === null || _nextSharedState$acti === void 0 ? void 0 : _nextSharedState$acti.pos) !== nodePos && !(nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging)) {
|
|
58
63
|
setHideWrapper(false);
|
|
59
64
|
return;
|
|
60
65
|
}
|
|
61
66
|
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.isDragging) {
|
|
62
|
-
setHideWrapper(
|
|
67
|
+
setHideWrapper(true);
|
|
63
68
|
return;
|
|
64
69
|
}
|
|
65
70
|
});
|
|
66
71
|
return function () {
|
|
67
72
|
unbind === null || unbind === void 0 || unbind();
|
|
68
73
|
};
|
|
69
|
-
}, [
|
|
74
|
+
}, [nodePos, api]);
|
|
70
75
|
useLayoutEffect(function () {
|
|
71
76
|
var supportsAnchor = CSS.supports('height', "anchor-size(".concat(anchorName, " height)")) && CSS.supports('top', "anchor(".concat(anchorName, " start)"));
|
|
72
77
|
if (supportsAnchor) {
|