@atlaskit/editor-plugin-block-controls 9.0.10 → 9.0.11

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
+ ## 9.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`029e47b456b89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/029e47b456b89) -
8
+ Fixing a bug where we expect the selection toolbar to show when selecting text and releasing on
9
+ the block controls handle.
10
+ - Updated dependencies
11
+
3
12
  ## 9.0.10
4
13
 
5
14
  ### Patch Changes
@@ -408,6 +408,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
408
408
  isTopLevelNode = _ref3$isTopLevelNode === void 0 ? true : _ref3$isTopLevelNode,
409
409
  anchorRectCache = _ref3.anchorRectCache;
410
410
  var buttonRef = (0, _react.useRef)(null);
411
+ var mouseDownRef = (0, _react.useRef)(false);
411
412
  var _useState = (0, _react.useState)(false),
412
413
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
413
414
  dragHandleSelected = _useState2[0],
@@ -488,11 +489,35 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
488
489
  }
489
490
  }
490
491
  }, [anchorName, nodeType, view.dom]);
492
+ (0, _react.useEffect)(function () {
493
+ if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_selection_toolbar_block_handle', 'isEnabled', true)) {
494
+ return;
495
+ }
496
+ var unbind = (0, _bindEventListener.bind)(window, {
497
+ type: 'mouseUp',
498
+ listener: function listener() {
499
+ return mouseDownRef.current = false;
500
+ }
501
+ });
502
+ return function () {
503
+ return unbind();
504
+ };
505
+ }, []);
506
+ var handleMouseDown = (0, _react.useCallback)(function () {
507
+ mouseDownRef.current = true;
508
+ }, []);
491
509
  var handleMouseUp = (0, _react.useCallback)(function (e) {
492
510
  // Stop propagation so that for drag handles in nested scenarios the click is captured
493
511
  // and doesn't propagate to the edge of the element and trigger a node selection
494
512
  // on the parent element
495
- e.stopPropagation();
513
+ if (!(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_selection_toolbar_block_handle', 'isEnabled', true)) {
514
+ e.stopPropagation();
515
+ }
516
+
517
+ // Fixes bug where selection toolbar is blocked when mouse is released on drag handle
518
+ if (mouseDownRef.current) {
519
+ e.stopPropagation();
520
+ }
496
521
  }, []);
497
522
  var handleOnClickNew = (0, _react.useCallback)(function (e) {
498
523
  var _api$core;
@@ -1116,6 +1141,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref3) {
1116
1141
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1117
1142
  ,
1118
1143
  style: !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
1144
+ onMouseDown: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
1119
1145
  onMouseUp: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? handleMouseUp : undefined,
1120
1146
  onClick: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? handleOnClickNew : handleOnClick,
1121
1147
  onKeyDown: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? handleKeyDownNew : handleKeyDown
@@ -405,6 +405,7 @@ export const DragHandle = ({
405
405
  }) => {
406
406
  var _api$core4;
407
407
  const buttonRef = useRef(null);
408
+ const mouseDownRef = useRef(false);
408
409
  const [dragHandleSelected, setDragHandleSelected] = useState(false);
409
410
  const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
410
411
  const [blockCardWidth, setBlockCardWidth] = useState(768);
@@ -466,11 +467,31 @@ export const DragHandle = ({
466
467
  }
467
468
  }
468
469
  }, [anchorName, nodeType, view.dom]);
470
+ useEffect(() => {
471
+ if (!expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true)) {
472
+ return;
473
+ }
474
+ const unbind = bind(window, {
475
+ type: 'mouseUp',
476
+ listener: () => mouseDownRef.current = false
477
+ });
478
+ return () => unbind();
479
+ }, []);
480
+ const handleMouseDown = useCallback(() => {
481
+ mouseDownRef.current = true;
482
+ }, []);
469
483
  const handleMouseUp = useCallback(e => {
470
484
  // Stop propagation so that for drag handles in nested scenarios the click is captured
471
485
  // and doesn't propagate to the edge of the element and trigger a node selection
472
486
  // on the parent element
473
- e.stopPropagation();
487
+ if (!expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true)) {
488
+ e.stopPropagation();
489
+ }
490
+
491
+ // Fixes bug where selection toolbar is blocked when mouse is released on drag handle
492
+ if (mouseDownRef.current) {
493
+ e.stopPropagation();
494
+ }
474
495
  }, []);
475
496
  const handleOnClickNew = useCallback(e => {
476
497
  var _api$core;
@@ -1104,6 +1125,7 @@ export const DragHandle = ({
1104
1125
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1105
1126
  ,
1106
1127
  style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
1128
+ onMouseDown: expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
1107
1129
  onMouseUp: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? handleMouseUp : undefined,
1108
1130
  onClick: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? handleOnClickNew : handleOnClick,
1109
1131
  onKeyDown: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? handleKeyDownNew : handleKeyDown
@@ -405,6 +405,7 @@ export var DragHandle = function DragHandle(_ref3) {
405
405
  isTopLevelNode = _ref3$isTopLevelNode === void 0 ? true : _ref3$isTopLevelNode,
406
406
  anchorRectCache = _ref3.anchorRectCache;
407
407
  var buttonRef = useRef(null);
408
+ var mouseDownRef = useRef(false);
408
409
  var _useState = useState(false),
409
410
  _useState2 = _slicedToArray(_useState, 2),
410
411
  dragHandleSelected = _useState2[0],
@@ -485,11 +486,35 @@ export var DragHandle = function DragHandle(_ref3) {
485
486
  }
486
487
  }
487
488
  }, [anchorName, nodeType, view.dom]);
489
+ useEffect(function () {
490
+ if (!expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true)) {
491
+ return;
492
+ }
493
+ var unbind = bind(window, {
494
+ type: 'mouseUp',
495
+ listener: function listener() {
496
+ return mouseDownRef.current = false;
497
+ }
498
+ });
499
+ return function () {
500
+ return unbind();
501
+ };
502
+ }, []);
503
+ var handleMouseDown = useCallback(function () {
504
+ mouseDownRef.current = true;
505
+ }, []);
488
506
  var handleMouseUp = useCallback(function (e) {
489
507
  // Stop propagation so that for drag handles in nested scenarios the click is captured
490
508
  // and doesn't propagate to the edge of the element and trigger a node selection
491
509
  // on the parent element
492
- e.stopPropagation();
510
+ if (!expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true)) {
511
+ e.stopPropagation();
512
+ }
513
+
514
+ // Fixes bug where selection toolbar is blocked when mouse is released on drag handle
515
+ if (mouseDownRef.current) {
516
+ e.stopPropagation();
517
+ }
493
518
  }, []);
494
519
  var handleOnClickNew = useCallback(function (e) {
495
520
  var _api$core;
@@ -1113,6 +1138,7 @@ export var DragHandle = function DragHandle(_ref3) {
1113
1138
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1114
1139
  ,
1115
1140
  style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
1141
+ onMouseDown: expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
1116
1142
  onMouseUp: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? handleMouseUp : undefined,
1117
1143
  onClick: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? handleOnClickNew : handleOnClick,
1118
1144
  onKeyDown: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) ? handleKeyDownNew : handleKeyDown
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "9.0.10",
3
+ "version": "9.0.11",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
57
57
  "@atlaskit/primitives": "^18.0.0",
58
58
  "@atlaskit/theme": "^22.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^40.5.0",
59
+ "@atlaskit/tmp-editor-statsig": "^40.6.0",
60
60
  "@atlaskit/tokens": "^11.1.0",
61
61
  "@atlaskit/tooltip": "^20.14.0",
62
62
  "@babel/runtime": "^7.0.0",