@atlaskit/editor-plugin-block-controls 2.21.1 → 2.21.3
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 +17 -0
- package/dist/cjs/pm-plugins/decorations-drop-target.js +5 -5
- package/dist/cjs/ui/drag-handle.js +36 -2
- package/dist/cjs/ui/drop-target.js +204 -150
- package/dist/es2019/pm-plugins/decorations-drop-target.js +3 -3
- package/dist/es2019/ui/drag-handle.js +36 -2
- package/dist/es2019/ui/drop-target.js +199 -150
- package/dist/esm/pm-plugins/decorations-drop-target.js +3 -3
- package/dist/esm/ui/drag-handle.js +36 -2
- 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 +5 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.21.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#103498](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103498)
|
|
8
|
+
[`a2fd134b068cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a2fd134b068cd) -
|
|
9
|
+
[ED-26267] Fix a bug where when selection is across multiple nodes, dragging a drag handle within
|
|
10
|
+
the selection range does not trigger pragmatic DnD
|
|
11
|
+
|
|
12
|
+
## 2.21.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#103365](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103365)
|
|
17
|
+
[`fb69e4b7a2f59`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb69e4b7a2f59) -
|
|
18
|
+
ED-26243 Removed unused drop-target v1
|
|
19
|
+
|
|
3
20
|
## 2.21.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -14,8 +14,8 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
14
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
15
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
16
|
var _consts = require("../ui/consts");
|
|
17
|
+
var _dropTarget = require("../ui/drop-target");
|
|
17
18
|
var _dropTargetLayout = require("../ui/drop-target-layout");
|
|
18
|
-
var _dropTargetV = require("../ui/drop-target-v2");
|
|
19
19
|
var _decorationsCommon = require("./decorations-common");
|
|
20
20
|
var _consts2 = require("./utils/consts");
|
|
21
21
|
var _dragTargetDebug = require("./utils/drag-target-debug");
|
|
@@ -104,19 +104,19 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
104
104
|
var _getGapAndOffset = getGapAndOffset(props.prevNode, props.nextNode, props.parentNode),
|
|
105
105
|
gap = _getGapAndOffset.gap,
|
|
106
106
|
offset = _getGapAndOffset.offset;
|
|
107
|
-
element.style.setProperty(
|
|
108
|
-
element.style.setProperty(
|
|
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
109
|
element.style.setProperty('display', 'block');
|
|
110
110
|
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
111
111
|
nodeViewPortalProviderAPI.render(function () {
|
|
112
|
-
return /*#__PURE__*/(0, _react.createElement)(
|
|
112
|
+
return /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
113
113
|
getPos: getPos,
|
|
114
114
|
anchorRectCache: anchorRectCache,
|
|
115
115
|
isSameLayout: isSameLayout
|
|
116
116
|
}));
|
|
117
117
|
}, element, key);
|
|
118
118
|
} else {
|
|
119
|
-
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(
|
|
119
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
120
120
|
getPos: getPos,
|
|
121
121
|
anchorRectCache: anchorRectCache,
|
|
122
122
|
isSameLayout: isSameLayout
|
|
@@ -11,6 +11,7 @@ var _react = require("react");
|
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _bindEventListener = require("bind-event-listener");
|
|
13
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
14
15
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
16
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
16
17
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
@@ -19,6 +20,7 @@ var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-han
|
|
|
19
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
21
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
21
22
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
23
|
+
var _primitives = require("@atlaskit/primitives");
|
|
22
24
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
23
25
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
24
26
|
var _main = require("../pm-plugins/main");
|
|
@@ -34,6 +36,11 @@ var _dragPreview = require("./drag-preview");
|
|
|
34
36
|
|
|
35
37
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
36
38
|
|
|
39
|
+
var iconWrapperStyles = (0, _primitives.xcss)({
|
|
40
|
+
display: 'flex',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
alignItems: 'center'
|
|
43
|
+
});
|
|
37
44
|
var dragHandleButtonStyles = (0, _react2.css)({
|
|
38
45
|
position: 'absolute',
|
|
39
46
|
padding: "var(--ds-space-025, 2px)".concat(" 0"),
|
|
@@ -72,6 +79,27 @@ var selectedStyles = (0, _react2.css)({
|
|
|
72
79
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
73
80
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
74
81
|
});
|
|
82
|
+
|
|
83
|
+
// [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
|
|
84
|
+
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
85
|
+
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
86
|
+
var handleIconDragStart = function handleIconDragStart(e) {
|
|
87
|
+
if (!_browser.browser.chrome || !(0, _platformFeatureFlags.fg)('platform_editor_dnd_update_drag_start_target')) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// prevent dragStart handler triggered by icon
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
var dragEvent = new DragEvent('dragstart', {
|
|
93
|
+
bubbles: true,
|
|
94
|
+
cancelable: true,
|
|
95
|
+
dataTransfer: e.dataTransfer
|
|
96
|
+
});
|
|
97
|
+
if (e.target instanceof HTMLElement) {
|
|
98
|
+
var _e$target$closest;
|
|
99
|
+
// re-dispatch drag event on button so that pragmatic DnD can be triggered properly
|
|
100
|
+
(_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 || _e$target$closest.dispatchEvent(dragEvent);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
75
103
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
76
104
|
var _api$core2, _api$analytics2, _api$core4;
|
|
77
105
|
var view = _ref.view,
|
|
@@ -411,10 +439,16 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
411
439
|
onMouseDown: handleMouseDown,
|
|
412
440
|
onKeyDown: handleKeyDown,
|
|
413
441
|
"data-testid": "block-ctrl-drag-handle"
|
|
414
|
-
}, (0, _react2.jsx)(
|
|
442
|
+
}, (0, _react2.jsx)(_primitives.Box, {
|
|
443
|
+
as: "span",
|
|
444
|
+
xcss: iconWrapperStyles
|
|
445
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
446
|
+
,
|
|
447
|
+
onDragStart: handleIconDragStart
|
|
448
|
+
}, ' ', (0, _react2.jsx)(_dragHandler.default, {
|
|
415
449
|
label: "",
|
|
416
450
|
size: "medium"
|
|
417
|
-
}))
|
|
451
|
+
})))
|
|
418
452
|
);
|
|
419
453
|
};
|
|
420
454
|
return (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') ? (0, _react2.jsx)(_tooltip.default, {
|
|
@@ -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
|
};
|
|
@@ -6,8 +6,8 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
8
|
import { nodeMargins } from '../ui/consts';
|
|
9
|
+
import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
|
|
9
10
|
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
10
|
-
import { DropTargetV2, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target-v2';
|
|
11
11
|
import { getNestedDepth, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
|
|
12
12
|
import { maxLayoutColumnSupported } from './utils/consts';
|
|
13
13
|
import { isBlocksDragTargetDebug } from './utils/drag-target-debug';
|
|
@@ -97,14 +97,14 @@ export const createDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI
|
|
|
97
97
|
element.style.setProperty(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, `${gap}px`);
|
|
98
98
|
element.style.setProperty('display', 'block');
|
|
99
99
|
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
100
|
-
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(
|
|
100
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTarget, {
|
|
101
101
|
...props,
|
|
102
102
|
getPos,
|
|
103
103
|
anchorRectCache,
|
|
104
104
|
isSameLayout
|
|
105
105
|
}), element, key);
|
|
106
106
|
} else {
|
|
107
|
-
ReactDOM.render( /*#__PURE__*/createElement(
|
|
107
|
+
ReactDOM.render( /*#__PURE__*/createElement(DropTarget, {
|
|
108
108
|
...props,
|
|
109
109
|
getPos,
|
|
110
110
|
anchorRectCache,
|
|
@@ -7,6 +7,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import { bind } from 'bind-event-listener';
|
|
9
9
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
10
|
+
import { browser } from '@atlaskit/editor-common/browser';
|
|
10
11
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
12
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
12
13
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -15,6 +16,7 @@ import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
17
18
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
19
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
18
20
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
21
|
import Tooltip from '@atlaskit/tooltip';
|
|
20
22
|
import { key } from '../pm-plugins/main';
|
|
@@ -23,6 +25,11 @@ import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition
|
|
|
23
25
|
import { selectNode } from '../pm-plugins/utils/getSelection';
|
|
24
26
|
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, topPositionAdjustment } from './consts';
|
|
25
27
|
import { dragPreview } from './drag-preview';
|
|
28
|
+
const iconWrapperStyles = xcss({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
alignItems: 'center'
|
|
32
|
+
});
|
|
26
33
|
const dragHandleButtonStyles = css({
|
|
27
34
|
position: 'absolute',
|
|
28
35
|
padding: `${"var(--ds-space-025, 2px)"} 0`,
|
|
@@ -61,6 +68,27 @@ const selectedStyles = css({
|
|
|
61
68
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
62
69
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
63
70
|
});
|
|
71
|
+
|
|
72
|
+
// [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
|
|
73
|
+
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
74
|
+
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
75
|
+
const handleIconDragStart = e => {
|
|
76
|
+
if (!browser.chrome || !fg('platform_editor_dnd_update_drag_start_target')) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// prevent dragStart handler triggered by icon
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
const dragEvent = new DragEvent('dragstart', {
|
|
82
|
+
bubbles: true,
|
|
83
|
+
cancelable: true,
|
|
84
|
+
dataTransfer: e.dataTransfer
|
|
85
|
+
});
|
|
86
|
+
if (e.target instanceof HTMLElement) {
|
|
87
|
+
var _e$target$closest;
|
|
88
|
+
// re-dispatch drag event on button so that pragmatic DnD can be triggered properly
|
|
89
|
+
(_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.dispatchEvent(dragEvent);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
64
92
|
export const DragHandle = ({
|
|
65
93
|
view,
|
|
66
94
|
api,
|
|
@@ -390,10 +418,16 @@ export const DragHandle = ({
|
|
|
390
418
|
onMouseDown: handleMouseDown,
|
|
391
419
|
onKeyDown: handleKeyDown,
|
|
392
420
|
"data-testid": "block-ctrl-drag-handle"
|
|
393
|
-
}, jsx(
|
|
421
|
+
}, jsx(Box, {
|
|
422
|
+
as: "span",
|
|
423
|
+
xcss: iconWrapperStyles
|
|
424
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
425
|
+
,
|
|
426
|
+
onDragStart: handleIconDragStart
|
|
427
|
+
}, ' ', jsx(DragHandlerIcon, {
|
|
394
428
|
label: "",
|
|
395
429
|
size: "medium"
|
|
396
|
-
}));
|
|
430
|
+
})));
|
|
397
431
|
return fg('platform_editor_element_drag_and_drop_ed_23873') ? jsx(Tooltip, {
|
|
398
432
|
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
399
433
|
helpDescriptors: helpDescriptors
|