@atlaskit/editor-plugin-block-controls 1.9.1 → 1.10.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 +8 -0
- package/dist/cjs/commands/move-node.js +23 -4
- package/dist/cjs/pm-plugins/decorations.js +66 -14
- package/dist/cjs/pm-plugins/handle-mouse-over.js +8 -1
- package/dist/cjs/pm-plugins/main.js +16 -8
- package/dist/cjs/ui/consts.js +6 -4
- package/dist/cjs/ui/drop-target.js +3 -3
- package/dist/cjs/ui/global-styles.js +47 -2
- package/dist/es2019/commands/move-node.js +22 -4
- package/dist/es2019/pm-plugins/decorations.js +67 -14
- package/dist/es2019/pm-plugins/handle-mouse-over.js +8 -1
- package/dist/es2019/pm-plugins/main.js +16 -8
- package/dist/es2019/ui/consts.js +5 -3
- package/dist/es2019/ui/drop-target.js +3 -3
- package/dist/es2019/ui/global-styles.js +47 -2
- package/dist/esm/commands/move-node.js +22 -4
- package/dist/esm/pm-plugins/decorations.js +66 -14
- package/dist/esm/pm-plugins/handle-mouse-over.js +8 -1
- package/dist/esm/pm-plugins/main.js +16 -8
- package/dist/esm/ui/consts.js +5 -3
- package/dist/esm/ui/drop-target.js +3 -3
- package/dist/esm/ui/global-styles.js +47 -2
- package/dist/types/pm-plugins/decorations.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/ui/consts.d.ts +3 -0
- package/dist/types/ui/drop-target.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/dist/types-ts4.5/ui/consts.d.ts +3 -0
- package/dist/types-ts4.5/ui/drop-target.d.ts +2 -2
- package/package.json +4 -1
|
@@ -146,13 +146,21 @@ export const createPlugin = (api, getIntl) => {
|
|
|
146
146
|
const decsLength = decorations.find().filter(({
|
|
147
147
|
spec
|
|
148
148
|
}) => spec.id !== 'drag-handle').length;
|
|
149
|
-
|
|
149
|
+
|
|
150
|
+
//TODO: Fix this logic for nested scenarios
|
|
151
|
+
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
152
|
+
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
153
|
+
}
|
|
150
154
|
}
|
|
151
155
|
if (fg('platform_editor_element_drag_and_drop_ed_24372')) {
|
|
152
156
|
const dropTargetLen = decorations.find().filter(({
|
|
153
157
|
spec
|
|
154
158
|
}) => spec.type === 'drop-target-decoration').length;
|
|
155
|
-
|
|
159
|
+
|
|
160
|
+
//TODO: Fix this logic for nested scenarios
|
|
161
|
+
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
162
|
+
isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
|
|
163
|
+
}
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
// This is not targeted enough - it's trying to catch events like expand being set to breakout
|
|
@@ -239,7 +247,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
239
247
|
const shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
240
248
|
let shouldMapDropTargets = false;
|
|
241
249
|
if (fg('platform_editor_element_drag_and_drop_ed_24372')) {
|
|
242
|
-
shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging;
|
|
250
|
+
shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
243
251
|
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
244
252
|
// Remove drop target decoration when dragging stops
|
|
245
253
|
const dropTargetDecs = decorations.find().filter(({
|
|
@@ -260,14 +268,14 @@ export const createPlugin = (api, getIntl) => {
|
|
|
260
268
|
}
|
|
261
269
|
}
|
|
262
270
|
|
|
263
|
-
//
|
|
271
|
+
//Map drop target decoration positions when the document changes
|
|
264
272
|
if (shouldMapDropTargets) {
|
|
265
273
|
decorationState = decorationState.map(({
|
|
266
|
-
|
|
274
|
+
id,
|
|
267
275
|
pos
|
|
268
276
|
}) => {
|
|
269
277
|
return {
|
|
270
|
-
|
|
278
|
+
id,
|
|
271
279
|
pos: tr.mapping.map(pos)
|
|
272
280
|
};
|
|
273
281
|
});
|
|
@@ -298,11 +306,11 @@ export const createPlugin = (api, getIntl) => {
|
|
|
298
306
|
// Map drop target decoration positions when the document changes
|
|
299
307
|
if (tr.docChanged && isDragging) {
|
|
300
308
|
decorationState = decorationState.map(({
|
|
301
|
-
|
|
309
|
+
id,
|
|
302
310
|
pos
|
|
303
311
|
}) => {
|
|
304
312
|
return {
|
|
305
|
-
|
|
313
|
+
id,
|
|
306
314
|
pos: tr.mapping.map(pos)
|
|
307
315
|
};
|
|
308
316
|
});
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -3,15 +3,17 @@ export const DRAG_HANDLE_HEIGHT = 24;
|
|
|
3
3
|
export const DRAG_HANDLE_WIDTH = 12;
|
|
4
4
|
export const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
5
5
|
export const DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
|
|
6
|
-
|
|
6
|
+
export const DRAG_HANDLE_DEFAULT_GAP = 8;
|
|
7
|
+
export const DRAG_HANDLE_MAX_GAP = 12;
|
|
8
|
+
export const DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = DRAG_HANDLE_WIDTH + DRAG_HANDLE_MAX_GAP;
|
|
7
9
|
export const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = 4 + 2; // 4px for the divider vertical padding and 2px for the divider height
|
|
8
10
|
|
|
9
11
|
const nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
|
|
10
12
|
export const dragHandleGap = nodeType => {
|
|
11
13
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
12
|
-
return
|
|
14
|
+
return DRAG_HANDLE_MAX_GAP;
|
|
13
15
|
}
|
|
14
|
-
return
|
|
16
|
+
return DRAG_HANDLE_DEFAULT_GAP;
|
|
15
17
|
};
|
|
16
18
|
export const topPositionAdjustment = nodeType => {
|
|
17
19
|
switch (nodeType) {
|
|
@@ -63,7 +63,7 @@ const styleDropIndicator = css({
|
|
|
63
63
|
});
|
|
64
64
|
export const DropTarget = ({
|
|
65
65
|
api,
|
|
66
|
-
|
|
66
|
+
id,
|
|
67
67
|
prevNode,
|
|
68
68
|
nextNode
|
|
69
69
|
}) => {
|
|
@@ -98,7 +98,7 @@ export const DropTarget = ({
|
|
|
98
98
|
}
|
|
99
99
|
const {
|
|
100
100
|
pos
|
|
101
|
-
} = decorationState.find(dec => dec.
|
|
101
|
+
} = decorationState.find(dec => dec.id === id) || {};
|
|
102
102
|
if (activeNode && pos !== undefined) {
|
|
103
103
|
var _api$core, _api$blockControls2, _api$blockControls2$c;
|
|
104
104
|
const {
|
|
@@ -108,7 +108,7 @@ export const DropTarget = ({
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
|
-
}, [
|
|
111
|
+
}, [id, api]);
|
|
112
112
|
const topTargetMarginStyle = useMemo(() => {
|
|
113
113
|
return getDropTargetPositionStyle(prevNode, nextNode);
|
|
114
114
|
}, [prevNode, nextNode]);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
|
|
8
9
|
const extendedHoverZone = css({
|
|
9
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
10
11
|
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
@@ -31,11 +32,55 @@ const extendedHoverZone = css({
|
|
|
31
32
|
'hr[data-drag-handler-anchor-name]': {
|
|
32
33
|
overflow: 'visible'
|
|
33
34
|
},
|
|
34
|
-
//
|
|
35
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
35
36
|
'[data-blocks-drag-handle-container="true"] + *::after': {
|
|
36
37
|
display: 'none'
|
|
37
38
|
}
|
|
38
39
|
});
|
|
40
|
+
const extendedHoverZoneNested = css({
|
|
41
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
42
|
+
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
44
|
+
display: 'none !important'
|
|
45
|
+
},
|
|
46
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
47
|
+
'.ProseMirror': {
|
|
48
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
49
|
+
'&& [data-drag-handler-anchor-name]::after': {
|
|
50
|
+
content: '""',
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
top: 0,
|
|
53
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
54
|
+
left: `-${DRAG_HANDLE_MAX_WIDTH_PLUS_GAP}px`,
|
|
55
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
56
|
+
width: `${DRAG_HANDLE_MAX_WIDTH_PLUS_GAP}px`,
|
|
57
|
+
height: '100%',
|
|
58
|
+
cursor: 'default',
|
|
59
|
+
zIndex: 1
|
|
60
|
+
},
|
|
61
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
62
|
+
'&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
|
|
63
|
+
content: '""',
|
|
64
|
+
position: 'absolute',
|
|
65
|
+
top: 0,
|
|
66
|
+
left: '-100%',
|
|
67
|
+
width: '100%',
|
|
68
|
+
height: '100%',
|
|
69
|
+
cursor: 'default',
|
|
70
|
+
zIndex: -1
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
// 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
|
|
74
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
75
|
+
'hr[data-drag-handler-anchor-name]': {
|
|
76
|
+
overflow: 'visible'
|
|
77
|
+
},
|
|
78
|
+
//Hide psudeo element at top depth level. Leave for nested depths to prevent mouseover loop.
|
|
79
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
80
|
+
'[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
|
|
81
|
+
display: 'none'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
39
84
|
const paragraphWithTrailingBreak = '+ p > .ProseMirror-trailingBreak';
|
|
40
85
|
const paragraphWithCursorTarget = '+ p > .cursor-target';
|
|
41
86
|
const paragraphWithTrailingBreakAsOnlyChild = '+ p > .ProseMirror-trailingBreak:only-child';
|
|
@@ -118,6 +163,6 @@ const getTextNodeStyle = () => {
|
|
|
118
163
|
};
|
|
119
164
|
export const GlobalStylesWrapper = () => {
|
|
120
165
|
return jsx(Global, {
|
|
121
|
-
styles: [globalStyles, fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')
|
|
166
|
+
styles: [globalStyles, fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? fg('platform_editor_elements_dnd_nested') ? extendedHoverZoneNested : extendedHoverZone : false, getTextNodeStyle(), fg('platform.editor.elements.drag-and-drop-ed-23932') && withDeleteLinesStyleFix, fg('platform_editor_element_drag_and_drop_ed_24005') && withMediaSingleStyleFix]
|
|
122
167
|
});
|
|
123
168
|
};
|
|
@@ -3,11 +3,19 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
6
|
+
import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
|
|
6
7
|
import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { DIRECTION } from '../consts';
|
|
9
10
|
import { key } from '../pm-plugins/main';
|
|
10
11
|
import { selectNode } from '../utils';
|
|
12
|
+
function transformNested(nodeCopy, destType) {
|
|
13
|
+
var firstChild = nodeCopy.content.firstChild;
|
|
14
|
+
if (firstChild && firstChild.type.name === 'nestedExpand' && destType === 'doc') {
|
|
15
|
+
return transformSliceNestedExpandToExpand(nodeCopy, firstChild.type.schema);
|
|
16
|
+
}
|
|
17
|
+
return nodeCopy;
|
|
18
|
+
}
|
|
11
19
|
|
|
12
20
|
/**
|
|
13
21
|
*
|
|
@@ -99,10 +107,20 @@ export var moveNode = function moveNode(api) {
|
|
|
99
107
|
}
|
|
100
108
|
var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
|
|
101
109
|
var end = start + size;
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
var mappedTo;
|
|
111
|
+
if (fg('platform_editor_elements_dnd_nested')) {
|
|
112
|
+
var nodeCopy = tr.doc.slice(start, end, false); // cut the content
|
|
113
|
+
var destType = tr.doc.resolve(to).node().type.name;
|
|
114
|
+
var convertedNode = transformNested(nodeCopy, destType).content;
|
|
115
|
+
tr.delete(start, end); // delete the content from the original position
|
|
116
|
+
mappedTo = tr.mapping.map(to);
|
|
117
|
+
tr.insert(mappedTo, convertedNode); // insert the content at the new position
|
|
118
|
+
} else {
|
|
119
|
+
var _nodeCopy = tr.doc.content.cut(start, end); // cut the content
|
|
120
|
+
tr.delete(start, end); // delete the content from the original position
|
|
121
|
+
mappedTo = tr.mapping.map(to);
|
|
122
|
+
tr.insert(mappedTo, _nodeCopy); // insert the content at the new position
|
|
123
|
+
}
|
|
106
124
|
tr = selectNode(tr, mappedTo, node.type.name);
|
|
107
125
|
tr.setMeta(key, {
|
|
108
126
|
nodeMoved: true
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { createElement } from 'react';
|
|
3
|
+
import { bind } from 'bind-event-listener';
|
|
3
4
|
import ReactDOM from 'react-dom';
|
|
4
5
|
import { RawIntlProvider } from 'react-intl-next';
|
|
5
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -7,6 +8,8 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
7
8
|
import { DragHandle } from '../ui/drag-handle';
|
|
8
9
|
import { DropTarget } from '../ui/drop-target';
|
|
9
10
|
import { MouseMoveWrapper } from '../ui/mouse-move-wrapper';
|
|
11
|
+
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
|
|
12
|
+
var NESTED_DEPTH = fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
10
13
|
export var dropTargetDecorations = function dropTargetDecorations(oldState, newState, api) {
|
|
11
14
|
var decs = [];
|
|
12
15
|
unmountDecorations('data-blocks-drop-target-container');
|
|
@@ -16,13 +19,28 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
16
19
|
var prevNode;
|
|
17
20
|
var state = fg('platform_editor_element_drag_and_drop_ed_24372') ? newState : oldState;
|
|
18
21
|
state.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, _parent, index) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
var depth = 0;
|
|
23
|
+
if (fg('platform_editor_elements_dnd_nested')) {
|
|
24
|
+
depth = newState.doc.resolve(pos).depth;
|
|
25
|
+
if (node.isInline) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (IGNORE_NODES.includes(node.type.name)) {
|
|
29
|
+
return true; //skip over, don't consider it a valid depth
|
|
30
|
+
}
|
|
31
|
+
decorationState.push({
|
|
32
|
+
id: pos,
|
|
33
|
+
pos: pos
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
decorationState.push({
|
|
37
|
+
id: index,
|
|
38
|
+
pos: pos
|
|
39
|
+
});
|
|
40
|
+
}
|
|
23
41
|
var dropTargetDec = /*#__PURE__*/createElement(DropTarget, {
|
|
24
42
|
api: api,
|
|
25
|
-
|
|
43
|
+
id: fg('platform_editor_elements_dnd_nested') ? pos : index,
|
|
26
44
|
prevNode: prevNode,
|
|
27
45
|
nextNode: node
|
|
28
46
|
});
|
|
@@ -37,7 +55,7 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
37
55
|
side: -1
|
|
38
56
|
}));
|
|
39
57
|
prevNode = node;
|
|
40
|
-
return
|
|
58
|
+
return depth < NESTED_DEPTH;
|
|
41
59
|
});
|
|
42
60
|
|
|
43
61
|
/**
|
|
@@ -47,16 +65,25 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
47
65
|
* node and not its size.
|
|
48
66
|
*
|
|
49
67
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
|
|
69
|
+
var lastPos = newState.doc.content.size;
|
|
70
|
+
if (fg('platform_editor_elements_dnd_nested')) {
|
|
71
|
+
decorationState.push({
|
|
72
|
+
id: lastPos,
|
|
73
|
+
pos: lastPos
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
decorationState.push({
|
|
77
|
+
id: decorationState.length + 1,
|
|
78
|
+
pos: newState.doc.nodeSize - 2
|
|
79
|
+
});
|
|
80
|
+
}
|
|
54
81
|
decs.push(Decoration.widget(newState.doc.nodeSize - 2, function () {
|
|
55
82
|
var element = document.createElement('div');
|
|
56
83
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
57
84
|
ReactDOM.render( /*#__PURE__*/createElement(DropTarget, {
|
|
58
85
|
api: api,
|
|
59
|
-
|
|
86
|
+
id: fg('platform_editor_elements_dnd_nested') ? lastPos : decorationState.length
|
|
60
87
|
}), element);
|
|
61
88
|
return element;
|
|
62
89
|
}, {
|
|
@@ -80,7 +107,20 @@ export var nodeDecorations = function nodeDecorations(newState) {
|
|
|
80
107
|
var decs = [];
|
|
81
108
|
newState.doc.descendants(function (node, pos, _parent, index) {
|
|
82
109
|
var _Decoration$node2;
|
|
83
|
-
var
|
|
110
|
+
var depth = 0;
|
|
111
|
+
var anchorName;
|
|
112
|
+
if (fg('platform_editor_elements_dnd_nested')) {
|
|
113
|
+
if (node.isInline) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (IGNORE_NODES.includes(node.type.name)) {
|
|
117
|
+
return true; //skip over, don't consider it a valid depth
|
|
118
|
+
}
|
|
119
|
+
depth = newState.doc.resolve(pos).depth;
|
|
120
|
+
anchorName = "--node-anchor-".concat(node.type.name, "-").concat(pos);
|
|
121
|
+
} else {
|
|
122
|
+
anchorName = "--node-anchor-".concat(node.type.name, "-").concat(index);
|
|
123
|
+
}
|
|
84
124
|
var style;
|
|
85
125
|
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
86
126
|
style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "; position: relative; z-index: 1;");
|
|
@@ -89,10 +129,10 @@ export var nodeDecorations = function nodeDecorations(newState) {
|
|
|
89
129
|
}
|
|
90
130
|
decs.push(Decoration.node(pos, pos + node.nodeSize, (_Decoration$node2 = {
|
|
91
131
|
style: style
|
|
92
|
-
}, _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _Decoration$node2), {
|
|
132
|
+
}, _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), {
|
|
93
133
|
type: 'node-decoration'
|
|
94
134
|
}));
|
|
95
|
-
return
|
|
135
|
+
return depth < NESTED_DEPTH;
|
|
96
136
|
});
|
|
97
137
|
return decs;
|
|
98
138
|
};
|
|
@@ -136,6 +176,7 @@ export var mouseMoveWrapperDecorations = function mouseMoveWrapperDecorations(ne
|
|
|
136
176
|
return decs;
|
|
137
177
|
};
|
|
138
178
|
export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, pos, anchorName, nodeType, handleOptions) {
|
|
179
|
+
var unbind;
|
|
139
180
|
var elementType = fg('platform_editor_element_drag_and_drop_ed_24150') ? 'span' : 'div';
|
|
140
181
|
return Decoration.widget(pos, function (view, getPos) {
|
|
141
182
|
var element = document.createElement(elementType);
|
|
@@ -143,6 +184,14 @@ export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, po
|
|
|
143
184
|
element.style.display = 'inline';
|
|
144
185
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
145
186
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
187
|
+
if (fg('platform_editor_elements_dnd_nested')) {
|
|
188
|
+
unbind = bind(element, {
|
|
189
|
+
type: 'mouseover',
|
|
190
|
+
listener: function listener(e) {
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
146
195
|
if (fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
147
196
|
unmountDecorations('data-blocks-drag-handle-container');
|
|
148
197
|
}
|
|
@@ -166,6 +215,9 @@ export var dragHandleDecoration = function dragHandleDecoration(api, getIntl, po
|
|
|
166
215
|
side: -1,
|
|
167
216
|
id: 'drag-handle',
|
|
168
217
|
destroy: function destroy(node) {
|
|
218
|
+
if (fg('platform_editor_elements_dnd_nested')) {
|
|
219
|
+
unbind && unbind();
|
|
220
|
+
}
|
|
169
221
|
if (!fg('platform_editor_element_drag_and_drop_ed_23896')) {
|
|
170
222
|
ReactDOM.unmountComponentAtNode(node);
|
|
171
223
|
}
|
|
@@ -23,7 +23,14 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
25
|
var pos = view.posAtDOM(rootElement, 0, 0);
|
|
26
|
-
var rootPos
|
|
26
|
+
var rootPos;
|
|
27
|
+
if (fg('platform_editor_elements_dnd_nested')) {
|
|
28
|
+
var $rootPos = view.state.doc.resolve(pos);
|
|
29
|
+
var depth = $rootPos.depth;
|
|
30
|
+
rootPos = depth ? $rootPos.before() : $rootPos.pos;
|
|
31
|
+
} else {
|
|
32
|
+
rootPos = view.state.doc.resolve(pos).start(1) - 1;
|
|
33
|
+
}
|
|
27
34
|
var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
|
|
28
35
|
if (nodeType) {
|
|
29
36
|
var _api$core, _api$blockControls2;
|
|
@@ -148,14 +148,22 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
148
148
|
var spec = _ref7.spec;
|
|
149
149
|
return spec.id !== 'drag-handle';
|
|
150
150
|
}).length;
|
|
151
|
-
|
|
151
|
+
|
|
152
|
+
//TODO: Fix this logic for nested scenarios
|
|
153
|
+
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
154
|
+
isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
|
|
155
|
+
}
|
|
152
156
|
}
|
|
153
157
|
if (fg('platform_editor_element_drag_and_drop_ed_24372')) {
|
|
154
158
|
var dropTargetLen = decorations.find().filter(function (_ref8) {
|
|
155
159
|
var spec = _ref8.spec;
|
|
156
160
|
return spec.type === 'drop-target-decoration';
|
|
157
161
|
}).length;
|
|
158
|
-
|
|
162
|
+
|
|
163
|
+
//TODO: Fix this logic for nested scenarios
|
|
164
|
+
if (!fg('platform_editor_elements_dnd_nested')) {
|
|
165
|
+
isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
|
|
166
|
+
}
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
// This is not targeted enough - it's trying to catch events like expand being set to breakout
|
|
@@ -245,7 +253,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
245
253
|
var shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
|
|
246
254
|
var shouldMapDropTargets = false;
|
|
247
255
|
if (fg('platform_editor_element_drag_and_drop_ed_24372')) {
|
|
248
|
-
shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging;
|
|
256
|
+
shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
249
257
|
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
250
258
|
// Remove drop target decoration when dragging stops
|
|
251
259
|
var dropTargetDecs = decorations.find().filter(function (_ref12) {
|
|
@@ -266,13 +274,13 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
266
274
|
}
|
|
267
275
|
}
|
|
268
276
|
|
|
269
|
-
//
|
|
277
|
+
//Map drop target decoration positions when the document changes
|
|
270
278
|
if (shouldMapDropTargets) {
|
|
271
279
|
decorationState = decorationState.map(function (_ref13) {
|
|
272
|
-
var
|
|
280
|
+
var id = _ref13.id,
|
|
273
281
|
pos = _ref13.pos;
|
|
274
282
|
return {
|
|
275
|
-
|
|
283
|
+
id: id,
|
|
276
284
|
pos: tr.mapping.map(pos)
|
|
277
285
|
};
|
|
278
286
|
});
|
|
@@ -303,10 +311,10 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
303
311
|
// Map drop target decoration positions when the document changes
|
|
304
312
|
if (tr.docChanged && isDragging) {
|
|
305
313
|
decorationState = decorationState.map(function (_ref15) {
|
|
306
|
-
var
|
|
314
|
+
var id = _ref15.id,
|
|
307
315
|
pos = _ref15.pos;
|
|
308
316
|
return {
|
|
309
|
-
|
|
317
|
+
id: id,
|
|
310
318
|
pos: tr.mapping.map(pos)
|
|
311
319
|
};
|
|
312
320
|
});
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -5,15 +5,17 @@ export var DRAG_HANDLE_HEIGHT = 24;
|
|
|
5
5
|
export var DRAG_HANDLE_WIDTH = 12;
|
|
6
6
|
export var DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
7
7
|
export var DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
|
|
8
|
-
|
|
8
|
+
export var DRAG_HANDLE_DEFAULT_GAP = 8;
|
|
9
|
+
export var DRAG_HANDLE_MAX_GAP = 12;
|
|
10
|
+
export var DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = DRAG_HANDLE_WIDTH + DRAG_HANDLE_MAX_GAP;
|
|
9
11
|
export var DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = 4 + 2; // 4px for the divider vertical padding and 2px for the divider height
|
|
10
12
|
|
|
11
13
|
var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
|
|
12
14
|
export var dragHandleGap = function dragHandleGap(nodeType) {
|
|
13
15
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
14
|
-
return
|
|
16
|
+
return DRAG_HANDLE_MAX_GAP;
|
|
15
17
|
}
|
|
16
|
-
return
|
|
18
|
+
return DRAG_HANDLE_DEFAULT_GAP;
|
|
17
19
|
};
|
|
18
20
|
export var topPositionAdjustment = function topPositionAdjustment(nodeType) {
|
|
19
21
|
switch (nodeType) {
|
|
@@ -69,7 +69,7 @@ var styleDropIndicator = css({
|
|
|
69
69
|
});
|
|
70
70
|
export var DropTarget = function DropTarget(_ref3) {
|
|
71
71
|
var api = _ref3.api,
|
|
72
|
-
|
|
72
|
+
id = _ref3.id,
|
|
73
73
|
prevNode = _ref3.prevNode,
|
|
74
74
|
nextNode = _ref3.nextNode;
|
|
75
75
|
var ref = useRef(null);
|
|
@@ -105,7 +105,7 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
var _ref5 = decorationState.find(function (dec) {
|
|
108
|
-
return dec.
|
|
108
|
+
return dec.id === id;
|
|
109
109
|
}) || {},
|
|
110
110
|
pos = _ref5.pos;
|
|
111
111
|
if (activeNode && pos !== undefined) {
|
|
@@ -115,7 +115,7 @@ export var DropTarget = function DropTarget(_ref3) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
|
-
}, [
|
|
118
|
+
}, [id, api]);
|
|
119
119
|
var topTargetMarginStyle = useMemo(function () {
|
|
120
120
|
return getDropTargetPositionStyle(prevNode, nextNode);
|
|
121
121
|
}, [prevNode, nextNode]);
|
|
@@ -6,6 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, Global, jsx } from '@emotion/react';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
|
|
9
10
|
var extendedHoverZone = css({
|
|
10
11
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
11
12
|
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
@@ -32,11 +33,55 @@ var extendedHoverZone = css({
|
|
|
32
33
|
'hr[data-drag-handler-anchor-name]': {
|
|
33
34
|
overflow: 'visible'
|
|
34
35
|
},
|
|
35
|
-
//
|
|
36
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
36
37
|
'[data-blocks-drag-handle-container="true"] + *::after': {
|
|
37
38
|
display: 'none'
|
|
38
39
|
}
|
|
39
40
|
});
|
|
41
|
+
var extendedHoverZoneNested = css({
|
|
42
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
43
|
+
'.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
|
|
44
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
45
|
+
display: 'none !important'
|
|
46
|
+
},
|
|
47
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
48
|
+
'.ProseMirror': {
|
|
49
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
50
|
+
'&& [data-drag-handler-anchor-name]::after': {
|
|
51
|
+
content: '""',
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
top: 0,
|
|
54
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
55
|
+
left: "-".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
56
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
57
|
+
width: "".concat(DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
|
|
58
|
+
height: '100%',
|
|
59
|
+
cursor: 'default',
|
|
60
|
+
zIndex: 1
|
|
61
|
+
},
|
|
62
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
63
|
+
'&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
|
|
64
|
+
content: '""',
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
top: 0,
|
|
67
|
+
left: '-100%',
|
|
68
|
+
width: '100%',
|
|
69
|
+
height: '100%',
|
|
70
|
+
cursor: 'default',
|
|
71
|
+
zIndex: -1
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
// 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
|
|
75
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
76
|
+
'hr[data-drag-handler-anchor-name]': {
|
|
77
|
+
overflow: 'visible'
|
|
78
|
+
},
|
|
79
|
+
//Hide psudeo element at top depth level. Leave for nested depths to prevent mouseover loop.
|
|
80
|
+
//eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
81
|
+
'[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
|
|
82
|
+
display: 'none'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
40
85
|
var paragraphWithTrailingBreak = '+ p > .ProseMirror-trailingBreak';
|
|
41
86
|
var paragraphWithCursorTarget = '+ p > .cursor-target';
|
|
42
87
|
var paragraphWithTrailingBreakAsOnlyChild = '+ p > .ProseMirror-trailingBreak:only-child';
|
|
@@ -96,6 +141,6 @@ var getTextNodeStyle = function getTextNodeStyle() {
|
|
|
96
141
|
};
|
|
97
142
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
98
143
|
return jsx(Global, {
|
|
99
|
-
styles: [globalStyles, fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')
|
|
144
|
+
styles: [globalStyles, fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? fg('platform_editor_elements_dnd_nested') ? extendedHoverZoneNested : extendedHoverZone : false, getTextNodeStyle(), fg('platform.editor.elements.drag-and-drop-ed-23932') && withDeleteLinesStyleFix, fg('platform_editor_element_drag_and_drop_ed_24005') && withMediaSingleStyleFix]
|
|
100
145
|
});
|
|
101
146
|
};
|
|
@@ -6,7 +6,7 @@ import type { BlockControlsPlugin, HandleOptions } from '../types';
|
|
|
6
6
|
export declare const dropTargetDecorations: (oldState: EditorState, newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>) => {
|
|
7
7
|
decs: Decoration[];
|
|
8
8
|
decorationState: {
|
|
9
|
-
|
|
9
|
+
id: number;
|
|
10
10
|
pos: number;
|
|
11
11
|
}[];
|
|
12
12
|
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export declare const DRAG_HANDLE_HEIGHT = 24;
|
|
|
2
2
|
export declare const DRAG_HANDLE_WIDTH = 12;
|
|
3
3
|
export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
4
4
|
export declare const DRAG_HANDLE_ZINDEX: number;
|
|
5
|
+
export declare const DRAG_HANDLE_DEFAULT_GAP = 8;
|
|
6
|
+
export declare const DRAG_HANDLE_MAX_GAP = 12;
|
|
7
|
+
export declare const DRAG_HANDLE_MAX_WIDTH_PLUS_GAP: number;
|
|
5
8
|
export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
|
|
6
9
|
export declare const dragHandleGap: (nodeType: string) => 8 | 12;
|
|
7
10
|
export declare const topPositionAdjustment: (nodeType: string) => number;
|
|
@@ -2,9 +2,9 @@ import { jsx } from '@emotion/react';
|
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { BlockControlsPlugin } from '../types';
|
|
5
|
-
export declare const DropTarget: ({ api,
|
|
5
|
+
export declare const DropTarget: ({ api, id, prevNode, nextNode, }: {
|
|
6
6
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
7
|
-
|
|
7
|
+
id: number;
|
|
8
8
|
prevNode?: PMNode | undefined;
|
|
9
9
|
nextNode?: PMNode | undefined;
|
|
10
10
|
}) => jsx.JSX.Element;
|
|
@@ -6,7 +6,7 @@ import type { BlockControlsPlugin, HandleOptions } from '../types';
|
|
|
6
6
|
export declare const dropTargetDecorations: (oldState: EditorState, newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>) => {
|
|
7
7
|
decs: Decoration[];
|
|
8
8
|
decorationState: {
|
|
9
|
-
|
|
9
|
+
id: number;
|
|
10
10
|
pos: number;
|
|
11
11
|
}[];
|
|
12
12
|
};
|