@atlaskit/editor-plugin-block-controls 2.21.1 → 2.21.2
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/pm-plugins/decorations-drop-target.js +5 -5
- package/dist/cjs/ui/drop-target.js +204 -150
- package/dist/es2019/pm-plugins/decorations-drop-target.js +3 -3
- package/dist/es2019/ui/drop-target.js +199 -150
- package/dist/esm/pm-plugins/decorations-drop-target.js +3 -3
- package/dist/esm/ui/drop-target.js +205 -151
- package/dist/types/ui/drop-target.d.ts +7 -1
- package/dist/types-ts4.5/ui/drop-target.d.ts +7 -1
- package/package.json +2 -2
- package/dist/cjs/ui/drop-target-v2.js +0 -267
- package/dist/es2019/ui/drop-target-v2.js +0 -252
- package/dist/esm/ui/drop-target-v2.js +0 -259
- package/dist/types/ui/drop-target-v2.d.ts +0 -9
- package/dist/types-ts4.5/ui/drop-target-v2.d.ts +0 -9
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
4
|
/**
|
|
4
5
|
* @jsxRuntime classic
|
|
5
6
|
* @jsx jsx
|
|
6
7
|
*/
|
|
7
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
+
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
9
|
|
|
9
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
11
|
import { css, jsx } from '@emotion/react';
|
|
@@ -13,21 +14,27 @@ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indi
|
|
|
13
14
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
15
|
import { layers } from '@atlaskit/theme/constants';
|
|
15
16
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
17
|
+
import { getNodeAnchor } from '../pm-plugins/decorations-common';
|
|
18
|
+
import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
|
|
19
|
+
import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
|
|
16
20
|
import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
|
|
17
|
-
import {
|
|
21
|
+
import { shouldAllowInlineDropTarget } from '../pm-plugins/utils/inline-drop-target';
|
|
22
|
+
import { getNestedNodeLeftPaddingMargin } from './consts';
|
|
23
|
+
import { InlineDropTarget } from './inline-drop-target';
|
|
18
24
|
var DEFAULT_DROP_INDICATOR_WIDTH = 760;
|
|
19
25
|
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
20
26
|
var EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN = '--editor-block-controls-drop-target-leftMargin';
|
|
21
27
|
var EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX = '--editor-block-controls-drop-target-zindex';
|
|
28
|
+
export var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET = '--editor-block-controls-drop-indicator-offset';
|
|
29
|
+
export var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP = '--editor-block-controls-drop-indicator-gap';
|
|
22
30
|
var styleDropTarget = css({
|
|
23
|
-
height: "var(--ds-space-100, 8px)",
|
|
24
|
-
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
25
31
|
marginLeft: "calc(-1 * var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, ", 0))"),
|
|
26
32
|
paddingLeft: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, ", 0)"),
|
|
27
33
|
position: 'absolute',
|
|
28
34
|
left: '0',
|
|
29
35
|
display: 'block',
|
|
30
|
-
zIndex: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, ", 110)")
|
|
36
|
+
zIndex: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, ", 110)"),
|
|
37
|
+
transform: "translateY(var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, ", 0))")
|
|
31
38
|
});
|
|
32
39
|
var styleDropIndicator = css({
|
|
33
40
|
height: '100%',
|
|
@@ -38,65 +45,141 @@ var styleDropIndicator = css({
|
|
|
38
45
|
var nestedDropIndicatorStyle = css({
|
|
39
46
|
position: 'relative'
|
|
40
47
|
});
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
48
|
+
var dropZoneStyles = css({
|
|
49
|
+
margin: 0,
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
width: '100%',
|
|
52
|
+
zIndex: 110,
|
|
53
|
+
minHeight: '4px'
|
|
54
|
+
});
|
|
55
|
+
var nestedDropZoneStyle = css({
|
|
56
|
+
left: '4px',
|
|
57
|
+
right: '4px',
|
|
58
|
+
width: 'unset'
|
|
59
|
+
});
|
|
60
|
+
var enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
|
|
61
|
+
|
|
62
|
+
// This z index is used in container like layout
|
|
63
|
+
var fullHeightStyleAdjustZIndexStyle = css({
|
|
64
|
+
zIndex: 0
|
|
65
|
+
});
|
|
66
|
+
var HoverZone = function HoverZone(_ref) {
|
|
67
|
+
var _onDragEnter = _ref.onDragEnter,
|
|
68
|
+
onDragLeave = _ref.onDragLeave,
|
|
69
|
+
onDrop = _ref.onDrop,
|
|
70
|
+
node = _ref.node,
|
|
71
|
+
parent = _ref.parent,
|
|
72
|
+
editorWidth = _ref.editorWidth,
|
|
73
|
+
anchorRectCache = _ref.anchorRectCache,
|
|
74
|
+
position = _ref.position,
|
|
75
|
+
isNestedDropTarget = _ref.isNestedDropTarget,
|
|
76
|
+
dropTargetStyle = _ref.dropTargetStyle;
|
|
77
|
+
var ref = useRef(null);
|
|
78
|
+
var isRemainingheight = dropTargetStyle === 'remainingHeight';
|
|
79
|
+
var anchorName = useMemo(function () {
|
|
80
|
+
return node ? getNodeAnchor(node) : '';
|
|
81
|
+
}, [node]);
|
|
82
|
+
var _useActiveAnchorTrack = useActiveAnchorTracker(anchorName),
|
|
83
|
+
_useActiveAnchorTrack2 = _slicedToArray(_useActiveAnchorTrack, 2),
|
|
84
|
+
_isActive = _useActiveAnchorTrack2[0],
|
|
85
|
+
setActiveAnchor = _useActiveAnchorTrack2[1];
|
|
86
|
+
useEffect(function () {
|
|
87
|
+
if (ref.current) {
|
|
88
|
+
return dropTargetForElements({
|
|
89
|
+
element: ref.current,
|
|
90
|
+
onDragEnter: function onDragEnter() {
|
|
91
|
+
if (!isNestedDropTarget && editorExperiment('advanced_layouts', true)) {
|
|
92
|
+
setActiveAnchor();
|
|
93
|
+
}
|
|
94
|
+
_onDragEnter();
|
|
95
|
+
},
|
|
96
|
+
onDragLeave: onDragLeave,
|
|
97
|
+
onDrop: onDrop
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, [isNestedDropTarget, _onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
|
|
101
|
+
var hoverZoneUpperStyle = useMemo(function () {
|
|
102
|
+
var heightStyleOffset = "var(--editor-block-controls-drop-indicator-gap, 0)/2";
|
|
103
|
+
var transformOffset = "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, ", 0)");
|
|
104
|
+
var heightStyle = anchorName && enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? isAnchorSupported() ? "calc(anchor-size(".concat(anchorName, " height)/2 + ").concat(heightStyleOffset, ")") : "calc(".concat(((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : anchorRectCache.getHeight(anchorName)) || 0) / 2, "px + ").concat(heightStyleOffset, ")") : '4px';
|
|
105
|
+
var transform = position === 'upper' ? "translateY(calc(-100% + ".concat(transformOffset, "))") : "translateY(".concat(transformOffset, ")");
|
|
74
106
|
return css({
|
|
75
|
-
|
|
107
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
108
|
+
height: heightStyle,
|
|
109
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
110
|
+
transform: transform,
|
|
111
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
112
|
+
maxWidth: "".concat(editorWidth || 0, "px")
|
|
76
113
|
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
|
|
114
|
+
}, [anchorName, anchorRectCache, editorWidth, node === null || node === void 0 ? void 0 : node.type.name, position]);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 1. Above the last empty line
|
|
118
|
+
* 2. Below the last element
|
|
119
|
+
*
|
|
120
|
+
* Both cases will take the remaining height of the the container
|
|
121
|
+
*/
|
|
122
|
+
var heightStyle = useMemo(function () {
|
|
123
|
+
// only apply upper drop zone
|
|
124
|
+
if (isRemainingheight && position === 'upper') {
|
|
125
|
+
// previous node
|
|
126
|
+
var _anchorName = node ? getNodeAnchor(node) : '';
|
|
127
|
+
var top = 'unset';
|
|
128
|
+
if (_anchorName) {
|
|
129
|
+
var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
|
|
130
|
+
if (isAnchorSupported()) {
|
|
131
|
+
top = enabledDropZone ? "calc(anchor(".concat(_anchorName, " 50%))") : "calc(anchor(".concat(_anchorName, " bottom) - 4px)");
|
|
132
|
+
} else if (anchorRectCache) {
|
|
133
|
+
var preNodeTopPos = anchorRectCache.getTop(_anchorName) || 0;
|
|
134
|
+
var prevNodeHeight = anchorRectCache.getHeight(_anchorName) || 0;
|
|
135
|
+
top = enabledDropZone ? "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight / 2, "px)") : "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight, "px - 4px)");
|
|
136
|
+
} else {
|
|
137
|
+
// Should not happen
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
// first empty paragraph
|
|
142
|
+
top = '4px';
|
|
143
|
+
}
|
|
144
|
+
return css({
|
|
145
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
146
|
+
top: top,
|
|
147
|
+
bottom: '4px',
|
|
148
|
+
height: 'unset',
|
|
149
|
+
zIndex: 10,
|
|
150
|
+
transform: 'none'
|
|
151
|
+
});
|
|
152
|
+
}
|
|
87
153
|
return null;
|
|
88
|
-
}
|
|
89
|
-
var
|
|
90
|
-
return
|
|
154
|
+
}, [anchorRectCache, isRemainingheight, node, position]);
|
|
155
|
+
var isFullHeightInLayout = isRemainingheight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
|
|
156
|
+
return jsx("div", {
|
|
157
|
+
ref: ref
|
|
158
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
159
|
+
,
|
|
160
|
+
className: "drop-target-hover-zone-".concat(position),
|
|
161
|
+
"data-testid": "drop-target-zone-".concat(position)
|
|
162
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
163
|
+
,
|
|
164
|
+
css: [dropZoneStyles, isNestedDropTarget && nestedDropZoneStyle,
|
|
165
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
166
|
+
hoverZoneUpperStyle,
|
|
167
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
168
|
+
heightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
|
|
169
|
+
});
|
|
91
170
|
};
|
|
92
|
-
export var DropTarget = function DropTarget(
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
171
|
+
export var DropTarget = function DropTarget(props) {
|
|
172
|
+
var _api$blockControls;
|
|
173
|
+
var api = props.api,
|
|
174
|
+
getPos = props.getPos,
|
|
175
|
+
prevNode = props.prevNode,
|
|
176
|
+
nextNode = props.nextNode,
|
|
177
|
+
parentNode = props.parentNode,
|
|
178
|
+
formatMessage = props.formatMessage,
|
|
179
|
+
anchorRectCache = props.anchorRectCache,
|
|
180
|
+
_props$dropTargetStyl = props.dropTargetStyle,
|
|
181
|
+
dropTargetStyle = _props$dropTargetStyl === void 0 ? 'default' : _props$dropTargetStyl,
|
|
182
|
+
isSameLayout = props.isSameLayout;
|
|
100
183
|
var _useState = useState(false),
|
|
101
184
|
_useState2 = _slicedToArray(_useState, 2),
|
|
102
185
|
isDraggedOver = _useState2[0],
|
|
@@ -104,102 +187,73 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
104
187
|
var _useSharedPluginState = useSharedPluginState(api, ['width']),
|
|
105
188
|
widthState = _useSharedPluginState.widthState;
|
|
106
189
|
var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
190
|
+
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
191
|
+
activeNode = _ref2.activeNode;
|
|
192
|
+
var onDrop = function onDrop() {
|
|
193
|
+
if (!activeNode) {
|
|
110
194
|
return;
|
|
111
195
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var _api$blockControls;
|
|
118
|
-
var _ref4 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
119
|
-
activeNode = _ref4.activeNode;
|
|
120
|
-
var parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
121
|
-
var activeNodeType = activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType;
|
|
122
|
-
if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (editorExperiment('nested-expand-in-expand', false)) {
|
|
127
|
-
var _api$blockControls2;
|
|
128
|
-
var _ref5 = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState.currentState()) || {},
|
|
129
|
-
_activeNode = _ref5.activeNode;
|
|
130
|
-
var _parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
131
|
-
var _activeNodeType = _activeNode === null || _activeNode === void 0 ? void 0 : _activeNode.nodeType;
|
|
132
|
-
if (_parentNodeType === 'expand' && (_activeNodeType === 'expand' || _activeNodeType === 'nestedExpand')) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return dropTargetForElements({
|
|
137
|
-
element: element,
|
|
138
|
-
getIsSticky: function getIsSticky() {
|
|
139
|
-
return true;
|
|
140
|
-
},
|
|
141
|
-
onDragEnter: function onDragEnter() {
|
|
142
|
-
setIsDraggedOver(true);
|
|
143
|
-
},
|
|
144
|
-
onDragLeave: function onDragLeave() {
|
|
145
|
-
setIsDraggedOver(false);
|
|
146
|
-
},
|
|
147
|
-
onDrop: function onDrop() {
|
|
148
|
-
var _api$blockControls3;
|
|
149
|
-
var _ref6 = (api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {},
|
|
150
|
-
activeNode = _ref6.activeNode;
|
|
151
|
-
if (!activeNode) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
var pos = getPos();
|
|
155
|
-
if (activeNode && pos !== undefined) {
|
|
156
|
-
var _api$core, _api$blockControls4;
|
|
157
|
-
var start = activeNode.pos;
|
|
158
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || (_api$blockControls4 = _api$blockControls4.commands) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.moveNode(start, pos, undefined, formatMessage));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}, [api, formatMessage, getPos, parentNode]);
|
|
163
|
-
var dropTargetOffsetStyle = useMemo(function () {
|
|
164
|
-
/**
|
|
165
|
-
* First child of a nested node.
|
|
166
|
-
* Disable the position adjustment temporarily
|
|
167
|
-
*/
|
|
168
|
-
if (parentNode === prevNode) {
|
|
169
|
-
return null;
|
|
196
|
+
var pos = getPos();
|
|
197
|
+
if (activeNode && pos !== undefined) {
|
|
198
|
+
var _api$core, _api$blockControls2;
|
|
199
|
+
var start = activeNode.pos;
|
|
200
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveNode(start, pos, undefined, formatMessage));
|
|
170
201
|
}
|
|
171
|
-
|
|
172
|
-
}, [prevNode, nextNode, parentNode]);
|
|
173
|
-
var dropTargetMarginTopStyles = useMemo(function () {
|
|
174
|
-
if (parentNode === prevNode) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
|
|
178
|
-
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
202
|
+
};
|
|
179
203
|
var dynamicStyle = _defineProperty(_defineProperty(_defineProperty({
|
|
180
204
|
width: isNestedDropTarget ? 'unset' : '100%'
|
|
181
205
|
}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, editorExperiment('nested-dnd', true) ? layers.navigation() : layers.card());
|
|
182
|
-
return (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
206
|
+
return jsx(Fragment, null, jsx(HoverZone, {
|
|
207
|
+
onDragEnter: function onDragEnter() {
|
|
208
|
+
return setIsDraggedOver(true);
|
|
209
|
+
},
|
|
210
|
+
onDragLeave: function onDragLeave() {
|
|
211
|
+
return setIsDraggedOver(false);
|
|
212
|
+
},
|
|
213
|
+
onDrop: onDrop,
|
|
214
|
+
node: prevNode,
|
|
215
|
+
editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
216
|
+
anchorRectCache: anchorRectCache,
|
|
217
|
+
position: "upper",
|
|
218
|
+
isNestedDropTarget: isNestedDropTarget,
|
|
219
|
+
dropTargetStyle: dropTargetStyle
|
|
220
|
+
}), jsx("div", {
|
|
221
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
222
|
+
css: [styleDropTarget, isNestedDropTarget && nestedDropIndicatorStyle]
|
|
223
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
224
|
+
,
|
|
225
|
+
style: dynamicStyle,
|
|
226
|
+
"data-testid": "block-ctrl-drop-target"
|
|
227
|
+
},
|
|
228
|
+
// 4px gap to clear expand node border
|
|
229
|
+
(isDraggedOver || isBlocksDragTargetDebug()) && jsx("div", {
|
|
230
|
+
css: styleDropIndicator,
|
|
231
|
+
"data-testid": "block-ctrl-drop-indicator"
|
|
232
|
+
}, jsx(DropIndicator, {
|
|
233
|
+
edge: "bottom"
|
|
234
|
+
}))), dropTargetStyle !== 'remainingHeight' && jsx(HoverZone, {
|
|
235
|
+
onDragEnter: function onDragEnter() {
|
|
236
|
+
return setIsDraggedOver(true);
|
|
237
|
+
},
|
|
238
|
+
onDragLeave: function onDragLeave() {
|
|
239
|
+
return setIsDraggedOver(false);
|
|
195
240
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
241
|
+
onDrop: onDrop,
|
|
242
|
+
node: nextNode,
|
|
243
|
+
parent: parentNode,
|
|
244
|
+
editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
245
|
+
anchorRectCache: anchorRectCache,
|
|
246
|
+
position: "lower",
|
|
247
|
+
isNestedDropTarget: isNestedDropTarget
|
|
248
|
+
}), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout, activeNode) && jsx(Fragment, null, jsx(InlineDropTarget
|
|
249
|
+
// Ignored via go/ees005
|
|
250
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
251
|
+
, _extends({}, props, {
|
|
252
|
+
position: "left"
|
|
253
|
+
})), jsx(InlineDropTarget
|
|
254
|
+
// Ignored via go/ees005
|
|
255
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
256
|
+
, _extends({}, props, {
|
|
257
|
+
position: "right"
|
|
258
|
+
}))));
|
|
205
259
|
};
|
|
@@ -3,6 +3,9 @@ import { type IntlShape } from 'react-intl-next';
|
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
|
+
import { type AnchorRectCache } from '../pm-plugins/utils/anchor-utils';
|
|
7
|
+
export declare const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET = "--editor-block-controls-drop-indicator-offset";
|
|
8
|
+
export declare const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP = "--editor-block-controls-drop-indicator-gap";
|
|
6
9
|
export type DropTargetStyle = 'default' | 'remainingHeight';
|
|
7
10
|
export type DropTargetProps = {
|
|
8
11
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
@@ -13,4 +16,7 @@ export type DropTargetProps = {
|
|
|
13
16
|
dropTargetStyle?: DropTargetStyle;
|
|
14
17
|
formatMessage?: IntlShape['formatMessage'];
|
|
15
18
|
};
|
|
16
|
-
export declare const DropTarget: (
|
|
19
|
+
export declare const DropTarget: (props: DropTargetProps & {
|
|
20
|
+
anchorRectCache?: AnchorRectCache | undefined;
|
|
21
|
+
isSameLayout?: boolean | undefined;
|
|
22
|
+
}) => jsx.JSX.Element;
|
|
@@ -3,6 +3,9 @@ import { type IntlShape } from 'react-intl-next';
|
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
6
|
+
import { type AnchorRectCache } from '../pm-plugins/utils/anchor-utils';
|
|
7
|
+
export declare const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET = "--editor-block-controls-drop-indicator-offset";
|
|
8
|
+
export declare const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP = "--editor-block-controls-drop-indicator-gap";
|
|
6
9
|
export type DropTargetStyle = 'default' | 'remainingHeight';
|
|
7
10
|
export type DropTargetProps = {
|
|
8
11
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
@@ -13,4 +16,7 @@ export type DropTargetProps = {
|
|
|
13
16
|
dropTargetStyle?: DropTargetStyle;
|
|
14
17
|
formatMessage?: IntlShape['formatMessage'];
|
|
15
18
|
};
|
|
16
|
-
export declare const DropTarget: (
|
|
19
|
+
export declare const DropTarget: (props: DropTargetProps & {
|
|
20
|
+
anchorRectCache?: AnchorRectCache | undefined;
|
|
21
|
+
isSameLayout?: boolean | undefined;
|
|
22
|
+
}) => jsx.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.2",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^13.3.0",
|
|
50
50
|
"@atlaskit/theme": "^14.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^2.37.0",
|
|
52
52
|
"@atlaskit/tokens": "^3.1.0",
|
|
53
53
|
"@atlaskit/tooltip": "^19.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|