@atlaskit/editor-plugin-block-controls 2.14.3 → 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 +12 -0
- 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/ui/drag-handle.js +13 -3
- package/dist/cjs/ui/global-styles.js +11 -1
- 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/ui/drag-handle.js +13 -3
- package/dist/es2019/ui/global-styles.js +11 -1
- 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/ui/drag-handle.js +13 -3
- package/dist/esm/ui/global-styles.js +11 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
3
15
|
## 2.14.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -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
|
};
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -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
|
};
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -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
|
};
|
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,7 +31,7 @@
|
|
|
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",
|
|
@@ -41,7 +41,7 @@
|
|
|
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
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|