@atlaskit/editor-plugin-block-controls 17.3.8 → 17.3.9

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,15 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 17.3.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`09b54fe3854bd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/09b54fe3854bd) -
8
+ Keep Quick Insert stationary when the drag handle moves to a nested block under
9
+ `platform_editor_block_control_migration`, and keep layout-column drag handles visible across the
10
+ full editor width.
11
+ - Updated dependencies
12
+
3
13
  ## 17.3.8
4
14
 
5
15
  ### Patch Changes
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseEnter = void 0;
7
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
7
8
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
8
9
  var _handleMouseOver = require("../handle-mouse-over");
9
10
  var _commands = require("./commands");
@@ -30,6 +31,10 @@ var clearPendingHoverSide = function clearPendingHoverSide(view) {
30
31
  };
31
32
  var BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
32
33
  var RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
34
+ var LEGACY_LEFT_CONTROL_SELECTOR = '[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
35
+ var getLeftControlSelector = function getLeftControlSelector() {
36
+ return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_LEFT_CONTROL_SELECTOR) : LEGACY_LEFT_CONTROL_SELECTOR;
37
+ };
33
38
 
34
39
  // Top-level blocks (no block ancestor), matched by anchor attribute so it works under both the
35
40
  // legacy and native-anchor schemes.
@@ -128,7 +133,7 @@ var processHoverSide = function processHoverSide(view, api) {
128
133
  }
129
134
  return;
130
135
  }
131
- var leftControlElement = target === null || target === void 0 ? void 0 : target.closest('[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]');
136
+ var leftControlElement = target === null || target === void 0 ? void 0 : target.closest(getLeftControlSelector());
132
137
  if (leftControlElement) {
133
138
  if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'left') {
134
139
  (0, _commands.setHoverSide)(view, 'left');
@@ -186,9 +191,7 @@ var processHoverSide = function processHoverSide(view, api) {
186
191
  (0, _commands.setHoverSide)(view, nextHoverSide);
187
192
  }
188
193
  };
189
- var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, event) {
190
- var rightSideControlsEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
191
- var api = arguments.length > 3 ? arguments[3] : undefined;
194
+ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, event, rightSideControlsEnabled, api) {
192
195
  var state = (0, _pmPlugin.getInteractionTrackingState)(view.state);
193
196
  // if user has stopped editing and moved their mouse, show block controls again
194
197
  if (state !== null && state !== void 0 && state.isEditing) {
@@ -210,8 +213,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
210
213
  rafIdByView.set(view, id);
211
214
  return false;
212
215
  };
213
- var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view) {
214
- var rightSideControlsEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
216
+ var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view, rightSideControlsEnabled) {
215
217
  if (rightSideControlsEnabled) {
216
218
  clearPendingHoverSide(view);
217
219
  }
@@ -19,13 +19,16 @@ var _handleMouseMove = require("./handle-mouse-move");
19
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
20
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
21
  /** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
22
- var BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
22
+ var LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
23
+ var getBlockControlsHoverAreaSelector = function getBlockControlsHoverAreaSelector() {
24
+ return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR) : LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR;
25
+ };
23
26
  var MOUSE_LEAVE_DEBOUNCE_MS = 200;
24
27
 
25
28
  /** ClickAreaBlock overlay that wraps the editor content and covers the right margin. */
26
29
  var CLICK_AREA_SELECTOR = '[data-editor-click-wrapper]';
27
30
  var isMovingToBlockControlsArea = function isMovingToBlockControlsArea(target) {
28
- return target instanceof Element && !!target.closest(BLOCK_CONTROLS_HOVER_AREA_SELECTOR);
31
+ return target instanceof Element && !!target.closest(getBlockControlsHoverAreaSelector());
29
32
  };
30
33
 
31
34
  /**
@@ -9,8 +9,11 @@ exports.BlockControlsLeftSurface = void 0;
9
9
  require("./block-controls-left-surface.compiled.css");
10
10
  var _runtime = require("@compiled/react/runtime");
11
11
  var _react = _interopRequireDefault(require("react"));
12
+ var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
12
13
  var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
13
14
  var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
15
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
16
+ var _blockControlsSurfaceContext = require("./block-controls-surface-context");
14
17
  var _visibilityContainer = require("./visibility-container");
15
18
  var leftSurfaceOuterStyles = null;
16
19
  var leftSurfaceRowStyles = null;
@@ -48,7 +51,7 @@ var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function Block
48
51
  className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
49
52
  }, /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
50
53
  api: api,
51
- controlSide: "left",
54
+ controlSide: (0, _blockControlsSurfaceContext.getBlockControlsSurfaceControlSide)(surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT), (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_controls_reliable_anchor')),
52
55
  forceVisibleOnMouseOut: forceVisibleOnMouseOut,
53
56
  shouldUseDisplayContents: true
54
57
  }, surface)));
@@ -4,10 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.createBlockControlsSurfaceContextForPosition = exports.createBlockControlsSurfaceContext = void 0;
7
+ exports.getBlockControlsSurfaceControlSide = exports.createBlockControlsSurfaceContextForPosition = exports.createBlockControlsSurfaceContext = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ var getBlockControlsSurfaceControlSide = exports.getBlockControlsSurfaceControlSide = function getBlockControlsSurfaceControlSide(context, reliableAnchorEnabled) {
12
+ return (context === null || context === void 0 ? void 0 : context.targetNode.type.name) === 'layoutColumn' || Boolean(context) && reliableAnchorEnabled && (context === null || context === void 0 ? void 0 : context.targetNode.parentType) !== 'doc' ? undefined : 'left';
13
+ };
11
14
  var getNodeContext = function getNodeContext(state, pos) {
12
15
  var node = state.doc.nodeAt(pos);
13
16
  if (!node) {
@@ -1,3 +1,4 @@
1
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
1
2
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
2
3
  import { handleMouseOver } from '../handle-mouse-over';
3
4
  import { clearHoverSide, mouseEnter, mouseLeave, setHoverSide, stopEditing } from './commands';
@@ -22,6 +23,8 @@ const clearPendingHoverSide = view => {
22
23
  };
23
24
  const BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
24
25
  const RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
26
+ const LEGACY_LEFT_CONTROL_SELECTOR = '[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
27
+ const getLeftControlSelector = () => isExperimentEnabled('platform_editor_block_control_migration') ? `[data-editor-block-ctrl-drag-handle], ${LEGACY_LEFT_CONTROL_SELECTOR}` : LEGACY_LEFT_CONTROL_SELECTOR;
25
28
 
26
29
  // Top-level blocks (no block ancestor), matched by anchor attribute so it works under both the
27
30
  // legacy and native-anchor schemes.
@@ -109,7 +112,7 @@ const processHoverSide = (view, api) => {
109
112
  }
110
113
  return;
111
114
  }
112
- const leftControlElement = target === null || target === void 0 ? void 0 : target.closest('[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]');
115
+ const leftControlElement = target === null || target === void 0 ? void 0 : target.closest(getLeftControlSelector());
113
116
  if (leftControlElement) {
114
117
  if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'left') {
115
118
  setHoverSide(view, 'left');
@@ -168,7 +171,7 @@ const processHoverSide = (view, api) => {
168
171
  setHoverSide(view, nextHoverSide);
169
172
  }
170
173
  };
171
- export const handleMouseMove = (view, event, rightSideControlsEnabled = false, api) => {
174
+ export const handleMouseMove = (view, event, rightSideControlsEnabled, api) => {
172
175
  const state = getInteractionTrackingState(view.state);
173
176
  // if user has stopped editing and moved their mouse, show block controls again
174
177
  if (state !== null && state !== void 0 && state.isEditing) {
@@ -190,7 +193,7 @@ export const handleMouseMove = (view, event, rightSideControlsEnabled = false, a
190
193
  rafIdByView.set(view, id);
191
194
  return false;
192
195
  };
193
- export const handleMouseLeave = (view, rightSideControlsEnabled = false) => {
196
+ export const handleMouseLeave = (view, rightSideControlsEnabled) => {
194
197
  if (rightSideControlsEnabled) {
195
198
  clearPendingHoverSide(view);
196
199
  }
@@ -10,12 +10,13 @@ import { handleKeyDown } from './handle-key-down';
10
10
  import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
11
11
 
12
12
  /** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
13
- const BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
13
+ const LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
14
+ const getBlockControlsHoverAreaSelector = () => isExperimentEnabled('platform_editor_block_control_migration') ? `[data-editor-block-ctrl-drag-handle], ${LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR}` : LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR;
14
15
  const MOUSE_LEAVE_DEBOUNCE_MS = 200;
15
16
 
16
17
  /** ClickAreaBlock overlay that wraps the editor content and covers the right margin. */
17
18
  const CLICK_AREA_SELECTOR = '[data-editor-click-wrapper]';
18
- const isMovingToBlockControlsArea = target => target instanceof Element && !!target.closest(BLOCK_CONTROLS_HOVER_AREA_SELECTOR);
19
+ const isMovingToBlockControlsArea = target => target instanceof Element && !!target.closest(getBlockControlsHoverAreaSelector());
19
20
 
20
21
  /**
21
22
  * The right margin is covered by the ClickAreaBlock overlay, which sits outside .ak-editor-content-area.
@@ -2,8 +2,11 @@
2
2
  import "./block-controls-left-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
+ import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
5
6
  import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
6
7
  import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
8
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
+ import { getBlockControlsSurfaceControlSide } from './block-controls-surface-context';
7
10
  import { VisibilityContainer } from './visibility-container';
8
11
  const leftSurfaceOuterStyles = null;
9
12
  const leftSurfaceRowStyles = null;
@@ -42,7 +45,7 @@ export const BlockControlsLeftSurface = ({
42
45
  className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
43
46
  }, /*#__PURE__*/React.createElement(VisibilityContainer, {
44
47
  api: api,
45
- controlSide: "left",
48
+ controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
46
49
  forceVisibleOnMouseOut: forceVisibleOnMouseOut,
47
50
  shouldUseDisplayContents: true
48
51
  }, surface)));
@@ -1,3 +1,4 @@
1
+ export const getBlockControlsSurfaceControlSide = (context, reliableAnchorEnabled) => (context === null || context === void 0 ? void 0 : context.targetNode.type.name) === 'layoutColumn' || Boolean(context) && reliableAnchorEnabled && (context === null || context === void 0 ? void 0 : context.targetNode.parentType) !== 'doc' ? undefined : 'left';
1
2
  const getNodeContext = (state, pos) => {
2
3
  const node = state.doc.nodeAt(pos);
3
4
  if (!node) {
@@ -1,6 +1,7 @@
1
1
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
2
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
3
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
5
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
6
  import { handleMouseOver } from '../handle-mouse-over';
6
7
  import { clearHoverSide, mouseEnter, mouseLeave, setHoverSide, stopEditing } from './commands';
@@ -25,6 +26,10 @@ var clearPendingHoverSide = function clearPendingHoverSide(view) {
25
26
  };
26
27
  var BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
27
28
  var RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
29
+ var LEGACY_LEFT_CONTROL_SELECTOR = '[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
30
+ var getLeftControlSelector = function getLeftControlSelector() {
31
+ return isExperimentEnabled('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_LEFT_CONTROL_SELECTOR) : LEGACY_LEFT_CONTROL_SELECTOR;
32
+ };
28
33
 
29
34
  // Top-level blocks (no block ancestor), matched by anchor attribute so it works under both the
30
35
  // legacy and native-anchor schemes.
@@ -123,7 +128,7 @@ var processHoverSide = function processHoverSide(view, api) {
123
128
  }
124
129
  return;
125
130
  }
126
- var leftControlElement = target === null || target === void 0 ? void 0 : target.closest('[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]');
131
+ var leftControlElement = target === null || target === void 0 ? void 0 : target.closest(getLeftControlSelector());
127
132
  if (leftControlElement) {
128
133
  if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'left') {
129
134
  setHoverSide(view, 'left');
@@ -181,9 +186,7 @@ var processHoverSide = function processHoverSide(view, api) {
181
186
  setHoverSide(view, nextHoverSide);
182
187
  }
183
188
  };
184
- export var handleMouseMove = function handleMouseMove(view, event) {
185
- var rightSideControlsEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
186
- var api = arguments.length > 3 ? arguments[3] : undefined;
189
+ export var handleMouseMove = function handleMouseMove(view, event, rightSideControlsEnabled, api) {
187
190
  var state = getInteractionTrackingState(view.state);
188
191
  // if user has stopped editing and moved their mouse, show block controls again
189
192
  if (state !== null && state !== void 0 && state.isEditing) {
@@ -205,8 +208,7 @@ export var handleMouseMove = function handleMouseMove(view, event) {
205
208
  rafIdByView.set(view, id);
206
209
  return false;
207
210
  };
208
- export var handleMouseLeave = function handleMouseLeave(view) {
209
- var rightSideControlsEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
211
+ export var handleMouseLeave = function handleMouseLeave(view, rightSideControlsEnabled) {
210
212
  if (rightSideControlsEnabled) {
211
213
  clearPendingHoverSide(view);
212
214
  }
@@ -13,13 +13,16 @@ import { handleKeyDown } from './handle-key-down';
13
13
  import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
14
14
 
15
15
  /** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
16
- var BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
16
+ var LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
17
+ var getBlockControlsHoverAreaSelector = function getBlockControlsHoverAreaSelector() {
18
+ return isExperimentEnabled('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR) : LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR;
19
+ };
17
20
  var MOUSE_LEAVE_DEBOUNCE_MS = 200;
18
21
 
19
22
  /** ClickAreaBlock overlay that wraps the editor content and covers the right margin. */
20
23
  var CLICK_AREA_SELECTOR = '[data-editor-click-wrapper]';
21
24
  var isMovingToBlockControlsArea = function isMovingToBlockControlsArea(target) {
22
- return target instanceof Element && !!target.closest(BLOCK_CONTROLS_HOVER_AREA_SELECTOR);
25
+ return target instanceof Element && !!target.closest(getBlockControlsHoverAreaSelector());
23
26
  };
24
27
 
25
28
  /**
@@ -2,8 +2,11 @@
2
2
  import "./block-controls-left-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
+ import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
5
6
  import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
6
7
  import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
8
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
+ import { getBlockControlsSurfaceControlSide } from './block-controls-surface-context';
7
10
  import { VisibilityContainer } from './visibility-container';
8
11
  var leftSurfaceOuterStyles = null;
9
12
  var leftSurfaceRowStyles = null;
@@ -41,7 +44,7 @@ export var BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref) {
41
44
  className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
42
45
  }, /*#__PURE__*/React.createElement(VisibilityContainer, {
43
46
  api: api,
44
- controlSide: "left",
47
+ controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
45
48
  forceVisibleOnMouseOut: forceVisibleOnMouseOut,
46
49
  shouldUseDisplayContents: true
47
50
  }, surface)));
@@ -1,6 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ export var getBlockControlsSurfaceControlSide = function getBlockControlsSurfaceControlSide(context, reliableAnchorEnabled) {
5
+ return (context === null || context === void 0 ? void 0 : context.targetNode.type.name) === 'layoutColumn' || Boolean(context) && reliableAnchorEnabled && (context === null || context === void 0 ? void 0 : context.targetNode.parentType) !== 'doc' ? undefined : 'left';
6
+ };
4
7
  var getNodeContext = function getNodeContext(state, pos) {
5
8
  var node = state.doc.nodeAt(pos);
6
9
  if (!node) {
@@ -2,5 +2,6 @@ import type { BlockControlUIContext } from '@atlaskit/editor-common/block-contro
2
2
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ActiveNode } from '../blockControlsPluginType';
5
+ export declare const getBlockControlsSurfaceControlSide: (context: BlockControlUIContext | undefined, reliableAnchorEnabled: boolean) => 'left' | undefined;
5
6
  export declare const createBlockControlsSurfaceContextForPosition: (state: EditorState, targetPos: number, activeNode?: ActiveNode) => BlockControlUIContext | undefined;
6
7
  export declare const createBlockControlsSurfaceContext: (view: EditorView, activeNode: ActiveNode | undefined, target?: 'active' | 'root') => BlockControlUIContext | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "17.3.8",
3
+ "version": "17.3.9",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -55,7 +55,7 @@
55
55
  "@atlaskit/primitives": "^22.5.0",
56
56
  "@atlaskit/section-message": "^10.2.0",
57
57
  "@atlaskit/theme": "^28.2.0",
58
- "@atlaskit/tmp-editor-statsig": "^173.0.0",
58
+ "@atlaskit/tmp-editor-statsig": "^174.0.0",
59
59
  "@atlaskit/tokens": "^16.11.0",
60
60
  "@atlaskit/tooltip": "^24.3.0",
61
61
  "@babel/runtime": "^7.0.0",
@@ -67,7 +67,7 @@
67
67
  "uuid": "^3.1.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@atlaskit/editor-common": "^120.11.0",
70
+ "@atlaskit/editor-common": "^120.12.0",
71
71
  "react": "^18.2.0 || ^19.2.0",
72
72
  "react-dom": "^18.2.0 || ^19.2.0",
73
73
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"