@atlaskit/editor-plugin-block-controls 2.14.2 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/editor-commands/move-to-layout.js +21 -6
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +8 -1
- package/dist/cjs/pm-plugins/decorations-drop-target.js +16 -2
- package/dist/cjs/pm-plugins/main.js +5 -0
- package/dist/cjs/pm-plugins/utils/update-selection.js +44 -0
- package/dist/cjs/ui/drag-handle.js +13 -3
- package/dist/cjs/ui/drop-target-layout.js +26 -2
- package/dist/cjs/ui/global-styles.js +11 -1
- package/dist/cjs/ui/inline-drop-target.js +31 -6
- package/dist/es2019/editor-commands/move-to-layout.js +21 -6
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +8 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +16 -2
- package/dist/es2019/pm-plugins/main.js +5 -0
- package/dist/es2019/pm-plugins/utils/update-selection.js +36 -0
- package/dist/es2019/ui/drag-handle.js +13 -3
- package/dist/es2019/ui/drop-target-layout.js +28 -2
- package/dist/es2019/ui/global-styles.js +11 -1
- package/dist/es2019/ui/inline-drop-target.js +31 -4
- package/dist/esm/editor-commands/move-to-layout.js +21 -6
- package/dist/esm/pm-plugins/decorations-drag-handle.js +8 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +16 -2
- package/dist/esm/pm-plugins/main.js +5 -0
- package/dist/esm/pm-plugins/utils/update-selection.js +38 -0
- package/dist/esm/ui/drag-handle.js +13 -3
- package/dist/esm/ui/drop-target-layout.js +26 -2
- package/dist/esm/ui/global-styles.js +11 -1
- package/dist/esm/ui/inline-drop-target.js +31 -6
- package/dist/types/pm-plugins/utils/update-selection.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/utils/update-selection.d.ts +3 -0
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#173846](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173846)
|
|
8
|
+
[`9db562f586e8b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9db562f586e8b) -
|
|
9
|
+
ED-25939 prevent native dnd and use block controls
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 2.14.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#169746](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169746)
|
|
20
|
+
[`5bfb485e85507`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5bfb485e85507) -
|
|
21
|
+
[ux] [ED-25925] After drag and drop to create a new layout or update an existing layout,
|
|
22
|
+
placecursor at the end of last node in the newly created column
|
|
23
|
+
|
|
3
24
|
## 2.14.2
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -7,6 +7,7 @@ exports.moveToLayout = void 0;
|
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _consts = require("../pm-plugins/utils/consts");
|
|
11
12
|
var _fireAnalytics = require("../pm-plugins/utils/fire-analytics");
|
|
12
13
|
var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
|
|
@@ -44,13 +45,21 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
44
45
|
// reorder columns
|
|
45
46
|
tr.delete(from, from + sourceNode.nodeSize);
|
|
46
47
|
var mappedTo = tr.mapping.map(to);
|
|
47
|
-
tr.insert(mappedTo, sourceNode)
|
|
48
|
+
tr.insert(mappedTo, sourceNode);
|
|
49
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
50
|
+
tr.setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
51
|
+
}
|
|
48
52
|
(0, _fireAnalytics.fireMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
|
|
49
53
|
} else if (toLayout.childCount < (0, _consts.maxLayoutColumnSupported)()) {
|
|
50
54
|
var _$originalFrom$nodeAf2;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
56
|
+
(0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(from));
|
|
57
|
+
insertToDestination(tr, tr.mapping.map(to), sourceNode, toLayout, tr.mapping.map(toLayoutPos));
|
|
58
|
+
} else {
|
|
59
|
+
insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
|
|
60
|
+
var mappedFrom = tr.mapping.map(from);
|
|
61
|
+
(0, _removeFromSource.removeFromSource)(tr, tr.doc.resolve(mappedFrom));
|
|
62
|
+
}
|
|
54
63
|
(0, _fireAnalytics.fireMoveNodeAnalytics)(tr, _analytics.INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
|
|
55
64
|
}
|
|
56
65
|
return tr;
|
|
@@ -63,7 +72,10 @@ var insertToDestination = function insertToDestination(tr, to, sourceNode, toLay
|
|
|
63
72
|
var content = layoutColumn.createChecked({
|
|
64
73
|
width: newColumnWidth
|
|
65
74
|
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
66
|
-
tr.insert(to, content)
|
|
75
|
+
tr.insert(to, content);
|
|
76
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
77
|
+
tr.setSelection(new _state.NodeSelection(tr.doc.resolve(to))).scrollIntoView();
|
|
78
|
+
}
|
|
67
79
|
return tr;
|
|
68
80
|
};
|
|
69
81
|
|
|
@@ -171,7 +183,10 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
|
|
|
171
183
|
if (newLayout) {
|
|
172
184
|
tr = (0, _removeFromSource.removeFromSource)(tr, $from);
|
|
173
185
|
var mappedTo = tr.mapping.map(to);
|
|
174
|
-
tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout)
|
|
186
|
+
tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
|
|
187
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
188
|
+
tr.setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
189
|
+
}
|
|
175
190
|
breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
|
|
176
191
|
mode: breakoutMode
|
|
177
192
|
})]);
|
|
@@ -33,7 +33,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
33
33
|
(0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
34
34
|
var unbind;
|
|
35
35
|
var key = (0, _uuid.default)();
|
|
36
|
-
return _view.Decoration.widget(pos, function (view,
|
|
36
|
+
return _view.Decoration.widget(pos, function (view, getPosUnsafe) {
|
|
37
37
|
var element = document.createElement('span');
|
|
38
38
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
39
39
|
// platform_editor_element_dnd_nested_fix_patch_2 -> inline decoration causes focus issues when refocusing Editor into first line
|
|
@@ -42,6 +42,13 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
42
42
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
43
43
|
element.setAttribute('data-blocks-drag-handle-key', key);
|
|
44
44
|
var isTopLevelNode = true;
|
|
45
|
+
var getPos = function getPos() {
|
|
46
|
+
try {
|
|
47
|
+
return getPosUnsafe();
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
45
52
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
46
53
|
var newPos = (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? getPos() : pos;
|
|
47
54
|
if (typeof newPos === 'number') {
|
|
@@ -90,7 +90,14 @@ var findDropTargetDecs = exports.findDropTargetDecs = function findDropTargetDec
|
|
|
90
90
|
};
|
|
91
91
|
var createDropTargetDecoration = exports.createDropTargetDecoration = function createDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) {
|
|
92
92
|
var key = (0, _uuid.default)();
|
|
93
|
-
return _view.Decoration.widget(pos, function (_,
|
|
93
|
+
return _view.Decoration.widget(pos, function (_, getPosUnsafe) {
|
|
94
|
+
var getPos = function getPos() {
|
|
95
|
+
try {
|
|
96
|
+
return getPosUnsafe();
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
94
101
|
var element = document.createElement('div');
|
|
95
102
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
96
103
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
@@ -138,7 +145,14 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
138
145
|
};
|
|
139
146
|
var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, anchorRectCache) {
|
|
140
147
|
var key = (0, _uuid.default)();
|
|
141
|
-
return _view.Decoration.widget(pos, function (_,
|
|
148
|
+
return _view.Decoration.widget(pos, function (_, getPosUnsafe) {
|
|
149
|
+
var getPos = function getPos() {
|
|
150
|
+
try {
|
|
151
|
+
return getPosUnsafe();
|
|
152
|
+
} catch (e) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
142
156
|
var element = document.createElement('div');
|
|
143
157
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
144
158
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
@@ -484,6 +484,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
484
484
|
// Currently we can only drag one node at a time
|
|
485
485
|
// so we only need to check first child
|
|
486
486
|
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
487
|
+
if ((draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
488
|
+
// we prevent native DnD for layoutColumn to prevent single column layout.
|
|
489
|
+
event.preventDefault();
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
487
492
|
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
488
493
|
if (!nodeElement) {
|
|
489
494
|
return false;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateSelection = exports.getInsertLayoutStep = void 0;
|
|
7
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
10
|
+
var getInsertLayoutStep = exports.getInsertLayoutStep = function getInsertLayoutStep(tr) {
|
|
11
|
+
return tr.steps.find(function (step) {
|
|
12
|
+
var _step$slice$content$f;
|
|
13
|
+
return step instanceof _transform.ReplaceStep && ['layoutSection', 'layoutColumn'].includes(((_step$slice$content$f = step.slice.content.firstChild) === null || _step$slice$content$f === void 0 ? void 0 : _step$slice$content$f.type.name) || '');
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var updateSelection = exports.updateSelection = function updateSelection(tr, to, insertAtRight) {
|
|
17
|
+
var _lastNode;
|
|
18
|
+
var $to = tr.doc.resolve(to);
|
|
19
|
+
var toNode = $to.nodeAfter;
|
|
20
|
+
var lastNode = toNode === null || toNode === void 0 ? void 0 : toNode.content.lastChild;
|
|
21
|
+
if (!toNode || !lastNode) {
|
|
22
|
+
return tr;
|
|
23
|
+
}
|
|
24
|
+
var offset = toNode.nodeSize;
|
|
25
|
+
|
|
26
|
+
// drop at the start of the layoutSection or to create a new layoutSection
|
|
27
|
+
if (toNode.type.name === 'layoutSection') {
|
|
28
|
+
if (insertAtRight) {
|
|
29
|
+
var _toNode$content$lastC;
|
|
30
|
+
lastNode = (_toNode$content$lastC = toNode.content.lastChild) === null || _toNode$content$lastC === void 0 ? void 0 : _toNode$content$lastC.lastChild;
|
|
31
|
+
offset = toNode.nodeSize - 1;
|
|
32
|
+
} else {
|
|
33
|
+
var _toNode$content$first, _toNode$content$first2;
|
|
34
|
+
lastNode = (_toNode$content$first = toNode.content.firstChild) === null || _toNode$content$first === void 0 ? void 0 : _toNode$content$first.lastChild;
|
|
35
|
+
offset = 1 + (((_toNode$content$first2 = toNode.content.firstChild) === null || _toNode$content$first2 === void 0 ? void 0 : _toNode$content$first2.nodeSize) || 0);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (['paragraph', 'heading'].includes(((_lastNode = lastNode) === null || _lastNode === void 0 ? void 0 : _lastNode.type.name) || '')) {
|
|
39
|
+
tr.setSelection(_state.TextSelection.near(tr.doc.resolve(to + offset - 2)));
|
|
40
|
+
} else if (lastNode) {
|
|
41
|
+
tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(to + offset - 1), _selection.Side.RIGHT));
|
|
42
|
+
}
|
|
43
|
+
return tr;
|
|
44
|
+
};
|
|
@@ -146,7 +146,17 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
146
146
|
// but ensures the preview is generated correctly.
|
|
147
147
|
var handleMouseDown = (0, _react.useCallback)(function () {
|
|
148
148
|
var _api$core3;
|
|
149
|
-
if (
|
|
149
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
150
|
+
// prevent native drag and drop.
|
|
151
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
152
|
+
var _buttonRef$current;
|
|
153
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
|
|
154
|
+
}
|
|
155
|
+
if (!isLayoutColumn) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24885')) {
|
|
150
160
|
return undefined;
|
|
151
161
|
}
|
|
152
162
|
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
@@ -363,8 +373,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
363
373
|
(0, _react.useEffect)(function () {
|
|
364
374
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
365
375
|
var id = requestAnimationFrame(function () {
|
|
366
|
-
var _buttonRef$
|
|
367
|
-
(_buttonRef$
|
|
376
|
+
var _buttonRef$current2;
|
|
377
|
+
(_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 || _buttonRef$current2.focus();
|
|
368
378
|
});
|
|
369
379
|
return function () {
|
|
370
380
|
cancelAnimationFrame(id);
|
|
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
14
15
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
15
16
|
var _colors = require("@atlaskit/theme/colors");
|
|
@@ -17,6 +18,7 @@ var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
|
17
18
|
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
18
19
|
var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
|
|
19
20
|
var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
|
|
21
|
+
var _updateSelection = require("../pm-plugins/utils/update-selection");
|
|
20
22
|
/**
|
|
21
23
|
* @jsxRuntime classic
|
|
22
24
|
* @jsx jsx
|
|
@@ -78,10 +80,32 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
|
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
82
|
var to = getPos();
|
|
83
|
+
var mappedTo;
|
|
81
84
|
if (to !== undefined) {
|
|
82
|
-
var _api$core
|
|
85
|
+
var _api$core;
|
|
83
86
|
var from = activeNode.pos;
|
|
84
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(
|
|
87
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
88
|
+
var _api$blockControls2;
|
|
89
|
+
var tr = _ref2.tr;
|
|
90
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(from, to)({
|
|
91
|
+
tr: tr
|
|
92
|
+
});
|
|
93
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
94
|
+
var insertColumnStep = (0, _updateSelection.getInsertLayoutStep)(tr);
|
|
95
|
+
mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
|
|
96
|
+
}
|
|
97
|
+
return tr;
|
|
98
|
+
});
|
|
99
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
100
|
+
var _api$core2;
|
|
101
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
|
|
102
|
+
var tr = _ref3.tr;
|
|
103
|
+
if (mappedTo !== undefined) {
|
|
104
|
+
(0, _updateSelection.updateSelection)(tr, mappedTo);
|
|
105
|
+
}
|
|
106
|
+
return tr;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
85
109
|
}
|
|
86
110
|
}, [api, getPos, activeNode]);
|
|
87
111
|
(0, _react.useEffect)(function () {
|
|
@@ -134,6 +134,16 @@ var legacyBreakoutWideLayoutStyle = (0, _react.css)({
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
|
+
var globalDnDStyle = (0, _react.css)({
|
|
138
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
139
|
+
'.ProseMirror': {
|
|
140
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
141
|
+
'[data-layout-content]': {
|
|
142
|
+
userDrag: 'none',
|
|
143
|
+
userSelect: 'none'
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
137
147
|
var globalStyles = function globalStyles() {
|
|
138
148
|
return (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? (0, _react.css)({
|
|
139
149
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
@@ -219,6 +229,6 @@ var blockCardWithoutLayout = (0, _react.css)({
|
|
|
219
229
|
});
|
|
220
230
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
221
231
|
return (0, _react.jsx)(_react.Global, {
|
|
222
|
-
styles: [globalStyles(), (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
232
|
+
styles: [globalStyles(), (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
223
233
|
});
|
|
224
234
|
};
|
|
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
|
|
14
15
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
15
16
|
var _colors = require("@atlaskit/theme/colors");
|
|
@@ -17,6 +18,7 @@ var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
|
17
18
|
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
18
19
|
var _anchorUtils = require("../pm-plugins/utils/anchor-utils");
|
|
19
20
|
var _dragTargetDebug = require("../pm-plugins/utils/drag-target-debug");
|
|
21
|
+
var _updateSelection = require("../pm-plugins/utils/update-selection");
|
|
20
22
|
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
21
23
|
/* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-values */
|
|
22
24
|
/**
|
|
@@ -188,16 +190,39 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
188
190
|
return;
|
|
189
191
|
}
|
|
190
192
|
var toPos = getPos();
|
|
193
|
+
var mappedTo;
|
|
191
194
|
if (activeNode && toPos !== undefined) {
|
|
192
|
-
var _api$core
|
|
195
|
+
var _api$core;
|
|
193
196
|
var start = activeNode.pos;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
var moveToEnd = position === 'right';
|
|
198
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
199
|
+
var _api$blockControls2;
|
|
200
|
+
var tr = _ref3.tr;
|
|
201
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(start, toPos, {
|
|
202
|
+
moveToEnd: moveToEnd
|
|
203
|
+
})({
|
|
204
|
+
tr: tr
|
|
205
|
+
});
|
|
206
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
207
|
+
var insertLayoutStep = (0, _updateSelection.getInsertLayoutStep)(tr);
|
|
208
|
+
mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
|
|
209
|
+
}
|
|
210
|
+
return tr;
|
|
211
|
+
});
|
|
212
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
213
|
+
var _api$core2;
|
|
214
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
215
|
+
var tr = _ref4.tr;
|
|
216
|
+
if (mappedTo !== undefined) {
|
|
217
|
+
(0, _updateSelection.updateSelection)(tr, mappedTo, moveToEnd);
|
|
218
|
+
}
|
|
219
|
+
return tr;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
197
222
|
}
|
|
198
223
|
}, [api, getPos, position]);
|
|
199
224
|
var hoverZoneRectStyle = (0, _react.useMemo)(function () {
|
|
200
|
-
var
|
|
225
|
+
var _ref5;
|
|
201
226
|
var isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
|
|
202
227
|
var layoutAdjustment = isLayoutNode ? {
|
|
203
228
|
width: 11,
|
|
@@ -205,7 +230,7 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
|
|
|
205
230
|
top: 6,
|
|
206
231
|
bottom: 2
|
|
207
232
|
} : undefined;
|
|
208
|
-
return
|
|
233
|
+
return _ref5 = {}, (0, _defineProperty2.default)(_ref5, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), (0, _defineProperty2.default)(_ref5, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref5;
|
|
209
234
|
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
|
|
210
235
|
var dropIndicatorPos = (0, _react.useMemo)(function () {
|
|
211
236
|
return isLeftPosition ? 'right' : 'left';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
|
|
5
6
|
import { fireInsertLayoutAnalytics, fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
|
|
6
7
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
@@ -39,13 +40,21 @@ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, $
|
|
|
39
40
|
// reorder columns
|
|
40
41
|
tr.delete(from, from + sourceNode.nodeSize);
|
|
41
42
|
const mappedTo = tr.mapping.map(to);
|
|
42
|
-
tr.insert(mappedTo, sourceNode)
|
|
43
|
+
tr.insert(mappedTo, sourceNode);
|
|
44
|
+
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
45
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
46
|
+
}
|
|
43
47
|
fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
|
|
44
48
|
} else if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
45
49
|
var _$originalFrom$nodeAf2;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
51
|
+
removeFromSource(tr, tr.doc.resolve(from));
|
|
52
|
+
insertToDestination(tr, tr.mapping.map(to), sourceNode, toLayout, tr.mapping.map(toLayoutPos));
|
|
53
|
+
} else {
|
|
54
|
+
insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
|
|
55
|
+
const mappedFrom = tr.mapping.map(from);
|
|
56
|
+
removeFromSource(tr, tr.doc.resolve(mappedFrom));
|
|
57
|
+
}
|
|
49
58
|
fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
|
|
50
59
|
}
|
|
51
60
|
return tr;
|
|
@@ -60,7 +69,10 @@ const insertToDestination = (tr, to, sourceNode, toLayout, toLayoutPos) => {
|
|
|
60
69
|
const content = layoutColumn.createChecked({
|
|
61
70
|
width: newColumnWidth
|
|
62
71
|
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
63
|
-
tr.insert(to, content)
|
|
72
|
+
tr.insert(to, content);
|
|
73
|
+
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
74
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
|
|
75
|
+
}
|
|
64
76
|
return tr;
|
|
65
77
|
};
|
|
66
78
|
|
|
@@ -166,7 +178,10 @@ export const moveToLayout = api => (from, to, options) => ({
|
|
|
166
178
|
if (newLayout) {
|
|
167
179
|
tr = removeFromSource(tr, $from);
|
|
168
180
|
const mappedTo = tr.mapping.map(to);
|
|
169
|
-
tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout)
|
|
181
|
+
tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
|
|
182
|
+
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
183
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
184
|
+
}
|
|
170
185
|
breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
|
|
171
186
|
mode: breakoutMode
|
|
172
187
|
})]);
|
|
@@ -24,7 +24,7 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
24
24
|
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
25
25
|
let unbind;
|
|
26
26
|
const key = uuid();
|
|
27
|
-
return Decoration.widget(pos, (view,
|
|
27
|
+
return Decoration.widget(pos, (view, getPosUnsafe) => {
|
|
28
28
|
const element = document.createElement('span');
|
|
29
29
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
30
30
|
// platform_editor_element_dnd_nested_fix_patch_2 -> inline decoration causes focus issues when refocusing Editor into first line
|
|
@@ -33,6 +33,13 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
33
33
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
34
34
|
element.setAttribute('data-blocks-drag-handle-key', key);
|
|
35
35
|
let isTopLevelNode = true;
|
|
36
|
+
const getPos = () => {
|
|
37
|
+
try {
|
|
38
|
+
return getPosUnsafe();
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
36
43
|
if (editorExperiment('nested-dnd', true)) {
|
|
37
44
|
const newPos = fg('platform_editor_element_dnd_nested_fix_patch_3') ? getPos() : pos;
|
|
38
45
|
if (typeof newPos === 'number') {
|
|
@@ -78,7 +78,14 @@ export const findDropTargetDecs = (decorations, from, to) => {
|
|
|
78
78
|
};
|
|
79
79
|
export const createDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) => {
|
|
80
80
|
const key = uuid();
|
|
81
|
-
return Decoration.widget(pos, (_,
|
|
81
|
+
return Decoration.widget(pos, (_, getPosUnsafe) => {
|
|
82
|
+
const getPos = () => {
|
|
83
|
+
try {
|
|
84
|
+
return getPosUnsafe();
|
|
85
|
+
} catch (e) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
82
89
|
const element = document.createElement('div');
|
|
83
90
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
84
91
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
@@ -127,7 +134,14 @@ export const createDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI
|
|
|
127
134
|
};
|
|
128
135
|
export const createLayoutDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI, anchorRectCache) => {
|
|
129
136
|
const key = uuid();
|
|
130
|
-
return Decoration.widget(pos, (_,
|
|
137
|
+
return Decoration.widget(pos, (_, getPosUnsafe) => {
|
|
138
|
+
const getPos = () => {
|
|
139
|
+
try {
|
|
140
|
+
return getPosUnsafe();
|
|
141
|
+
} catch (e) {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
131
145
|
const element = document.createElement('div');
|
|
132
146
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
133
147
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
@@ -461,6 +461,11 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
|
|
|
461
461
|
// Currently we can only drag one node at a time
|
|
462
462
|
// so we only need to check first child
|
|
463
463
|
const draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
464
|
+
if ((draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
465
|
+
// we prevent native DnD for layoutColumn to prevent single column layout.
|
|
466
|
+
event.preventDefault();
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
464
469
|
const nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
465
470
|
if (!nodeElement) {
|
|
466
471
|
return false;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
2
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
export const getInsertLayoutStep = tr => tr.steps.find(step => {
|
|
5
|
+
var _step$slice$content$f;
|
|
6
|
+
return step instanceof ReplaceStep && ['layoutSection', 'layoutColumn'].includes(((_step$slice$content$f = step.slice.content.firstChild) === null || _step$slice$content$f === void 0 ? void 0 : _step$slice$content$f.type.name) || '');
|
|
7
|
+
});
|
|
8
|
+
export const updateSelection = (tr, to, insertAtRight) => {
|
|
9
|
+
var _lastNode;
|
|
10
|
+
const $to = tr.doc.resolve(to);
|
|
11
|
+
const toNode = $to.nodeAfter;
|
|
12
|
+
let lastNode = toNode === null || toNode === void 0 ? void 0 : toNode.content.lastChild;
|
|
13
|
+
if (!toNode || !lastNode) {
|
|
14
|
+
return tr;
|
|
15
|
+
}
|
|
16
|
+
let offset = toNode.nodeSize;
|
|
17
|
+
|
|
18
|
+
// drop at the start of the layoutSection or to create a new layoutSection
|
|
19
|
+
if (toNode.type.name === 'layoutSection') {
|
|
20
|
+
if (insertAtRight) {
|
|
21
|
+
var _toNode$content$lastC;
|
|
22
|
+
lastNode = (_toNode$content$lastC = toNode.content.lastChild) === null || _toNode$content$lastC === void 0 ? void 0 : _toNode$content$lastC.lastChild;
|
|
23
|
+
offset = toNode.nodeSize - 1;
|
|
24
|
+
} else {
|
|
25
|
+
var _toNode$content$first, _toNode$content$first2;
|
|
26
|
+
lastNode = (_toNode$content$first = toNode.content.firstChild) === null || _toNode$content$first === void 0 ? void 0 : _toNode$content$first.lastChild;
|
|
27
|
+
offset = 1 + (((_toNode$content$first2 = toNode.content.firstChild) === null || _toNode$content$first2 === void 0 ? void 0 : _toNode$content$first2.nodeSize) || 0);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (['paragraph', 'heading'].includes(((_lastNode = lastNode) === null || _lastNode === void 0 ? void 0 : _lastNode.type.name) || '')) {
|
|
31
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(to + offset - 2)));
|
|
32
|
+
} else if (lastNode) {
|
|
33
|
+
tr.setSelection(new GapCursorSelection(tr.doc.resolve(to + offset - 1), Side.RIGHT));
|
|
34
|
+
}
|
|
35
|
+
return tr;
|
|
36
|
+
};
|
|
@@ -129,7 +129,17 @@ export const DragHandle = ({
|
|
|
129
129
|
// but ensures the preview is generated correctly.
|
|
130
130
|
const handleMouseDown = useCallback(() => {
|
|
131
131
|
var _api$core3;
|
|
132
|
-
if (
|
|
132
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
133
|
+
// prevent native drag and drop.
|
|
134
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
135
|
+
var _buttonRef$current;
|
|
136
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
137
|
+
}
|
|
138
|
+
if (!isLayoutColumn) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (fg('platform_editor_element_drag_and_drop_ed_24885')) {
|
|
133
143
|
return undefined;
|
|
134
144
|
}
|
|
135
145
|
api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
|
|
@@ -344,8 +354,8 @@ export const DragHandle = ({
|
|
|
344
354
|
useEffect(() => {
|
|
345
355
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
346
356
|
const id = requestAnimationFrame(() => {
|
|
347
|
-
var _buttonRef$
|
|
348
|
-
(_buttonRef$
|
|
357
|
+
var _buttonRef$current2;
|
|
358
|
+
(_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 ? void 0 : _buttonRef$current2.focus();
|
|
349
359
|
});
|
|
350
360
|
return () => {
|
|
351
361
|
cancelAnimationFrame(id);
|
|
@@ -7,6 +7,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { layoutBreakpointWidth } from '@atlaskit/editor-shared-styles';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
11
12
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
12
13
|
import { B200 } from '@atlaskit/theme/colors';
|
|
@@ -14,6 +15,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
|
|
|
14
15
|
import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
|
|
15
16
|
import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
|
|
16
17
|
import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
|
|
18
|
+
import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
|
|
17
19
|
|
|
18
20
|
// 8px gap + 16px on left and right
|
|
19
21
|
const DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH = 40;
|
|
@@ -70,12 +72,36 @@ export const DropTargetLayout = props => {
|
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
74
|
const to = getPos();
|
|
75
|
+
let mappedTo;
|
|
73
76
|
if (to !== undefined) {
|
|
74
|
-
var _api$core
|
|
77
|
+
var _api$core;
|
|
75
78
|
const {
|
|
76
79
|
pos: from
|
|
77
80
|
} = activeNode;
|
|
78
|
-
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(
|
|
81
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
82
|
+
tr
|
|
83
|
+
}) => {
|
|
84
|
+
var _api$blockControls2, _api$blockControls2$c;
|
|
85
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(from, to)({
|
|
86
|
+
tr
|
|
87
|
+
});
|
|
88
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
89
|
+
const insertColumnStep = getInsertLayoutStep(tr);
|
|
90
|
+
mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
|
|
91
|
+
}
|
|
92
|
+
return tr;
|
|
93
|
+
});
|
|
94
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
95
|
+
var _api$core2;
|
|
96
|
+
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
97
|
+
tr
|
|
98
|
+
}) => {
|
|
99
|
+
if (mappedTo !== undefined) {
|
|
100
|
+
updateSelection(tr, mappedTo);
|
|
101
|
+
}
|
|
102
|
+
return tr;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
79
105
|
}
|
|
80
106
|
}, [api, getPos, activeNode]);
|
|
81
107
|
useEffect(() => {
|
|
@@ -160,6 +160,16 @@ const legacyBreakoutWideLayoutStyle = css({
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
|
+
const globalDnDStyle = css({
|
|
164
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
165
|
+
'.ProseMirror': {
|
|
166
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
167
|
+
'[data-layout-content]': {
|
|
168
|
+
userDrag: 'none',
|
|
169
|
+
userSelect: 'none'
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
163
173
|
const globalStyles = () => fg('platform_editor_element_dnd_nested_fix_patch_3') ? css({
|
|
164
174
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
165
175
|
'.ProseMirror-widget:first-child + *:not([data-panel-type], .code-block, [data-node-type="nestedExpand"], [data-layout-section="true"])': {
|
|
@@ -261,6 +271,6 @@ const blockCardWithoutLayout = css({
|
|
|
261
271
|
});
|
|
262
272
|
export const GlobalStylesWrapper = () => {
|
|
263
273
|
return jsx(Global, {
|
|
264
|
-
styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
274
|
+
styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
265
275
|
});
|
|
266
276
|
};
|
|
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
13
14
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
15
|
import { B200 } from '@atlaskit/theme/colors';
|
|
@@ -16,6 +17,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
|
|
|
16
17
|
import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
|
|
17
18
|
import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
|
|
18
19
|
import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
|
|
20
|
+
import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
|
|
19
21
|
const HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
|
|
20
22
|
const HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
|
|
21
23
|
const HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
|
|
@@ -175,14 +177,39 @@ export const InlineDropTarget = ({
|
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
177
179
|
const toPos = getPos();
|
|
180
|
+
let mappedTo;
|
|
178
181
|
if (activeNode && toPos !== undefined) {
|
|
179
|
-
var _api$core
|
|
182
|
+
var _api$core;
|
|
180
183
|
const {
|
|
181
184
|
pos: start
|
|
182
185
|
} = activeNode;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
const moveToEnd = position === 'right';
|
|
187
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
188
|
+
tr
|
|
189
|
+
}) => {
|
|
190
|
+
var _api$blockControls2, _api$blockControls2$c;
|
|
191
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(start, toPos, {
|
|
192
|
+
moveToEnd
|
|
193
|
+
})({
|
|
194
|
+
tr
|
|
195
|
+
});
|
|
196
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
197
|
+
const insertLayoutStep = getInsertLayoutStep(tr);
|
|
198
|
+
mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
|
|
199
|
+
}
|
|
200
|
+
return tr;
|
|
201
|
+
});
|
|
202
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
203
|
+
var _api$core2;
|
|
204
|
+
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
205
|
+
tr
|
|
206
|
+
}) => {
|
|
207
|
+
if (mappedTo !== undefined) {
|
|
208
|
+
updateSelection(tr, mappedTo, moveToEnd);
|
|
209
|
+
}
|
|
210
|
+
return tr;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
186
213
|
}
|
|
187
214
|
}, [api, getPos, position]);
|
|
188
215
|
const hoverZoneRectStyle = useMemo(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
|
|
5
6
|
import { fireInsertLayoutAnalytics, fireMoveNodeAnalytics } from '../pm-plugins/utils/fire-analytics';
|
|
6
7
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
@@ -38,13 +39,21 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
|
|
|
38
39
|
// reorder columns
|
|
39
40
|
tr.delete(from, from + sourceNode.nodeSize);
|
|
40
41
|
var mappedTo = tr.mapping.map(to);
|
|
41
|
-
tr.insert(mappedTo, sourceNode)
|
|
42
|
+
tr.insert(mappedTo, sourceNode);
|
|
43
|
+
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
44
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
45
|
+
}
|
|
42
46
|
fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api);
|
|
43
47
|
} else if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
44
48
|
var _$originalFrom$nodeAf2;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
50
|
+
removeFromSource(tr, tr.doc.resolve(from));
|
|
51
|
+
insertToDestination(tr, tr.mapping.map(to), sourceNode, toLayout, tr.mapping.map(toLayoutPos));
|
|
52
|
+
} else {
|
|
53
|
+
insertToDestination(tr, to, sourceNode, toLayout, toLayoutPos);
|
|
54
|
+
var mappedFrom = tr.mapping.map(from);
|
|
55
|
+
removeFromSource(tr, tr.doc.resolve(mappedFrom));
|
|
56
|
+
}
|
|
48
57
|
fireMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api);
|
|
49
58
|
}
|
|
50
59
|
return tr;
|
|
@@ -57,7 +66,10 @@ var insertToDestination = function insertToDestination(tr, to, sourceNode, toLay
|
|
|
57
66
|
var content = layoutColumn.createChecked({
|
|
58
67
|
width: newColumnWidth
|
|
59
68
|
}, sourceNode.type.name === 'layoutColumn' ? sourceNode.content : sourceNode);
|
|
60
|
-
tr.insert(to, content)
|
|
69
|
+
tr.insert(to, content);
|
|
70
|
+
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
71
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
|
|
72
|
+
}
|
|
61
73
|
return tr;
|
|
62
74
|
};
|
|
63
75
|
|
|
@@ -165,7 +177,10 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
165
177
|
if (newLayout) {
|
|
166
178
|
tr = removeFromSource(tr, $from);
|
|
167
179
|
var mappedTo = tr.mapping.map(to);
|
|
168
|
-
tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout)
|
|
180
|
+
tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
|
|
181
|
+
if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
182
|
+
tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
183
|
+
}
|
|
169
184
|
breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
|
|
170
185
|
mode: breakoutMode
|
|
171
186
|
})]);
|
|
@@ -26,7 +26,7 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
26
26
|
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
27
27
|
var unbind;
|
|
28
28
|
var key = uuid();
|
|
29
|
-
return Decoration.widget(pos, function (view,
|
|
29
|
+
return Decoration.widget(pos, function (view, getPosUnsafe) {
|
|
30
30
|
var element = document.createElement('span');
|
|
31
31
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
32
32
|
// platform_editor_element_dnd_nested_fix_patch_2 -> inline decoration causes focus issues when refocusing Editor into first line
|
|
@@ -35,6 +35,13 @@ export var dragHandleDecoration = function dragHandleDecoration(api, formatMessa
|
|
|
35
35
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
36
36
|
element.setAttribute('data-blocks-drag-handle-key', key);
|
|
37
37
|
var isTopLevelNode = true;
|
|
38
|
+
var getPos = function getPos() {
|
|
39
|
+
try {
|
|
40
|
+
return getPosUnsafe();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
38
45
|
if (editorExperiment('nested-dnd', true)) {
|
|
39
46
|
var newPos = fg('platform_editor_element_dnd_nested_fix_patch_3') ? getPos() : pos;
|
|
40
47
|
if (typeof newPos === 'number') {
|
|
@@ -83,7 +83,14 @@ export var findDropTargetDecs = function findDropTargetDecs(decorations, from, t
|
|
|
83
83
|
};
|
|
84
84
|
export var createDropTargetDecoration = function createDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) {
|
|
85
85
|
var key = uuid();
|
|
86
|
-
return Decoration.widget(pos, function (_,
|
|
86
|
+
return Decoration.widget(pos, function (_, getPosUnsafe) {
|
|
87
|
+
var getPos = function getPos() {
|
|
88
|
+
try {
|
|
89
|
+
return getPosUnsafe();
|
|
90
|
+
} catch (e) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
87
94
|
var element = document.createElement('div');
|
|
88
95
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
89
96
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
@@ -131,7 +138,14 @@ export var createDropTargetDecoration = function createDropTargetDecoration(pos,
|
|
|
131
138
|
};
|
|
132
139
|
export var createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, anchorRectCache) {
|
|
133
140
|
var key = uuid();
|
|
134
|
-
return Decoration.widget(pos, function (_,
|
|
141
|
+
return Decoration.widget(pos, function (_, getPosUnsafe) {
|
|
142
|
+
var getPos = function getPos() {
|
|
143
|
+
try {
|
|
144
|
+
return getPosUnsafe();
|
|
145
|
+
} catch (e) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
135
149
|
var element = document.createElement('div');
|
|
136
150
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
137
151
|
element.setAttribute('data-blocks-drop-target-key', key);
|
|
@@ -477,6 +477,11 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
477
477
|
// Currently we can only drag one node at a time
|
|
478
478
|
// so we only need to check first child
|
|
479
479
|
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
480
|
+
if ((draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
481
|
+
// we prevent native DnD for layoutColumn to prevent single column layout.
|
|
482
|
+
event.preventDefault();
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
480
485
|
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
481
486
|
if (!nodeElement) {
|
|
482
487
|
return false;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
2
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
export var getInsertLayoutStep = function getInsertLayoutStep(tr) {
|
|
5
|
+
return tr.steps.find(function (step) {
|
|
6
|
+
var _step$slice$content$f;
|
|
7
|
+
return step instanceof ReplaceStep && ['layoutSection', 'layoutColumn'].includes(((_step$slice$content$f = step.slice.content.firstChild) === null || _step$slice$content$f === void 0 ? void 0 : _step$slice$content$f.type.name) || '');
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export var updateSelection = function updateSelection(tr, to, insertAtRight) {
|
|
11
|
+
var _lastNode;
|
|
12
|
+
var $to = tr.doc.resolve(to);
|
|
13
|
+
var toNode = $to.nodeAfter;
|
|
14
|
+
var lastNode = toNode === null || toNode === void 0 ? void 0 : toNode.content.lastChild;
|
|
15
|
+
if (!toNode || !lastNode) {
|
|
16
|
+
return tr;
|
|
17
|
+
}
|
|
18
|
+
var offset = toNode.nodeSize;
|
|
19
|
+
|
|
20
|
+
// drop at the start of the layoutSection or to create a new layoutSection
|
|
21
|
+
if (toNode.type.name === 'layoutSection') {
|
|
22
|
+
if (insertAtRight) {
|
|
23
|
+
var _toNode$content$lastC;
|
|
24
|
+
lastNode = (_toNode$content$lastC = toNode.content.lastChild) === null || _toNode$content$lastC === void 0 ? void 0 : _toNode$content$lastC.lastChild;
|
|
25
|
+
offset = toNode.nodeSize - 1;
|
|
26
|
+
} else {
|
|
27
|
+
var _toNode$content$first, _toNode$content$first2;
|
|
28
|
+
lastNode = (_toNode$content$first = toNode.content.firstChild) === null || _toNode$content$first === void 0 ? void 0 : _toNode$content$first.lastChild;
|
|
29
|
+
offset = 1 + (((_toNode$content$first2 = toNode.content.firstChild) === null || _toNode$content$first2 === void 0 ? void 0 : _toNode$content$first2.nodeSize) || 0);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (['paragraph', 'heading'].includes(((_lastNode = lastNode) === null || _lastNode === void 0 ? void 0 : _lastNode.type.name) || '')) {
|
|
33
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(to + offset - 2)));
|
|
34
|
+
} else if (lastNode) {
|
|
35
|
+
tr.setSelection(new GapCursorSelection(tr.doc.resolve(to + offset - 1), Side.RIGHT));
|
|
36
|
+
}
|
|
37
|
+
return tr;
|
|
38
|
+
};
|
|
@@ -137,7 +137,17 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
137
137
|
// but ensures the preview is generated correctly.
|
|
138
138
|
var handleMouseDown = useCallback(function () {
|
|
139
139
|
var _api$core3;
|
|
140
|
-
if (
|
|
140
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
141
|
+
// prevent native drag and drop.
|
|
142
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
143
|
+
var _buttonRef$current;
|
|
144
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
|
|
145
|
+
}
|
|
146
|
+
if (!isLayoutColumn) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (fg('platform_editor_element_drag_and_drop_ed_24885')) {
|
|
141
151
|
return undefined;
|
|
142
152
|
}
|
|
143
153
|
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
@@ -354,8 +364,8 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
354
364
|
useEffect(function () {
|
|
355
365
|
if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current && fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
356
366
|
var id = requestAnimationFrame(function () {
|
|
357
|
-
var _buttonRef$
|
|
358
|
-
(_buttonRef$
|
|
367
|
+
var _buttonRef$current2;
|
|
368
|
+
(_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 || _buttonRef$current2.focus();
|
|
359
369
|
});
|
|
360
370
|
return function () {
|
|
361
371
|
cancelAnimationFrame(id);
|
|
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { layoutBreakpointWidth } from '@atlaskit/editor-shared-styles';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
13
14
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
14
15
|
import { B200 } from '@atlaskit/theme/colors';
|
|
@@ -16,6 +17,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
|
|
|
16
17
|
import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
|
|
17
18
|
import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
|
|
18
19
|
import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
|
|
20
|
+
import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
|
|
19
21
|
|
|
20
22
|
// 8px gap + 16px on left and right
|
|
21
23
|
var DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH = 40;
|
|
@@ -71,10 +73,32 @@ export var DropTargetLayout = function DropTargetLayout(props) {
|
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
var to = getPos();
|
|
76
|
+
var mappedTo;
|
|
74
77
|
if (to !== undefined) {
|
|
75
|
-
var _api$core
|
|
78
|
+
var _api$core;
|
|
76
79
|
var from = activeNode.pos;
|
|
77
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(
|
|
80
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
81
|
+
var _api$blockControls2;
|
|
82
|
+
var tr = _ref2.tr;
|
|
83
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(from, to)({
|
|
84
|
+
tr: tr
|
|
85
|
+
});
|
|
86
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
87
|
+
var insertColumnStep = getInsertLayoutStep(tr);
|
|
88
|
+
mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
|
|
89
|
+
}
|
|
90
|
+
return tr;
|
|
91
|
+
});
|
|
92
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
93
|
+
var _api$core2;
|
|
94
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
|
|
95
|
+
var tr = _ref3.tr;
|
|
96
|
+
if (mappedTo !== undefined) {
|
|
97
|
+
updateSelection(tr, mappedTo);
|
|
98
|
+
}
|
|
99
|
+
return tr;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
78
102
|
}
|
|
79
103
|
}, [api, getPos, activeNode]);
|
|
80
104
|
useEffect(function () {
|
|
@@ -127,6 +127,16 @@ var legacyBreakoutWideLayoutStyle = css({
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
|
+
var globalDnDStyle = css({
|
|
131
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
132
|
+
'.ProseMirror': {
|
|
133
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
134
|
+
'[data-layout-content]': {
|
|
135
|
+
userDrag: 'none',
|
|
136
|
+
userSelect: 'none'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
130
140
|
var globalStyles = function globalStyles() {
|
|
131
141
|
return fg('platform_editor_element_dnd_nested_fix_patch_3') ? css({
|
|
132
142
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
@@ -212,6 +222,6 @@ var blockCardWithoutLayout = css({
|
|
|
212
222
|
});
|
|
213
223
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
214
224
|
return jsx(Global, {
|
|
215
|
-
styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
225
|
+
styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
|
|
216
226
|
});
|
|
217
227
|
};
|
|
@@ -11,6 +11,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
11
11
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
12
12
|
import { css, jsx } from '@emotion/react';
|
|
13
13
|
import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
15
16
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
16
17
|
import { B200 } from '@atlaskit/theme/colors';
|
|
@@ -18,6 +19,7 @@ import { getNodeAnchor } from '../pm-plugins/decorations-common';
|
|
|
18
19
|
import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
|
|
19
20
|
import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
|
|
20
21
|
import { isBlocksDragTargetDebug } from '../pm-plugins/utils/drag-target-debug';
|
|
22
|
+
import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
|
|
21
23
|
var HOVER_ZONE_WIDTH = '--editor-blocks-inline-hover-zone-width';
|
|
22
24
|
var HOVER_ZONE_HEIGHT = '--editor-blocks-inline-hover-zone-height';
|
|
23
25
|
var HOVER_ZONE_TOP = '--editor-blocks-inline-hover-zone-top';
|
|
@@ -180,16 +182,39 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
180
182
|
return;
|
|
181
183
|
}
|
|
182
184
|
var toPos = getPos();
|
|
185
|
+
var mappedTo;
|
|
183
186
|
if (activeNode && toPos !== undefined) {
|
|
184
|
-
var _api$core
|
|
187
|
+
var _api$core;
|
|
185
188
|
var start = activeNode.pos;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
var moveToEnd = position === 'right';
|
|
190
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
191
|
+
var _api$blockControls2;
|
|
192
|
+
var tr = _ref3.tr;
|
|
193
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 || _api$blockControls2.moveToLayout(start, toPos, {
|
|
194
|
+
moveToEnd: moveToEnd
|
|
195
|
+
})({
|
|
196
|
+
tr: tr
|
|
197
|
+
});
|
|
198
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
199
|
+
var insertLayoutStep = getInsertLayoutStep(tr);
|
|
200
|
+
mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
|
|
201
|
+
}
|
|
202
|
+
return tr;
|
|
203
|
+
});
|
|
204
|
+
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
205
|
+
var _api$core2;
|
|
206
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
207
|
+
var tr = _ref4.tr;
|
|
208
|
+
if (mappedTo !== undefined) {
|
|
209
|
+
updateSelection(tr, mappedTo, moveToEnd);
|
|
210
|
+
}
|
|
211
|
+
return tr;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
189
214
|
}
|
|
190
215
|
}, [api, getPos, position]);
|
|
191
216
|
var hoverZoneRectStyle = useMemo(function () {
|
|
192
|
-
var
|
|
217
|
+
var _ref5;
|
|
193
218
|
var isLayoutNode = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name) === 'layoutSection';
|
|
194
219
|
var layoutAdjustment = isLayoutNode ? {
|
|
195
220
|
width: 11,
|
|
@@ -197,7 +222,7 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
|
|
|
197
222
|
top: 6,
|
|
198
223
|
bottom: 2
|
|
199
224
|
} : undefined;
|
|
200
|
-
return
|
|
225
|
+
return _ref5 = {}, _defineProperty(_ref5, HOVER_ZONE_WIDTH, nodeDimension.widthOffset ? "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px + ").concat(nodeDimension.widthOffset, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)") : "calc((100% - ".concat(nodeDimension.width, ")/2 - ").concat(GAP, "px - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.width) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_HEIGHT, "calc(".concat(nodeDimension.height, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.height) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_TOP, "calc(".concat(nodeDimension.top, " + ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.top) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_BOTTOM, "calc(".concat(nodeDimension.bottom, " - ").concat((layoutAdjustment === null || layoutAdjustment === void 0 ? void 0 : layoutAdjustment.bottom) || 0, "px)")), _defineProperty(_ref5, HOVER_ZONE_ANCHOR_NAME, anchorName), _ref5;
|
|
201
226
|
}, [nextNode === null || nextNode === void 0 ? void 0 : nextNode.type.name, nodeDimension, anchorName]);
|
|
202
227
|
var dropIndicatorPos = useMemo(function () {
|
|
203
228
|
return isLeftPosition ? 'right' : 'left';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const getInsertLayoutStep: (tr: Transaction) => import("prosemirror-transform").Step | undefined;
|
|
3
|
+
export declare const updateSelection: (tr: Transaction, to: number, insertAtRight?: boolean) => Transaction;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const getInsertLayoutStep: (tr: Transaction) => import("prosemirror-transform").Step | undefined;
|
|
3
|
+
export declare const updateSelection: (tr: Transaction, to: number, insertAtRight?: boolean) => Transaction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,24 +31,24 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
34
|
-
"@atlaskit/editor-common": "^96.
|
|
34
|
+
"@atlaskit/editor-common": "^96.3.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
39
|
-
"@atlaskit/editor-plugin-quick-insert": "^1.
|
|
39
|
+
"@atlaskit/editor-plugin-quick-insert": "^1.8.0",
|
|
40
40
|
"@atlaskit/editor-plugin-width": "^1.3.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
44
|
-
"@atlaskit/icon": "^23.
|
|
44
|
+
"@atlaskit/icon": "^23.1.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
47
|
-
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.
|
|
47
|
+
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^13.3.0",
|
|
50
50
|
"@atlaskit/theme": "^14.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^2.23.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.4.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.9.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
@@ -165,6 +165,9 @@
|
|
|
165
165
|
},
|
|
166
166
|
"platform_editor_use_nested_table_pm_nodes": {
|
|
167
167
|
"type": "boolean"
|
|
168
|
+
},
|
|
169
|
+
"platform_editor_advanced_layouts_post_fix_patch_1": {
|
|
170
|
+
"type": "boolean"
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
}
|