@atlaskit/editor-plugin-block-controls 2.10.1 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/pm-plugins/decorations-anchor.js +6 -8
- package/dist/cjs/pm-plugins/decorations-drop-target.js +32 -5
- package/dist/cjs/ui/drop-target-layout.js +79 -0
- package/dist/cjs/ui/global-styles.js +101 -86
- package/dist/es2019/pm-plugins/decorations-anchor.js +6 -8
- package/dist/es2019/pm-plugins/decorations-drop-target.js +28 -0
- package/dist/es2019/ui/drop-target-layout.js +71 -0
- package/dist/es2019/ui/global-styles.js +17 -6
- package/dist/esm/pm-plugins/decorations-anchor.js +6 -8
- package/dist/esm/pm-plugins/decorations-drop-target.js +27 -0
- package/dist/esm/ui/drop-target-layout.js +72 -0
- package/dist/esm/ui/global-styles.js +101 -86
- package/dist/types/pm-plugins/decorations-drop-target.d.ts +2 -0
- package/dist/types/ui/drop-target-layout.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/decorations-drop-target.d.ts +2 -0
- package/dist/types-ts4.5/ui/drop-target-layout.d.ts +10 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#157523](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/157523)
|
|
8
|
+
[`0ae18423289a5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0ae18423289a5) -
|
|
9
|
+
ED-25289 implement drop zone in between columns
|
|
10
|
+
|
|
11
|
+
## 2.11.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#156360](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/156360)
|
|
16
|
+
[`482dbb03dbf68`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/482dbb03dbf68) -
|
|
17
|
+
[ux] Ignore embedCard nodes that have wrapped layout when creating node decs
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 2.10.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -23,13 +23,11 @@ var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDesce
|
|
|
23
23
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
24
24
|
};
|
|
25
25
|
var shouldIgnoreNode = function shouldIgnoreNode(node) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return IGNORE_NODES.includes(node.type.name);
|
|
26
|
+
var isEmbedCard = 'embedCard' === node.type.name && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3');
|
|
27
|
+
|
|
28
|
+
// TODO use isWrappedMedia when clean up the feature flag
|
|
29
|
+
var isMediaSingle = 'mediaSingle' === node.type.name && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1');
|
|
30
|
+
return (isEmbedCard || isMediaSingle) && ['wrap-right', 'wrap-left'].includes(node.attrs.layout) ? true : IGNORE_NODES.includes(node.type.name);
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
/**
|
|
@@ -87,7 +85,7 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
87
85
|
anchorName = (_anchorName2 = anchorName) !== null && _anchorName2 !== void 0 ? _anchorName2 : "--node-anchor-".concat(node.type.name, "-").concat(index);
|
|
88
86
|
}
|
|
89
87
|
decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (_Decoration$node = {
|
|
90
|
-
style: "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "
|
|
88
|
+
style: "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', " ").concat((0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? '' : 'position: relative; z-index: 1;')
|
|
91
89
|
}, (0, _defineProperty2.default)(_Decoration$node, 'data-drag-handler-anchor-name', anchorName), (0, _defineProperty2.default)(_Decoration$node, 'data-drag-handler-node-type', node.type.name), (0, _defineProperty2.default)(_Decoration$node, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node), {
|
|
92
90
|
type: _decorationsCommon.TYPE_NODE_DEC,
|
|
93
91
|
anchorName: anchorName,
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.findDropTargetDecs = exports.dropTargetDecorations = exports.createDropTargetDecoration = void 0;
|
|
7
|
+
exports.findDropTargetDecs = exports.dropTargetDecorations = exports.createLayoutDropTargetDecoration = exports.createDropTargetDecoration = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
@@ -12,9 +12,12 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
12
12
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
13
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
|
-
var _consts = require("../
|
|
15
|
+
var _consts = require("../consts");
|
|
16
|
+
var _consts2 = require("../ui/consts");
|
|
16
17
|
var _dropTarget = require("../ui/drop-target");
|
|
18
|
+
var _dropTargetLayout = require("../ui/drop-target-layout");
|
|
17
19
|
var _dropTargetV = require("../ui/drop-target-v2");
|
|
20
|
+
var _advancedLayoutsFlags = require("../utils/advanced-layouts-flags");
|
|
18
21
|
var _dragTargetDebug = require("../utils/drag-target-debug");
|
|
19
22
|
var _validation = require("../utils/validation");
|
|
20
23
|
var _decorationsCommon = require("./decorations-common");
|
|
@@ -31,13 +34,13 @@ var shouldDescend = function shouldDescend(node) {
|
|
|
31
34
|
};
|
|
32
35
|
var getNodeMargins = function getNodeMargins(node) {
|
|
33
36
|
if (!node) {
|
|
34
|
-
return
|
|
37
|
+
return _consts2.nodeMargins['default'];
|
|
35
38
|
}
|
|
36
39
|
var nodeTypeName = node.type.name;
|
|
37
40
|
if (nodeTypeName === 'heading') {
|
|
38
|
-
return
|
|
41
|
+
return _consts2.nodeMargins["heading".concat(node.attrs.level)] || _consts2.nodeMargins['default'];
|
|
39
42
|
}
|
|
40
|
-
return
|
|
43
|
+
return _consts2.nodeMargins[nodeTypeName] || _consts2.nodeMargins['default'];
|
|
41
44
|
};
|
|
42
45
|
var shouldCollapseMargin = function shouldCollapseMargin(prevNode, nextNode) {
|
|
43
46
|
if (((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) === 'mediaSingle' || (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'mediaSingle') && (prevNode === null || prevNode === void 0 ? void 0 : prevNode.type.name) !== (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name)) {
|
|
@@ -112,6 +115,19 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
112
115
|
side: side
|
|
113
116
|
});
|
|
114
117
|
};
|
|
118
|
+
var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props) {
|
|
119
|
+
return _view.Decoration.widget(pos, function (_, getPos) {
|
|
120
|
+
var element = document.createElement('div');
|
|
121
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
122
|
+
element.style.clear = 'unset';
|
|
123
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetLayout.DropTargetLayout, _objectSpread(_objectSpread({}, props), {}, {
|
|
124
|
+
getPos: getPos
|
|
125
|
+
})), element);
|
|
126
|
+
return element;
|
|
127
|
+
}, {
|
|
128
|
+
type: _decorationsCommon.TYPE_DROP_TARGET_DEC
|
|
129
|
+
});
|
|
130
|
+
};
|
|
115
131
|
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, activeNode, anchorRectCache, from, to) {
|
|
116
132
|
(0, _decorationsCommon.unmountDecorations)('data-blocks-drop-target-container');
|
|
117
133
|
var decs = [];
|
|
@@ -135,12 +151,23 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
135
151
|
popNodeStack(depth);
|
|
136
152
|
prevNodeStack.push(node);
|
|
137
153
|
};
|
|
154
|
+
var isAdvancedLayoutsPreRelease2 = (0, _advancedLayoutsFlags.isPreRelease2)();
|
|
138
155
|
newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
|
|
139
156
|
var depth = 0;
|
|
140
157
|
// drop target deco at the end position
|
|
141
158
|
var endPos;
|
|
142
159
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
143
160
|
depth = newState.doc.resolve(pos).depth;
|
|
161
|
+
if (isAdvancedLayoutsPreRelease2) {
|
|
162
|
+
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
|
|
163
|
+
// Not the first node
|
|
164
|
+
(parent === null || parent === void 0 ? void 0 : parent.childCount) < _consts.MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
165
|
+
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
166
|
+
api: api,
|
|
167
|
+
formatMessage: formatMessage
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
144
171
|
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
145
172
|
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
146
173
|
pushNodeStack(node, depth);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DropTargetLayout = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
12
|
+
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
13
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
14
|
+
var _dragTargetDebug = require("../utils/drag-target-debug");
|
|
15
|
+
/**
|
|
16
|
+
* @jsxRuntime classic
|
|
17
|
+
* @jsx jsx
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
21
|
+
|
|
22
|
+
// 8px gap + 16px on left and right
|
|
23
|
+
var DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH = 40;
|
|
24
|
+
var dropTargetLayoutStyle = (0, _react2.css)({
|
|
25
|
+
height: '100%',
|
|
26
|
+
width: "".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px"),
|
|
27
|
+
transform: 'translateX(-50%)',
|
|
28
|
+
zIndex: 120,
|
|
29
|
+
position: 'relative',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'center'
|
|
32
|
+
});
|
|
33
|
+
var dropTargetLayoutHintStyle = (0, _react2.css)({
|
|
34
|
+
height: '100%',
|
|
35
|
+
position: 'relative',
|
|
36
|
+
borderRight: "1px dashed ".concat("var(--ds-background-selected-hovered, ".concat(_colors.B75, ")")),
|
|
37
|
+
width: 0
|
|
38
|
+
});
|
|
39
|
+
var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(props) {
|
|
40
|
+
var _api$blockControls2;
|
|
41
|
+
var api = props.api;
|
|
42
|
+
var ref = (0, _react.useRef)(null);
|
|
43
|
+
var _useState = (0, _react.useState)(false),
|
|
44
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
45
|
+
isDraggedOver = _useState2[0],
|
|
46
|
+
setIsDraggedOver = _useState2[1];
|
|
47
|
+
var onDrop = (0, _react.useCallback)(function () {
|
|
48
|
+
var _api$blockControls;
|
|
49
|
+
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
50
|
+
activeNode = _ref.activeNode;
|
|
51
|
+
if (!activeNode) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}, [api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState]);
|
|
55
|
+
(0, _react.useEffect)(function () {
|
|
56
|
+
if (ref.current) {
|
|
57
|
+
return (0, _adapter.dropTargetForElements)({
|
|
58
|
+
element: ref.current,
|
|
59
|
+
onDragEnter: function onDragEnter() {
|
|
60
|
+
setIsDraggedOver(true);
|
|
61
|
+
},
|
|
62
|
+
onDragLeave: function onDragLeave() {
|
|
63
|
+
setIsDraggedOver(false);
|
|
64
|
+
},
|
|
65
|
+
onDrop: onDrop
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [onDrop]);
|
|
69
|
+
return (0, _react2.jsx)("div", {
|
|
70
|
+
ref: ref,
|
|
71
|
+
css: dropTargetLayoutStyle,
|
|
72
|
+
"data-testid": "block-ctrl-drop-indicator"
|
|
73
|
+
}, isDraggedOver || (0, _dragTargetDebug.isBlocksDragTargetDebug)() ? (0, _react2.jsx)(_box.DropIndicator, {
|
|
74
|
+
edge: "right",
|
|
75
|
+
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
76
|
+
}) : (0, _react2.jsx)("div", {
|
|
77
|
+
css: dropTargetLayoutHintStyle
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
@@ -17,94 +17,100 @@ var _globalStyles = require("./empty-block-experiment/global-styles");
|
|
|
17
17
|
*/
|
|
18
18
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
19
19
|
|
|
20
|
-
var extendedHoverZone = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
var extendedHoverZone = function extendedHoverZone() {
|
|
21
|
+
return (0, _react.css)({
|
|
22
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
23
|
+
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
24
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
25
|
+
display: 'none !important'
|
|
26
|
+
},
|
|
27
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
28
|
+
'.ProseMirror': {
|
|
29
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
30
|
+
'&& [data-drag-handler-anchor-name]::after': {
|
|
31
|
+
content: '""',
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
top: 0,
|
|
34
|
+
left: '-100%',
|
|
35
|
+
width: '100%',
|
|
36
|
+
height: '100%',
|
|
37
|
+
background: 'transparent',
|
|
38
|
+
cursor: 'default',
|
|
39
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
40
|
+
zIndex: (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
44
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
45
|
+
'hr[data-drag-handler-anchor-name]': {
|
|
46
|
+
overflow: 'visible'
|
|
47
|
+
},
|
|
48
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
49
|
+
'[data-blocks-drag-handle-container="true"] + *::after': {
|
|
50
|
+
display: 'none'
|
|
39
51
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
display: 'none'
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
var extendedHoverZoneNested = (0, _react.css)({
|
|
52
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
53
|
-
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
54
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
55
|
-
display: 'none !important'
|
|
56
|
-
},
|
|
57
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
58
|
-
'.ProseMirror': {
|
|
59
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
60
|
-
'&& [data-drag-handler-anchor-name]::after': {
|
|
61
|
-
content: '""',
|
|
62
|
-
position: 'absolute',
|
|
63
|
-
top: 0,
|
|
64
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
65
|
-
left: "-".concat(_consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
66
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
67
|
-
width: "".concat(_consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
68
|
-
height: '100%',
|
|
69
|
-
cursor: 'default',
|
|
70
|
-
zIndex: 1
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var extendedHoverZoneNested = function extendedHoverZoneNested() {
|
|
55
|
+
return (0, _react.css)({
|
|
56
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
57
|
+
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
58
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
59
|
+
display: 'none !important'
|
|
71
60
|
},
|
|
72
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
73
|
-
'
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
61
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
62
|
+
'.ProseMirror': {
|
|
63
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
64
|
+
'&& [data-drag-handler-anchor-name]::after': {
|
|
65
|
+
content: '""',
|
|
66
|
+
position: 'absolute',
|
|
67
|
+
top: 0,
|
|
68
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
69
|
+
left: "-".concat(_consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
70
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
71
|
+
width: "".concat(_consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
72
|
+
height: '100%',
|
|
73
|
+
cursor: 'default',
|
|
74
|
+
zIndex: 1
|
|
75
|
+
},
|
|
76
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
77
|
+
'&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
|
|
78
|
+
content: '""',
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
top: 0,
|
|
81
|
+
left: '-100%',
|
|
82
|
+
width: '100%',
|
|
83
|
+
height: '100%',
|
|
84
|
+
cursor: 'default',
|
|
85
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
86
|
+
zIndex: (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
|
|
87
|
+
},
|
|
88
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
89
|
+
'&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
|
|
90
|
+
content: '""',
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
top: 0,
|
|
93
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
94
|
+
left: "-".concat((0, _experiments.editorExperiment)('table-nested-dnd', true) ? _consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
|
|
95
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
96
|
+
width: "".concat((0, _experiments.editorExperiment)('table-nested-dnd', true) ? _consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
|
|
97
|
+
height: '100%',
|
|
98
|
+
cursor: 'default',
|
|
99
|
+
zIndex: 1
|
|
100
|
+
}
|
|
82
101
|
},
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
height: '100%',
|
|
93
|
-
cursor: 'default',
|
|
94
|
-
zIndex: 1
|
|
102
|
+
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
103
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
104
|
+
'hr[data-drag-handler-anchor-name]': {
|
|
105
|
+
overflow: 'visible'
|
|
106
|
+
},
|
|
107
|
+
//Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
|
|
108
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
109
|
+
'[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
|
|
110
|
+
display: 'none'
|
|
95
111
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
99
|
-
'hr[data-drag-handler-anchor-name]': {
|
|
100
|
-
overflow: 'visible'
|
|
101
|
-
},
|
|
102
|
-
//Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
|
|
103
|
-
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
104
|
-
'[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
|
|
105
|
-
display: 'none'
|
|
106
|
-
}
|
|
107
|
-
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
108
114
|
var paragraphWithTrailingBreakAsOnlyChild = '+ :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
109
115
|
var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-indentation-mark > :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
110
116
|
var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
@@ -157,10 +163,19 @@ var withFormatInLayoutStyleFix = (0, _react.css)((0, _defineProperty2.default)({
|
|
|
157
163
|
var getTextNodeStyle = function getTextNodeStyle() {
|
|
158
164
|
return (0, _platformFeatureFlags.fg)('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
159
165
|
};
|
|
166
|
+
var withRelativePosStyle = (0, _react.css)({
|
|
167
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
168
|
+
'.ProseMirror': {
|
|
169
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
170
|
+
'&& [data-drag-handler-anchor-name]': {
|
|
171
|
+
position: 'relative'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
160
175
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
161
176
|
return (0, _react.jsx)(_react.Global, {
|
|
162
|
-
styles: [globalStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, (0, _experiments.editorExperiment)('platform_editor_empty_line_prompt', true, {
|
|
177
|
+
styles: [globalStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, (0, _experiments.editorExperiment)('platform_editor_empty_line_prompt', true, {
|
|
163
178
|
exposure: false
|
|
164
|
-
}) ? _globalStyles.emptyBlockExperimentGlobalStyles : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
|
|
179
|
+
}) ? _globalStyles.emptyBlockExperimentGlobalStyles : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? withRelativePosStyle : undefined]
|
|
165
180
|
});
|
|
166
181
|
};
|
|
@@ -15,13 +15,11 @@ export const shouldDescendIntoNode = node => {
|
|
|
15
15
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
16
16
|
};
|
|
17
17
|
const shouldIgnoreNode = node => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
return IGNORE_NODES.includes(node.type.name);
|
|
18
|
+
const isEmbedCard = 'embedCard' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_3');
|
|
19
|
+
|
|
20
|
+
// TODO use isWrappedMedia when clean up the feature flag
|
|
21
|
+
const isMediaSingle = 'mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1');
|
|
22
|
+
return (isEmbedCard || isMediaSingle) && ['wrap-right', 'wrap-left'].includes(node.attrs.layout) ? true : IGNORE_NODES.includes(node.type.name);
|
|
25
23
|
};
|
|
26
24
|
|
|
27
25
|
/**
|
|
@@ -76,7 +74,7 @@ export const nodeDecorations = (newState, from, to) => {
|
|
|
76
74
|
anchorName = (_anchorName2 = anchorName) !== null && _anchorName2 !== void 0 ? _anchorName2 : `--node-anchor-${node.type.name}-${index}`;
|
|
77
75
|
}
|
|
78
76
|
decs.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
79
|
-
style: `anchor-name: ${anchorName}; ${pos === 0 ? 'margin-top: 0px;' : ''}
|
|
77
|
+
style: `anchor-name: ${anchorName}; ${pos === 0 ? 'margin-top: 0px;' : ''} ${fg('platform_editor_element_dnd_nested_fix_patch_3') ? '' : 'position: relative; z-index: 1;'}`,
|
|
80
78
|
['data-drag-handler-anchor-name']: anchorName,
|
|
81
79
|
['data-drag-handler-node-type']: node.type.name,
|
|
82
80
|
['data-drag-handler-anchor-depth']: `${depth}`
|
|
@@ -4,9 +4,12 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
|
+
import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
|
|
7
8
|
import { nodeMargins } from '../ui/consts';
|
|
8
9
|
import { DropTarget } from '../ui/drop-target';
|
|
10
|
+
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
9
11
|
import { DropTargetV2, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target-v2';
|
|
12
|
+
import { isPreRelease2 } from '../utils/advanced-layouts-flags';
|
|
10
13
|
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
11
14
|
import { canMoveNodeToIndex } from '../utils/validation';
|
|
12
15
|
import { getNestedDepth, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
|
|
@@ -103,6 +106,20 @@ export const createDropTargetDecoration = (pos, props, side, anchorRectCache) =>
|
|
|
103
106
|
side
|
|
104
107
|
});
|
|
105
108
|
};
|
|
109
|
+
export const createLayoutDropTargetDecoration = (pos, props) => {
|
|
110
|
+
return Decoration.widget(pos, (_, getPos) => {
|
|
111
|
+
const element = document.createElement('div');
|
|
112
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
113
|
+
element.style.clear = 'unset';
|
|
114
|
+
ReactDOM.render( /*#__PURE__*/createElement(DropTargetLayout, {
|
|
115
|
+
...props,
|
|
116
|
+
getPos
|
|
117
|
+
}), element);
|
|
118
|
+
return element;
|
|
119
|
+
}, {
|
|
120
|
+
type: TYPE_DROP_TARGET_DEC
|
|
121
|
+
});
|
|
122
|
+
};
|
|
106
123
|
export const dropTargetDecorations = (newState, api, formatMessage, activeNode, anchorRectCache, from, to) => {
|
|
107
124
|
unmountDecorations('data-blocks-drop-target-container');
|
|
108
125
|
const decs = [];
|
|
@@ -126,12 +143,23 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
|
|
|
126
143
|
popNodeStack(depth);
|
|
127
144
|
prevNodeStack.push(node);
|
|
128
145
|
};
|
|
146
|
+
const isAdvancedLayoutsPreRelease2 = isPreRelease2();
|
|
129
147
|
newState.doc.nodesBetween(docFrom, docTo, (node, pos, parent, index) => {
|
|
130
148
|
let depth = 0;
|
|
131
149
|
// drop target deco at the end position
|
|
132
150
|
let endPos;
|
|
133
151
|
if (editorExperiment('nested-dnd', true)) {
|
|
134
152
|
depth = newState.doc.resolve(pos).depth;
|
|
153
|
+
if (isAdvancedLayoutsPreRelease2) {
|
|
154
|
+
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
|
|
155
|
+
// Not the first node
|
|
156
|
+
(parent === null || parent === void 0 ? void 0 : parent.childCount) < MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
157
|
+
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
158
|
+
api,
|
|
159
|
+
formatMessage
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
135
163
|
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
136
164
|
if (fg('platform_editor_drag_and_drop_target_v2')) {
|
|
137
165
|
pushNodeStack(node, depth);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
8
|
+
import { css, jsx } from '@emotion/react';
|
|
9
|
+
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
10
|
+
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
11
|
+
import { B75 } from '@atlaskit/theme/colors';
|
|
12
|
+
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
13
|
+
|
|
14
|
+
// 8px gap + 16px on left and right
|
|
15
|
+
const DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH = 40;
|
|
16
|
+
const dropTargetLayoutStyle = css({
|
|
17
|
+
height: '100%',
|
|
18
|
+
width: `${DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH}px`,
|
|
19
|
+
transform: 'translateX(-50%)',
|
|
20
|
+
zIndex: 120,
|
|
21
|
+
position: 'relative',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
justifyContent: 'center'
|
|
24
|
+
});
|
|
25
|
+
const dropTargetLayoutHintStyle = css({
|
|
26
|
+
height: '100%',
|
|
27
|
+
position: 'relative',
|
|
28
|
+
borderRight: `1px dashed ${`var(--ds-background-selected-hovered, ${B75})`}`,
|
|
29
|
+
width: 0
|
|
30
|
+
});
|
|
31
|
+
export const DropTargetLayout = props => {
|
|
32
|
+
var _api$blockControls2;
|
|
33
|
+
const {
|
|
34
|
+
api
|
|
35
|
+
} = props;
|
|
36
|
+
const ref = useRef(null);
|
|
37
|
+
const [isDraggedOver, setIsDraggedOver] = useState(false);
|
|
38
|
+
const onDrop = useCallback(() => {
|
|
39
|
+
var _api$blockControls;
|
|
40
|
+
const {
|
|
41
|
+
activeNode
|
|
42
|
+
} = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
|
|
43
|
+
if (!activeNode) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}, [api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (ref.current) {
|
|
49
|
+
return dropTargetForElements({
|
|
50
|
+
element: ref.current,
|
|
51
|
+
onDragEnter: () => {
|
|
52
|
+
setIsDraggedOver(true);
|
|
53
|
+
},
|
|
54
|
+
onDragLeave: () => {
|
|
55
|
+
setIsDraggedOver(false);
|
|
56
|
+
},
|
|
57
|
+
onDrop
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, [onDrop]);
|
|
61
|
+
return jsx("div", {
|
|
62
|
+
ref: ref,
|
|
63
|
+
css: dropTargetLayoutStyle,
|
|
64
|
+
"data-testid": "block-ctrl-drop-indicator"
|
|
65
|
+
}, isDraggedOver || isBlocksDragTargetDebug() ? jsx(DropIndicator, {
|
|
66
|
+
edge: "right",
|
|
67
|
+
gap: `-${DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH}px`
|
|
68
|
+
}) : jsx("div", {
|
|
69
|
+
css: dropTargetLayoutHintStyle
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
@@ -8,7 +8,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
8
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
9
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
|
|
10
10
|
import { emptyBlockExperimentGlobalStyles } from './empty-block-experiment/global-styles';
|
|
11
|
-
const extendedHoverZone = css({
|
|
11
|
+
const extendedHoverZone = () => css({
|
|
12
12
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
13
13
|
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
14
14
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
@@ -26,7 +26,8 @@ const extendedHoverZone = css({
|
|
|
26
26
|
height: '100%',
|
|
27
27
|
background: 'transparent',
|
|
28
28
|
cursor: 'default',
|
|
29
|
-
|
|
29
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
30
|
+
zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
|
|
30
31
|
}
|
|
31
32
|
},
|
|
32
33
|
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
@@ -39,7 +40,7 @@ const extendedHoverZone = css({
|
|
|
39
40
|
display: 'none'
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
|
-
const extendedHoverZoneNested = css({
|
|
43
|
+
const extendedHoverZoneNested = () => css({
|
|
43
44
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
44
45
|
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
45
46
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
@@ -69,7 +70,8 @@ const extendedHoverZoneNested = css({
|
|
|
69
70
|
width: '100%',
|
|
70
71
|
height: '100%',
|
|
71
72
|
cursor: 'default',
|
|
72
|
-
|
|
73
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
74
|
+
zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
|
|
73
75
|
},
|
|
74
76
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
75
77
|
'&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
|
|
@@ -166,10 +168,19 @@ const withFormatInLayoutStyleFix = css({
|
|
|
166
168
|
const getTextNodeStyle = () => {
|
|
167
169
|
return fg('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
168
170
|
};
|
|
171
|
+
const withRelativePosStyle = css({
|
|
172
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
173
|
+
'.ProseMirror': {
|
|
174
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
175
|
+
'&& [data-drag-handler-anchor-name]': {
|
|
176
|
+
position: 'relative'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
169
180
|
export const GlobalStylesWrapper = () => {
|
|
170
181
|
return jsx(Global, {
|
|
171
|
-
styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
|
|
182
|
+
styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
|
|
172
183
|
exposure: false
|
|
173
|
-
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
|
|
184
|
+
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? withRelativePosStyle : undefined]
|
|
174
185
|
});
|
|
175
186
|
};
|
|
@@ -16,13 +16,11 @@ export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
|
16
16
|
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
17
17
|
};
|
|
18
18
|
var shouldIgnoreNode = function shouldIgnoreNode(node) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return IGNORE_NODES.includes(node.type.name);
|
|
19
|
+
var isEmbedCard = 'embedCard' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_3');
|
|
20
|
+
|
|
21
|
+
// TODO use isWrappedMedia when clean up the feature flag
|
|
22
|
+
var isMediaSingle = 'mediaSingle' === node.type.name && fg('platform_editor_element_dnd_nested_fix_patch_1');
|
|
23
|
+
return (isEmbedCard || isMediaSingle) && ['wrap-right', 'wrap-left'].includes(node.attrs.layout) ? true : IGNORE_NODES.includes(node.type.name);
|
|
26
24
|
};
|
|
27
25
|
|
|
28
26
|
/**
|
|
@@ -80,7 +78,7 @@ export var nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
|
80
78
|
anchorName = (_anchorName2 = anchorName) !== null && _anchorName2 !== void 0 ? _anchorName2 : "--node-anchor-".concat(node.type.name, "-").concat(index);
|
|
81
79
|
}
|
|
82
80
|
decs.push(Decoration.node(pos, pos + node.nodeSize, (_Decoration$node = {
|
|
83
|
-
style: "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "
|
|
81
|
+
style: "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', " ").concat(fg('platform_editor_element_dnd_nested_fix_patch_3') ? '' : 'position: relative; z-index: 1;')
|
|
84
82
|
}, _defineProperty(_Decoration$node, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node, 'data-drag-handler-node-type', node.type.name), _defineProperty(_Decoration$node, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node), {
|
|
85
83
|
type: TYPE_NODE_DEC,
|
|
86
84
|
anchorName: anchorName,
|
|
@@ -7,9 +7,12 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
7
7
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
|
+
import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
|
|
10
11
|
import { nodeMargins } from '../ui/consts';
|
|
11
12
|
import { DropTarget } from '../ui/drop-target';
|
|
13
|
+
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
12
14
|
import { DropTargetV2, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target-v2';
|
|
15
|
+
import { isPreRelease2 } from '../utils/advanced-layouts-flags';
|
|
13
16
|
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
14
17
|
import { canMoveNodeToIndex } from '../utils/validation';
|
|
15
18
|
import { getNestedDepth, TYPE_DROP_TARGET_DEC, unmountDecorations } from './decorations-common';
|
|
@@ -105,6 +108,19 @@ export var createDropTargetDecoration = function createDropTargetDecoration(pos,
|
|
|
105
108
|
side: side
|
|
106
109
|
});
|
|
107
110
|
};
|
|
111
|
+
export var createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props) {
|
|
112
|
+
return Decoration.widget(pos, function (_, getPos) {
|
|
113
|
+
var element = document.createElement('div');
|
|
114
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
115
|
+
element.style.clear = 'unset';
|
|
116
|
+
ReactDOM.render( /*#__PURE__*/createElement(DropTargetLayout, _objectSpread(_objectSpread({}, props), {}, {
|
|
117
|
+
getPos: getPos
|
|
118
|
+
})), element);
|
|
119
|
+
return element;
|
|
120
|
+
}, {
|
|
121
|
+
type: TYPE_DROP_TARGET_DEC
|
|
122
|
+
});
|
|
123
|
+
};
|
|
108
124
|
export var dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, activeNode, anchorRectCache, from, to) {
|
|
109
125
|
unmountDecorations('data-blocks-drop-target-container');
|
|
110
126
|
var decs = [];
|
|
@@ -128,12 +144,23 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
128
144
|
popNodeStack(depth);
|
|
129
145
|
prevNodeStack.push(node);
|
|
130
146
|
};
|
|
147
|
+
var isAdvancedLayoutsPreRelease2 = isPreRelease2();
|
|
131
148
|
newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
|
|
132
149
|
var depth = 0;
|
|
133
150
|
// drop target deco at the end position
|
|
134
151
|
var endPos;
|
|
135
152
|
if (editorExperiment('nested-dnd', true)) {
|
|
136
153
|
depth = newState.doc.resolve(pos).depth;
|
|
154
|
+
if (isAdvancedLayoutsPreRelease2) {
|
|
155
|
+
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
|
|
156
|
+
// Not the first node
|
|
157
|
+
(parent === null || parent === void 0 ? void 0 : parent.childCount) < MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
158
|
+
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
159
|
+
api: api,
|
|
160
|
+
formatMessage: formatMessage
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
137
164
|
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
138
165
|
if (fg('platform_editor_drag_and_drop_target_v2')) {
|
|
139
166
|
pushNodeStack(node, depth);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
9
|
+
import { css, jsx } from '@emotion/react';
|
|
10
|
+
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
11
|
+
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
12
|
+
import { B75 } from '@atlaskit/theme/colors';
|
|
13
|
+
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
14
|
+
|
|
15
|
+
// 8px gap + 16px on left and right
|
|
16
|
+
var DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH = 40;
|
|
17
|
+
var dropTargetLayoutStyle = css({
|
|
18
|
+
height: '100%',
|
|
19
|
+
width: "".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px"),
|
|
20
|
+
transform: 'translateX(-50%)',
|
|
21
|
+
zIndex: 120,
|
|
22
|
+
position: 'relative',
|
|
23
|
+
display: 'flex',
|
|
24
|
+
justifyContent: 'center'
|
|
25
|
+
});
|
|
26
|
+
var dropTargetLayoutHintStyle = css({
|
|
27
|
+
height: '100%',
|
|
28
|
+
position: 'relative',
|
|
29
|
+
borderRight: "1px dashed ".concat("var(--ds-background-selected-hovered, ".concat(B75, ")")),
|
|
30
|
+
width: 0
|
|
31
|
+
});
|
|
32
|
+
export var DropTargetLayout = function DropTargetLayout(props) {
|
|
33
|
+
var _api$blockControls2;
|
|
34
|
+
var api = props.api;
|
|
35
|
+
var ref = useRef(null);
|
|
36
|
+
var _useState = useState(false),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
isDraggedOver = _useState2[0],
|
|
39
|
+
setIsDraggedOver = _useState2[1];
|
|
40
|
+
var onDrop = useCallback(function () {
|
|
41
|
+
var _api$blockControls;
|
|
42
|
+
var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
|
|
43
|
+
activeNode = _ref.activeNode;
|
|
44
|
+
if (!activeNode) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}, [api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.sharedState]);
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
if (ref.current) {
|
|
50
|
+
return dropTargetForElements({
|
|
51
|
+
element: ref.current,
|
|
52
|
+
onDragEnter: function onDragEnter() {
|
|
53
|
+
setIsDraggedOver(true);
|
|
54
|
+
},
|
|
55
|
+
onDragLeave: function onDragLeave() {
|
|
56
|
+
setIsDraggedOver(false);
|
|
57
|
+
},
|
|
58
|
+
onDrop: onDrop
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [onDrop]);
|
|
62
|
+
return jsx("div", {
|
|
63
|
+
ref: ref,
|
|
64
|
+
css: dropTargetLayoutStyle,
|
|
65
|
+
"data-testid": "block-ctrl-drop-indicator"
|
|
66
|
+
}, isDraggedOver || isBlocksDragTargetDebug() ? jsx(DropIndicator, {
|
|
67
|
+
edge: "right",
|
|
68
|
+
gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
|
|
69
|
+
}) : jsx("div", {
|
|
70
|
+
css: dropTargetLayoutHintStyle
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
@@ -9,94 +9,100 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
9
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
10
|
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
|
|
11
11
|
import { emptyBlockExperimentGlobalStyles } from './empty-block-experiment/global-styles';
|
|
12
|
-
var extendedHoverZone =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
var extendedHoverZone = function extendedHoverZone() {
|
|
13
|
+
return css({
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
15
|
+
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
17
|
+
display: 'none !important'
|
|
18
|
+
},
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
20
|
+
'.ProseMirror': {
|
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
22
|
+
'&& [data-drag-handler-anchor-name]::after': {
|
|
23
|
+
content: '""',
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
top: 0,
|
|
26
|
+
left: '-100%',
|
|
27
|
+
width: '100%',
|
|
28
|
+
height: '100%',
|
|
29
|
+
background: 'transparent',
|
|
30
|
+
cursor: 'default',
|
|
31
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
32
|
+
zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
36
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
37
|
+
'hr[data-drag-handler-anchor-name]': {
|
|
38
|
+
overflow: 'visible'
|
|
39
|
+
},
|
|
40
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
41
|
+
'[data-blocks-drag-handle-container="true"] + *::after': {
|
|
42
|
+
display: 'none'
|
|
31
43
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
display: 'none'
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
var extendedHoverZoneNested = css({
|
|
44
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
45
|
-
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
46
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
47
|
-
display: 'none !important'
|
|
48
|
-
},
|
|
49
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
50
|
-
'.ProseMirror': {
|
|
51
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
52
|
-
'&& [data-drag-handler-anchor-name]::after': {
|
|
53
|
-
content: '""',
|
|
54
|
-
position: 'absolute',
|
|
55
|
-
top: 0,
|
|
56
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
57
|
-
left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
58
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
59
|
-
width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
60
|
-
height: '100%',
|
|
61
|
-
cursor: 'default',
|
|
62
|
-
zIndex: 1
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var extendedHoverZoneNested = function extendedHoverZoneNested() {
|
|
47
|
+
return css({
|
|
48
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
49
|
+
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
50
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
51
|
+
display: 'none !important'
|
|
63
52
|
},
|
|
64
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
65
|
-
'
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
54
|
+
'.ProseMirror': {
|
|
55
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
56
|
+
'&& [data-drag-handler-anchor-name]::after': {
|
|
57
|
+
content: '""',
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
top: 0,
|
|
60
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
61
|
+
left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
62
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
63
|
+
width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
64
|
+
height: '100%',
|
|
65
|
+
cursor: 'default',
|
|
66
|
+
zIndex: 1
|
|
67
|
+
},
|
|
68
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
69
|
+
'&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
|
|
70
|
+
content: '""',
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
top: 0,
|
|
73
|
+
left: '-100%',
|
|
74
|
+
width: '100%',
|
|
75
|
+
height: '100%',
|
|
76
|
+
cursor: 'default',
|
|
77
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
78
|
+
zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
|
|
79
|
+
},
|
|
80
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
81
|
+
'&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
|
|
82
|
+
content: '""',
|
|
83
|
+
position: 'absolute',
|
|
84
|
+
top: 0,
|
|
85
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
86
|
+
left: "-".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
|
|
87
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
88
|
+
width: "".concat(editorExperiment('table-nested-dnd', true) ? DRAG_HANDLE_MAX_WIDTH_PLUS_GAP : 0, "px"),
|
|
89
|
+
height: '100%',
|
|
90
|
+
cursor: 'default',
|
|
91
|
+
zIndex: 1
|
|
92
|
+
}
|
|
74
93
|
},
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
height: '100%',
|
|
85
|
-
cursor: 'default',
|
|
86
|
-
zIndex: 1
|
|
94
|
+
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
95
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
96
|
+
'hr[data-drag-handler-anchor-name]': {
|
|
97
|
+
overflow: 'visible'
|
|
98
|
+
},
|
|
99
|
+
//Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
|
|
100
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
101
|
+
'[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
|
|
102
|
+
display: 'none'
|
|
87
103
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
91
|
-
'hr[data-drag-handler-anchor-name]': {
|
|
92
|
-
overflow: 'visible'
|
|
93
|
-
},
|
|
94
|
-
//Hide pseudo element at top depth level. Leave for nested depths to prevent mouseover loop.
|
|
95
|
-
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
96
|
-
'[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
|
|
97
|
-
display: 'none'
|
|
98
|
-
}
|
|
99
|
-
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
100
106
|
var paragraphWithTrailingBreakAsOnlyChild = '+ :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
101
107
|
var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-indentation-mark > :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
102
108
|
var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
@@ -149,10 +155,19 @@ var withFormatInLayoutStyleFix = css(_defineProperty({}, "".concat(withFormatInL
|
|
|
149
155
|
var getTextNodeStyle = function getTextNodeStyle() {
|
|
150
156
|
return fg('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
|
|
151
157
|
};
|
|
158
|
+
var withRelativePosStyle = css({
|
|
159
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
160
|
+
'.ProseMirror': {
|
|
161
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
162
|
+
'&& [data-drag-handler-anchor-name]': {
|
|
163
|
+
position: 'relative'
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
152
167
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
153
168
|
return jsx(Global, {
|
|
154
|
-
styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
|
|
169
|
+
styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
|
|
155
170
|
exposure: false
|
|
156
|
-
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
|
|
171
|
+
}) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? withRelativePosStyle : undefined]
|
|
157
172
|
});
|
|
158
173
|
};
|
|
@@ -4,6 +4,7 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { ActiveNode, BlockControlsPlugin } from '../types';
|
|
6
6
|
import { type DropTargetProps } from '../ui/drop-target';
|
|
7
|
+
import { type DropTargetLayoutProps } from '../ui/drop-target-layout';
|
|
7
8
|
import { type AnchorRectCache } from '../utils/anchor-utils';
|
|
8
9
|
/**
|
|
9
10
|
* Find drop target decorations in the pos range between from and to
|
|
@@ -14,4 +15,5 @@ import { type AnchorRectCache } from '../utils/anchor-utils';
|
|
|
14
15
|
*/
|
|
15
16
|
export declare const findDropTargetDecs: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
16
17
|
export declare const createDropTargetDecoration: (pos: number, props: Omit<DropTargetProps, 'getPos'>, side?: number, anchorRectCache?: AnchorRectCache) => Decoration;
|
|
18
|
+
export declare const createLayoutDropTargetDecoration: (pos: number, props: Omit<DropTargetLayoutProps, 'getPos'>) => Decoration;
|
|
17
19
|
export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode, anchorRectCache?: AnchorRectCache, from?: number, to?: number) => Decoration[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { type IntlShape } from 'react-intl-next';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { BlockControlsPlugin } from '../types';
|
|
5
|
+
export type DropTargetLayoutProps = {
|
|
6
|
+
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
7
|
+
getPos: () => number | undefined;
|
|
8
|
+
formatMessage?: IntlShape['formatMessage'];
|
|
9
|
+
};
|
|
10
|
+
export declare const DropTargetLayout: (props: DropTargetLayoutProps) => jsx.JSX.Element;
|
|
@@ -4,6 +4,7 @@ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { Decoration, type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import type { ActiveNode, BlockControlsPlugin } from '../types';
|
|
6
6
|
import { type DropTargetProps } from '../ui/drop-target';
|
|
7
|
+
import { type DropTargetLayoutProps } from '../ui/drop-target-layout';
|
|
7
8
|
import { type AnchorRectCache } from '../utils/anchor-utils';
|
|
8
9
|
/**
|
|
9
10
|
* Find drop target decorations in the pos range between from and to
|
|
@@ -14,4 +15,5 @@ import { type AnchorRectCache } from '../utils/anchor-utils';
|
|
|
14
15
|
*/
|
|
15
16
|
export declare const findDropTargetDecs: (decorations: DecorationSet, from?: number, to?: number) => Decoration[];
|
|
16
17
|
export declare const createDropTargetDecoration: (pos: number, props: Omit<DropTargetProps, 'getPos'>, side?: number, anchorRectCache?: AnchorRectCache) => Decoration;
|
|
18
|
+
export declare const createLayoutDropTargetDecoration: (pos: number, props: Omit<DropTargetLayoutProps, 'getPos'>) => Decoration;
|
|
17
19
|
export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode, anchorRectCache?: AnchorRectCache, from?: number, to?: number) => Decoration[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { type IntlShape } from 'react-intl-next';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { BlockControlsPlugin } from '../types';
|
|
5
|
+
export type DropTargetLayoutProps = {
|
|
6
|
+
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
7
|
+
getPos: () => number | undefined;
|
|
8
|
+
formatMessage?: IntlShape['formatMessage'];
|
|
9
|
+
};
|
|
10
|
+
export declare const DropTargetLayout: (props: DropTargetLayoutProps) => jsx.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^42.3.1",
|
|
34
|
-
"@atlaskit/editor-common": "^94.
|
|
34
|
+
"@atlaskit/editor-common": "^94.6.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^12.2.0",
|
|
50
50
|
"@atlaskit/theme": "^14.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^2.10.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.0.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.8.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|