@atlaskit/editor-plugin-block-controls 1.4.28 → 1.4.30

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 1.4.30
4
+
5
+ ### Patch Changes
6
+
7
+ - [#114676](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114676)
8
+ [`8b085c84572b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8b085c84572b0) -
9
+ remove mouse move wrapper under feature flag
10
+
11
+ ## 1.4.29
12
+
13
+ ### Patch Changes
14
+
15
+ - [#113919](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113919)
16
+ [`b23ee751fde25`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b23ee751fde25) -
17
+ [ux] fix : the page is not scrolled down when click on the handle of a long node
18
+ - [#113848](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113848)
19
+ [`173e8cc6ecdb3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/173e8cc6ecdb3) -
20
+ ED-23779 fix undo caused wrong selector position
21
+
3
22
  ## 1.4.28
4
23
 
5
24
  ### Patch Changes
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _react = require("react");
10
10
  var _reactDom = _interopRequireDefault(require("react-dom"));
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _dragHandle = require("../ui/drag-handle");
13
14
  var _dropTarget = require("../ui/drop-target");
14
15
  var _mouseMoveWrapper = require("../ui/mouse-move-wrapper");
@@ -26,6 +27,9 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
26
27
  decs.push(_view.Decoration.widget(pos, function () {
27
28
  var element = document.createElement('div');
28
29
  element.setAttribute('data-blocks-drop-target-container', 'true');
30
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
31
+ element.style.clear = 'unset';
32
+ }
29
33
  _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
30
34
  api: api,
31
35
  index: index
@@ -68,11 +72,17 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
68
72
  var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState) {
69
73
  var decs = [];
70
74
  newState.doc.descendants(function (node, pos, _parent, index) {
75
+ var _Decoration$node;
71
76
  var anchorName = "--node-anchor-".concat(node.type.name, "-").concat(index);
72
- var style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '');
73
- decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (0, _defineProperty2.default)({
77
+ var style;
78
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
79
+ style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "; position: relative; z-index: 1;");
80
+ } else {
81
+ style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '');
82
+ }
83
+ decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (_Decoration$node = {
74
84
  style: style
75
- }, 'data-drag-handler-anchor-name', anchorName)));
85
+ }, (0, _defineProperty2.default)(_Decoration$node, 'data-drag-handler-anchor-name', anchorName), (0, _defineProperty2.default)(_Decoration$node, 'data-drag-handler-node-type', node.type.name), _Decoration$node)));
76
86
  return false;
77
87
  });
78
88
  return decs;
@@ -117,6 +127,11 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
117
127
  element.style.display = 'inline';
118
128
  element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
119
129
  element.setAttribute('data-blocks-drag-handle-container', 'true');
130
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
131
+ // There are times when global clear: "both" styles are applied to this decoration causing jumpiness
132
+ // due to margins applied to other nodes eg. Headings
133
+ element.style.clear = 'unset';
134
+ }
120
135
  _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
121
136
  view: view,
122
137
  api: api,
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleMouseOver = void 0;
7
+ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
8
+ var _api$blockControls;
9
+ var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
10
+ isDragging = _ref.isDragging,
11
+ activeNode = _ref.activeNode;
12
+ // Most mouseover events don't fire during drag but some can slip through
13
+ // when the drag begins. This prevents those.
14
+ if (isDragging) {
15
+ return false;
16
+ }
17
+ var target = event.target;
18
+ if (target.classList.contains('ProseMirror')) {
19
+ return false;
20
+ }
21
+ var rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
22
+ if (rootElement) {
23
+ var anchorName = rootElement.getAttribute('data-drag-handler-anchor-name');
24
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
25
+ return false;
26
+ }
27
+ var pos = view.posAtDOM(rootElement, 0, 0);
28
+ var rootPos = view.state.doc.resolve(pos).start(1) - 1;
29
+ var nodeType = rootElement.getAttribute('data-drag-handler-node-type');
30
+ if (nodeType) {
31
+ var _api$core, _api$blockControls2;
32
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
33
+ }
34
+ }
35
+ };
@@ -17,6 +17,7 @@ var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
17
17
  var _combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
18
18
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
19
19
  var _decorations = require("./decorations");
20
+ var _handleMouseOver = require("./handle-mouse-over");
20
21
  var key = exports.key = new _state.PluginKey('blockControls');
21
22
  var destroyFn = function destroyFn(api) {
22
23
  var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
@@ -89,7 +90,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
89
90
  return initialState;
90
91
  },
91
92
  apply: function apply(tr, currentState, oldState, newState) {
92
- var _meta$activeNode, _meta$isDragging, _meta$editorHeight;
93
+ var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight;
93
94
  if (initialState.isDocSizeLimitEnabled && newState.doc.nodeSize > DRAG_AND_DROP_DOC_SIZE_LIMIT) {
94
95
  return initialState;
95
96
  }
@@ -120,21 +121,47 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
120
121
  });
121
122
  decorations = decorations.remove(oldHandle);
122
123
  }
124
+ var isDecsMissing = false;
125
+ var isHandleMissing = false;
126
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
127
+ // Ensure decorations stay in sync when nodes are added or removed from the doc
128
+ isHandleMissing = !(meta !== null && meta !== void 0 && meta.activeNode) && !decorations.find().some(function (_ref6) {
129
+ var spec = _ref6.spec;
130
+ return spec.id === 'drag-handle';
131
+ });
132
+ var decsLength = decorations.find().filter(function (_ref7) {
133
+ var spec = _ref7.spec;
134
+ return spec.id !== 'drag-handle';
135
+ }).length;
136
+ isDecsMissing = !isDragging && decsLength !== newState.doc.childCount;
137
+ }
123
138
 
124
139
  // This is not targeted enough - it's trying to catch events like expand being set to breakout
125
140
  var maybeWidthUpdated = tr.docChanged && oldState.doc.nodeSize === newState.doc.nodeSize && !nodeCountChanged;
126
- var redrawDecorations = decorations === _view.DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || resizerMeta === false || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
141
+
142
+ // This addresses scenarios such as undoing table resizing,
143
+ // where a keyboard shortcut triggers a width change, and
144
+ // the node's actual width is then updated in a separate renderering cycle.
145
+ // The tr.meta.activeNode is triggered by the showDragHandleAt function during the mouse entry event
146
+ // (when the table node rerenders)
147
+ // The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
148
+ var maybeNodeWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 || (_meta$activeNode = meta.activeNode) === null || _meta$activeNode === void 0 ? void 0 : _meta$activeNode.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
149
+ var redrawDecorations = decorations === _view.DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || isDecsMissing || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
127
150
 
128
151
  // Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
129
152
  if (redrawDecorations && !isResizerResizing && api) {
130
153
  decorations = _view.DecorationSet.create(newState.doc, []);
131
154
  var nodeDecs = (0, _decorations.nodeDecorations)(newState);
132
- var mouseWrapperDecs = (0, _decorations.mouseMoveWrapperDecorations)(newState, api);
133
- decorations = decorations.add(newState.doc, [].concat((0, _toConsumableArray2.default)(nodeDecs), (0, _toConsumableArray2.default)(mouseWrapperDecs)));
155
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
156
+ decorations = decorations.add(newState.doc, (0, _toConsumableArray2.default)(nodeDecs));
157
+ } else {
158
+ var mouseWrapperDecs = (0, _decorations.mouseMoveWrapperDecorations)(newState, api);
159
+ decorations = decorations.add(newState.doc, [].concat((0, _toConsumableArray2.default)(nodeDecs), (0, _toConsumableArray2.default)(mouseWrapperDecs)));
160
+ }
134
161
 
135
162
  // Note: Quite often the handle is not in the right position after a node is moved
136
163
  // it is safer for now to not show it when a node is moved
137
- if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved)) {
164
+ if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
138
165
  var newActiveNode = activeNode && tr.doc.nodeAt(tr.mapping.map(activeNode.pos));
139
166
  var nodeType = activeNode.nodeType;
140
167
  var anchorName = activeNode.anchorName;
@@ -149,8 +176,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
149
176
 
150
177
  // Remove previous drag handle widget and draw new drag handle widget when activeNode changes
151
178
  if (meta !== null && meta !== void 0 && meta.activeNode && (meta === null || meta === void 0 ? void 0 : meta.activeNode.pos) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) && (meta === null || meta === void 0 ? void 0 : meta.activeNode.anchorName) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) && api) {
152
- var _oldHandle = decorations.find().filter(function (_ref6) {
153
- var spec = _ref6.spec;
179
+ var _oldHandle = decorations.find().filter(function (_ref8) {
180
+ var spec = _ref8.spec;
154
181
  return spec.id === 'drag-handle';
155
182
  });
156
183
  decorations = decorations.remove(_oldHandle);
@@ -170,8 +197,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
170
197
 
171
198
  // Remove drop target decoration when dragging stops
172
199
  if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && !tr.docChanged) {
173
- var dropTargetDecs = decorations.find().filter(function (_ref7) {
174
- var spec = _ref7.spec;
200
+ var dropTargetDecs = decorations.find().filter(function (_ref9) {
201
+ var spec = _ref9.spec;
175
202
  return spec.type === 'drop-target-decoration';
176
203
  });
177
204
  decorations = decorations.remove(dropTargetDecs);
@@ -179,9 +206,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
179
206
 
180
207
  // Map drop target decoration positions when the document changes
181
208
  if (tr.docChanged && isDragging) {
182
- decorationState = decorationState.map(function (_ref8) {
183
- var index = _ref8.index,
184
- pos = _ref8.pos;
209
+ decorationState = decorationState.map(function (_ref10) {
210
+ var index = _ref10.index,
211
+ pos = _ref10.pos;
185
212
  return {
186
213
  index: index,
187
214
  pos: tr.mapping.map(pos)
@@ -204,7 +231,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
204
231
  return {
205
232
  decorations: decorations,
206
233
  decorationState: decorationState,
207
- activeNode: isEmptyDoc ? null : (_meta$activeNode = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode !== void 0 ? _meta$activeNode : mappedActiveNodePos,
234
+ activeNode: isEmptyDoc || isHandleMissing ? null : (_meta$activeNode2 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode2 !== void 0 ? _meta$activeNode2 : mappedActiveNodePos,
208
235
  isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
209
236
  isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
210
237
  editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
@@ -241,41 +268,50 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
241
268
  return true;
242
269
  }
243
270
  return false;
271
+ },
272
+ mouseover: function mouseover(view, event) {
273
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
274
+ (0, _handleMouseOver.handleMouseOver)(view, event, api);
275
+ }
276
+ return false;
244
277
  }
245
278
  }
246
279
  },
247
280
  view: function view(editorView) {
248
281
  var dom = editorView.dom;
282
+ var resizeObserver;
283
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
284
+ // Use ResizeObserver to observe height changes
285
+ resizeObserver = new ResizeObserver((0, _rafSchd.default)(function (entries) {
286
+ var editorHeight = entries[0].contentBoxSize[0].blockSize;
249
287
 
250
- // Use ResizeObserver to observe height changes
251
- var resizeObserver = new ResizeObserver((0, _rafSchd.default)(function (entries) {
252
- var editorHeight = entries[0].contentBoxSize[0].blockSize;
253
-
254
- // Update the plugin state when the height changes
255
- var pluginState = key.getState(editorView.state);
256
- if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
257
- var isResizerResizing = !!dom.querySelector('.is-resizing');
258
- var transaction = editorView.state.tr;
259
- if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
260
- transaction.setMeta('is-resizer-resizing', isResizerResizing);
261
- }
262
- if (!isResizerResizing) {
263
- transaction.setMeta(key, {
264
- editorHeight: editorHeight
265
- });
288
+ // Update the plugin state when the height changes
289
+ var pluginState = key.getState(editorView.state);
290
+ if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
291
+ var isResizerResizing = !!dom.querySelector('.is-resizing');
292
+ var transaction = editorView.state.tr;
293
+ if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
294
+ transaction.setMeta('is-resizer-resizing', isResizerResizing);
295
+ }
296
+ if (!isResizerResizing) {
297
+ transaction.setMeta(key, {
298
+ editorHeight: editorHeight
299
+ });
300
+ }
301
+ editorView.dispatch(transaction);
266
302
  }
267
- editorView.dispatch(transaction);
268
- }
269
- }));
270
-
271
- // Start observing the editor DOM element
272
- resizeObserver.observe(dom);
303
+ }));
304
+ // Start observing the editor DOM element
305
+ resizeObserver.observe(dom);
306
+ }
273
307
 
274
308
  // Start pragmatic monitors
275
309
  var pragmaticCleanup = destroyFn(api);
276
310
  return {
277
311
  destroy: function destroy() {
278
- resizeObserver.unobserve(dom);
312
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
313
+ resizeObserver.unobserve(dom);
314
+ }
279
315
  pragmaticCleanup();
280
316
  }
281
317
  };
@@ -10,7 +10,9 @@ var _react = require("react");
10
10
  var _react2 = require("@emotion/react");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _hooks = require("@atlaskit/editor-common/hooks");
13
+ var _state = require("@atlaskit/editor-prosemirror/state");
13
14
  var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-handler"));
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
16
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
15
17
  var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
16
18
  var _main = require("../pm-plugins/main");
@@ -89,7 +91,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
89
91
  }
90
92
  }, [anchorName, nodeType, view.dom]);
91
93
  var handleOnClick = (0, _react.useCallback)(function () {
92
- var _api$core, _api$core2;
94
+ var _api$core;
93
95
  setDragHandleSelected(!dragHandleSelected);
94
96
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
95
97
  var tr = _ref2.tr;
@@ -102,15 +104,15 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
102
104
  });
103
105
  return tr;
104
106
  });
105
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
106
- }, [start, api, dragHandleSelected, setDragHandleSelected, nodeType]);
107
+ view.focus();
108
+ }, [start, api, view, dragHandleSelected, setDragHandleSelected, nodeType]);
107
109
 
108
110
  // handleMouseDown required along with onClick to ensure the correct selection
109
111
  // is set immediately when the drag handle is clicked. Otherwise browser native
110
112
  // drag and drop can take over and cause unpredictable behaviour.
111
113
  var handleMouseDown = (0, _react.useCallback)(function () {
112
- var _api$core3, _api$core4;
113
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
114
+ var _api$core2;
115
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
114
116
  var tr = _ref3.tr;
115
117
  if (start === undefined) {
116
118
  return tr;
@@ -121,8 +123,32 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
121
123
  });
122
124
  return tr;
123
125
  });
124
- api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.focus();
125
- }, [start, api, nodeType]);
126
+ view.focus();
127
+ }, [start, api, view, nodeType]);
128
+
129
+ // TODO - This needs to be investigated further. Drag preview generation is not always working
130
+ // as expected with a node selection. This workaround sets the selection to the node on mouseDown,
131
+ // but ensures the preview is generated correctly.
132
+ var handleMouseDownWrapperRemoved = (0, _react.useCallback)(function () {
133
+ var _api$core3;
134
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref4) {
135
+ var tr = _ref4.tr;
136
+ if (start === undefined) {
137
+ return tr;
138
+ }
139
+ var node = tr.doc.nodeAt(start);
140
+ if (!node) {
141
+ return tr;
142
+ }
143
+ var $startPos = tr.doc.resolve(start + node.nodeSize);
144
+ var selection = new _state.TextSelection($startPos);
145
+ tr.setSelection(selection);
146
+ tr.setMeta(_main.key, {
147
+ pos: start
148
+ });
149
+ return tr;
150
+ });
151
+ }, [start, api]);
126
152
  (0, _react.useEffect)(function () {
127
153
  var element = buttonRef.current;
128
154
  if (!element) {
@@ -136,11 +162,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
136
162
  start: start
137
163
  };
138
164
  },
139
- onGenerateDragPreview: function onGenerateDragPreview(_ref4) {
140
- var nativeSetDragImage = _ref4.nativeSetDragImage;
165
+ onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
166
+ var nativeSetDragImage = _ref5.nativeSetDragImage;
141
167
  (0, _setCustomNativeDragPreview.setCustomNativeDragPreview)({
142
- render: function render(_ref5) {
143
- var container = _ref5.container;
168
+ render: function render(_ref6) {
169
+ var container = _ref6.container;
144
170
  var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
145
171
  if (!dom) {
146
172
  return;
@@ -151,18 +177,19 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
151
177
  });
152
178
  },
153
179
  onDragStart: function onDragStart() {
154
- var _api$core5, _api$core6;
180
+ var _api$core4;
155
181
  if (start === undefined) {
156
182
  return;
157
183
  }
158
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
184
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref7) {
159
185
  var _api$blockControls, _api$analytics;
160
- var tr = _ref6.tr;
186
+ var tr = _ref7.tr;
161
187
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setNodeDragged(start, anchorName, nodeType)({
162
188
  tr: tr
163
189
  });
164
190
  var resolvedMovingNode = tr.doc.resolve(start);
165
191
  var maybeNode = resolvedMovingNode.nodeAfter;
192
+ tr.setMeta('scrollIntoView', false);
166
193
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
167
194
  eventType: _analytics.EVENT_TYPE.UI,
168
195
  action: _analytics.ACTION.DRAGGED,
@@ -175,7 +202,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
175
202
  })(tr);
176
203
  return tr;
177
204
  });
178
- api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.focus();
205
+ view.focus();
179
206
  }
180
207
  });
181
208
  }, [anchorName, api, nodeType, view, start]);
@@ -202,7 +229,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
202
229
  }
203
230
  if (supportsAnchor) {
204
231
  return {
205
- left: hasResizer || isExtension || isBlockCard || isEmbedCard ? (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
232
+ left: hasResizer || isExtension || isBlockCard || isEmbedCard ? (0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? "calc(calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates)) : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
206
233
  top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
207
234
  };
208
235
  }
@@ -219,7 +246,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
219
246
  ,
220
247
  style: positionStyles,
221
248
  onClick: handleOnClick,
222
- onMouseDown: handleMouseDown,
249
+ onMouseDown: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? handleMouseDownWrapperRemoved : handleMouseDown,
223
250
  "data-testid": "block-ctrl-drag-handle"
224
251
  }, (0, _react2.jsx)(_dragHandler.default, {
225
252
  label: "",
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.dragPreview = void 0;
7
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
7
8
  var _colors = require("@atlaskit/theme/colors");
8
9
  var previewStyle = {
9
10
  borderColor: "var(--ds-border-focused, ".concat(_colors.B200, ")"),
@@ -20,6 +21,9 @@ var dragPreview = exports.dragPreview = function dragPreview(container, dom, nod
20
21
  var parent = document.createElement('div');
21
22
  // ProseMirror class is required to make sure the cloned dom is styled correctly
22
23
  parent.classList.add('ProseMirror');
24
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
25
+ parent.classList.add('block-ctrl-drag-preview');
26
+ }
23
27
  var shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension';
24
28
  var embedCard = dom.querySelector('.embedCardView-content-wrap');
25
29
  if (shouldBeGenericPreview || embedCard) {
@@ -22,7 +22,8 @@ var styleDropTarget = (0, _react2.css)({
22
22
  position: 'absolute',
23
23
  width: '100%',
24
24
  left: '0',
25
- display: 'block'
25
+ display: 'block',
26
+ zIndex: 1
26
27
  });
27
28
  var styleDropIndicator = (0, _react2.css)({
28
29
  height: '100%',
@@ -5,9 +5,33 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.GlobalStylesWrapper = void 0;
7
7
  var _react = require("@emotion/react");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
9
  /** @jsx jsx */
9
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
11
 
12
+ var extendedHoverZone = (0, _react.css)({
13
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
14
+ '.block-ctrl-drag-preview [data-drag-handler-anchor-name]::after': {
15
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
16
+ display: 'none !important'
17
+ },
18
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
19
+ '[data-drag-handler-anchor-name]::after': {
20
+ content: '""',
21
+ position: 'absolute',
22
+ top: 0,
23
+ left: '-100%',
24
+ width: '100%',
25
+ height: '100%',
26
+ background: 'transparent',
27
+ cursor: 'default',
28
+ zIndex: -1
29
+ },
30
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
31
+ '[data-blocks-decoration-container="true"] + *::after': {
32
+ display: 'none'
33
+ }
34
+ });
11
35
  var globalStyles = (0, _react.css)({
12
36
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
13
37
  '.ProseMirror-widget:first-child + *': {
@@ -17,6 +41,6 @@ var globalStyles = (0, _react.css)({
17
41
  });
18
42
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
19
43
  return (0, _react.jsx)(_react.Global, {
20
- styles: globalStyles
44
+ styles: [globalStyles, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') && extendedHoverZone]
21
45
  });
22
46
  };
@@ -32,7 +32,7 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
32
32
  return true;
33
33
  });
34
34
  var inlineNodeDepth = inlineNodePos - start;
35
- return new _state.TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(start + nodeSize - inlineNodeDepth));
35
+ return new _state.TextSelection(tr.doc.resolve(start + nodeSize - inlineNodeDepth), tr.doc.resolve(inlineNodePos));
36
36
  }
37
37
  };
38
38
  var selectNode = exports.selectNode = function selectNode(tr, start, nodeType) {
@@ -1,6 +1,7 @@
1
1
  import { createElement } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
3
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import { DragHandle } from '../ui/drag-handle';
5
6
  import { DropTarget } from '../ui/drop-target';
6
7
  import { MouseMoveWrapper } from '../ui/mouse-move-wrapper';
@@ -18,6 +19,9 @@ export const dropTargetDecorations = (oldState, newState, api) => {
18
19
  decs.push(Decoration.widget(pos, () => {
19
20
  const element = document.createElement('div');
20
21
  element.setAttribute('data-blocks-drop-target-container', 'true');
22
+ if (getBooleanFF('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
23
+ element.style.clear = 'unset';
24
+ }
21
25
  ReactDOM.render( /*#__PURE__*/createElement(DropTarget, {
22
26
  api,
23
27
  index
@@ -61,10 +65,16 @@ export const nodeDecorations = newState => {
61
65
  const decs = [];
62
66
  newState.doc.descendants((node, pos, _parent, index) => {
63
67
  const anchorName = `--node-anchor-${node.type.name}-${index}`;
64
- const style = `anchor-name: ${anchorName}; ${pos === 0 ? 'margin-top: 0px;' : ''}`;
68
+ let style;
69
+ if (getBooleanFF('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
70
+ style = `anchor-name: ${anchorName}; ${pos === 0 ? 'margin-top: 0px;' : ''}; position: relative; z-index: 1;`;
71
+ } else {
72
+ style = `anchor-name: ${anchorName}; ${pos === 0 ? 'margin-top: 0px;' : ''}`;
73
+ }
65
74
  decs.push(Decoration.node(pos, pos + node.nodeSize, {
66
75
  style,
67
- ['data-drag-handler-anchor-name']: anchorName
76
+ ['data-drag-handler-anchor-name']: anchorName,
77
+ ['data-drag-handler-node-type']: node.type.name
68
78
  }));
69
79
  return false;
70
80
  });
@@ -110,6 +120,11 @@ export const dragHandleDecoration = (pos, anchorName, nodeType, api) => {
110
120
  element.style.display = 'inline';
111
121
  element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
112
122
  element.setAttribute('data-blocks-drag-handle-container', 'true');
123
+ if (getBooleanFF('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
124
+ // There are times when global clear: "both" styles are applied to this decoration causing jumpiness
125
+ // due to margins applied to other nodes eg. Headings
126
+ element.style.clear = 'unset';
127
+ }
113
128
  ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
114
129
  view,
115
130
  api,
@@ -0,0 +1,30 @@
1
+ export const handleMouseOver = (view, event, api) => {
2
+ var _api$blockControls;
3
+ const {
4
+ isDragging,
5
+ activeNode
6
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
7
+ // Most mouseover events don't fire during drag but some can slip through
8
+ // when the drag begins. This prevents those.
9
+ if (isDragging) {
10
+ return false;
11
+ }
12
+ const target = event.target;
13
+ if (target.classList.contains('ProseMirror')) {
14
+ return false;
15
+ }
16
+ const rootElement = target === null || target === void 0 ? void 0 : target.closest('[data-drag-handler-anchor-name]');
17
+ if (rootElement) {
18
+ const anchorName = rootElement.getAttribute('data-drag-handler-anchor-name');
19
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) === anchorName) {
20
+ return false;
21
+ }
22
+ const pos = view.posAtDOM(rootElement, 0, 0);
23
+ const rootPos = view.state.doc.resolve(pos).start(1) - 1;
24
+ const nodeType = rootElement.getAttribute('data-drag-handler-node-type');
25
+ if (nodeType) {
26
+ var _api$core, _api$blockControls2;
27
+ api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.showDragHandleAt(rootPos, anchorName, nodeType));
28
+ }
29
+ }
30
+ };