@atlaskit/editor-plugin-block-controls 2.21.2 → 2.21.4
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 +20 -0
- package/dist/cjs/pm-plugins/decorations-anchor.js +2 -1
- package/dist/cjs/ui/drag-handle.js +45 -3
- package/dist/es2019/pm-plugins/decorations-anchor.js +2 -1
- package/dist/es2019/ui/drag-handle.js +45 -3
- package/dist/esm/pm-plugins/decorations-anchor.js +2 -1
- package/dist/esm/ui/drag-handle.js +45 -3
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.21.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#102952](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102952)
|
|
8
|
+
[`6d865148eda80`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6d865148eda80) -
|
|
9
|
+
Fix incorrect drop zone on table cell
|
|
10
|
+
- [#103494](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103494)
|
|
11
|
+
[`955dbd85f329f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/955dbd85f329f) -
|
|
12
|
+
[ux] ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
13
|
+
|
|
14
|
+
## 2.21.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#103498](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103498)
|
|
19
|
+
[`a2fd134b068cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a2fd134b068cd) -
|
|
20
|
+
[ED-26267] Fix a bug where when selection is across multiple nodes, dragging a drag handle within
|
|
21
|
+
the selection range does not trigger pragmatic DnD
|
|
22
|
+
|
|
3
23
|
## 2.21.2
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.shouldDescendIntoNode = exports.nodeDecorations = exports.findNodeDecs = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
11
12
|
var _decorationsCommon = require("./decorations-common");
|
|
12
13
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
|
|
@@ -17,7 +18,7 @@ var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDesce
|
|
|
17
18
|
// Optimisation to avoid drawing node decorations for empty table cells
|
|
18
19
|
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
|
|
19
20
|
var _node$firstChild;
|
|
20
|
-
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
21
|
+
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph' && ((0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_6') ? node.firstChild.childCount === 0 : true)) {
|
|
21
22
|
return false;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -11,6 +11,7 @@ var _react = require("react");
|
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
12
|
var _bindEventListener = require("bind-event-listener");
|
|
13
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
14
15
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
16
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
16
17
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
@@ -19,6 +20,7 @@ var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-han
|
|
|
19
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
21
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
21
22
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
23
|
+
var _primitives = require("@atlaskit/primitives");
|
|
22
24
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
23
25
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
24
26
|
var _main = require("../pm-plugins/main");
|
|
@@ -34,6 +36,11 @@ var _dragPreview = require("./drag-preview");
|
|
|
34
36
|
|
|
35
37
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
36
38
|
|
|
39
|
+
var iconWrapperStyles = (0, _primitives.xcss)({
|
|
40
|
+
display: 'flex',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
alignItems: 'center'
|
|
43
|
+
});
|
|
37
44
|
var dragHandleButtonStyles = (0, _react2.css)({
|
|
38
45
|
position: 'absolute',
|
|
39
46
|
padding: "var(--ds-space-025, 2px)".concat(" 0"),
|
|
@@ -65,6 +72,11 @@ var dragHandleButtonStyles = (0, _react2.css)({
|
|
|
65
72
|
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
66
73
|
}
|
|
67
74
|
});
|
|
75
|
+
var dragHandleMultiLineSelectionFixFirefox = (0, _react2.css)({
|
|
76
|
+
'&::selection': {
|
|
77
|
+
backgroundColor: 'transparent'
|
|
78
|
+
}
|
|
79
|
+
});
|
|
68
80
|
var layoutColumnDragHandleStyles = (0, _react2.css)({
|
|
69
81
|
transform: 'rotate(90deg)'
|
|
70
82
|
});
|
|
@@ -72,6 +84,27 @@ var selectedStyles = (0, _react2.css)({
|
|
|
72
84
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
73
85
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
74
86
|
});
|
|
87
|
+
|
|
88
|
+
// [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
|
|
89
|
+
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
90
|
+
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
91
|
+
var handleIconDragStart = function handleIconDragStart(e) {
|
|
92
|
+
if (!_browser.browser.chrome || !(0, _platformFeatureFlags.fg)('platform_editor_dnd_update_drag_start_target')) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// prevent dragStart handler triggered by icon
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
var dragEvent = new DragEvent('dragstart', {
|
|
98
|
+
bubbles: true,
|
|
99
|
+
cancelable: true,
|
|
100
|
+
dataTransfer: e.dataTransfer
|
|
101
|
+
});
|
|
102
|
+
if (e.target instanceof HTMLElement) {
|
|
103
|
+
var _e$target$closest;
|
|
104
|
+
// re-dispatch drag event on button so that pragmatic DnD can be triggered properly
|
|
105
|
+
(_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 || _e$target$closest.dispatchEvent(dragEvent);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
75
108
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
76
109
|
var _api$core2, _api$analytics2, _api$core4;
|
|
77
110
|
var view = _ref.view,
|
|
@@ -402,7 +435,10 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
402
435
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
403
436
|
(0, _react2.jsx)("button", {
|
|
404
437
|
type: "button",
|
|
405
|
-
css: [dragHandleButtonStyles,
|
|
438
|
+
css: [dragHandleButtonStyles,
|
|
439
|
+
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
440
|
+
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
441
|
+
_browser.browser.gecko && (0, _platformFeatureFlags.fg)('platform_editor_dnd_handle_highlight_fix_firefox') && dragHandleMultiLineSelectionFixFirefox, (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
406
442
|
ref: buttonRef
|
|
407
443
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
408
444
|
,
|
|
@@ -411,10 +447,16 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
411
447
|
onMouseDown: handleMouseDown,
|
|
412
448
|
onKeyDown: handleKeyDown,
|
|
413
449
|
"data-testid": "block-ctrl-drag-handle"
|
|
414
|
-
}, (0, _react2.jsx)(
|
|
450
|
+
}, (0, _react2.jsx)(_primitives.Box, {
|
|
451
|
+
as: "span",
|
|
452
|
+
xcss: iconWrapperStyles
|
|
453
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
454
|
+
,
|
|
455
|
+
onDragStart: handleIconDragStart
|
|
456
|
+
}, ' ', (0, _react2.jsx)(_dragHandler.default, {
|
|
415
457
|
label: "",
|
|
416
458
|
size: "medium"
|
|
417
|
-
}))
|
|
459
|
+
})))
|
|
418
460
|
);
|
|
419
461
|
};
|
|
420
462
|
return (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') ? (0, _react2.jsx)(_tooltip.default, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
4
|
import { getNestedDepth, getNodeAnchor, TYPE_NODE_DEC } from './decorations-common';
|
|
4
5
|
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
|
|
@@ -9,7 +10,7 @@ export const shouldDescendIntoNode = node => {
|
|
|
9
10
|
// Optimisation to avoid drawing node decorations for empty table cells
|
|
10
11
|
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
|
|
11
12
|
var _node$firstChild;
|
|
12
|
-
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
13
|
+
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph' && (fg('platform_editor_element_dnd_nested_fix_patch_6') ? node.firstChild.childCount === 0 : true)) {
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -7,6 +7,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import { bind } from 'bind-event-listener';
|
|
9
9
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
10
|
+
import { browser } from '@atlaskit/editor-common/browser';
|
|
10
11
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
12
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
12
13
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -15,6 +16,7 @@ import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
17
18
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
19
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
18
20
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
21
|
import Tooltip from '@atlaskit/tooltip';
|
|
20
22
|
import { key } from '../pm-plugins/main';
|
|
@@ -23,6 +25,11 @@ import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition
|
|
|
23
25
|
import { selectNode } from '../pm-plugins/utils/getSelection';
|
|
24
26
|
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, topPositionAdjustment } from './consts';
|
|
25
27
|
import { dragPreview } from './drag-preview';
|
|
28
|
+
const iconWrapperStyles = xcss({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
alignItems: 'center'
|
|
32
|
+
});
|
|
26
33
|
const dragHandleButtonStyles = css({
|
|
27
34
|
position: 'absolute',
|
|
28
35
|
padding: `${"var(--ds-space-025, 2px)"} 0`,
|
|
@@ -54,6 +61,11 @@ const dragHandleButtonStyles = css({
|
|
|
54
61
|
outline: `2px solid ${"var(--ds-border-focused, #388BFF)"}`
|
|
55
62
|
}
|
|
56
63
|
});
|
|
64
|
+
const dragHandleMultiLineSelectionFixFirefox = css({
|
|
65
|
+
'&::selection': {
|
|
66
|
+
backgroundColor: 'transparent'
|
|
67
|
+
}
|
|
68
|
+
});
|
|
57
69
|
const layoutColumnDragHandleStyles = css({
|
|
58
70
|
transform: 'rotate(90deg)'
|
|
59
71
|
});
|
|
@@ -61,6 +73,27 @@ const selectedStyles = css({
|
|
|
61
73
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
62
74
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
63
75
|
});
|
|
76
|
+
|
|
77
|
+
// [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
|
|
78
|
+
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
79
|
+
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
80
|
+
const handleIconDragStart = e => {
|
|
81
|
+
if (!browser.chrome || !fg('platform_editor_dnd_update_drag_start_target')) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// prevent dragStart handler triggered by icon
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
const dragEvent = new DragEvent('dragstart', {
|
|
87
|
+
bubbles: true,
|
|
88
|
+
cancelable: true,
|
|
89
|
+
dataTransfer: e.dataTransfer
|
|
90
|
+
});
|
|
91
|
+
if (e.target instanceof HTMLElement) {
|
|
92
|
+
var _e$target$closest;
|
|
93
|
+
// re-dispatch drag event on button so that pragmatic DnD can be triggered properly
|
|
94
|
+
(_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.dispatchEvent(dragEvent);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
64
97
|
export const DragHandle = ({
|
|
65
98
|
view,
|
|
66
99
|
api,
|
|
@@ -381,7 +414,10 @@ export const DragHandle = ({
|
|
|
381
414
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
382
415
|
jsx("button", {
|
|
383
416
|
type: "button",
|
|
384
|
-
css: [dragHandleButtonStyles,
|
|
417
|
+
css: [dragHandleButtonStyles,
|
|
418
|
+
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
419
|
+
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
420
|
+
browser.gecko && fg('platform_editor_dnd_handle_highlight_fix_firefox') && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
385
421
|
ref: buttonRef
|
|
386
422
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
387
423
|
,
|
|
@@ -390,10 +426,16 @@ export const DragHandle = ({
|
|
|
390
426
|
onMouseDown: handleMouseDown,
|
|
391
427
|
onKeyDown: handleKeyDown,
|
|
392
428
|
"data-testid": "block-ctrl-drag-handle"
|
|
393
|
-
}, jsx(
|
|
429
|
+
}, jsx(Box, {
|
|
430
|
+
as: "span",
|
|
431
|
+
xcss: iconWrapperStyles
|
|
432
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
433
|
+
,
|
|
434
|
+
onDragStart: handleIconDragStart
|
|
435
|
+
}, ' ', jsx(DragHandlerIcon, {
|
|
394
436
|
label: "",
|
|
395
437
|
size: "medium"
|
|
396
|
-
}));
|
|
438
|
+
})));
|
|
397
439
|
return fg('platform_editor_element_drag_and_drop_ed_23873') ? jsx(Tooltip, {
|
|
398
440
|
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
399
441
|
helpDescriptors: helpDescriptors
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { getNestedDepth, getNodeAnchor, TYPE_NODE_DEC } from './decorations-common';
|
|
5
6
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
|
|
@@ -10,7 +11,7 @@ export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
|
10
11
|
// Optimisation to avoid drawing node decorations for empty table cells
|
|
11
12
|
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
|
|
12
13
|
var _node$firstChild;
|
|
13
|
-
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
14
|
+
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph' && (fg('platform_editor_element_dnd_nested_fix_patch_6') ? node.firstChild.childCount === 0 : true)) {
|
|
14
15
|
return false;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
9
9
|
import { css, jsx } from '@emotion/react';
|
|
10
10
|
import { bind } from 'bind-event-listener';
|
|
11
11
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
12
|
+
import { browser } from '@atlaskit/editor-common/browser';
|
|
12
13
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
13
14
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
14
15
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -17,6 +18,7 @@ import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
|
17
18
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
19
20
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
21
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
20
22
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
21
23
|
import Tooltip from '@atlaskit/tooltip';
|
|
22
24
|
import { key } from '../pm-plugins/main';
|
|
@@ -25,6 +27,11 @@ import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition
|
|
|
25
27
|
import { selectNode } from '../pm-plugins/utils/getSelection';
|
|
26
28
|
import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, topPositionAdjustment } from './consts';
|
|
27
29
|
import { dragPreview } from './drag-preview';
|
|
30
|
+
var iconWrapperStyles = xcss({
|
|
31
|
+
display: 'flex',
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
alignItems: 'center'
|
|
34
|
+
});
|
|
28
35
|
var dragHandleButtonStyles = css({
|
|
29
36
|
position: 'absolute',
|
|
30
37
|
padding: "var(--ds-space-025, 2px)".concat(" 0"),
|
|
@@ -56,6 +63,11 @@ var dragHandleButtonStyles = css({
|
|
|
56
63
|
outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
|
|
57
64
|
}
|
|
58
65
|
});
|
|
66
|
+
var dragHandleMultiLineSelectionFixFirefox = css({
|
|
67
|
+
'&::selection': {
|
|
68
|
+
backgroundColor: 'transparent'
|
|
69
|
+
}
|
|
70
|
+
});
|
|
59
71
|
var layoutColumnDragHandleStyles = css({
|
|
60
72
|
transform: 'rotate(90deg)'
|
|
61
73
|
});
|
|
@@ -63,6 +75,27 @@ var selectedStyles = css({
|
|
|
63
75
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
64
76
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
65
77
|
});
|
|
78
|
+
|
|
79
|
+
// [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
|
|
80
|
+
// icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
|
|
81
|
+
// with pragmatic DnD and pragmatic DnD is not triggered
|
|
82
|
+
var handleIconDragStart = function handleIconDragStart(e) {
|
|
83
|
+
if (!browser.chrome || !fg('platform_editor_dnd_update_drag_start_target')) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// prevent dragStart handler triggered by icon
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
var dragEvent = new DragEvent('dragstart', {
|
|
89
|
+
bubbles: true,
|
|
90
|
+
cancelable: true,
|
|
91
|
+
dataTransfer: e.dataTransfer
|
|
92
|
+
});
|
|
93
|
+
if (e.target instanceof HTMLElement) {
|
|
94
|
+
var _e$target$closest;
|
|
95
|
+
// re-dispatch drag event on button so that pragmatic DnD can be triggered properly
|
|
96
|
+
(_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 || _e$target$closest.dispatchEvent(dragEvent);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
66
99
|
export var DragHandle = function DragHandle(_ref) {
|
|
67
100
|
var _api$core2, _api$analytics2, _api$core4;
|
|
68
101
|
var view = _ref.view,
|
|
@@ -393,7 +426,10 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
393
426
|
// eslint-disable-next-line @atlaskit/design-system/no-html-button
|
|
394
427
|
jsx("button", {
|
|
395
428
|
type: "button",
|
|
396
|
-
css: [dragHandleButtonStyles,
|
|
429
|
+
css: [dragHandleButtonStyles,
|
|
430
|
+
// ED-26266: Fixed the drag handle highlight when selecting multiple line in Firefox
|
|
431
|
+
// See https://product-fabric.atlassian.net/browse/ED-26266
|
|
432
|
+
browser.gecko && fg('platform_editor_dnd_handle_highlight_fix_firefox') && dragHandleMultiLineSelectionFixFirefox, editorExperiment('advanced_layouts', true) && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
|
|
397
433
|
ref: buttonRef
|
|
398
434
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
399
435
|
,
|
|
@@ -402,10 +438,16 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
402
438
|
onMouseDown: handleMouseDown,
|
|
403
439
|
onKeyDown: handleKeyDown,
|
|
404
440
|
"data-testid": "block-ctrl-drag-handle"
|
|
405
|
-
}, jsx(
|
|
441
|
+
}, jsx(Box, {
|
|
442
|
+
as: "span",
|
|
443
|
+
xcss: iconWrapperStyles
|
|
444
|
+
// eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
|
|
445
|
+
,
|
|
446
|
+
onDragStart: handleIconDragStart
|
|
447
|
+
}, ' ', jsx(DragHandlerIcon, {
|
|
406
448
|
label: "",
|
|
407
449
|
size: "medium"
|
|
408
|
-
}))
|
|
450
|
+
})))
|
|
409
451
|
);
|
|
410
452
|
};
|
|
411
453
|
return fg('platform_editor_element_drag_and_drop_ed_23873') ? jsx(Tooltip, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.4",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -144,6 +144,12 @@
|
|
|
144
144
|
},
|
|
145
145
|
"platform_editor_advanced_layouts_DnD_remove_layout": {
|
|
146
146
|
"type": "boolean"
|
|
147
|
+
},
|
|
148
|
+
"platform_editor_dnd_update_drag_start_target": {
|
|
149
|
+
"type": "boolean"
|
|
150
|
+
},
|
|
151
|
+
"platform_editor_dnd_handle_highlight_fix_firefox": {
|
|
152
|
+
"type": "boolean"
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
}
|