@atlaskit/editor-plugin-block-controls 2.21.0 → 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 +16 -0
- package/dist/cjs/pm-plugins/decorations-drop-target.js +24 -59
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/drop-target.js +204 -150
- package/dist/es2019/pm-plugins/decorations-drop-target.js +29 -64
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/drop-target.js +199 -150
- package/dist/esm/pm-plugins/decorations-drop-target.js +25 -60
- package/dist/esm/pm-plugins/main.js +1 -1
- 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 +3 -6
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.21.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#103365](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103365)
|
|
8
|
+
[`fb69e4b7a2f59`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb69e4b7a2f59) -
|
|
9
|
+
ED-26243 Removed unused drop-target v1
|
|
10
|
+
|
|
11
|
+
## 2.21.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#102744](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102744)
|
|
16
|
+
[`289c0169e410a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/289c0169e410a) -
|
|
17
|
+
ED-26243 Cleaned up platform_editor_drag_and_drop_target_v2 FG
|
|
18
|
+
|
|
3
19
|
## 2.21.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -16,7 +16,6 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
16
16
|
var _consts = require("../ui/consts");
|
|
17
17
|
var _dropTarget = require("../ui/drop-target");
|
|
18
18
|
var _dropTargetLayout = require("../ui/drop-target-layout");
|
|
19
|
-
var _dropTargetV = require("../ui/drop-target-v2");
|
|
20
19
|
var _decorationsCommon = require("./decorations-common");
|
|
21
20
|
var _consts2 = require("./utils/consts");
|
|
22
21
|
var _dragTargetDebug = require("./utils/drag-target-debug");
|
|
@@ -27,10 +26,7 @@ var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'lis
|
|
|
27
26
|
var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
|
|
28
27
|
var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
|
|
29
28
|
var shouldDescend = function shouldDescend(node) {
|
|
30
|
-
|
|
31
|
-
return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
29
|
+
return !['mediaSingle', 'paragraph', 'heading'].includes(node.type.name);
|
|
34
30
|
};
|
|
35
31
|
var getNodeMargins = function getNodeMargins(node) {
|
|
36
32
|
if (!node) {
|
|
@@ -105,40 +101,26 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
105
101
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
106
102
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
107
103
|
element.style.clear = 'unset';
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return /*#__PURE__*/(0, _react.createElement)(_dropTargetV.DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
|
|
118
|
-
getPos: getPos,
|
|
119
|
-
anchorRectCache: anchorRectCache,
|
|
120
|
-
isSameLayout: isSameLayout
|
|
121
|
-
}));
|
|
122
|
-
}, element, key);
|
|
123
|
-
} else {
|
|
124
|
-
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetV.DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
|
|
104
|
+
var _getGapAndOffset = getGapAndOffset(props.prevNode, props.nextNode, props.parentNode),
|
|
105
|
+
gap = _getGapAndOffset.gap,
|
|
106
|
+
offset = _getGapAndOffset.offset;
|
|
107
|
+
element.style.setProperty(_dropTarget.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, "".concat(offset, "px"));
|
|
108
|
+
element.style.setProperty(_dropTarget.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, "".concat(gap, "px"));
|
|
109
|
+
element.style.setProperty('display', 'block');
|
|
110
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
111
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
112
|
+
return /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
125
113
|
getPos: getPos,
|
|
126
114
|
anchorRectCache: anchorRectCache,
|
|
127
115
|
isSameLayout: isSameLayout
|
|
128
|
-
}))
|
|
129
|
-
}
|
|
116
|
+
}));
|
|
117
|
+
}, element, key);
|
|
130
118
|
} else {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}, element, key);
|
|
137
|
-
} else {
|
|
138
|
-
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
139
|
-
getPos: getPos
|
|
140
|
-
})), element);
|
|
141
|
-
}
|
|
119
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
120
|
+
getPos: getPos,
|
|
121
|
+
anchorRectCache: anchorRectCache,
|
|
122
|
+
isSameLayout: isSameLayout
|
|
123
|
+
})), element);
|
|
142
124
|
}
|
|
143
125
|
return element;
|
|
144
126
|
}, {
|
|
@@ -190,7 +172,6 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
190
172
|
var POS_END_OF_DOC = newState.doc.nodeSize - 2;
|
|
191
173
|
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
192
174
|
var docTo = to === undefined || to > POS_END_OF_DOC ? POS_END_OF_DOC : to;
|
|
193
|
-
var prevNode;
|
|
194
175
|
var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
195
176
|
var $activeNodePos = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos);
|
|
196
177
|
var activePMNode = $activeNodePos && $activeNodePos.nodeAfter;
|
|
@@ -236,40 +217,28 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
236
217
|
}
|
|
237
218
|
}
|
|
238
219
|
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
239
|
-
|
|
240
|
-
pushNodeStack(node, depth);
|
|
241
|
-
} else {
|
|
242
|
-
prevNode = node;
|
|
243
|
-
}
|
|
220
|
+
pushNodeStack(node, depth);
|
|
244
221
|
return false;
|
|
245
222
|
}
|
|
246
223
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
247
|
-
|
|
248
|
-
pushNodeStack(node, depth);
|
|
249
|
-
} else {
|
|
250
|
-
prevNode = node;
|
|
251
|
-
}
|
|
224
|
+
pushNodeStack(node, depth);
|
|
252
225
|
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
253
226
|
}
|
|
254
227
|
var canDrop = activePMNode && (0, _validation.canMoveNodeToIndex)(parent, index, activePMNode, $pos, node);
|
|
255
228
|
|
|
256
229
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
257
230
|
if (!canDrop && !(0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
258
|
-
|
|
259
|
-
pushNodeStack(node, depth);
|
|
260
|
-
} else {
|
|
261
|
-
prevNode = node;
|
|
262
|
-
}
|
|
231
|
+
pushNodeStack(node, depth);
|
|
263
232
|
return false; //not valid pos, so nested not valid either
|
|
264
233
|
}
|
|
265
234
|
if (parent.lastChild === node && !(0, _utils.isEmptyParagraph)(node) && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
266
235
|
endPos = pos + node.nodeSize;
|
|
267
236
|
}
|
|
268
237
|
}
|
|
269
|
-
var previousNode =
|
|
238
|
+
var previousNode = popNodeStack(depth); // created scoped variable
|
|
270
239
|
|
|
271
240
|
// only table and layout need to render full height drop target
|
|
272
|
-
var isInSupportedContainer =
|
|
241
|
+
var isInSupportedContainer = ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
|
|
273
242
|
var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && (0, _utils.isEmptyParagraph)(node);
|
|
274
243
|
decs.push(createDropTargetDecoration(pos, {
|
|
275
244
|
api: api,
|
|
@@ -282,17 +251,13 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
282
251
|
if (endPos !== undefined) {
|
|
283
252
|
decs.push(createDropTargetDecoration(endPos, {
|
|
284
253
|
api: api,
|
|
285
|
-
prevNode:
|
|
254
|
+
prevNode: node,
|
|
286
255
|
parentNode: parent || undefined,
|
|
287
256
|
formatMessage: formatMessage,
|
|
288
257
|
dropTargetStyle: 'remainingHeight'
|
|
289
258
|
}, nodeViewPortalProviderAPI, -1, anchorRectCache));
|
|
290
259
|
}
|
|
291
|
-
|
|
292
|
-
pushNodeStack(node, depth);
|
|
293
|
-
} else {
|
|
294
|
-
prevNode = node;
|
|
295
|
-
}
|
|
260
|
+
pushNodeStack(node, depth);
|
|
296
261
|
return depth < (0, _decorationsCommon.getNestedDepth)() && shouldDescend(node);
|
|
297
262
|
});
|
|
298
263
|
if (docTo === POS_END_OF_DOC) {
|
|
@@ -430,7 +430,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
430
430
|
isNestedEnabled: isNestedEnabled
|
|
431
431
|
};
|
|
432
432
|
var anchorRectCache;
|
|
433
|
-
if (!(0, _anchorUtils.isAnchorSupported)()
|
|
433
|
+
if (!(0, _anchorUtils.isAnchorSupported)()) {
|
|
434
434
|
anchorRectCache = new _anchorUtils.AnchorRectCache();
|
|
435
435
|
}
|
|
436
436
|
return new _safePlugin.SafePlugin({
|
|
@@ -4,7 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.DropTarget = void 0;
|
|
7
|
+
exports.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET = exports.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP = exports.DropTarget = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = require("react");
|
|
@@ -14,8 +15,13 @@ var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box")
|
|
|
14
15
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
15
16
|
var _constants = require("@atlaskit/theme/constants");
|
|
16
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
|
+
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
19
|
+
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
20
|
+
var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
|
|
17
21
|
var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
|
|
22
|
+
var _inlineDropTarget = require("../pm-plugins/utils/inline-drop-target");
|
|
18
23
|
var _consts = require("./consts");
|
|
24
|
+
var _inlineDropTarget2 = require("./inline-drop-target");
|
|
19
25
|
/**
|
|
20
26
|
* @jsxRuntime classic
|
|
21
27
|
* @jsx jsx
|
|
@@ -27,15 +33,16 @@ var DEFAULT_DROP_INDICATOR_WIDTH = 760;
|
|
|
27
33
|
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
28
34
|
var EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN = '--editor-block-controls-drop-target-leftMargin';
|
|
29
35
|
var EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX = '--editor-block-controls-drop-target-zindex';
|
|
36
|
+
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET = exports.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET = '--editor-block-controls-drop-indicator-offset';
|
|
37
|
+
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP = exports.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP = '--editor-block-controls-drop-indicator-gap';
|
|
30
38
|
var styleDropTarget = (0, _react2.css)({
|
|
31
|
-
height: "var(--ds-space-100, 8px)",
|
|
32
|
-
marginTop: "var(--ds-space-negative-100, -8px)",
|
|
33
39
|
marginLeft: "calc(-1 * var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, ", 0))"),
|
|
34
40
|
paddingLeft: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, ", 0)"),
|
|
35
41
|
position: 'absolute',
|
|
36
42
|
left: '0',
|
|
37
43
|
display: 'block',
|
|
38
|
-
zIndex: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, ", 110)")
|
|
44
|
+
zIndex: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, ", 110)"),
|
|
45
|
+
transform: "translateY(var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, ", 0))")
|
|
39
46
|
});
|
|
40
47
|
var styleDropIndicator = (0, _react2.css)({
|
|
41
48
|
height: '100%',
|
|
@@ -46,65 +53,141 @@ var styleDropIndicator = (0, _react2.css)({
|
|
|
46
53
|
var nestedDropIndicatorStyle = (0, _react2.css)({
|
|
47
54
|
position: 'relative'
|
|
48
55
|
});
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
56
|
+
var dropZoneStyles = (0, _react2.css)({
|
|
57
|
+
margin: 0,
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
width: '100%',
|
|
60
|
+
zIndex: 110,
|
|
61
|
+
minHeight: '4px'
|
|
62
|
+
});
|
|
63
|
+
var nestedDropZoneStyle = (0, _react2.css)({
|
|
64
|
+
left: '4px',
|
|
65
|
+
right: '4px',
|
|
66
|
+
width: 'unset'
|
|
67
|
+
});
|
|
68
|
+
var enableDropZone = ['paragraph', 'mediaSingle', 'heading', 'codeBlock', 'decisionList', 'bulletList', 'orderedList', 'taskList', 'extension', 'blockCard'];
|
|
69
|
+
|
|
70
|
+
// This z index is used in container like layout
|
|
71
|
+
var fullHeightStyleAdjustZIndexStyle = (0, _react2.css)({
|
|
72
|
+
zIndex: 0
|
|
73
|
+
});
|
|
74
|
+
var HoverZone = function HoverZone(_ref) {
|
|
75
|
+
var _onDragEnter = _ref.onDragEnter,
|
|
76
|
+
onDragLeave = _ref.onDragLeave,
|
|
77
|
+
onDrop = _ref.onDrop,
|
|
78
|
+
node = _ref.node,
|
|
79
|
+
parent = _ref.parent,
|
|
80
|
+
editorWidth = _ref.editorWidth,
|
|
81
|
+
anchorRectCache = _ref.anchorRectCache,
|
|
82
|
+
position = _ref.position,
|
|
83
|
+
isNestedDropTarget = _ref.isNestedDropTarget,
|
|
84
|
+
dropTargetStyle = _ref.dropTargetStyle;
|
|
85
|
+
var ref = (0, _react.useRef)(null);
|
|
86
|
+
var isRemainingheight = dropTargetStyle === 'remainingHeight';
|
|
87
|
+
var anchorName = (0, _react.useMemo)(function () {
|
|
88
|
+
return node ? (0, _decorationsCommon.getNodeAnchor)(node) : '';
|
|
89
|
+
}, [node]);
|
|
90
|
+
var _useActiveAnchorTrack = (0, _activeAnchorTracker.useActiveAnchorTracker)(anchorName),
|
|
91
|
+
_useActiveAnchorTrack2 = (0, _slicedToArray2.default)(_useActiveAnchorTrack, 2),
|
|
92
|
+
_isActive = _useActiveAnchorTrack2[0],
|
|
93
|
+
setActiveAnchor = _useActiveAnchorTrack2[1];
|
|
94
|
+
(0, _react.useEffect)(function () {
|
|
95
|
+
if (ref.current) {
|
|
96
|
+
return (0, _adapter.dropTargetForElements)({
|
|
97
|
+
element: ref.current,
|
|
98
|
+
onDragEnter: function onDragEnter() {
|
|
99
|
+
if (!isNestedDropTarget && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
100
|
+
setActiveAnchor();
|
|
101
|
+
}
|
|
102
|
+
_onDragEnter();
|
|
103
|
+
},
|
|
104
|
+
onDragLeave: onDragLeave,
|
|
105
|
+
onDrop: onDrop
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}, [isNestedDropTarget, _onDragEnter, onDragLeave, onDrop, setActiveAnchor]);
|
|
109
|
+
var hoverZoneUpperStyle = (0, _react.useMemo)(function () {
|
|
110
|
+
var heightStyleOffset = "var(--editor-block-controls-drop-indicator-gap, 0)/2";
|
|
111
|
+
var transformOffset = "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, ", 0)");
|
|
112
|
+
var heightStyle = anchorName && enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '') ? (0, _anchorUtils.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';
|
|
113
|
+
var transform = position === 'upper' ? "translateY(calc(-100% + ".concat(transformOffset, "))") : "translateY(".concat(transformOffset, ")");
|
|
82
114
|
return (0, _react2.css)({
|
|
83
|
-
|
|
115
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
116
|
+
height: heightStyle,
|
|
117
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
118
|
+
transform: transform,
|
|
119
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
120
|
+
maxWidth: "".concat(editorWidth || 0, "px")
|
|
84
121
|
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var
|
|
94
|
-
|
|
122
|
+
}, [anchorName, anchorRectCache, editorWidth, node === null || node === void 0 ? void 0 : node.type.name, position]);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 1. Above the last empty line
|
|
126
|
+
* 2. Below the last element
|
|
127
|
+
*
|
|
128
|
+
* Both cases will take the remaining height of the the container
|
|
129
|
+
*/
|
|
130
|
+
var heightStyle = (0, _react.useMemo)(function () {
|
|
131
|
+
// only apply upper drop zone
|
|
132
|
+
if (isRemainingheight && position === 'upper') {
|
|
133
|
+
// previous node
|
|
134
|
+
var _anchorName = node ? (0, _decorationsCommon.getNodeAnchor)(node) : '';
|
|
135
|
+
var top = 'unset';
|
|
136
|
+
if (_anchorName) {
|
|
137
|
+
var enabledDropZone = enableDropZone.includes((node === null || node === void 0 ? void 0 : node.type.name) || '');
|
|
138
|
+
if ((0, _anchorUtils.isAnchorSupported)()) {
|
|
139
|
+
top = enabledDropZone ? "calc(anchor(".concat(_anchorName, " 50%))") : "calc(anchor(".concat(_anchorName, " bottom) - 4px)");
|
|
140
|
+
} else if (anchorRectCache) {
|
|
141
|
+
var preNodeTopPos = anchorRectCache.getTop(_anchorName) || 0;
|
|
142
|
+
var prevNodeHeight = anchorRectCache.getHeight(_anchorName) || 0;
|
|
143
|
+
top = enabledDropZone ? "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight / 2, "px)") : "calc(".concat(preNodeTopPos, "px + ").concat(prevNodeHeight, "px - 4px)");
|
|
144
|
+
} else {
|
|
145
|
+
// Should not happen
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
// first empty paragraph
|
|
150
|
+
top = '4px';
|
|
151
|
+
}
|
|
152
|
+
return (0, _react2.css)({
|
|
153
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
154
|
+
top: top,
|
|
155
|
+
bottom: '4px',
|
|
156
|
+
height: 'unset',
|
|
157
|
+
zIndex: 10,
|
|
158
|
+
transform: 'none'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
95
161
|
return null;
|
|
96
|
-
}
|
|
97
|
-
var
|
|
98
|
-
return
|
|
162
|
+
}, [anchorRectCache, isRemainingheight, node, position]);
|
|
163
|
+
var isFullHeightInLayout = isRemainingheight && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutColumn';
|
|
164
|
+
return (0, _react2.jsx)("div", {
|
|
165
|
+
ref: ref
|
|
166
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
167
|
+
,
|
|
168
|
+
className: "drop-target-hover-zone-".concat(position),
|
|
169
|
+
"data-testid": "drop-target-zone-".concat(position)
|
|
170
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
171
|
+
,
|
|
172
|
+
css: [dropZoneStyles, isNestedDropTarget && nestedDropZoneStyle,
|
|
173
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
174
|
+
hoverZoneUpperStyle,
|
|
175
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
176
|
+
heightStyle, isFullHeightInLayout && fullHeightStyleAdjustZIndexStyle]
|
|
177
|
+
});
|
|
99
178
|
};
|
|
100
|
-
var DropTarget = exports.DropTarget = function DropTarget(
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
179
|
+
var DropTarget = exports.DropTarget = function DropTarget(props) {
|
|
180
|
+
var _api$blockControls;
|
|
181
|
+
var api = props.api,
|
|
182
|
+
getPos = props.getPos,
|
|
183
|
+
prevNode = props.prevNode,
|
|
184
|
+
nextNode = props.nextNode,
|
|
185
|
+
parentNode = props.parentNode,
|
|
186
|
+
formatMessage = props.formatMessage,
|
|
187
|
+
anchorRectCache = props.anchorRectCache,
|
|
188
|
+
_props$dropTargetStyl = props.dropTargetStyle,
|
|
189
|
+
dropTargetStyle = _props$dropTargetStyl === void 0 ? 'default' : _props$dropTargetStyl,
|
|
190
|
+
isSameLayout = props.isSameLayout;
|
|
108
191
|
var _useState = (0, _react.useState)(false),
|
|
109
192
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
110
193
|
isDraggedOver = _useState2[0],
|
|
@@ -112,102 +195,73 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
112
195
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']),
|
|
113
196
|
widthState = _useSharedPluginState.widthState;
|
|
114
197
|
var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
115
|
-
(0
|
|
116
|
-
|
|
117
|
-
|
|
198
|
+
var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
199
|
+
activeNode = _ref2.activeNode;
|
|
200
|
+
var onDrop = function onDrop() {
|
|
201
|
+
if (!activeNode) {
|
|
118
202
|
return;
|
|
119
203
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var _api$blockControls;
|
|
126
|
-
var _ref4 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
127
|
-
activeNode = _ref4.activeNode;
|
|
128
|
-
var parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
129
|
-
var activeNodeType = activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType;
|
|
130
|
-
if (parentNodeType === 'blockquote' && (activeNodeType === 'mediaGroup' || activeNodeType === 'mediaSingle' || activeNodeType === 'codeBlock')) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if ((0, _experiments.editorExperiment)('nested-expand-in-expand', false)) {
|
|
135
|
-
var _api$blockControls2;
|
|
136
|
-
var _ref5 = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState.currentState()) || {},
|
|
137
|
-
_activeNode = _ref5.activeNode;
|
|
138
|
-
var _parentNodeType = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name;
|
|
139
|
-
var _activeNodeType = _activeNode === null || _activeNode === void 0 ? void 0 : _activeNode.nodeType;
|
|
140
|
-
if (_parentNodeType === 'expand' && (_activeNodeType === 'expand' || _activeNodeType === 'nestedExpand')) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return (0, _adapter.dropTargetForElements)({
|
|
145
|
-
element: element,
|
|
146
|
-
getIsSticky: function getIsSticky() {
|
|
147
|
-
return true;
|
|
148
|
-
},
|
|
149
|
-
onDragEnter: function onDragEnter() {
|
|
150
|
-
setIsDraggedOver(true);
|
|
151
|
-
},
|
|
152
|
-
onDragLeave: function onDragLeave() {
|
|
153
|
-
setIsDraggedOver(false);
|
|
154
|
-
},
|
|
155
|
-
onDrop: function onDrop() {
|
|
156
|
-
var _api$blockControls3;
|
|
157
|
-
var _ref6 = (api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {},
|
|
158
|
-
activeNode = _ref6.activeNode;
|
|
159
|
-
if (!activeNode) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
var pos = getPos();
|
|
163
|
-
if (activeNode && pos !== undefined) {
|
|
164
|
-
var _api$core, _api$blockControls4;
|
|
165
|
-
var start = activeNode.pos;
|
|
166
|
-
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));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}, [api, formatMessage, getPos, parentNode]);
|
|
171
|
-
var dropTargetOffsetStyle = (0, _react.useMemo)(function () {
|
|
172
|
-
/**
|
|
173
|
-
* First child of a nested node.
|
|
174
|
-
* Disable the position adjustment temporarily
|
|
175
|
-
*/
|
|
176
|
-
if (parentNode === prevNode) {
|
|
177
|
-
return null;
|
|
204
|
+
var pos = getPos();
|
|
205
|
+
if (activeNode && pos !== undefined) {
|
|
206
|
+
var _api$core, _api$blockControls2;
|
|
207
|
+
var start = activeNode.pos;
|
|
208
|
+
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));
|
|
178
209
|
}
|
|
179
|
-
|
|
180
|
-
}, [prevNode, nextNode, parentNode]);
|
|
181
|
-
var dropTargetMarginTopStyles = (0, _react.useMemo)(function () {
|
|
182
|
-
if (parentNode === prevNode) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
|
|
186
|
-
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
210
|
+
};
|
|
187
211
|
var dynamicStyle = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
|
|
188
212
|
width: isNestedDropTarget ? 'unset' : '100%'
|
|
189
213
|
}, 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 ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, (0, _experiments.editorExperiment)('nested-dnd', true) ? _constants.layers.navigation() : _constants.layers.card());
|
|
190
|
-
return (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
214
|
+
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(HoverZone, {
|
|
215
|
+
onDragEnter: function onDragEnter() {
|
|
216
|
+
return setIsDraggedOver(true);
|
|
217
|
+
},
|
|
218
|
+
onDragLeave: function onDragLeave() {
|
|
219
|
+
return setIsDraggedOver(false);
|
|
220
|
+
},
|
|
221
|
+
onDrop: onDrop,
|
|
222
|
+
node: prevNode,
|
|
223
|
+
editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
224
|
+
anchorRectCache: anchorRectCache,
|
|
225
|
+
position: "upper",
|
|
226
|
+
isNestedDropTarget: isNestedDropTarget,
|
|
227
|
+
dropTargetStyle: dropTargetStyle
|
|
228
|
+
}), (0, _react2.jsx)("div", {
|
|
229
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
230
|
+
css: [styleDropTarget, isNestedDropTarget && nestedDropIndicatorStyle]
|
|
231
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
232
|
+
,
|
|
233
|
+
style: dynamicStyle,
|
|
234
|
+
"data-testid": "block-ctrl-drop-target"
|
|
235
|
+
},
|
|
236
|
+
// 4px gap to clear expand node border
|
|
237
|
+
(isDraggedOver || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) && (0, _react2.jsx)("div", {
|
|
238
|
+
css: styleDropIndicator,
|
|
239
|
+
"data-testid": "block-ctrl-drop-indicator"
|
|
240
|
+
}, (0, _react2.jsx)(_box.DropIndicator, {
|
|
241
|
+
edge: "bottom"
|
|
242
|
+
}))), dropTargetStyle !== 'remainingHeight' && (0, _react2.jsx)(HoverZone, {
|
|
243
|
+
onDragEnter: function onDragEnter() {
|
|
244
|
+
return setIsDraggedOver(true);
|
|
245
|
+
},
|
|
246
|
+
onDragLeave: function onDragLeave() {
|
|
247
|
+
return setIsDraggedOver(false);
|
|
203
248
|
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
249
|
+
onDrop: onDrop,
|
|
250
|
+
node: nextNode,
|
|
251
|
+
parent: parentNode,
|
|
252
|
+
editorWidth: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
|
|
253
|
+
anchorRectCache: anchorRectCache,
|
|
254
|
+
position: "lower",
|
|
255
|
+
isNestedDropTarget: isNestedDropTarget
|
|
256
|
+
}), (0, _inlineDropTarget.shouldAllowInlineDropTarget)(isNestedDropTarget, nextNode, isSameLayout, activeNode) && (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget
|
|
257
|
+
// Ignored via go/ees005
|
|
258
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
259
|
+
, (0, _extends2.default)({}, props, {
|
|
260
|
+
position: "left"
|
|
261
|
+
})), (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget
|
|
262
|
+
// Ignored via go/ees005
|
|
263
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
264
|
+
, (0, _extends2.default)({}, props, {
|
|
265
|
+
position: "right"
|
|
266
|
+
}))));
|
|
213
267
|
};
|