@atlaskit/editor-plugin-block-controls 1.4.29 → 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 +8 -0
- package/dist/cjs/pm-plugins/decorations.js +18 -3
- package/dist/cjs/pm-plugins/handle-mouse-over.js +35 -0
- package/dist/cjs/pm-plugins/main.js +63 -35
- package/dist/cjs/ui/drag-handle.js +35 -9
- package/dist/cjs/ui/drag-preview.js +4 -0
- package/dist/cjs/ui/drop-target.js +2 -1
- package/dist/cjs/ui/global-styles.js +25 -1
- package/dist/es2019/pm-plugins/decorations.js +17 -2
- package/dist/es2019/pm-plugins/handle-mouse-over.js +30 -0
- package/dist/es2019/pm-plugins/main.js +54 -28
- package/dist/es2019/ui/drag-handle.js +31 -4
- package/dist/es2019/ui/drag-preview.js +4 -0
- package/dist/es2019/ui/drop-target.js +2 -1
- package/dist/es2019/ui/global-styles.js +25 -1
- package/dist/esm/pm-plugins/decorations.js +18 -3
- package/dist/esm/pm-plugins/handle-mouse-over.js +29 -0
- package/dist/esm/pm-plugins/main.js +63 -35
- package/dist/esm/ui/drag-handle.js +35 -9
- package/dist/esm/ui/drag-preview.js +4 -0
- package/dist/esm/ui/drop-target.js +2 -1
- package/dist/esm/ui/global-styles.js +25 -1
- package/dist/types/pm-plugins/handle-mouse-over.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/handle-mouse-over.d.ts +4 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 1.4.29
|
|
4
12
|
|
|
5
13
|
### 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
|
|
73
|
-
|
|
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');
|
|
@@ -120,6 +121,20 @@ 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;
|
|
@@ -131,18 +146,22 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
131
146
|
// (when the table node rerenders)
|
|
132
147
|
// The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
|
|
133
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);
|
|
134
|
-
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 || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
|
|
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;
|
|
135
150
|
|
|
136
151
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
137
152
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
138
153
|
decorations = _view.DecorationSet.create(newState.doc, []);
|
|
139
154
|
var nodeDecs = (0, _decorations.nodeDecorations)(newState);
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
}
|
|
142
161
|
|
|
143
162
|
// Note: Quite often the handle is not in the right position after a node is moved
|
|
144
163
|
// it is safer for now to not show it when a node is moved
|
|
145
|
-
if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved)) {
|
|
164
|
+
if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
|
|
146
165
|
var newActiveNode = activeNode && tr.doc.nodeAt(tr.mapping.map(activeNode.pos));
|
|
147
166
|
var nodeType = activeNode.nodeType;
|
|
148
167
|
var anchorName = activeNode.anchorName;
|
|
@@ -157,8 +176,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
157
176
|
|
|
158
177
|
// Remove previous drag handle widget and draw new drag handle widget when activeNode changes
|
|
159
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) {
|
|
160
|
-
var _oldHandle = decorations.find().filter(function (
|
|
161
|
-
var spec =
|
|
179
|
+
var _oldHandle = decorations.find().filter(function (_ref8) {
|
|
180
|
+
var spec = _ref8.spec;
|
|
162
181
|
return spec.id === 'drag-handle';
|
|
163
182
|
});
|
|
164
183
|
decorations = decorations.remove(_oldHandle);
|
|
@@ -178,8 +197,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
178
197
|
|
|
179
198
|
// Remove drop target decoration when dragging stops
|
|
180
199
|
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false && !tr.docChanged) {
|
|
181
|
-
var dropTargetDecs = decorations.find().filter(function (
|
|
182
|
-
var spec =
|
|
200
|
+
var dropTargetDecs = decorations.find().filter(function (_ref9) {
|
|
201
|
+
var spec = _ref9.spec;
|
|
183
202
|
return spec.type === 'drop-target-decoration';
|
|
184
203
|
});
|
|
185
204
|
decorations = decorations.remove(dropTargetDecs);
|
|
@@ -187,9 +206,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
187
206
|
|
|
188
207
|
// Map drop target decoration positions when the document changes
|
|
189
208
|
if (tr.docChanged && isDragging) {
|
|
190
|
-
decorationState = decorationState.map(function (
|
|
191
|
-
var index =
|
|
192
|
-
pos =
|
|
209
|
+
decorationState = decorationState.map(function (_ref10) {
|
|
210
|
+
var index = _ref10.index,
|
|
211
|
+
pos = _ref10.pos;
|
|
193
212
|
return {
|
|
194
213
|
index: index,
|
|
195
214
|
pos: tr.mapping.map(pos)
|
|
@@ -212,7 +231,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
212
231
|
return {
|
|
213
232
|
decorations: decorations,
|
|
214
233
|
decorationState: decorationState,
|
|
215
|
-
activeNode: isEmptyDoc ? null : (_meta$activeNode2 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode2 !== void 0 ? _meta$activeNode2 : 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,
|
|
216
235
|
isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
|
|
217
236
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
218
237
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
@@ -249,41 +268,50 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
249
268
|
return true;
|
|
250
269
|
}
|
|
251
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;
|
|
252
277
|
}
|
|
253
278
|
}
|
|
254
279
|
},
|
|
255
280
|
view: function view(editorView) {
|
|
256
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;
|
|
257
287
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
editorHeight: editorHeight
|
|
273
|
-
});
|
|
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);
|
|
274
302
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
// Start observing the editor DOM element
|
|
280
|
-
resizeObserver.observe(dom);
|
|
303
|
+
}));
|
|
304
|
+
// Start observing the editor DOM element
|
|
305
|
+
resizeObserver.observe(dom);
|
|
306
|
+
}
|
|
281
307
|
|
|
282
308
|
// Start pragmatic monitors
|
|
283
309
|
var pragmaticCleanup = destroyFn(api);
|
|
284
310
|
return {
|
|
285
311
|
destroy: function destroy() {
|
|
286
|
-
|
|
312
|
+
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
313
|
+
resizeObserver.unobserve(dom);
|
|
314
|
+
}
|
|
287
315
|
pragmaticCleanup();
|
|
288
316
|
}
|
|
289
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");
|
|
@@ -123,6 +125,30 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
123
125
|
});
|
|
124
126
|
view.focus();
|
|
125
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(
|
|
140
|
-
var nativeSetDragImage =
|
|
165
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref5) {
|
|
166
|
+
var nativeSetDragImage = _ref5.nativeSetDragImage;
|
|
141
167
|
(0, _setCustomNativeDragPreview.setCustomNativeDragPreview)({
|
|
142
|
-
render: function render(
|
|
143
|
-
var 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,13 +177,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
151
177
|
});
|
|
152
178
|
},
|
|
153
179
|
onDragStart: function onDragStart() {
|
|
154
|
-
var _api$
|
|
180
|
+
var _api$core4;
|
|
155
181
|
if (start === undefined) {
|
|
156
182
|
return;
|
|
157
183
|
}
|
|
158
|
-
api === null || api === void 0 || (_api$
|
|
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 =
|
|
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
|
});
|
|
@@ -203,7 +229,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
203
229
|
}
|
|
204
230
|
if (supportsAnchor) {
|
|
205
231
|
return {
|
|
206
|
-
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)"),
|
|
207
233
|
top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
208
234
|
};
|
|
209
235
|
}
|
|
@@ -220,7 +246,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
220
246
|
,
|
|
221
247
|
style: positionStyles,
|
|
222
248
|
onClick: handleOnClick,
|
|
223
|
-
onMouseDown: handleMouseDown,
|
|
249
|
+
onMouseDown: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? handleMouseDownWrapperRemoved : handleMouseDown,
|
|
224
250
|
"data-testid": "block-ctrl-drag-handle"
|
|
225
251
|
}, (0, _react2.jsx)(_dragHandler.default, {
|
|
226
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) {
|
|
@@ -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
|
};
|
|
@@ -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
|
-
|
|
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
|
+
};
|