@atlaskit/editor-plugin-block-controls 1.10.7 → 1.11.1
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 +28 -0
- package/dist/cjs/pm-plugins/decorations.js +49 -20
- package/dist/cjs/pm-plugins/main.js +6 -12
- package/dist/cjs/ui/drag-handle.js +1 -1
- package/dist/cjs/ui/drop-target.js +26 -12
- package/dist/es2019/pm-plugins/decorations.js +47 -20
- package/dist/es2019/pm-plugins/main.js +5 -11
- package/dist/es2019/ui/drag-handle.js +1 -1
- package/dist/es2019/ui/drop-target.js +25 -10
- package/dist/esm/pm-plugins/decorations.js +49 -20
- package/dist/esm/pm-plugins/main.js +6 -12
- package/dist/esm/ui/drag-handle.js +1 -1
- package/dist/esm/ui/drop-target.js +26 -12
- package/dist/types/ui/drop-target.d.ts +7 -9
- package/dist/types-ts4.5/ui/drop-target.d.ts +7 -9
- package/package.json +5 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#128476](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128476)
|
|
8
|
+
[`e6ccffdd6fe90`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e6ccffdd6fe90) -
|
|
9
|
+
ED-24408 fix nested drop target indicator location and appearance
|
|
10
|
+
|
|
11
|
+
## 1.11.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#128347](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128347)
|
|
16
|
+
[`e33566cebd5d1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e33566cebd5d1) -
|
|
17
|
+
[ED-24175] bump @atlaskit/adf-schema to 40.8.1 and @atlassian/adf-schema-json to 1.22.0 to
|
|
18
|
+
promotecodeblocks & media in quotes, and nested expands in expands to full schema, and allow
|
|
19
|
+
quotes in panels and decisions in lists in stage0 schema, and a validator spec change
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#128138](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128138)
|
|
24
|
+
[`5c7bc23671459`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c7bc23671459) -
|
|
25
|
+
ED-24471 Clean up feature flags in main.ts apply and long scroll FF
|
|
26
|
+
- [#127946](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127946)
|
|
27
|
+
[`93f225e326474`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/93f225e326474) -
|
|
28
|
+
ED-24405 fix drop target not showing at last pos
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
|
|
3
31
|
## 1.10.7
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -14,10 +14,26 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
14
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
15
|
var _dragHandle = require("../ui/drag-handle");
|
|
16
16
|
var _dropTarget = require("../ui/drop-target");
|
|
17
|
+
var _dragTargetDebug = require("../utils/drag-target-debug");
|
|
17
18
|
var _validation = require("../utils/validation");
|
|
18
19
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
19
20
|
var IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
20
|
-
var
|
|
21
|
+
var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand'];
|
|
22
|
+
var getNestedDepth = function getNestedDepth() {
|
|
23
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
24
|
+
};
|
|
25
|
+
var createDropTargetDecoration = function createDropTargetDecoration(pos, dropTargetDec) {
|
|
26
|
+
return _view.Decoration.widget(pos, function () {
|
|
27
|
+
var element = document.createElement('div');
|
|
28
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
29
|
+
element.style.clear = 'unset';
|
|
30
|
+
_reactDom.default.render(dropTargetDec, element);
|
|
31
|
+
return element;
|
|
32
|
+
}, {
|
|
33
|
+
type: 'drop-target-decoration',
|
|
34
|
+
side: -1
|
|
35
|
+
});
|
|
36
|
+
};
|
|
21
37
|
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
|
|
22
38
|
var decs = [];
|
|
23
39
|
unmountDecorations('data-blocks-drop-target-container');
|
|
@@ -28,49 +44,63 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
28
44
|
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
29
45
|
var depth = 0;
|
|
30
46
|
var nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
47
|
+
var endDec = null;
|
|
31
48
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
32
49
|
depth = newState.doc.resolve(pos).depth;
|
|
33
|
-
if (node.isInline) {
|
|
50
|
+
if (node.isInline || !parent) {
|
|
51
|
+
prevNode = node;
|
|
34
52
|
return false;
|
|
35
53
|
}
|
|
36
54
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
55
|
+
prevNode = node;
|
|
37
56
|
return true; //skip over, don't consider it a valid depth
|
|
38
57
|
}
|
|
39
|
-
var canDrop =
|
|
58
|
+
var canDrop = activeNodeType && (0, _validation.canMoveToIndex)(parent, index, nodeType);
|
|
40
59
|
|
|
41
60
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
42
|
-
if (!canDrop) {
|
|
61
|
+
if (!canDrop && !(0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
62
|
+
prevNode = node;
|
|
43
63
|
return false; //not valid pos, so nested not valid either
|
|
44
64
|
}
|
|
45
65
|
decorationState.push({
|
|
46
66
|
id: pos,
|
|
47
67
|
pos: pos
|
|
48
68
|
});
|
|
69
|
+
if (parent.lastChild === node && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
70
|
+
var endpos = pos + node.nodeSize;
|
|
71
|
+
endDec = {
|
|
72
|
+
id: endpos,
|
|
73
|
+
pos: endpos
|
|
74
|
+
};
|
|
75
|
+
decorationState.push({
|
|
76
|
+
id: endpos,
|
|
77
|
+
pos: endpos
|
|
78
|
+
});
|
|
79
|
+
}
|
|
49
80
|
} else {
|
|
50
81
|
decorationState.push({
|
|
51
82
|
id: index,
|
|
52
83
|
pos: pos
|
|
53
84
|
});
|
|
54
85
|
}
|
|
55
|
-
|
|
86
|
+
decs.push(createDropTargetDecoration(pos, /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
|
|
56
87
|
api: api,
|
|
57
88
|
id: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? pos : index,
|
|
58
89
|
formatMessage: formatMessage,
|
|
59
90
|
prevNode: prevNode,
|
|
60
|
-
nextNode: node
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}));
|
|
91
|
+
nextNode: node,
|
|
92
|
+
parentNode: parent
|
|
93
|
+
})));
|
|
94
|
+
if (endDec) {
|
|
95
|
+
decs.push(createDropTargetDecoration(endDec.pos, /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
|
|
96
|
+
api: api,
|
|
97
|
+
id: endDec.id,
|
|
98
|
+
parentNode: parent,
|
|
99
|
+
formatMessage: formatMessage
|
|
100
|
+
})));
|
|
101
|
+
}
|
|
72
102
|
prevNode = node;
|
|
73
|
-
return depth <
|
|
103
|
+
return depth < getNestedDepth();
|
|
74
104
|
});
|
|
75
105
|
|
|
76
106
|
/**
|
|
@@ -80,7 +110,6 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
80
110
|
* node and not its size.
|
|
81
111
|
*
|
|
82
112
|
*/
|
|
83
|
-
|
|
84
113
|
var lastPos = newState.doc.content.size;
|
|
85
114
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
86
115
|
decorationState.push({
|
|
@@ -143,7 +172,7 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
143
172
|
}, (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node2), {
|
|
144
173
|
type: 'node-decoration'
|
|
145
174
|
}));
|
|
146
|
-
return depth <
|
|
175
|
+
return depth < getNestedDepth();
|
|
147
176
|
});
|
|
148
177
|
return decs;
|
|
149
178
|
};
|
|
@@ -164,15 +164,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
164
164
|
|
|
165
165
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
166
166
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
167
|
-
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
decorations = decorations.remove(oldNodeDecs);
|
|
173
|
-
} else {
|
|
174
|
-
decorations = _view.DecorationSet.create(newState.doc, []);
|
|
175
|
-
}
|
|
167
|
+
var oldNodeDecs = decorations.find().filter(function (_ref9) {
|
|
168
|
+
var spec = _ref9.spec;
|
|
169
|
+
return spec.type !== 'drop-target-decoration';
|
|
170
|
+
});
|
|
171
|
+
decorations = decorations.remove(oldNodeDecs);
|
|
176
172
|
var nodeDecs = (0, _decorations.nodeDecorations)(newState);
|
|
177
173
|
decorations = decorations.add(newState.doc, (0, _toConsumableArray2.default)(nodeDecs));
|
|
178
174
|
|
|
@@ -184,9 +180,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
184
180
|
|
|
185
181
|
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
186
182
|
// This is a workaround to fix the position of the active node when it is nested
|
|
187
|
-
|
|
188
|
-
var shouldUpdateNestedPosition = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24049') ? tr.docChanged && !nodeCountChanged : true;
|
|
189
|
-
if (shouldUpdateNestedPosition && mappedPosisiton === prevMappedPos + 1) {
|
|
183
|
+
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
190
184
|
mappedPosisiton = prevMappedPos;
|
|
191
185
|
}
|
|
192
186
|
var newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
@@ -121,7 +121,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
121
121
|
});
|
|
122
122
|
var resolvedMovingNode = tr.doc.resolve(startPos);
|
|
123
123
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
124
|
-
|
|
124
|
+
tr.setMeta('scrollIntoView', false);
|
|
125
125
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
126
126
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
127
127
|
action: _analytics.ACTION.CLICKED,
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.DropTarget = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _react2 = require("@emotion/react");
|
|
@@ -31,13 +32,16 @@ var styleDropTarget = (0, _react2.css)({
|
|
|
31
32
|
display: 'block',
|
|
32
33
|
zIndex: _constants.layers.card()
|
|
33
34
|
});
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
var nestedDropIndicatorStyle = (0, _react2.css)({
|
|
36
|
+
position: 'relative'
|
|
37
|
+
});
|
|
38
|
+
var marginLookupMap = Object.fromEntries(Object.entries(_consts.spaceLookupMap).map(function (_ref, i) {
|
|
37
39
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
38
40
|
key = _ref2[0],
|
|
39
41
|
value = _ref2[1];
|
|
40
|
-
return [key,
|
|
42
|
+
return [key,
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
44
|
+
(0, _react2.css)({
|
|
41
45
|
marginTop: value
|
|
42
46
|
})];
|
|
43
47
|
}));
|
|
@@ -65,17 +69,19 @@ var getDropTargetPositionStyle = function getDropTargetPositionStyle(prevNode, n
|
|
|
65
69
|
return marginLookupMap[space];
|
|
66
70
|
}
|
|
67
71
|
};
|
|
72
|
+
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
68
73
|
var styleDropIndicator = (0, _react2.css)({
|
|
69
74
|
height: '100%',
|
|
70
|
-
width: '100%',
|
|
71
75
|
margin: '0 auto',
|
|
72
|
-
position: 'relative'
|
|
76
|
+
position: 'relative',
|
|
77
|
+
width: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, ", 100%)")
|
|
73
78
|
});
|
|
74
79
|
var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
75
80
|
var api = _ref3.api,
|
|
76
81
|
id = _ref3.id,
|
|
77
82
|
prevNode = _ref3.prevNode,
|
|
78
83
|
nextNode = _ref3.nextNode,
|
|
84
|
+
parentNode = _ref3.parentNode,
|
|
79
85
|
formatMessage = _ref3.formatMessage;
|
|
80
86
|
var ref = (0, _react.useRef)(null);
|
|
81
87
|
var _useState = (0, _react.useState)(false),
|
|
@@ -84,7 +90,7 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
84
90
|
setIsDraggedOver = _useState2[1];
|
|
85
91
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']),
|
|
86
92
|
widthState = _useSharedPluginState.widthState;
|
|
87
|
-
var
|
|
93
|
+
var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
88
94
|
(0, _react.useEffect)(function () {
|
|
89
95
|
var element = ref.current;
|
|
90
96
|
if (!element) {
|
|
@@ -122,22 +128,30 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
|
|
|
122
128
|
});
|
|
123
129
|
}, [id, api, formatMessage]);
|
|
124
130
|
var topTargetMarginStyle = (0, _react.useMemo)(function () {
|
|
131
|
+
/**
|
|
132
|
+
* First child of a nested node.
|
|
133
|
+
* Disable the position adjustment for the nested node temporarily
|
|
134
|
+
*/
|
|
135
|
+
if (parentNode === prevNode || isNestedDropTarget) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
125
138
|
return getDropTargetPositionStyle(prevNode, nextNode);
|
|
126
|
-
}, [prevNode, nextNode]);
|
|
139
|
+
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
140
|
+
var widthStyle = (0, _defineProperty2.default)({}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px"));
|
|
127
141
|
return (
|
|
128
142
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
129
143
|
(0, _react2.jsx)("div", {
|
|
130
144
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
131
|
-
css: [styleDropTarget, topTargetMarginStyle]
|
|
145
|
+
css: [styleDropTarget, topTargetMarginStyle, isNestedDropTarget && nestedDropIndicatorStyle]
|
|
146
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
147
|
+
,
|
|
148
|
+
style: widthStyle,
|
|
132
149
|
ref: ref,
|
|
133
150
|
"data-testid": "block-ctrl-drop-target"
|
|
134
151
|
},
|
|
135
152
|
// 4px gap to clear expand node border
|
|
136
153
|
(isDraggedOver || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) && (0, _react2.jsx)("div", {
|
|
137
154
|
css: styleDropIndicator,
|
|
138
|
-
style: {
|
|
139
|
-
width: "".concat(lineLength, "px")
|
|
140
|
-
},
|
|
141
155
|
"data-testid": "block-ctrl-drop-indicator"
|
|
142
156
|
}, (0, _react2.jsx)(_box.DropIndicator, {
|
|
143
157
|
edge: "bottom",
|
|
@@ -6,10 +6,24 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { DragHandle } from '../ui/drag-handle';
|
|
8
8
|
import { DropTarget } from '../ui/drop-target';
|
|
9
|
+
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
9
10
|
import { canMoveToIndex } from '../utils/validation';
|
|
10
11
|
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
11
12
|
const IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
12
|
-
const
|
|
13
|
+
const PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand'];
|
|
14
|
+
const getNestedDepth = () => fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
15
|
+
const createDropTargetDecoration = (pos, dropTargetDec) => {
|
|
16
|
+
return Decoration.widget(pos, () => {
|
|
17
|
+
const element = document.createElement('div');
|
|
18
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
19
|
+
element.style.clear = 'unset';
|
|
20
|
+
ReactDOM.render(dropTargetDec, element);
|
|
21
|
+
return element;
|
|
22
|
+
}, {
|
|
23
|
+
type: 'drop-target-decoration',
|
|
24
|
+
side: -1
|
|
25
|
+
});
|
|
26
|
+
};
|
|
13
27
|
export const dropTargetDecorations = (oldState, newState, api, formatMessage, activeNodeType) => {
|
|
14
28
|
const decs = [];
|
|
15
29
|
unmountDecorations('data-blocks-drop-target-container');
|
|
@@ -20,49 +34,63 @@ export const dropTargetDecorations = (oldState, newState, api, formatMessage, ac
|
|
|
20
34
|
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, (node, pos, parent, index) => {
|
|
21
35
|
let depth = 0;
|
|
22
36
|
const nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
37
|
+
let endDec = null;
|
|
23
38
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
24
39
|
depth = newState.doc.resolve(pos).depth;
|
|
25
|
-
if (node.isInline) {
|
|
40
|
+
if (node.isInline || !parent) {
|
|
41
|
+
prevNode = node;
|
|
26
42
|
return false;
|
|
27
43
|
}
|
|
28
44
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
45
|
+
prevNode = node;
|
|
29
46
|
return true; //skip over, don't consider it a valid depth
|
|
30
47
|
}
|
|
31
|
-
const canDrop =
|
|
48
|
+
const canDrop = activeNodeType && canMoveToIndex(parent, index, nodeType);
|
|
32
49
|
|
|
33
50
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
34
|
-
if (!canDrop) {
|
|
51
|
+
if (!canDrop && !isBlocksDragTargetDebug()) {
|
|
52
|
+
prevNode = node;
|
|
35
53
|
return false; //not valid pos, so nested not valid either
|
|
36
54
|
}
|
|
37
55
|
decorationState.push({
|
|
38
56
|
id: pos,
|
|
39
57
|
pos
|
|
40
58
|
});
|
|
59
|
+
if (parent.lastChild === node && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
60
|
+
const endpos = pos + node.nodeSize;
|
|
61
|
+
endDec = {
|
|
62
|
+
id: endpos,
|
|
63
|
+
pos: endpos
|
|
64
|
+
};
|
|
65
|
+
decorationState.push({
|
|
66
|
+
id: endpos,
|
|
67
|
+
pos: endpos
|
|
68
|
+
});
|
|
69
|
+
}
|
|
41
70
|
} else {
|
|
42
71
|
decorationState.push({
|
|
43
72
|
id: index,
|
|
44
73
|
pos
|
|
45
74
|
});
|
|
46
75
|
}
|
|
47
|
-
|
|
76
|
+
decs.push(createDropTargetDecoration(pos, /*#__PURE__*/createElement(DropTarget, {
|
|
48
77
|
api,
|
|
49
78
|
id: fg('platform_editor_elements_dnd_nested') ? pos : index,
|
|
50
79
|
formatMessage,
|
|
51
80
|
prevNode,
|
|
52
|
-
nextNode: node
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}));
|
|
81
|
+
nextNode: node,
|
|
82
|
+
parentNode: parent
|
|
83
|
+
})));
|
|
84
|
+
if (endDec) {
|
|
85
|
+
decs.push(createDropTargetDecoration(endDec.pos, /*#__PURE__*/createElement(DropTarget, {
|
|
86
|
+
api,
|
|
87
|
+
id: endDec.id,
|
|
88
|
+
parentNode: parent,
|
|
89
|
+
formatMessage
|
|
90
|
+
})));
|
|
91
|
+
}
|
|
64
92
|
prevNode = node;
|
|
65
|
-
return depth <
|
|
93
|
+
return depth < getNestedDepth();
|
|
66
94
|
});
|
|
67
95
|
|
|
68
96
|
/**
|
|
@@ -72,7 +100,6 @@ export const dropTargetDecorations = (oldState, newState, api, formatMessage, ac
|
|
|
72
100
|
* node and not its size.
|
|
73
101
|
*
|
|
74
102
|
*/
|
|
75
|
-
|
|
76
103
|
const lastPos = newState.doc.content.size;
|
|
77
104
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
78
105
|
decorationState.push({
|
|
@@ -138,7 +165,7 @@ export const nodeDecorations = newState => {
|
|
|
138
165
|
}, {
|
|
139
166
|
type: 'node-decoration'
|
|
140
167
|
}));
|
|
141
|
-
return depth <
|
|
168
|
+
return depth < getNestedDepth();
|
|
142
169
|
});
|
|
143
170
|
return decs;
|
|
144
171
|
};
|
|
@@ -157,14 +157,10 @@ export const createPlugin = (api, getIntl) => {
|
|
|
157
157
|
|
|
158
158
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
159
159
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
decorations = decorations.remove(oldNodeDecs);
|
|
165
|
-
} else {
|
|
166
|
-
decorations = DecorationSet.create(newState.doc, []);
|
|
167
|
-
}
|
|
160
|
+
const oldNodeDecs = decorations.find().filter(({
|
|
161
|
+
spec
|
|
162
|
+
}) => spec.type !== 'drop-target-decoration');
|
|
163
|
+
decorations = decorations.remove(oldNodeDecs);
|
|
168
164
|
const nodeDecs = nodeDecorations(newState);
|
|
169
165
|
decorations = decorations.add(newState.doc, [...nodeDecs]);
|
|
170
166
|
|
|
@@ -176,9 +172,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
176
172
|
|
|
177
173
|
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
178
174
|
// This is a workaround to fix the position of the active node when it is nested
|
|
179
|
-
|
|
180
|
-
const shouldUpdateNestedPosition = fg('platform_editor_element_drag_and_drop_ed_24049') ? tr.docChanged && !nodeCountChanged : true;
|
|
181
|
-
if (shouldUpdateNestedPosition && mappedPosisiton === prevMappedPos + 1) {
|
|
175
|
+
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
182
176
|
mappedPosisiton = prevMappedPos;
|
|
183
177
|
}
|
|
184
178
|
const newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
@@ -108,7 +108,7 @@ const DragHandleInternal = ({
|
|
|
108
108
|
});
|
|
109
109
|
const resolvedMovingNode = tr.doc.resolve(startPos);
|
|
110
110
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
111
|
-
|
|
111
|
+
tr.setMeta('scrollIntoView', false);
|
|
112
112
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
113
113
|
eventType: EVENT_TYPE.UI,
|
|
114
114
|
action: ACTION.CLICKED,
|
|
@@ -22,9 +22,12 @@ const styleDropTarget = css({
|
|
|
22
22
|
display: 'block',
|
|
23
23
|
zIndex: layers.card()
|
|
24
24
|
});
|
|
25
|
-
const
|
|
25
|
+
const nestedDropIndicatorStyle = css({
|
|
26
|
+
position: 'relative'
|
|
27
|
+
});
|
|
28
|
+
const marginLookupMap = Object.fromEntries(Object.entries(spaceLookupMap).map(([key, value], i) => [key,
|
|
26
29
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
27
|
-
|
|
30
|
+
css({
|
|
28
31
|
marginTop: value
|
|
29
32
|
})]));
|
|
30
33
|
const BASE_LINE_MARGIN = -8;
|
|
@@ -51,17 +54,19 @@ const getDropTargetPositionStyle = (prevNode, nextNode) => {
|
|
|
51
54
|
return marginLookupMap[space];
|
|
52
55
|
}
|
|
53
56
|
};
|
|
57
|
+
const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
54
58
|
const styleDropIndicator = css({
|
|
55
59
|
height: '100%',
|
|
56
|
-
width: '100%',
|
|
57
60
|
margin: '0 auto',
|
|
58
|
-
position: 'relative'
|
|
61
|
+
position: 'relative',
|
|
62
|
+
width: `var(${EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH}, 100%)`
|
|
59
63
|
});
|
|
60
64
|
export const DropTarget = ({
|
|
61
65
|
api,
|
|
62
66
|
id,
|
|
63
67
|
prevNode,
|
|
64
68
|
nextNode,
|
|
69
|
+
parentNode,
|
|
65
70
|
formatMessage
|
|
66
71
|
}) => {
|
|
67
72
|
const ref = useRef(null);
|
|
@@ -69,7 +74,7 @@ export const DropTarget = ({
|
|
|
69
74
|
const {
|
|
70
75
|
widthState
|
|
71
76
|
} = useSharedPluginState(api, ['width']);
|
|
72
|
-
const
|
|
77
|
+
const isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
73
78
|
useEffect(() => {
|
|
74
79
|
const element = ref.current;
|
|
75
80
|
if (!element) {
|
|
@@ -107,22 +112,32 @@ export const DropTarget = ({
|
|
|
107
112
|
});
|
|
108
113
|
}, [id, api, formatMessage]);
|
|
109
114
|
const topTargetMarginStyle = useMemo(() => {
|
|
115
|
+
/**
|
|
116
|
+
* First child of a nested node.
|
|
117
|
+
* Disable the position adjustment for the nested node temporarily
|
|
118
|
+
*/
|
|
119
|
+
if (parentNode === prevNode || isNestedDropTarget) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
110
122
|
return getDropTargetPositionStyle(prevNode, nextNode);
|
|
111
|
-
}, [prevNode, nextNode]);
|
|
123
|
+
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
124
|
+
const widthStyle = {
|
|
125
|
+
[EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`
|
|
126
|
+
};
|
|
112
127
|
return (
|
|
113
128
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
114
129
|
jsx("div", {
|
|
115
130
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
116
|
-
css: [styleDropTarget, topTargetMarginStyle]
|
|
131
|
+
css: [styleDropTarget, topTargetMarginStyle, isNestedDropTarget && nestedDropIndicatorStyle]
|
|
132
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
133
|
+
,
|
|
134
|
+
style: widthStyle,
|
|
117
135
|
ref: ref,
|
|
118
136
|
"data-testid": "block-ctrl-drop-target"
|
|
119
137
|
},
|
|
120
138
|
// 4px gap to clear expand node border
|
|
121
139
|
(isDraggedOver || isBlocksDragTargetDebug()) && jsx("div", {
|
|
122
140
|
css: styleDropIndicator,
|
|
123
|
-
style: {
|
|
124
|
-
width: `${lineLength}px`
|
|
125
|
-
},
|
|
126
141
|
"data-testid": "block-ctrl-drop-indicator"
|
|
127
142
|
}, jsx(DropIndicator, {
|
|
128
143
|
edge: "bottom",
|
|
@@ -7,10 +7,26 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import { DragHandle } from '../ui/drag-handle';
|
|
9
9
|
import { DropTarget } from '../ui/drop-target';
|
|
10
|
+
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
10
11
|
import { canMoveToIndex } from '../utils/validation';
|
|
11
12
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
12
13
|
var IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
13
|
-
var
|
|
14
|
+
var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand'];
|
|
15
|
+
var getNestedDepth = function getNestedDepth() {
|
|
16
|
+
return fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
17
|
+
};
|
|
18
|
+
var createDropTargetDecoration = function createDropTargetDecoration(pos, dropTargetDec) {
|
|
19
|
+
return Decoration.widget(pos, function () {
|
|
20
|
+
var element = document.createElement('div');
|
|
21
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
22
|
+
element.style.clear = 'unset';
|
|
23
|
+
ReactDOM.render(dropTargetDec, element);
|
|
24
|
+
return element;
|
|
25
|
+
}, {
|
|
26
|
+
type: 'drop-target-decoration',
|
|
27
|
+
side: -1
|
|
28
|
+
});
|
|
29
|
+
};
|
|
14
30
|
export var dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
|
|
15
31
|
var decs = [];
|
|
16
32
|
unmountDecorations('data-blocks-drop-target-container');
|
|
@@ -21,49 +37,63 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
21
37
|
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
22
38
|
var depth = 0;
|
|
23
39
|
var nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
40
|
+
var endDec = null;
|
|
24
41
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
25
42
|
depth = newState.doc.resolve(pos).depth;
|
|
26
|
-
if (node.isInline) {
|
|
43
|
+
if (node.isInline || !parent) {
|
|
44
|
+
prevNode = node;
|
|
27
45
|
return false;
|
|
28
46
|
}
|
|
29
47
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
48
|
+
prevNode = node;
|
|
30
49
|
return true; //skip over, don't consider it a valid depth
|
|
31
50
|
}
|
|
32
|
-
var canDrop =
|
|
51
|
+
var canDrop = activeNodeType && canMoveToIndex(parent, index, nodeType);
|
|
33
52
|
|
|
34
53
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
35
|
-
if (!canDrop) {
|
|
54
|
+
if (!canDrop && !isBlocksDragTargetDebug()) {
|
|
55
|
+
prevNode = node;
|
|
36
56
|
return false; //not valid pos, so nested not valid either
|
|
37
57
|
}
|
|
38
58
|
decorationState.push({
|
|
39
59
|
id: pos,
|
|
40
60
|
pos: pos
|
|
41
61
|
});
|
|
62
|
+
if (parent.lastChild === node && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
63
|
+
var endpos = pos + node.nodeSize;
|
|
64
|
+
endDec = {
|
|
65
|
+
id: endpos,
|
|
66
|
+
pos: endpos
|
|
67
|
+
};
|
|
68
|
+
decorationState.push({
|
|
69
|
+
id: endpos,
|
|
70
|
+
pos: endpos
|
|
71
|
+
});
|
|
72
|
+
}
|
|
42
73
|
} else {
|
|
43
74
|
decorationState.push({
|
|
44
75
|
id: index,
|
|
45
76
|
pos: pos
|
|
46
77
|
});
|
|
47
78
|
}
|
|
48
|
-
|
|
79
|
+
decs.push(createDropTargetDecoration(pos, /*#__PURE__*/createElement(DropTarget, {
|
|
49
80
|
api: api,
|
|
50
81
|
id: fg('platform_editor_elements_dnd_nested') ? pos : index,
|
|
51
82
|
formatMessage: formatMessage,
|
|
52
83
|
prevNode: prevNode,
|
|
53
|
-
nextNode: node
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}));
|
|
84
|
+
nextNode: node,
|
|
85
|
+
parentNode: parent
|
|
86
|
+
})));
|
|
87
|
+
if (endDec) {
|
|
88
|
+
decs.push(createDropTargetDecoration(endDec.pos, /*#__PURE__*/createElement(DropTarget, {
|
|
89
|
+
api: api,
|
|
90
|
+
id: endDec.id,
|
|
91
|
+
parentNode: parent,
|
|
92
|
+
formatMessage: formatMessage
|
|
93
|
+
})));
|
|
94
|
+
}
|
|
65
95
|
prevNode = node;
|
|
66
|
-
return depth <
|
|
96
|
+
return depth < getNestedDepth();
|
|
67
97
|
});
|
|
68
98
|
|
|
69
99
|
/**
|
|
@@ -73,7 +103,6 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
73
103
|
* node and not its size.
|
|
74
104
|
*
|
|
75
105
|
*/
|
|
76
|
-
|
|
77
106
|
var lastPos = newState.doc.content.size;
|
|
78
107
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
79
108
|
decorationState.push({
|
|
@@ -136,7 +165,7 @@ export var nodeDecorations = function nodeDecorations(newState) {
|
|
|
136
165
|
}, _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node2), {
|
|
137
166
|
type: 'node-decoration'
|
|
138
167
|
}));
|
|
139
|
-
return depth <
|
|
168
|
+
return depth < getNestedDepth();
|
|
140
169
|
});
|
|
141
170
|
return decs;
|
|
142
171
|
};
|
|
@@ -157,15 +157,11 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
157
157
|
|
|
158
158
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
159
159
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
160
|
-
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
decorations = decorations.remove(oldNodeDecs);
|
|
166
|
-
} else {
|
|
167
|
-
decorations = DecorationSet.create(newState.doc, []);
|
|
168
|
-
}
|
|
160
|
+
var oldNodeDecs = decorations.find().filter(function (_ref9) {
|
|
161
|
+
var spec = _ref9.spec;
|
|
162
|
+
return spec.type !== 'drop-target-decoration';
|
|
163
|
+
});
|
|
164
|
+
decorations = decorations.remove(oldNodeDecs);
|
|
169
165
|
var nodeDecs = nodeDecorations(newState);
|
|
170
166
|
decorations = decorations.add(newState.doc, _toConsumableArray(nodeDecs));
|
|
171
167
|
|
|
@@ -177,9 +173,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
177
173
|
|
|
178
174
|
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
179
175
|
// This is a workaround to fix the position of the active node when it is nested
|
|
180
|
-
|
|
181
|
-
var shouldUpdateNestedPosition = fg('platform_editor_element_drag_and_drop_ed_24049') ? tr.docChanged && !nodeCountChanged : true;
|
|
182
|
-
if (shouldUpdateNestedPosition && mappedPosisiton === prevMappedPos + 1) {
|
|
176
|
+
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
183
177
|
mappedPosisiton = prevMappedPos;
|
|
184
178
|
}
|
|
185
179
|
var newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
@@ -112,7 +112,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
112
112
|
});
|
|
113
113
|
var resolvedMovingNode = tr.doc.resolve(startPos);
|
|
114
114
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
115
|
-
|
|
115
|
+
tr.setMeta('scrollIntoView', false);
|
|
116
116
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
117
117
|
eventType: EVENT_TYPE.UI,
|
|
118
118
|
action: ACTION.CLICKED,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
/**
|
|
3
4
|
* @jsxRuntime classic
|
|
@@ -23,13 +24,16 @@ var styleDropTarget = css({
|
|
|
23
24
|
display: 'block',
|
|
24
25
|
zIndex: layers.card()
|
|
25
26
|
});
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var nestedDropIndicatorStyle = css({
|
|
28
|
+
position: 'relative'
|
|
29
|
+
});
|
|
30
|
+
var marginLookupMap = Object.fromEntries(Object.entries(spaceLookupMap).map(function (_ref, i) {
|
|
29
31
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
30
32
|
key = _ref2[0],
|
|
31
33
|
value = _ref2[1];
|
|
32
|
-
return [key,
|
|
34
|
+
return [key,
|
|
35
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
36
|
+
css({
|
|
33
37
|
marginTop: value
|
|
34
38
|
})];
|
|
35
39
|
}));
|
|
@@ -57,17 +61,19 @@ var getDropTargetPositionStyle = function getDropTargetPositionStyle(prevNode, n
|
|
|
57
61
|
return marginLookupMap[space];
|
|
58
62
|
}
|
|
59
63
|
};
|
|
64
|
+
var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
|
|
60
65
|
var styleDropIndicator = css({
|
|
61
66
|
height: '100%',
|
|
62
|
-
width: '100%',
|
|
63
67
|
margin: '0 auto',
|
|
64
|
-
position: 'relative'
|
|
68
|
+
position: 'relative',
|
|
69
|
+
width: "var(".concat(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, ", 100%)")
|
|
65
70
|
});
|
|
66
71
|
export var DropTarget = function DropTarget(_ref3) {
|
|
67
72
|
var api = _ref3.api,
|
|
68
73
|
id = _ref3.id,
|
|
69
74
|
prevNode = _ref3.prevNode,
|
|
70
75
|
nextNode = _ref3.nextNode,
|
|
76
|
+
parentNode = _ref3.parentNode,
|
|
71
77
|
formatMessage = _ref3.formatMessage;
|
|
72
78
|
var ref = useRef(null);
|
|
73
79
|
var _useState = useState(false),
|
|
@@ -76,7 +82,7 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
76
82
|
setIsDraggedOver = _useState2[1];
|
|
77
83
|
var _useSharedPluginState = useSharedPluginState(api, ['width']),
|
|
78
84
|
widthState = _useSharedPluginState.widthState;
|
|
79
|
-
var
|
|
85
|
+
var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
|
|
80
86
|
useEffect(function () {
|
|
81
87
|
var element = ref.current;
|
|
82
88
|
if (!element) {
|
|
@@ -114,22 +120,30 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
114
120
|
});
|
|
115
121
|
}, [id, api, formatMessage]);
|
|
116
122
|
var topTargetMarginStyle = useMemo(function () {
|
|
123
|
+
/**
|
|
124
|
+
* First child of a nested node.
|
|
125
|
+
* Disable the position adjustment for the nested node temporarily
|
|
126
|
+
*/
|
|
127
|
+
if (parentNode === prevNode || isNestedDropTarget) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
117
130
|
return getDropTargetPositionStyle(prevNode, nextNode);
|
|
118
|
-
}, [prevNode, nextNode]);
|
|
131
|
+
}, [prevNode, nextNode, parentNode, isNestedDropTarget]);
|
|
132
|
+
var widthStyle = _defineProperty({}, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px"));
|
|
119
133
|
return (
|
|
120
134
|
// Note: Firefox has trouble with using a button element as the handle for drag and drop
|
|
121
135
|
jsx("div", {
|
|
122
136
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
123
|
-
css: [styleDropTarget, topTargetMarginStyle]
|
|
137
|
+
css: [styleDropTarget, topTargetMarginStyle, isNestedDropTarget && nestedDropIndicatorStyle]
|
|
138
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
139
|
+
,
|
|
140
|
+
style: widthStyle,
|
|
124
141
|
ref: ref,
|
|
125
142
|
"data-testid": "block-ctrl-drop-target"
|
|
126
143
|
},
|
|
127
144
|
// 4px gap to clear expand node border
|
|
128
145
|
(isDraggedOver || isBlocksDragTargetDebug()) && jsx("div", {
|
|
129
146
|
css: styleDropIndicator,
|
|
130
|
-
style: {
|
|
131
|
-
width: "".concat(lineLength, "px")
|
|
132
|
-
},
|
|
133
147
|
"data-testid": "block-ctrl-drop-indicator"
|
|
134
148
|
}, jsx(DropIndicator, {
|
|
135
149
|
edge: "bottom",
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { jsx } from '@emotion/react';
|
|
3
2
|
import { type IntlShape } from 'react-intl-next';
|
|
4
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
5
|
import type { BlockControlsPlugin } from '../types';
|
|
7
|
-
export
|
|
6
|
+
export type DropTargetProps = {
|
|
8
7
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
9
8
|
id: number;
|
|
10
|
-
prevNode?: PMNode
|
|
11
|
-
nextNode?: PMNode
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}) => jsx.JSX.Element;
|
|
9
|
+
prevNode?: PMNode;
|
|
10
|
+
nextNode?: PMNode;
|
|
11
|
+
parentNode?: PMNode;
|
|
12
|
+
formatMessage?: IntlShape['formatMessage'];
|
|
13
|
+
};
|
|
14
|
+
export declare const DropTarget: ({ api, id, prevNode, nextNode, parentNode, formatMessage, }: DropTargetProps) => jsx.JSX.Element;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { jsx } from '@emotion/react';
|
|
3
2
|
import { type IntlShape } from 'react-intl-next';
|
|
4
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
5
|
import type { BlockControlsPlugin } from '../types';
|
|
7
|
-
export
|
|
6
|
+
export type DropTargetProps = {
|
|
8
7
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
9
8
|
id: number;
|
|
10
|
-
prevNode?: PMNode
|
|
11
|
-
nextNode?: PMNode
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}) => jsx.JSX.Element;
|
|
9
|
+
prevNode?: PMNode;
|
|
10
|
+
nextNode?: PMNode;
|
|
11
|
+
parentNode?: PMNode;
|
|
12
|
+
formatMessage?: IntlShape['formatMessage'];
|
|
13
|
+
};
|
|
14
|
+
export declare const DropTarget: ({ api, id, prevNode, nextNode, parentNode, formatMessage, }: DropTargetProps) => jsx.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^87.
|
|
34
|
+
"@atlaskit/editor-common": "^87.6.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
36
|
+
"@atlaskit/editor-plugin-analytics": "^1.7.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.2.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-width": "^1.2.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
41
41
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
43
|
-
"@atlaskit/icon": "^22.
|
|
43
|
+
"@atlaskit/icon": "^22.11.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
45
|
-
"@atlaskit/pragmatic-drag-and-drop": "^1.
|
|
45
|
+
"@atlaskit/pragmatic-drag-and-drop": "^1.3.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
48
48
|
"@atlaskit/theme": "^12.11.0",
|
|
@@ -94,16 +94,10 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"platform-feature-flags": {
|
|
97
|
-
"platform.editor.elements.drag-and-drop-long-node-scroll": {
|
|
98
|
-
"type": "boolean"
|
|
99
|
-
},
|
|
100
97
|
"platform.editor.media.extended-resize-experience": {
|
|
101
98
|
"type": "boolean",
|
|
102
99
|
"referenceOnly": true
|
|
103
100
|
},
|
|
104
|
-
"platform_editor_elements_drag_and_drop_ed_24000": {
|
|
105
|
-
"type": "boolean"
|
|
106
|
-
},
|
|
107
101
|
"platform_editor_elements_drag_and_drop_ed_23189": {
|
|
108
102
|
"type": "boolean"
|
|
109
103
|
},
|
|
@@ -116,9 +110,6 @@
|
|
|
116
110
|
"platform_editor_elements_drag_and_drop_ed_23394": {
|
|
117
111
|
"type": "boolean"
|
|
118
112
|
},
|
|
119
|
-
"platform_editor_element_drag_and_drop_ed_24049": {
|
|
120
|
-
"type": "boolean"
|
|
121
|
-
},
|
|
122
113
|
"platform_editor_element_controls_chrome_input_fix": {
|
|
123
114
|
"type": "boolean"
|
|
124
115
|
},
|