@atlaskit/editor-plugin-block-controls 2.13.30 → 2.13.31
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 +12 -0
- package/dist/cjs/pm-plugins/handle-mouse-over.js +0 -25
- package/dist/cjs/ui/inline-drop-target.js +33 -19
- package/dist/es2019/pm-plugins/handle-mouse-over.js +0 -25
- package/dist/es2019/ui/inline-drop-target.js +37 -19
- package/dist/esm/pm-plugins/handle-mouse-over.js +0 -25
- package/dist/esm/ui/inline-drop-target.js +33 -19
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.13.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#171553](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171553)
|
|
8
|
+
[`ef0f90dd048d8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ef0f90dd048d8) -
|
|
9
|
+
[ED-25917] Replace dynamic styles for inline hover zone with css var
|
|
10
|
+
- [#171077](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171077)
|
|
11
|
+
[`0a92cf56671ac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0a92cf56671ac) -
|
|
12
|
+
ED-25867 always show drag handler for layout columns
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 2.13.30
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -13,26 +13,6 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
|
|
|
13
13
|
}
|
|
14
14
|
return false;
|
|
15
15
|
};
|
|
16
|
-
var isEmptyParagraphOrPlaceholder = function isEmptyParagraphOrPlaceholder(node) {
|
|
17
|
-
if (node && node.type.name === 'paragraph') {
|
|
18
|
-
var _node$firstChild;
|
|
19
|
-
return node.childCount === 0 || node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'placeholder';
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
};
|
|
23
|
-
var isLayoutColumnWithoutContent = function isLayoutColumnWithoutContent(node) {
|
|
24
|
-
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutColumn') {
|
|
25
|
-
var foundNonEmptyNode = false;
|
|
26
|
-
for (var i = 0; i < node.childCount; i++) {
|
|
27
|
-
var child = node.child(i);
|
|
28
|
-
if (!isEmptyParagraphOrPlaceholder(child)) {
|
|
29
|
-
foundNonEmptyNode = true;
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return !foundNonEmptyNode;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
16
|
var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
|
|
37
17
|
var _api$blockControls, _target$classList;
|
|
38
18
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -98,11 +78,6 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
98
78
|
} else {
|
|
99
79
|
pos = view.posAtDOM(rootElement, 0);
|
|
100
80
|
}
|
|
101
|
-
var node = view.state.doc.nodeAt(pos);
|
|
102
|
-
if ((0, _experiments.editorExperiment)('advanced_layouts', true) && node && isLayoutColumnWithoutContent(node)) {
|
|
103
|
-
// Don't show drag handle when there is no content/only placeholder in layout column
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
81
|
var rootPos;
|
|
107
82
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
108
83
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.InlineDropTarget = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _react2 = require("@emotion/react");
|
|
@@ -12,7 +13,6 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
12
13
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
13
14
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
14
15
|
var _colors = require("@atlaskit/theme/colors");
|
|
15
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
16
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
17
17
|
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
18
18
|
var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
|
|
@@ -26,10 +26,31 @@ var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
|
|
|
26
26
|
|
|
27
27
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
28
28
|
|
|
29
|
+
var HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
|
|
30
|
+
var HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
|
|
31
|
+
var HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
|
|
32
|
+
var HOVER_ZONE_BOTTOM = '--editor-blocks-inline-hover-zone-bottom';
|
|
33
|
+
var HOVER_ZONE_ANCHOR_NAME = '--editor-blocks-inline-hover-zone-anchor-name';
|
|
29
34
|
var hoverZoneCommonStyle = (0, _react2.css)({
|
|
30
35
|
position: 'absolute',
|
|
31
36
|
// above the top and bottom drop zone as block hover zone
|
|
32
|
-
zIndex: 120
|
|
37
|
+
zIndex: 120,
|
|
38
|
+
positionAnchor: "var(".concat(HOVER_ZONE_ANCHOR_NAME, ")"),
|
|
39
|
+
minWidth: "var(--ds-space-100, 8px)",
|
|
40
|
+
left: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
width: "var(".concat(HOVER_ZONE_WIDTH, ")"),
|
|
43
|
+
height: "var(".concat(HOVER_ZONE_HEIGHT, ")")
|
|
44
|
+
});
|
|
45
|
+
var leftHoverZoneStyle = (0, _react2.css)({
|
|
46
|
+
right: "unset",
|
|
47
|
+
top: "var(".concat(HOVER_ZONE_TOP, ")"),
|
|
48
|
+
bottom: 'unset'
|
|
49
|
+
});
|
|
50
|
+
var rightHoverZoneStyle = (0, _react2.css)({
|
|
51
|
+
left: "unset",
|
|
52
|
+
top: 'unset',
|
|
53
|
+
bottom: "var(".concat(HOVER_ZONE_BOTTOM, ")")
|
|
33
54
|
});
|
|
34
55
|
|
|
35
56
|
// gap between node boundary and drop indicator/drop zone
|
|
@@ -125,7 +146,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
125
146
|
|
|
126
147
|
// Set the height target anchor name to the first or last column of the layout section so that it also works for stacked layout
|
|
127
148
|
var heightTargetAnchorName = targetAnchorName;
|
|
128
|
-
if (
|
|
149
|
+
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
129
150
|
heightTargetAnchorName = isLeftPosition ? (0, _decorationsCommon.getNodeAnchor)(nextNode.firstChild) : (0, _decorationsCommon.getNodeAnchor)(nextNode.lastChild);
|
|
130
151
|
}
|
|
131
152
|
if ((0, _anchorUtils.isAnchorSupported)()) {
|
|
@@ -175,27 +196,17 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
175
196
|
}));
|
|
176
197
|
}
|
|
177
198
|
}, [api, getPos, position]);
|
|
178
|
-
var
|
|
179
|
-
var
|
|
199
|
+
var hoverZoneRectStyle = (0, _react.useMemo)(function () {
|
|
200
|
+
var _ref3;
|
|
201
|
+
var isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
|
|
180
202
|
var layoutAdjustment = isLayoutNode ? {
|
|
181
203
|
width: 11,
|
|
182
204
|
height: 4,
|
|
183
205
|
top: 6,
|
|
184
206
|
bottom: 2
|
|
185
207
|
} : undefined;
|
|
186
|
-
return (0,
|
|
187
|
-
|
|
188
|
-
minWidth: "var(--ds-space-100, 8px)",
|
|
189
|
-
left: isLeftPosition ? 0 : 'unset',
|
|
190
|
-
right: isLeftPosition ? 'unset' : 0,
|
|
191
|
-
top: "calc(anchor(top))",
|
|
192
|
-
width: nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)"),
|
|
193
|
-
height: "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")
|
|
194
|
-
}, isLayoutNode && {
|
|
195
|
-
top: isLeftPosition ? "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)") : 'unset',
|
|
196
|
-
bottom: isLeftPosition ? 'unset' : "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")
|
|
197
|
-
});
|
|
198
|
-
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, anchorName, isLeftPosition, nodeDimension]);
|
|
208
|
+
return _ref3 = {}, (0, _defineProperty2.default)(_ref3, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), (0, _defineProperty2.default)(_ref3, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref3;
|
|
209
|
+
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
|
|
199
210
|
var dropIndicatorPos = (0, _react.useMemo)(function () {
|
|
200
211
|
return isLeftPosition ? 'right' : 'left';
|
|
201
212
|
}, [isLeftPosition]);
|
|
@@ -216,7 +227,10 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
216
227
|
return (0, _react2.jsx)("div", {
|
|
217
228
|
ref: ref,
|
|
218
229
|
"data-testid": "drop-target-hover-zone-".concat(position),
|
|
219
|
-
css: [hoverZoneCommonStyle,
|
|
230
|
+
css: [hoverZoneCommonStyle, isLeftPosition ? leftHoverZoneStyle : rightHoverZoneStyle]
|
|
231
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
232
|
+
,
|
|
233
|
+
style: hoverZoneRectStyle
|
|
220
234
|
}, isDraggedOver || (0, _dragTargetDebug.isBlocksDragTargetDebug)() ? (0, _react2.jsx)(_box.DropIndicator, {
|
|
221
235
|
edge: dropIndicatorPos
|
|
222
236
|
}) : isActiveAnchor && (0, _react2.jsx)("div", {
|
|
@@ -7,26 +7,6 @@ const isEmptyNestedParagraphOrHeading = target => {
|
|
|
7
7
|
}
|
|
8
8
|
return false;
|
|
9
9
|
};
|
|
10
|
-
const isEmptyParagraphOrPlaceholder = node => {
|
|
11
|
-
if (node && node.type.name === 'paragraph') {
|
|
12
|
-
var _node$firstChild;
|
|
13
|
-
return node.childCount === 0 || node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'placeholder';
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
};
|
|
17
|
-
const isLayoutColumnWithoutContent = node => {
|
|
18
|
-
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutColumn') {
|
|
19
|
-
let foundNonEmptyNode = false;
|
|
20
|
-
for (let i = 0; i < node.childCount; i++) {
|
|
21
|
-
const child = node.child(i);
|
|
22
|
-
if (!isEmptyParagraphOrPlaceholder(child)) {
|
|
23
|
-
foundNonEmptyNode = true;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return !foundNonEmptyNode;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
10
|
export const handleMouseOver = (view, event, api) => {
|
|
31
11
|
var _api$blockControls, _target$classList;
|
|
32
12
|
const {
|
|
@@ -93,11 +73,6 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
93
73
|
} else {
|
|
94
74
|
pos = view.posAtDOM(rootElement, 0);
|
|
95
75
|
}
|
|
96
|
-
const node = view.state.doc.nodeAt(pos);
|
|
97
|
-
if (editorExperiment('advanced_layouts', true) && node && isLayoutColumnWithoutContent(node)) {
|
|
98
|
-
// Don't show drag handle when there is no content/only placeholder in layout column
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
76
|
let rootPos;
|
|
102
77
|
if (editorExperiment('nested-dnd', true)) {
|
|
103
78
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -12,15 +12,35 @@ import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
|
12
12
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
13
13
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
14
|
import { B200 } from '@atlaskit/theme/colors';
|
|
15
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
16
15
|
import { getNodeAnchor } from '../pm-plugins/decorations-common';
|
|
17
16
|
import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
|
|
18
17
|
import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
|
|
19
18
|
import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
|
|
19
|
+
const HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
|
|
20
|
+
const HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
|
|
21
|
+
const HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
|
|
22
|
+
const HOVER_ZONE_BOTTOM = '--editor-blocks-inline-hover-zone-bottom';
|
|
23
|
+
const HOVER_ZONE_ANCHOR_NAME = '--editor-blocks-inline-hover-zone-anchor-name';
|
|
20
24
|
const hoverZoneCommonStyle = css({
|
|
21
25
|
position: 'absolute',
|
|
22
26
|
// above the top and bottom drop zone as block hover zone
|
|
23
|
-
zIndex: 120
|
|
27
|
+
zIndex: 120,
|
|
28
|
+
positionAnchor: `var(${HOVER_ZONE_ANCHOR_NAME})`,
|
|
29
|
+
minWidth: "var(--ds-space-100, 8px)",
|
|
30
|
+
left: 0,
|
|
31
|
+
right: 0,
|
|
32
|
+
width: `var(${HOVER_ZONE_WIDTH})`,
|
|
33
|
+
height: `var(${HOVER_ZONE_HEIGHT})`
|
|
34
|
+
});
|
|
35
|
+
const leftHoverZoneStyle = css({
|
|
36
|
+
right: `unset`,
|
|
37
|
+
top: `var(${HOVER_ZONE_TOP})`,
|
|
38
|
+
bottom: 'unset'
|
|
39
|
+
});
|
|
40
|
+
const rightHoverZoneStyle = css({
|
|
41
|
+
left: `unset`,
|
|
42
|
+
top: 'unset',
|
|
43
|
+
bottom: `var(${HOVER_ZONE_BOTTOM})`
|
|
24
44
|
});
|
|
25
45
|
|
|
26
46
|
// gap between node boundary and drop indicator/drop zone
|
|
@@ -112,7 +132,7 @@ export const InlineDropTarget = ({
|
|
|
112
132
|
|
|
113
133
|
// Set the height target anchor name to the first or last column of the layout section so that it also works for stacked layout
|
|
114
134
|
let heightTargetAnchorName = targetAnchorName;
|
|
115
|
-
if (
|
|
135
|
+
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
116
136
|
heightTargetAnchorName = isLeftPosition ? getNodeAnchor(nextNode.firstChild) : getNodeAnchor(nextNode.lastChild);
|
|
117
137
|
}
|
|
118
138
|
if (isAnchorSupported()) {
|
|
@@ -165,27 +185,22 @@ export const InlineDropTarget = ({
|
|
|
165
185
|
}));
|
|
166
186
|
}
|
|
167
187
|
}, [api, getPos, position]);
|
|
168
|
-
const
|
|
169
|
-
const isLayoutNode =
|
|
188
|
+
const hoverZoneRectStyle = useMemo(() => {
|
|
189
|
+
const isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
|
|
170
190
|
const layoutAdjustment = isLayoutNode ? {
|
|
171
191
|
width: 11,
|
|
172
192
|
height: 4,
|
|
173
193
|
top: 6,
|
|
174
194
|
bottom: 2
|
|
175
195
|
} : undefined;
|
|
176
|
-
return
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}, isLayoutNode && {
|
|
185
|
-
top: isLeftPosition ? `calc(${nodeDimension.top} + ${(layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0}px)` : 'unset',
|
|
186
|
-
bottom: isLeftPosition ? 'unset' : `calc(${nodeDimension.bottom} - ${(layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0}px)`
|
|
187
|
-
});
|
|
188
|
-
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, anchorName, isLeftPosition, nodeDimension]);
|
|
196
|
+
return {
|
|
197
|
+
[HOVER_ZONE_WIDTH]: nodeDimension.widthOffset ? `calc((100% - ${nodeDimension.width})/2 - ${GAP}px + ${nodeDimension.widthOffset} - ${(layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0}px)` : `calc((100% - ${nodeDimension.width})/2 - ${GAP}px - ${(layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0}px)`,
|
|
198
|
+
[HOVER_ZONE_HEIGHT]: `calc(${nodeDimension.height} + ${(layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0}px)`,
|
|
199
|
+
[HOVER_ZONE_TOP]: `calc(${nodeDimension.top} + ${(layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0}px)`,
|
|
200
|
+
[HOVER_ZONE_BOTTOM]: `calc(${nodeDimension.bottom} - ${(layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0}px)`,
|
|
201
|
+
[HOVER_ZONE_ANCHOR_NAME]: anchorName
|
|
202
|
+
};
|
|
203
|
+
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
|
|
189
204
|
const dropIndicatorPos = useMemo(() => {
|
|
190
205
|
return isLeftPosition ? 'right' : 'left';
|
|
191
206
|
}, [isLeftPosition]);
|
|
@@ -206,7 +221,10 @@ export const InlineDropTarget = ({
|
|
|
206
221
|
return jsx("div", {
|
|
207
222
|
ref: ref,
|
|
208
223
|
"data-testid": `drop-target-hover-zone-${position}`,
|
|
209
|
-
css: [hoverZoneCommonStyle,
|
|
224
|
+
css: [hoverZoneCommonStyle, isLeftPosition ? leftHoverZoneStyle : rightHoverZoneStyle]
|
|
225
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
226
|
+
,
|
|
227
|
+
style: hoverZoneRectStyle
|
|
210
228
|
}, isDraggedOver || isBlocksDragTargetDebug() ? jsx(DropIndicator, {
|
|
211
229
|
edge: dropIndicatorPos
|
|
212
230
|
}) : isActiveAnchor && jsx("div", {
|
|
@@ -7,26 +7,6 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
|
|
|
7
7
|
}
|
|
8
8
|
return false;
|
|
9
9
|
};
|
|
10
|
-
var isEmptyParagraphOrPlaceholder = function isEmptyParagraphOrPlaceholder(node) {
|
|
11
|
-
if (node && node.type.name === 'paragraph') {
|
|
12
|
-
var _node$firstChild;
|
|
13
|
-
return node.childCount === 0 || node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'placeholder';
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
};
|
|
17
|
-
var isLayoutColumnWithoutContent = function isLayoutColumnWithoutContent(node) {
|
|
18
|
-
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutColumn') {
|
|
19
|
-
var foundNonEmptyNode = false;
|
|
20
|
-
for (var i = 0; i < node.childCount; i++) {
|
|
21
|
-
var child = node.child(i);
|
|
22
|
-
if (!isEmptyParagraphOrPlaceholder(child)) {
|
|
23
|
-
foundNonEmptyNode = true;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return !foundNonEmptyNode;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
10
|
export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
31
11
|
var _api$blockControls, _target$classList;
|
|
32
12
|
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
@@ -92,11 +72,6 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
92
72
|
} else {
|
|
93
73
|
pos = view.posAtDOM(rootElement, 0);
|
|
94
74
|
}
|
|
95
|
-
var node = view.state.doc.nodeAt(pos);
|
|
96
|
-
if (editorExperiment('advanced_layouts', true) && node && isLayoutColumnWithoutContent(node)) {
|
|
97
|
-
// Don't show drag handle when there is no content/only placeholder in layout column
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
75
|
var rootPos;
|
|
101
76
|
if (editorExperiment('nested-dnd', true)) {
|
|
102
77
|
rootPos = view.state.doc.resolve(pos).pos;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
3
4
|
/* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-values */
|
|
@@ -13,15 +14,35 @@ import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
|
13
14
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
14
15
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
15
16
|
import { B200 } from '@atlaskit/theme/colors';
|
|
16
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
17
17
|
import { getNodeAnchor } from '../pm-plugins/decorations-common';
|
|
18
18
|
import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
|
|
19
19
|
import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
|
|
20
20
|
import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
|
|
21
|
+
var HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
|
|
22
|
+
var HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
|
|
23
|
+
var HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
|
|
24
|
+
var HOVER_ZONE_BOTTOM = '--editor-blocks-inline-hover-zone-bottom';
|
|
25
|
+
var HOVER_ZONE_ANCHOR_NAME = '--editor-blocks-inline-hover-zone-anchor-name';
|
|
21
26
|
var hoverZoneCommonStyle = css({
|
|
22
27
|
position: 'absolute',
|
|
23
28
|
// above the top and bottom drop zone as block hover zone
|
|
24
|
-
zIndex: 120
|
|
29
|
+
zIndex: 120,
|
|
30
|
+
positionAnchor: "var(".concat(HOVER_ZONE_ANCHOR_NAME, ")"),
|
|
31
|
+
minWidth: "var(--ds-space-100, 8px)",
|
|
32
|
+
left: 0,
|
|
33
|
+
right: 0,
|
|
34
|
+
width: "var(".concat(HOVER_ZONE_WIDTH, ")"),
|
|
35
|
+
height: "var(".concat(HOVER_ZONE_HEIGHT, ")")
|
|
36
|
+
});
|
|
37
|
+
var leftHoverZoneStyle = css({
|
|
38
|
+
right: "unset",
|
|
39
|
+
top: "var(".concat(HOVER_ZONE_TOP, ")"),
|
|
40
|
+
bottom: 'unset'
|
|
41
|
+
});
|
|
42
|
+
var rightHoverZoneStyle = css({
|
|
43
|
+
left: "unset",
|
|
44
|
+
top: 'unset',
|
|
45
|
+
bottom: "var(".concat(HOVER_ZONE_BOTTOM, ")")
|
|
25
46
|
});
|
|
26
47
|
|
|
27
48
|
// gap between node boundary and drop indicator/drop zone
|
|
@@ -117,7 +138,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
117
138
|
|
|
118
139
|
// Set the height target anchor name to the first or last column of the layout section so that it also works for stacked layout
|
|
119
140
|
var heightTargetAnchorName = targetAnchorName;
|
|
120
|
-
if (
|
|
141
|
+
if (nextNode.type.name === 'layoutSection' && nextNode.firstChild && nextNode.lastChild) {
|
|
121
142
|
heightTargetAnchorName = isLeftPosition ? getNodeAnchor(nextNode.firstChild) : getNodeAnchor(nextNode.lastChild);
|
|
122
143
|
}
|
|
123
144
|
if (isAnchorSupported()) {
|
|
@@ -167,27 +188,17 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
167
188
|
}));
|
|
168
189
|
}
|
|
169
190
|
}, [api, getPos, position]);
|
|
170
|
-
var
|
|
171
|
-
var
|
|
191
|
+
var hoverZoneRectStyle = useMemo(function () {
|
|
192
|
+
var _ref3;
|
|
193
|
+
var isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
|
|
172
194
|
var layoutAdjustment = isLayoutNode ? {
|
|
173
195
|
width: 11,
|
|
174
196
|
height: 4,
|
|
175
197
|
top: 6,
|
|
176
198
|
bottom: 2
|
|
177
199
|
} : undefined;
|
|
178
|
-
return
|
|
179
|
-
|
|
180
|
-
minWidth: "var(--ds-space-100, 8px)",
|
|
181
|
-
left: isLeftPosition ? 0 : 'unset',
|
|
182
|
-
right: isLeftPosition ? 'unset' : 0,
|
|
183
|
-
top: "calc(anchor(top))",
|
|
184
|
-
width: nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)"),
|
|
185
|
-
height: "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")
|
|
186
|
-
}, isLayoutNode && {
|
|
187
|
-
top: isLeftPosition ? "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)") : 'unset',
|
|
188
|
-
bottom: isLeftPosition ? 'unset' : "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")
|
|
189
|
-
});
|
|
190
|
-
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, anchorName, isLeftPosition, nodeDimension]);
|
|
200
|
+
return _ref3 = {}, _defineProperty(_ref3, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), _defineProperty(_ref3, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref3;
|
|
201
|
+
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
|
|
191
202
|
var dropIndicatorPos = useMemo(function () {
|
|
192
203
|
return isLeftPosition ? 'right' : 'left';
|
|
193
204
|
}, [isLeftPosition]);
|
|
@@ -208,7 +219,10 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
208
219
|
return jsx("div", {
|
|
209
220
|
ref: ref,
|
|
210
221
|
"data-testid": "drop-target-hover-zone-".concat(position),
|
|
211
|
-
css: [hoverZoneCommonStyle,
|
|
222
|
+
css: [hoverZoneCommonStyle, isLeftPosition ? leftHoverZoneStyle : rightHoverZoneStyle]
|
|
223
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
224
|
+
,
|
|
225
|
+
style: hoverZoneRectStyle
|
|
212
226
|
}, isDraggedOver || isBlocksDragTargetDebug() ? jsx(DropIndicator, {
|
|
213
227
|
edge: dropIndicatorPos
|
|
214
228
|
}) : isActiveAnchor && jsx("div", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.31",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
44
|
-
"@atlaskit/icon": "^
|
|
44
|
+
"@atlaskit/icon": "^23.0.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
47
|
-
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^
|
|
47
|
+
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.0.0",
|
|
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.22.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.4.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.9.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|