@atlaskit/editor-plugin-block-controls 2.21.2 → 2.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.21.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#103498](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103498)
8
+ [`a2fd134b068cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a2fd134b068cd) -
9
+ [ED-26267] Fix a bug where when selection is across multiple nodes, dragging a drag handle within
10
+ the selection range does not trigger pragmatic DnD
11
+
3
12
  ## 2.21.2
4
13
 
5
14
  ### Patch Changes
@@ -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"),
@@ -72,6 +79,27 @@ var selectedStyles = (0, _react2.css)({
72
79
  backgroundColor: "var(--ds-background-selected, #E9F2FF)",
73
80
  color: "var(--ds-icon-selected, #0C66E4)"
74
81
  });
82
+
83
+ // [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
84
+ // icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
85
+ // with pragmatic DnD and pragmatic DnD is not triggered
86
+ var handleIconDragStart = function handleIconDragStart(e) {
87
+ if (!_browser.browser.chrome || !(0, _platformFeatureFlags.fg)('platform_editor_dnd_update_drag_start_target')) {
88
+ return;
89
+ }
90
+ // prevent dragStart handler triggered by icon
91
+ e.stopPropagation();
92
+ var dragEvent = new DragEvent('dragstart', {
93
+ bubbles: true,
94
+ cancelable: true,
95
+ dataTransfer: e.dataTransfer
96
+ });
97
+ if (e.target instanceof HTMLElement) {
98
+ var _e$target$closest;
99
+ // re-dispatch drag event on button so that pragmatic DnD can be triggered properly
100
+ (_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 || _e$target$closest.dispatchEvent(dragEvent);
101
+ }
102
+ };
75
103
  var DragHandle = exports.DragHandle = function DragHandle(_ref) {
76
104
  var _api$core2, _api$analytics2, _api$core4;
77
105
  var view = _ref.view,
@@ -411,10 +439,16 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
411
439
  onMouseDown: handleMouseDown,
412
440
  onKeyDown: handleKeyDown,
413
441
  "data-testid": "block-ctrl-drag-handle"
414
- }, (0, _react2.jsx)(_dragHandler.default, {
442
+ }, (0, _react2.jsx)(_primitives.Box, {
443
+ as: "span",
444
+ xcss: iconWrapperStyles
445
+ // eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
446
+ ,
447
+ onDragStart: handleIconDragStart
448
+ }, ' ', (0, _react2.jsx)(_dragHandler.default, {
415
449
  label: "",
416
450
  size: "medium"
417
- }))
451
+ })))
418
452
  );
419
453
  };
420
454
  return (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') ? (0, _react2.jsx)(_tooltip.default, {
@@ -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`,
@@ -61,6 +68,27 @@ const selectedStyles = css({
61
68
  backgroundColor: "var(--ds-background-selected, #E9F2FF)",
62
69
  color: "var(--ds-icon-selected, #0C66E4)"
63
70
  });
71
+
72
+ // [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
73
+ // icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
74
+ // with pragmatic DnD and pragmatic DnD is not triggered
75
+ const handleIconDragStart = e => {
76
+ if (!browser.chrome || !fg('platform_editor_dnd_update_drag_start_target')) {
77
+ return;
78
+ }
79
+ // prevent dragStart handler triggered by icon
80
+ e.stopPropagation();
81
+ const dragEvent = new DragEvent('dragstart', {
82
+ bubbles: true,
83
+ cancelable: true,
84
+ dataTransfer: e.dataTransfer
85
+ });
86
+ if (e.target instanceof HTMLElement) {
87
+ var _e$target$closest;
88
+ // re-dispatch drag event on button so that pragmatic DnD can be triggered properly
89
+ (_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.dispatchEvent(dragEvent);
90
+ }
91
+ };
64
92
  export const DragHandle = ({
65
93
  view,
66
94
  api,
@@ -390,10 +418,16 @@ export const DragHandle = ({
390
418
  onMouseDown: handleMouseDown,
391
419
  onKeyDown: handleKeyDown,
392
420
  "data-testid": "block-ctrl-drag-handle"
393
- }, jsx(DragHandlerIcon, {
421
+ }, jsx(Box, {
422
+ as: "span",
423
+ xcss: iconWrapperStyles
424
+ // eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
425
+ ,
426
+ onDragStart: handleIconDragStart
427
+ }, ' ', jsx(DragHandlerIcon, {
394
428
  label: "",
395
429
  size: "medium"
396
- }));
430
+ })));
397
431
  return fg('platform_editor_element_drag_and_drop_ed_23873') ? jsx(Tooltip, {
398
432
  content: jsx(TooltipContentWithMultipleShortcuts, {
399
433
  helpDescriptors: helpDescriptors
@@ -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"),
@@ -63,6 +70,27 @@ var selectedStyles = css({
63
70
  backgroundColor: "var(--ds-background-selected, #E9F2FF)",
64
71
  color: "var(--ds-icon-selected, #0C66E4)"
65
72
  });
73
+
74
+ // [Chrome only] When selection contains multiple nodes and then drag a drag handle that is within the selection range,
75
+ // icon span receives dragStart event, instead of button, and since it is not registered as a draggable element
76
+ // with pragmatic DnD and pragmatic DnD is not triggered
77
+ var handleIconDragStart = function handleIconDragStart(e) {
78
+ if (!browser.chrome || !fg('platform_editor_dnd_update_drag_start_target')) {
79
+ return;
80
+ }
81
+ // prevent dragStart handler triggered by icon
82
+ e.stopPropagation();
83
+ var dragEvent = new DragEvent('dragstart', {
84
+ bubbles: true,
85
+ cancelable: true,
86
+ dataTransfer: e.dataTransfer
87
+ });
88
+ if (e.target instanceof HTMLElement) {
89
+ var _e$target$closest;
90
+ // re-dispatch drag event on button so that pragmatic DnD can be triggered properly
91
+ (_e$target$closest = e.target.closest('button')) === null || _e$target$closest === void 0 || _e$target$closest.dispatchEvent(dragEvent);
92
+ }
93
+ };
66
94
  export var DragHandle = function DragHandle(_ref) {
67
95
  var _api$core2, _api$analytics2, _api$core4;
68
96
  var view = _ref.view,
@@ -402,10 +430,16 @@ export var DragHandle = function DragHandle(_ref) {
402
430
  onMouseDown: handleMouseDown,
403
431
  onKeyDown: handleKeyDown,
404
432
  "data-testid": "block-ctrl-drag-handle"
405
- }, jsx(DragHandlerIcon, {
433
+ }, jsx(Box, {
434
+ as: "span",
435
+ xcss: iconWrapperStyles
436
+ // eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
437
+ ,
438
+ onDragStart: handleIconDragStart
439
+ }, ' ', jsx(DragHandlerIcon, {
406
440
  label: "",
407
441
  size: "medium"
408
- }))
442
+ })))
409
443
  );
410
444
  };
411
445
  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.2",
3
+ "version": "2.21.3",
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,9 @@
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"
147
150
  }
148
151
  }
149
152
  }