@atlaskit/editor-plugin-block-controls 1.9.1 → 1.10.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/commands/move-node.js +23 -4
  3. package/dist/cjs/pm-plugins/decorations.js +66 -14
  4. package/dist/cjs/pm-plugins/handle-mouse-over.js +8 -1
  5. package/dist/cjs/pm-plugins/main.js +18 -9
  6. package/dist/cjs/ui/consts.js +6 -4
  7. package/dist/cjs/ui/drag-handle.js +30 -25
  8. package/dist/cjs/ui/drop-target.js +3 -3
  9. package/dist/cjs/ui/global-styles.js +47 -2
  10. package/dist/es2019/commands/move-node.js +22 -4
  11. package/dist/es2019/pm-plugins/decorations.js +67 -14
  12. package/dist/es2019/pm-plugins/handle-mouse-over.js +8 -1
  13. package/dist/es2019/pm-plugins/main.js +18 -9
  14. package/dist/es2019/ui/consts.js +5 -3
  15. package/dist/es2019/ui/drag-handle.js +30 -25
  16. package/dist/es2019/ui/drop-target.js +3 -3
  17. package/dist/es2019/ui/global-styles.js +47 -2
  18. package/dist/esm/commands/move-node.js +22 -4
  19. package/dist/esm/pm-plugins/decorations.js +66 -14
  20. package/dist/esm/pm-plugins/handle-mouse-over.js +8 -1
  21. package/dist/esm/pm-plugins/main.js +18 -9
  22. package/dist/esm/ui/consts.js +5 -3
  23. package/dist/esm/ui/drag-handle.js +30 -25
  24. package/dist/esm/ui/drop-target.js +3 -3
  25. package/dist/esm/ui/global-styles.js +47 -2
  26. package/dist/types/pm-plugins/decorations.d.ts +1 -1
  27. package/dist/types/types.d.ts +1 -1
  28. package/dist/types/ui/consts.d.ts +3 -0
  29. package/dist/types/ui/drop-target.d.ts +2 -2
  30. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +1 -1
  31. package/dist/types-ts4.5/types.d.ts +1 -1
  32. package/dist/types-ts4.5/ui/consts.d.ts +3 -0
  33. package/dist/types-ts4.5/ui/drop-target.d.ts +2 -2
  34. package/package.json +9 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#125542](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/125542)
8
+ [`06bc2f65f892e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/06bc2f65f892e) -
9
+ ED-24304 resolve range error issue
10
+
11
+ ## 1.10.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#123594](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/123594)
16
+ [`ea6c9a5361f96`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ea6c9a5361f96) -
17
+ [ux] Add prelim nested DnD support
18
+
3
19
  ## 1.9.1
4
20
 
5
21
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.moveNodeViaShortcut = exports.moveNode = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _selection = require("@atlaskit/editor-common/selection");
11
+ var _transforms = require("@atlaskit/editor-common/transforms");
11
12
  var _utils = require("@atlaskit/editor-tables/utils");
12
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _consts = require("../consts");
@@ -15,6 +16,14 @@ var _main = require("../pm-plugins/main");
15
16
  var _utils2 = require("../utils");
16
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
18
  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) { (0, _defineProperty2.default)(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; }
19
+ function transformNested(nodeCopy, destType) {
20
+ var firstChild = nodeCopy.content.firstChild;
21
+ if (firstChild && firstChild.type.name === 'nestedExpand' && destType === 'doc') {
22
+ return (0, _transforms.transformSliceNestedExpandToExpand)(nodeCopy, firstChild.type.schema);
23
+ }
24
+ return nodeCopy;
25
+ }
26
+
18
27
  /**
19
28
  *
20
29
  * @returns the start position of a node if the node can be moved, otherwise -1
@@ -105,10 +114,20 @@ var moveNode = exports.moveNode = function moveNode(api) {
105
114
  }
106
115
  var size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
107
116
  var end = start + size;
108
- var nodeCopy = tr.doc.content.cut(start, end); // cut the content
109
- tr.delete(start, end); // delete the content from the original position
110
- var mappedTo = tr.mapping.map(to);
111
- tr.insert(mappedTo, nodeCopy); // insert the content at the new position
117
+ var mappedTo;
118
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
119
+ var nodeCopy = tr.doc.slice(start, end, false); // cut the content
120
+ var destType = tr.doc.resolve(to).node().type.name;
121
+ var convertedNode = transformNested(nodeCopy, destType).content;
122
+ tr.delete(start, end); // delete the content from the original position
123
+ mappedTo = tr.mapping.map(to);
124
+ tr.insert(mappedTo, convertedNode); // insert the content at the new position
125
+ } else {
126
+ var _nodeCopy = tr.doc.content.cut(start, end); // cut the content
127
+ tr.delete(start, end); // delete the content from the original position
128
+ mappedTo = tr.mapping.map(to);
129
+ tr.insert(mappedTo, _nodeCopy); // insert the content at the new position
130
+ }
112
131
  tr = (0, _utils2.selectNode)(tr, mappedTo, node.type.name);
113
132
  tr.setMeta(_main.key, {
114
133
  nodeMoved: true
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.nodeDecorations = exports.mouseMoveWrapperDecorations = exports.emptyParagraphNodeDecorations = exports.dropTargetDecorations = exports.dragHandleDecoration = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
+ var _bindEventListener = require("bind-event-listener");
10
11
  var _reactDom = _interopRequireDefault(require("react-dom"));
11
12
  var _reactIntlNext = require("react-intl-next");
12
13
  var _view = require("@atlaskit/editor-prosemirror/view");
@@ -14,6 +15,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
15
  var _dragHandle = require("../ui/drag-handle");
15
16
  var _dropTarget = require("../ui/drop-target");
16
17
  var _mouseMoveWrapper = require("../ui/mouse-move-wrapper");
18
+ var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn'];
19
+ var NESTED_DEPTH = (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? 100 : 0;
17
20
  var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(oldState, newState, api) {
18
21
  var decs = [];
19
22
  unmountDecorations('data-blocks-drop-target-container');
@@ -23,13 +26,28 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
23
26
  var prevNode;
24
27
  var state = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24372') ? newState : oldState;
25
28
  state.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, _parent, index) {
26
- decorationState.push({
27
- index: index,
28
- pos: pos
29
- });
29
+ var depth = 0;
30
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
31
+ depth = newState.doc.resolve(pos).depth;
32
+ if (node.isInline) {
33
+ return false;
34
+ }
35
+ if (IGNORE_NODES.includes(node.type.name)) {
36
+ return true; //skip over, don't consider it a valid depth
37
+ }
38
+ decorationState.push({
39
+ id: pos,
40
+ pos: pos
41
+ });
42
+ } else {
43
+ decorationState.push({
44
+ id: index,
45
+ pos: pos
46
+ });
47
+ }
30
48
  var dropTargetDec = /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
31
49
  api: api,
32
- index: index,
50
+ id: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? pos : index,
33
51
  prevNode: prevNode,
34
52
  nextNode: node
35
53
  });
@@ -44,7 +62,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
44
62
  side: -1
45
63
  }));
46
64
  prevNode = node;
47
- return false;
65
+ return depth < NESTED_DEPTH;
48
66
  });
49
67
 
50
68
  /**
@@ -54,16 +72,25 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
54
72
  * node and not its size.
55
73
  *
56
74
  */
57
- decorationState.push({
58
- index: decorationState.length + 1,
59
- pos: newState.doc.nodeSize - 2
60
- });
75
+
76
+ var lastPos = newState.doc.content.size;
77
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
78
+ decorationState.push({
79
+ id: lastPos,
80
+ pos: lastPos
81
+ });
82
+ } else {
83
+ decorationState.push({
84
+ id: decorationState.length + 1,
85
+ pos: newState.doc.nodeSize - 2
86
+ });
87
+ }
61
88
  decs.push(_view.Decoration.widget(newState.doc.nodeSize - 2, function () {
62
89
  var element = document.createElement('div');
63
90
  element.setAttribute('data-blocks-drop-target-container', 'true');
64
91
  _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
65
92
  api: api,
66
- index: decorationState.length
93
+ id: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? lastPos : decorationState.length
67
94
  }), element);
68
95
  return element;
69
96
  }, {
@@ -87,7 +114,20 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
87
114
  var decs = [];
88
115
  newState.doc.descendants(function (node, pos, _parent, index) {
89
116
  var _Decoration$node2;
90
- var anchorName = "--node-anchor-".concat(node.type.name, "-").concat(index);
117
+ var depth = 0;
118
+ var anchorName;
119
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
120
+ if (node.isInline) {
121
+ return false;
122
+ }
123
+ if (IGNORE_NODES.includes(node.type.name)) {
124
+ return true; //skip over, don't consider it a valid depth
125
+ }
126
+ depth = newState.doc.resolve(pos).depth;
127
+ anchorName = "--node-anchor-".concat(node.type.name, "-").concat(pos);
128
+ } else {
129
+ anchorName = "--node-anchor-".concat(node.type.name, "-").concat(index);
130
+ }
91
131
  var style;
92
132
  if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
93
133
  style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "; position: relative; z-index: 1;");
@@ -96,10 +136,10 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
96
136
  }
97
137
  decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (_Decoration$node2 = {
98
138
  style: style
99
- }, (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _Decoration$node2), {
139
+ }, (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), {
100
140
  type: 'node-decoration'
101
141
  }));
102
- return false;
142
+ return depth < NESTED_DEPTH;
103
143
  });
104
144
  return decs;
105
145
  };
@@ -143,6 +183,7 @@ var mouseMoveWrapperDecorations = exports.mouseMoveWrapperDecorations = function
143
183
  return decs;
144
184
  };
145
185
  var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, getIntl, pos, anchorName, nodeType, handleOptions) {
186
+ var unbind;
146
187
  var elementType = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24150') ? 'span' : 'div';
147
188
  return _view.Decoration.widget(pos, function (view, getPos) {
148
189
  var element = document.createElement(elementType);
@@ -150,6 +191,14 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
150
191
  element.style.display = 'inline';
151
192
  element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
152
193
  element.setAttribute('data-blocks-drag-handle-container', 'true');
194
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
195
+ unbind = (0, _bindEventListener.bind)(element, {
196
+ type: 'mouseover',
197
+ listener: function listener(e) {
198
+ e.stopPropagation();
199
+ }
200
+ });
201
+ }
153
202
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23896')) {
154
203
  unmountDecorations('data-blocks-drag-handle-container');
155
204
  }
@@ -173,6 +222,9 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
173
222
  side: -1,
174
223
  id: 'drag-handle',
175
224
  destroy: function destroy(node) {
225
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
226
+ unbind && unbind();
227
+ }
176
228
  if (!(0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23896')) {
177
229
  _reactDom.default.unmountComponentAtNode(node);
178
230
  }
@@ -29,7 +29,14 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
29
29
  return false;
30
30
  }
31
31
  var pos = view.posAtDOM(rootElement, 0, 0);
32
- var rootPos = view.state.doc.resolve(pos).start(1) - 1;
32
+ var rootPos;
33
+ if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
34
+ var $rootPos = view.state.doc.resolve(pos);
35
+ var depth = $rootPos.depth;
36
+ rootPos = depth ? $rootPos.before() : $rootPos.pos;
37
+ } else {
38
+ rootPos = view.state.doc.resolve(pos).start(1) - 1;
39
+ }
33
40
  var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
34
41
  if (nodeType) {
35
42
  var _api$core, _api$blockControls2;
@@ -155,14 +155,22 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
155
155
  var spec = _ref7.spec;
156
156
  return spec.id !== 'drag-handle';
157
157
  }).length;
158
- isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
158
+
159
+ //TODO: Fix this logic for nested scenarios
160
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
161
+ isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
162
+ }
159
163
  }
160
164
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24372')) {
161
165
  var dropTargetLen = decorations.find().filter(function (_ref8) {
162
166
  var spec = _ref8.spec;
163
167
  return spec.type === 'drop-target-decoration';
164
168
  }).length;
165
- isDropTargetsMissing = isDragging && dropTargetLen !== newState.doc.childCount + 1;
169
+
170
+ //TODO: Fix this logic for nested scenarios
171
+ if (!(0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
172
+ isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
173
+ }
166
174
  }
167
175
 
168
176
  // This is not targeted enough - it's trying to catch events like expand being set to breakout
@@ -252,7 +260,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
252
260
  var shouldUpdateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
253
261
  var shouldMapDropTargets = false;
254
262
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24372')) {
255
- shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging;
263
+ shouldMapDropTargets = !shouldUpdateDropTargets && tr.docChanged && isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && !(meta !== null && meta !== void 0 && meta.nodeMoved);
256
264
  if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
257
265
  // Remove drop target decoration when dragging stops
258
266
  var dropTargetDecs = decorations.find().filter(function (_ref12) {
@@ -273,13 +281,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
273
281
  }
274
282
  }
275
283
 
276
- // Map drop target decoration positions when the document changes
284
+ //Map drop target decoration positions when the document changes
277
285
  if (shouldMapDropTargets) {
278
286
  decorationState = decorationState.map(function (_ref13) {
279
- var index = _ref13.index,
287
+ var id = _ref13.id,
280
288
  pos = _ref13.pos;
281
289
  return {
282
- index: index,
290
+ id: id,
283
291
  pos: tr.mapping.map(pos)
284
292
  };
285
293
  });
@@ -310,10 +318,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
310
318
  // Map drop target decoration positions when the document changes
311
319
  if (tr.docChanged && isDragging) {
312
320
  decorationState = decorationState.map(function (_ref15) {
313
- var index = _ref15.index,
321
+ var id = _ref15.id,
314
322
  pos = _ref15.pos;
315
323
  return {
316
- index: index,
324
+ id: id,
317
325
  pos: tr.mapping.map(pos)
318
326
  };
319
327
  });
@@ -400,7 +408,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
400
408
  if (!nodeElement) {
401
409
  return false;
402
410
  }
403
- var nodeTarget = state.doc.nodeAt(view.posAtDOM(nodeElement, 0) - 1);
411
+ var domPos = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24304') ? Math.max(view.posAtDOM(nodeElement, 0) - 1, 0) : view.posAtDOM(nodeElement, 0) - 1;
412
+ var nodeTarget = state.doc.nodeAt(domPos);
404
413
  isSameNode = !!(nodeTarget && draggable !== null && draggable !== void 0 && draggable.eq(nodeTarget));
405
414
  }
406
415
  if (isSameNode) {
@@ -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.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
7
+ exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
10
10
  var _dropTargetMarginMap;
@@ -12,15 +12,17 @@ var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
12
12
  var DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_WIDTH = 12;
13
13
  var DRAG_HANDLE_BORDER_RADIUS = exports.DRAG_HANDLE_BORDER_RADIUS = 4;
14
14
  var DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_ZINDEX = _editorSharedStyles.akRichMediaResizeZIndex + _editorSharedStyles.akEditorUnitZIndex; //place above legacy resizer
15
-
15
+ var DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_DEFAULT_GAP = 8;
16
+ var DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_MAX_GAP = 12;
17
+ var DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = DRAG_HANDLE_WIDTH + DRAG_HANDLE_MAX_GAP;
16
18
  var DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = 4 + 2; // 4px for the divider vertical padding and 2px for the divider height
17
19
 
18
20
  var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
19
21
  var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType) {
20
22
  if (nodeTypeExcludeList.includes(nodeType)) {
21
- return 12;
23
+ return DRAG_HANDLE_MAX_GAP;
22
24
  }
23
- return 8;
25
+ return DRAG_HANDLE_DEFAULT_GAP;
24
26
  };
25
27
  var topPositionAdjustment = exports.topPositionAdjustment = function topPositionAdjustment(nodeType) {
26
28
  switch (nodeType) {
@@ -68,6 +68,7 @@ var selectedStyles = (0, _react2.css)({
68
68
  color: "var(--ds-icon-selected, #0C66E4)"
69
69
  });
70
70
  var DragHandleInternal = function DragHandleInternal(_ref) {
71
+ var _api$core2, _api$analytics2, _api$core5, _api$core7;
71
72
  var view = _ref.view,
72
73
  api = _ref.api,
73
74
  getPos = _ref.getPos,
@@ -110,14 +111,15 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
110
111
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
111
112
  var _api$analytics;
112
113
  var tr = _ref2.tr;
113
- if (start === undefined) {
114
+ var startPos = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24304') ? getPos() : start;
115
+ if (startPos === undefined) {
114
116
  return tr;
115
117
  }
116
- tr = (0, _utils.selectNode)(tr, start, nodeType);
118
+ tr = (0, _utils.selectNode)(tr, startPos, nodeType);
117
119
  tr.setMeta(_main.key, {
118
- pos: start
120
+ pos: startPos
119
121
  });
120
- var resolvedMovingNode = tr.doc.resolve(start);
122
+ var resolvedMovingNode = tr.doc.resolve(startPos);
121
123
  var maybeNode = resolvedMovingNode.nodeAfter;
122
124
  (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-long-node-scroll') && tr.setMeta('scrollIntoView', false);
123
125
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
@@ -133,14 +135,14 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
133
135
  return tr;
134
136
  });
135
137
  view.focus();
136
- }, [start, api, view, dragHandleSelected, setDragHandleSelected, nodeType]);
138
+ }, [dragHandleSelected, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, view, getPos, start, nodeType]);
137
139
 
138
140
  // handleMouseDown required along with onClick to ensure the correct selection
139
141
  // is set immediately when the drag handle is clicked. Otherwise browser native
140
142
  // drag and drop can take over and cause unpredictable behaviour.
141
143
  var handleMouseDown = (0, _react.useCallback)(function () {
142
- var _api$core2;
143
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
144
+ var _api$core3;
145
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
144
146
  var tr = _ref3.tr;
145
147
  if (start === undefined) {
146
148
  return tr;
@@ -158,44 +160,47 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
158
160
  // as expected with a node selection. This workaround sets the selection to the node on mouseDown,
159
161
  // but ensures the preview is generated correctly.
160
162
  var handleMouseDownWrapperRemoved = (0, _react.useCallback)(function () {
161
- var _api$core3;
162
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref4) {
163
+ var _api$core4;
164
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref4) {
163
165
  var tr = _ref4.tr;
164
- if (start === undefined) {
166
+ var startPos = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24304') ? getPos() : start;
167
+ if (startPos === undefined) {
165
168
  return tr;
166
169
  }
167
- var node = tr.doc.nodeAt(start);
170
+ var node = tr.doc.nodeAt(startPos);
168
171
  if (!node) {
169
172
  return tr;
170
173
  }
171
- var $startPos = tr.doc.resolve(start + node.nodeSize);
174
+ var $startPos = tr.doc.resolve(startPos + node.nodeSize);
172
175
  var selection = new _state.TextSelection($startPos);
173
176
  tr.setSelection(selection);
174
177
  tr.setMeta(_main.key, {
175
- pos: start
178
+ pos: startPos
176
179
  });
177
180
  return tr;
178
181
  });
179
- }, [start, api]);
182
+ }, [api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions, getPos, start]);
180
183
  var handleKeyDown = (0, _react.useCallback)(function (e) {
181
184
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
182
185
  // allow user to use spacebar to select the node
186
+
183
187
  if (!e.repeat && e.key === ' ') {
184
- var _api$core4;
185
- api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref5) {
188
+ var _api$core6;
189
+ var startPos = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24304') ? getPos() : start;
190
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref5) {
186
191
  var tr = _ref5.tr;
187
- if (start === undefined) {
192
+ if (startPos === undefined) {
188
193
  return tr;
189
194
  }
190
- var node = tr.doc.nodeAt(start);
195
+ var node = tr.doc.nodeAt(startPos);
191
196
  if (!node) {
192
197
  return tr;
193
198
  }
194
- var $startPos = tr.doc.resolve(start + node.nodeSize);
199
+ var $startPos = tr.doc.resolve(startPos + node.nodeSize);
195
200
  var selection = new _state.TextSelection($startPos);
196
201
  tr.setSelection(selection);
197
202
  tr.setMeta(_main.key, {
198
- pos: start
203
+ pos: startPos
199
204
  });
200
205
  return tr;
201
206
  });
@@ -207,7 +212,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
207
212
  view.focus();
208
213
  }
209
214
  }
210
- }, [start, api, view]);
215
+ }, [getPos, start, api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 ? void 0 : _api$core7.actions, view]);
211
216
  (0, _react.useEffect)(function () {
212
217
  var element = buttonRef.current;
213
218
  if (!element) {
@@ -236,12 +241,12 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
236
241
  });
237
242
  },
238
243
  onDragStart: function onDragStart() {
239
- var _api$core5;
244
+ var _api$core8;
240
245
  if (start === undefined) {
241
246
  return;
242
247
  }
243
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref8) {
244
- var _api$blockControls, _api$analytics2;
248
+ api === null || api === void 0 || (_api$core8 = api.core) === null || _api$core8 === void 0 || _api$core8.actions.execute(function (_ref8) {
249
+ var _api$blockControls, _api$analytics3;
245
250
  var tr = _ref8.tr;
246
251
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setNodeDragged(start, anchorName, nodeType)({
247
252
  tr: tr
@@ -249,7 +254,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
249
254
  var resolvedMovingNode = tr.doc.resolve(start);
250
255
  var maybeNode = resolvedMovingNode.nodeAfter;
251
256
  tr.setMeta('scrollIntoView', false);
252
- api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
257
+ api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
253
258
  eventType: _analytics.EVENT_TYPE.UI,
254
259
  action: _analytics.ACTION.DRAGGED,
255
260
  actionSubject: _analytics.ACTION_SUBJECT.ELEMENT,
@@ -77,7 +77,7 @@ var styleDropIndicator = (0, _react2.css)({
77
77
  });
78
78
  var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
79
79
  var api = _ref3.api,
80
- index = _ref3.index,
80
+ id = _ref3.id,
81
81
  prevNode = _ref3.prevNode,
82
82
  nextNode = _ref3.nextNode;
83
83
  var ref = (0, _react.useRef)(null);
@@ -113,7 +113,7 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
113
113
  return;
114
114
  }
115
115
  var _ref5 = decorationState.find(function (dec) {
116
- return dec.index === index;
116
+ return dec.id === id;
117
117
  }) || {},
118
118
  pos = _ref5.pos;
119
119
  if (activeNode && pos !== undefined) {
@@ -123,7 +123,7 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
123
123
  }
124
124
  }
125
125
  });
126
- }, [index, api]);
126
+ }, [id, api]);
127
127
  var topTargetMarginStyle = (0, _react.useMemo)(function () {
128
128
  return getDropTargetPositionStyle(prevNode, nextNode);
129
129
  }, [prevNode, nextNode]);
@@ -8,6 +8,7 @@ exports.GlobalStylesWrapper = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("@emotion/react");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ var _consts = require("./consts");
11
12
  /**
12
13
  * @jsxRuntime classic
13
14
  * @jsx jsx
@@ -40,11 +41,55 @@ var extendedHoverZone = (0, _react.css)({
40
41
  'hr[data-drag-handler-anchor-name]': {
41
42
  overflow: 'visible'
42
43
  },
43
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
44
+ //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
44
45
  '[data-blocks-drag-handle-container="true"] + *::after': {
45
46
  display: 'none'
46
47
  }
47
48
  });
49
+ var extendedHoverZoneNested = (0, _react.css)({
50
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
51
+ '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
52
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
53
+ display: 'none !important'
54
+ },
55
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
56
+ '.ProseMirror': {
57
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
58
+ '&& [data-drag-handler-anchor-name]::after': {
59
+ content: '""',
60
+ position: 'absolute',
61
+ top: 0,
62
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
63
+ left: "-".concat(_consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
64
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
65
+ width: "".concat(_consts.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, "px"),
66
+ height: '100%',
67
+ cursor: 'default',
68
+ zIndex: 1
69
+ },
70
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
71
+ '&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]::after': {
72
+ content: '""',
73
+ position: 'absolute',
74
+ top: 0,
75
+ left: '-100%',
76
+ width: '100%',
77
+ height: '100%',
78
+ cursor: 'default',
79
+ zIndex: -1
80
+ }
81
+ },
82
+ // 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
83
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
84
+ 'hr[data-drag-handler-anchor-name]': {
85
+ overflow: 'visible'
86
+ },
87
+ //Hide psudeo element at top depth level. Leave for nested depths to prevent mouseover loop.
88
+ //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
89
+ '[data-blocks-drag-handle-container="true"] + [data-drag-handler-anchor-depth="0"]::after': {
90
+ display: 'none'
91
+ }
92
+ });
48
93
  var paragraphWithTrailingBreak = '+ p > .ProseMirror-trailingBreak';
49
94
  var paragraphWithCursorTarget = '+ p > .cursor-target';
50
95
  var paragraphWithTrailingBreakAsOnlyChild = '+ p > .ProseMirror-trailingBreak:only-child';
@@ -104,6 +149,6 @@ var getTextNodeStyle = function getTextNodeStyle() {
104
149
  };
105
150
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
106
151
  return (0, _react.jsx)(_react.Global, {
107
- styles: [globalStyles, (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') && extendedHoverZone, getTextNodeStyle(), (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23932') && withDeleteLinesStyleFix, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24005') && withMediaSingleStyleFix]
152
+ styles: [globalStyles, (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? extendedHoverZoneNested : extendedHoverZone : false, getTextNodeStyle(), (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23932') && withDeleteLinesStyleFix, (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24005') && withMediaSingleStyleFix]
108
153
  });
109
154
  };
@@ -1,10 +1,18 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
3
+ import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
3
4
  import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { DIRECTION } from '../consts';
6
7
  import { key } from '../pm-plugins/main';
7
8
  import { selectNode } from '../utils';
9
+ function transformNested(nodeCopy, destType) {
10
+ const firstChild = nodeCopy.content.firstChild;
11
+ if (firstChild && firstChild.type.name === 'nestedExpand' && destType === 'doc') {
12
+ return transformSliceNestedExpandToExpand(nodeCopy, firstChild.type.schema);
13
+ }
14
+ return nodeCopy;
15
+ }
8
16
 
9
17
  /**
10
18
  *
@@ -99,10 +107,20 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
99
107
  }
100
108
  const size = (_node$nodeSize = node === null || node === void 0 ? void 0 : node.nodeSize) !== null && _node$nodeSize !== void 0 ? _node$nodeSize : 1;
101
109
  const end = start + size;
102
- let nodeCopy = tr.doc.content.cut(start, end); // cut the content
103
- tr.delete(start, end); // delete the content from the original position
104
- const mappedTo = tr.mapping.map(to);
105
- tr.insert(mappedTo, nodeCopy); // insert the content at the new position
110
+ let mappedTo;
111
+ if (fg('platform_editor_elements_dnd_nested')) {
112
+ const nodeCopy = tr.doc.slice(start, end, false); // cut the content
113
+ const destType = tr.doc.resolve(to).node().type.name;
114
+ const 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
+ const 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