@atlaskit/editor-plugin-block-controls 34.0.3 → 34.0.5

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/blockControlsPlugin.js +2 -10
  3. package/dist/cjs/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
  4. package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +121 -2
  5. package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +3 -0
  6. package/dist/cjs/pm-plugins/sparse-gutter-hover.js +17 -57
  7. package/dist/cjs/pm-plugins/sparse-surfaces.js +2 -2
  8. package/dist/cjs/pm-plugins/utils/after-render-scheduler.js +39 -0
  9. package/dist/cjs/ui/block-controls-left-surface.js +19 -83
  10. package/dist/cjs/ui/block-controls-right-surface.js +19 -70
  11. package/dist/cjs/ui/block-controls-surface-targets.js +1 -1
  12. package/dist/es2019/blockControlsPlugin.js +2 -10
  13. package/dist/es2019/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
  14. package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +118 -1
  15. package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
  16. package/dist/es2019/pm-plugins/sparse-gutter-hover.js +16 -56
  17. package/dist/es2019/pm-plugins/sparse-surfaces.js +2 -2
  18. package/dist/es2019/pm-plugins/utils/after-render-scheduler.js +33 -0
  19. package/dist/es2019/ui/block-controls-left-surface.js +10 -76
  20. package/dist/es2019/ui/block-controls-right-surface.js +10 -63
  21. package/dist/es2019/ui/block-controls-surface-targets.js +1 -1
  22. package/dist/esm/blockControlsPlugin.js +2 -10
  23. package/dist/esm/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
  24. package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +120 -1
  25. package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
  26. package/dist/esm/pm-plugins/sparse-gutter-hover.js +16 -56
  27. package/dist/esm/pm-plugins/sparse-surfaces.js +2 -2
  28. package/dist/esm/pm-plugins/utils/after-render-scheduler.js +33 -0
  29. package/dist/esm/ui/block-controls-left-surface.js +19 -83
  30. package/dist/esm/ui/block-controls-right-surface.js +19 -70
  31. package/dist/esm/ui/block-controls-surface-targets.js +1 -1
  32. package/dist/types/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +1 -0
  33. package/dist/types/pm-plugins/utils/after-render-scheduler.d.ts +9 -0
  34. package/dist/types/ui/block-controls-left-surface.d.ts +1 -1
  35. package/dist/types/ui/block-controls-right-surface.d.ts +1 -1
  36. package/dist/types/ui/block-controls-surface-targets.d.ts +1 -1
  37. package/package.json +4 -4
  38. package/dist/cjs/pm-plugins/sparse-surfaces-view.js +0 -149
  39. package/dist/cjs/ui/block-controls-left-surfaces.js +0 -294
  40. package/dist/cjs/ui/block-controls-right-surfaces.js +0 -285
  41. package/dist/es2019/pm-plugins/sparse-surfaces-view.js +0 -136
  42. package/dist/es2019/ui/block-controls-left-surfaces.js +0 -259
  43. package/dist/es2019/ui/block-controls-right-surfaces.js +0 -245
  44. package/dist/esm/pm-plugins/sparse-surfaces-view.js +0 -142
  45. package/dist/esm/ui/block-controls-left-surfaces.js +0 -285
  46. package/dist/esm/ui/block-controls-right-surfaces.js +0 -276
  47. package/dist/types/pm-plugins/sparse-surfaces-view.d.ts +0 -16
  48. package/dist/types/ui/block-controls-left-surfaces.d.ts +0 -15
  49. package/dist/types/ui/block-controls-right-surfaces.d.ts +0 -24
@@ -3,12 +3,7 @@ import "./block-controls-right-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
5
  import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
6
- import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
7
- import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
8
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
6
  import { BlockControlsSurfaceWithClsFix } from '../surface-lifecycle/block-controls-surface-with-cls-fix';
10
- import { BlockControlsVisibilityProvider } from './block-controls-surface-components';
11
- import { useBlockControlsVisibility } from './visibility-container';
12
7
  const rightSurfaceHiddenWrapperStyles = null;
13
8
  const rightSurfaceOuterStyles = null;
14
9
  const rightSurfaceRowStyles = null;
@@ -21,43 +16,6 @@ const rightSurfaceStickyStyles = null;
21
16
 
22
17
  // Keep in sync with STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER in ./consts (must be a static literal here)
23
18
  const rightSurfaceStickyTableHeaderStyles = null;
24
- const BlockControlsRightSurfaceContent = ({
25
- api,
26
- components,
27
- forceVisibleOnMouseOut,
28
- placement,
29
- source,
30
- surfaceContext
31
- }) => {
32
- const blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
33
- const {
34
- shouldHide: shouldHideHoverControls,
35
- useCssStyles
36
- } = useBlockControlsVisibility({
37
- api,
38
- controlSide: 'right',
39
- forceVisibleOnMouseOut
40
- });
41
- const isSticky = placement.isSticky;
42
- return /*#__PURE__*/React.createElement("div", {
43
- "data-editor-block-controls-surface": true,
44
- "data-editor-block-controls-side": "right",
45
- "data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
46
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved per target node, from its runtime DOM geometry or from its CSS anchor.
47
- ,
48
- style: placement.style,
49
- className: ax(["_kqswstnw _17c61i8t _1pbyb4wl"])
50
- }, /*#__PURE__*/React.createElement("div", {
51
- className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && "_154i1ejb"])
52
- }, /*#__PURE__*/React.createElement(BlockControlsVisibilityProvider, {
53
- shouldHideHoverControls: shouldHideHoverControls,
54
- useCssStyles: useCssStyles
55
- }, /*#__PURE__*/React.createElement(SurfaceRenderer, {
56
- components: components,
57
- surface: BLOCK_CONTROLS_RIGHT_SURFACE,
58
- surfaceContext: surfaceContext
59
- }))));
60
- };
61
19
  const BlockControlsRightSurfaceWrapper = ({
62
20
  children,
63
21
  placement,
@@ -91,25 +49,14 @@ export const BlockControlsRightSurface = ({
91
49
  if (!placement) {
92
50
  return null;
93
51
  }
94
- if (isExperimentEnabled('platform_editor_block_controls_cls_fix')) {
95
- return /*#__PURE__*/React.createElement(BlockControlsSurfaceWithClsFix, {
96
- side: "right",
97
- SurfaceWrapper: BlockControlsRightSurfaceWrapper,
98
- api: api,
99
- components: components,
100
- forceVisibleOnMouseOut: forceVisibleOnMouseOut,
101
- placement: placement,
102
- source: source,
103
- surfaceContext: surfaceContext
104
- });
105
- } else {
106
- return /*#__PURE__*/React.createElement(BlockControlsRightSurfaceContent, {
107
- api: api,
108
- components: components,
109
- forceVisibleOnMouseOut: forceVisibleOnMouseOut,
110
- placement: placement,
111
- source: source,
112
- surfaceContext: surfaceContext
113
- });
114
- }
52
+ return /*#__PURE__*/React.createElement(BlockControlsSurfaceWithClsFix, {
53
+ side: "right",
54
+ SurfaceWrapper: BlockControlsRightSurfaceWrapper,
55
+ api: api,
56
+ components: components,
57
+ forceVisibleOnMouseOut: forceVisibleOnMouseOut,
58
+ placement: placement,
59
+ source: source,
60
+ surfaceContext: surfaceContext
61
+ });
115
62
  };
@@ -3,7 +3,7 @@
3
3
  * Shared by both the left and right surfaces: this is pure position bookkeeping with no
4
4
  * surface-specific behavior, so there's nothing to keep independent between them. What *is*
5
5
  * kept independent is each surface's own React tree (component lookup, measurement effects,
6
- * observers) — see block-controls-left-surfaces.tsx / block-controls-right-surfaces.tsx.
6
+ * observers) — see ../surface-lifecycle/block-controls-surfaces.tsx.
7
7
  */
8
8
  export const getBlockControlsSurfaceTargets = (activeNode, storedPositions) => {
9
9
  const targetsByPosition = new Map();
@@ -26,8 +26,6 @@ import { createSparseSurfacesPlugin, sparseSurfacesKey } from './pm-plugins/spar
26
26
  import { expandAndUpdateSelection as _expandAndUpdateSelection } from './pm-plugins/utils/expand-and-update-selection';
27
27
  import { selectNode } from './pm-plugins/utils/getSelection';
28
28
  import { CommittedBlockControlsSurfaces } from './surface-lifecycle/block-controls-surfaces';
29
- import { BlockControlsLeftSurfaces } from './ui/block-controls-left-surfaces';
30
- import { BlockControlsRightSurfaces } from './ui/block-controls-right-surfaces';
31
29
  import { getBlockControlsSurfaceDragHandleComponents } from './ui/block-controls-surface-drag-handle-registration';
32
30
  import { GlobalStylesWrapper } from './ui/global-styles';
33
31
  import { SurfaceEditorViewContext } from './ui/surface-editor-view-context';
@@ -491,16 +489,10 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
491
489
  api: api
492
490
  }), registryBlockControlsEnabled && editorView && api ? /*#__PURE__*/React.createElement(SurfaceEditorViewContext.Provider, {
493
491
  value: editorView
494
- }, isExperimentEnabled('platform_editor_block_controls_cls_fix') ? /*#__PURE__*/React.createElement(CommittedBlockControlsSurfaces, {
492
+ }, /*#__PURE__*/React.createElement(CommittedBlockControlsSurfaces, {
495
493
  api: api,
496
494
  editorView: editorView
497
- }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BlockControlsLeftSurfaces, {
498
- api: api,
499
- editorView: editorView
500
- }), /*#__PURE__*/React.createElement(BlockControlsRightSurfaces, {
501
- api: api,
502
- editorView: editorView
503
- }))) : null);
495
+ })) : null);
504
496
  }
505
497
  };
506
498
  };
@@ -1,4 +1,6 @@
1
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
1
2
  import { startEditing } from './commands';
3
+ import { clearPendingHoverSide } from './handle-mouse-move';
2
4
  import { getInteractionTrackingState } from './pm-plugin';
3
5
  export var handleKeyDown = function handleKeyDown(view, event) {
4
6
  // Check if this is a keyboard shortcut (Ctrl/Cmd + key)
@@ -16,6 +18,12 @@ export var handleKeyDown = function handleKeyDown(view, event) {
16
18
  if (!isTypingKey) {
17
19
  return false;
18
20
  }
21
+
22
+ // With the experiment, a queued mousemove clears the typing state when it finally runs. Typing
23
+ // is newer than that move, so drop it, even if we are already editing.
24
+ if (isExperimentEnabled('platform_editor_improve_inp_batch_3')) {
25
+ clearPendingHoverSide(view);
26
+ }
19
27
  var state = getInteractionTrackingState(view.state);
20
28
 
21
29
  // if user hasnt started typing yet, start timer
@@ -3,6 +3,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
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
4
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
5
  import { handleMouseOver } from '../handle-mouse-over';
6
+ import { createAfterRenderScheduler } from '../utils/after-render-scheduler';
6
7
  import { clearHoverSide, mouseEnter, mouseLeave, setHoverSide, stopEditing } from './commands';
7
8
  import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
8
9
  import { getInteractionTrackingState } from './pm-plugin';
@@ -19,9 +20,12 @@ var cancelScheduledProcessForView = function cancelScheduledProcessForView(view)
19
20
  rafIdByView.delete(view);
20
21
  }
21
22
  };
22
- var clearPendingHoverSide = function clearPendingHoverSide(view) {
23
+ export var clearPendingHoverSide = function clearPendingHoverSide(view) {
23
24
  pendingByView.delete(view);
24
25
  cancelScheduledProcessForView(view);
26
+ if (isExperimentEnabled('platform_editor_improve_inp_batch_3')) {
27
+ cancelHoverSideAfterRender(view);
28
+ }
25
29
  };
26
30
  var BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
27
31
  var LEGACY_RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
@@ -74,6 +78,9 @@ var getRightMarginBoundary = function getRightMarginBoundary(view) {
74
78
  // Classify where the cursor sits in the right margin beside the block at its height, running the
75
79
  // block lookup once so the caller doesn't traverse the DOM twice per mousemove.
76
80
  var classifyRightMarginPosition = function classifyRightMarginPosition(view, event) {
81
+ if (isExperimentEnabled('platform_editor_improve_inp_batch_3')) {
82
+ return classifyRightMarginPositionByHitTest(view, event);
83
+ }
77
84
  var found = findBlockAtY(view, event.clientY);
78
85
  if (!found) {
79
86
  return null;
@@ -183,6 +190,9 @@ var processHoverSide = function processHoverSide(view, api) {
183
190
  }
184
191
  };
185
192
  export var handleMouseMove = function handleMouseMove(view, event, rightSideControlsEnabled, api) {
193
+ if (rightSideControlsEnabled && event instanceof MouseEvent && isExperimentEnabled('platform_editor_improve_inp_batch_3')) {
194
+ return handleMouseMoveAfterRender(view, event, api);
195
+ }
186
196
  var state = getInteractionTrackingState(view.state);
187
197
  // if user has stopped editing and moved their mouse, show block controls again
188
198
  if (state !== null && state !== void 0 && state.isEditing) {
@@ -214,4 +224,113 @@ export var handleMouseLeave = function handleMouseLeave(view, rightSideControlsE
214
224
  export var handleMouseEnter = function handleMouseEnter(view) {
215
225
  mouseEnter(view);
216
226
  return false;
227
+ };
228
+
229
+ /* -------------------------------------------------------------------------------------------------
230
+ * EDITOR-9730: platform_editor_improve_inp_batch_3
231
+ *
232
+ * Everything below is the treatment path, reached through these gates only:
233
+ * - handleMouseMove -> handleMouseMoveAfterRender
234
+ * - classifyRightMarginPosition -> classifyRightMarginPositionByHitTest
235
+ * - clearPendingHoverSide -> cancelHoverSideAfterRender
236
+ * Clean-up when the experiment ships: delete this section, take the treatment branch at each gate
237
+ * (dropping findBlockAtY, getRootBlocks, the rAF bookkeeping and the legacy handleMouseMove body),
238
+ * and remove the gated calls in pm-plugin.ts and handle-key-down.ts.
239
+ * ---------------------------------------------------------------------------------------------- */
240
+
241
+ /** Per-view scheduler plus the latest plugin API to use when it runs. */
242
+ var afterRenderByView = new WeakMap();
243
+ var cancelHoverSideAfterRender = function cancelHoverSideAfterRender(view) {
244
+ var _afterRenderByView$ge;
245
+ (_afterRenderByView$ge = afterRenderByView.get(view)) === null || _afterRenderByView$ge === void 0 || _afterRenderByView$ge.scheduler.cancel();
246
+ };
247
+ var processHoverSideAfterRender = function processHoverSideAfterRender(view) {
248
+ var _getInteractionTracki;
249
+ var state = afterRenderByView.get(view);
250
+ if (!state || view.isDestroyed || !pendingByView.has(view)) {
251
+ return;
252
+ }
253
+ processHoverSide(view, state.api);
254
+
255
+ // The typing state is cleared last, after every read above has finished, so no layout read
256
+ // follows one of our own writes. Typing cancels pending work (see handle-key-down.ts), so this
257
+ // never undoes a newer keystroke.
258
+ if ((_getInteractionTracki = getInteractionTrackingState(view.state)) !== null && _getInteractionTracki !== void 0 && _getInteractionTracki.isEditing) {
259
+ stopEditing(view);
260
+ }
261
+ };
262
+ var handleMouseMoveAfterRender = function handleMouseMoveAfterRender(view, event, api) {
263
+ var win = view.dom.ownerDocument.defaultView;
264
+ if (!win) {
265
+ return false;
266
+ }
267
+ pendingByView.set(view, event);
268
+ var state = afterRenderByView.get(view);
269
+ if (!state) {
270
+ state = {
271
+ api: api,
272
+ scheduler: createAfterRenderScheduler(win, function () {
273
+ return processHoverSideAfterRender(view);
274
+ })
275
+ };
276
+ afterRenderByView.set(view, state);
277
+ }
278
+ // The latest event and API win when several moves coalesce into one run.
279
+ state.api = api;
280
+ // Reads run after the next frame renders, giving the browser an opportunity to update layout
281
+ // first (other work can still dirty it).
282
+ state.scheduler.schedule();
283
+ return false;
284
+ };
285
+
286
+ // Walk up from a block to its top-level block (no block ancestor). Cost is bounded by nesting
287
+ // depth, matching getRootBlocks' filter without scanning the whole document.
288
+ var toRootBlock = function toRootBlock(block) {
289
+ var _root$parentElement;
290
+ var root = block;
291
+ var parent = (_root$parentElement = root.parentElement) === null || _root$parentElement === void 0 ? void 0 : _root$parentElement.closest(BLOCK_SELECTORS);
292
+ while (parent instanceof HTMLElement) {
293
+ var _root$parentElement2;
294
+ root = parent;
295
+ parent = (_root$parentElement2 = root.parentElement) === null || _root$parentElement2 === void 0 ? void 0 : _root$parentElement2.closest(BLOCK_SELECTORS);
296
+ }
297
+ return root;
298
+ };
299
+
300
+ // Right-margin lookup without the document-wide scan (EDITOR-9730): when the cursor is past the
301
+ // right edge of the editor content, hit-test once just inside that edge at the cursor's height and
302
+ // resolve the top-level block there.
303
+ //
304
+ // This still reads layout (getBoundingClientRect and elementFromPoint), so like findBlockAtY it
305
+ // forces a synchronous layout if layout is dirty when it runs. What changes is how much and when:
306
+ // one rect and one hit test instead of a rect per top-level block, and it runs in the
307
+ // after-render callback, where the browser has had an opportunity to update layout first.
308
+ var findRootBlockBesideCursor = function findRootBlockBesideCursor(view, event) {
309
+ var _root$elementFromPoin;
310
+ var contentRight = view.dom.getBoundingClientRect().right;
311
+ if (event.clientX <= contentRight) {
312
+ return null;
313
+ }
314
+ var root = view.root;
315
+ if (typeof root.elementFromPoint !== 'function') {
316
+ return null;
317
+ }
318
+ var block = (_root$elementFromPoin = root.elementFromPoint(contentRight - 1, event.clientY)) === null || _root$elementFromPoin === void 0 ? void 0 : _root$elementFromPoin.closest(BLOCK_SELECTORS);
319
+ if (!(block instanceof HTMLElement)) {
320
+ return null;
321
+ }
322
+ var rootBlock = toRootBlock(block);
323
+ return view.dom.contains(rootBlock) ? rootBlock : null;
324
+ };
325
+
326
+ // Same classification as the legacy path, with the block found by a hit test.
327
+ var classifyRightMarginPositionByHitTest = function classifyRightMarginPositionByHitTest(view, event) {
328
+ var block = findRootBlockBesideCursor(view, event);
329
+ if (!block) {
330
+ return null;
331
+ }
332
+ return {
333
+ type: 'active',
334
+ block: block
335
+ };
217
336
  };
@@ -8,7 +8,7 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
8
8
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
9
  import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
10
10
  import { handleKeyDown } from './handle-key-down';
11
- import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
11
+ import { clearPendingHoverSide, handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
12
12
 
13
13
  /** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
14
14
  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"]';
@@ -218,6 +218,9 @@ export var createInteractionTrackingPlugin = function createInteractionTrackingP
218
218
  var _unbindDocumentMouseM;
219
219
  cancelScheduledMouseLeave();
220
220
  (_unbindDocumentMouseM = unbindDocumentMouseMove) === null || _unbindDocumentMouseM === void 0 || _unbindDocumentMouseM();
221
+ if (isExperimentEnabled('platform_editor_improve_inp_batch_3')) {
222
+ clearPendingHoverSide(_view);
223
+ }
221
224
  }
222
225
  (_unbindMouseEnter = unbindMouseEnter) === null || _unbindMouseEnter === void 0 || _unbindMouseEnter();
223
226
  (_unbindMouseLeave = unbindMouseLeave) === null || _unbindMouseLeave === void 0 || _unbindMouseLeave();
@@ -1,13 +1,13 @@
1
1
  import { bind } from 'bind-event-listener';
2
2
  import { DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles/drag-handle';
3
3
  import { akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles/constants';
4
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
4
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
6
5
  import { BLOCK_CONTROLS_SURFACE_SELECTOR, DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from '../ui/consts';
7
6
  import { handleSparseHoverTarget, isSparseHoverSuppressed } from './handle-sparse-hover-target';
8
7
  import { mouseEnter, setHoverSide, stopEditing } from './interaction-tracking/commands';
9
8
  import { handleMouseLeave } from './interaction-tracking/handle-mouse-move';
10
9
  import { getInteractionTrackingState } from './interaction-tracking/pm-plugin';
10
+ import { createAfterRenderScheduler } from './utils/after-render-scheduler';
11
11
  import { getVisibleBox } from './utils/visible-box';
12
12
  var BLOCK_SELECTOR = '[data-prosemirror-node-block="true"]';
13
13
  var TABLE_STRUCTURE_NODES = new Set(['table', 'tableRow', 'tableCell', 'tableHeader']);
@@ -144,40 +144,6 @@ var classifyGutterHover = function classifyGutterHover(view, findGutterBlock, _r
144
144
  };
145
145
  };
146
146
 
147
- /**
148
- * Runs `callback` once after the next frame renders (`requestAnimationFrame`, then `setTimeout`).
149
- * Layout is clean then, so reading positions never forces a synchronous layout. Calls made while a
150
- * run is already scheduled are ignored.
151
- */
152
- var createAfterRenderScheduler = function createAfterRenderScheduler(win, callback) {
153
- var frame;
154
- var timeout;
155
- return {
156
- schedule: function schedule() {
157
- if (frame !== undefined || timeout !== undefined) {
158
- return;
159
- }
160
- frame = win.requestAnimationFrame(function () {
161
- frame = undefined;
162
- timeout = win.setTimeout(function () {
163
- timeout = undefined;
164
- callback();
165
- }, 0);
166
- });
167
- },
168
- cancel: function cancel() {
169
- if (frame !== undefined) {
170
- win.cancelAnimationFrame(frame);
171
- frame = undefined;
172
- }
173
- if (timeout !== undefined) {
174
- win.clearTimeout(timeout);
175
- timeout = undefined;
176
- }
177
- }
178
- };
179
- };
180
-
181
147
  /**
182
148
  * Keeps interaction tracking in step with gutter hover, as the legacy hover zones did. They sat
183
149
  * inside the block tree, so hovering one cleared the typing state, counted as inside the editor even
@@ -301,28 +267,22 @@ export var bindSparseGutterHover = function bindSparseGutterHover(_ref2) {
301
267
  }
302
268
  });
303
269
  };
304
- var unbindMouseOver;
305
- var unbindMouseMove;
306
- if (isExperimentEnabled('platform_editor_block_controls_cls_fix')) {
307
- // Match the legacy ignoreRestingPointerHover guard until the pointer first moves.
308
- var pointerHasMoved = false;
309
- unbindMouseOver = bindMouseListener('mouseover', function (event) {
310
- if (!pointerHasMoved) {
311
- return;
312
- }
270
+
271
+ // Ignore hover from a resting pointer until it first moves.
272
+ var pointerHasMoved = false;
273
+ var unbindMouseOver = bindMouseListener('mouseover', function (event) {
274
+ if (!pointerHasMoved) {
275
+ return;
276
+ }
277
+ onMouseOver(event);
278
+ });
279
+ var unbindMouseMove = bindMouseListener('mousemove', function (event) {
280
+ if (!pointerHasMoved) {
281
+ pointerHasMoved = true;
313
282
  onMouseOver(event);
314
- });
315
- unbindMouseMove = bindMouseListener('mousemove', function (event) {
316
- if (!pointerHasMoved) {
317
- pointerHasMoved = true;
318
- onMouseOver(event);
319
- }
320
- onMouseMove(event);
321
- });
322
- } else {
323
- unbindMouseOver = bindMouseListener('mouseover', onMouseOver);
324
- unbindMouseMove = bindMouseListener('mousemove', onMouseMove);
325
- }
283
+ }
284
+ onMouseMove(event);
285
+ });
326
286
  return function () {
327
287
  unbindMouseOver();
328
288
  unbindMouseMove();
@@ -2,8 +2,8 @@ import { BLOCK_CONTROLS_SURFACE_INVALIDATION } from '@atlaskit/editor-common/blo
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
+ import { createSparseSurfacesViewWithLifecycle } from '../surface-lifecycle/sparse-surfaces-view-with-lifecycle';
5
6
  import { key as blockControlsKey } from './main';
6
- import { createSparseSurfacesView } from './sparse-surfaces-view';
7
7
  import { emptySparseSurfaceCandidateState } from './utils/sparse-surface-candidates';
8
8
  import { applySparseSurfacesTransaction, createInitialSparseSurfacesState } from './utils/sparse-surfaces-state';
9
9
  export var sparseSurfacesKey = new PluginKey('blockControlsSparseSurfaces');
@@ -33,7 +33,7 @@ export var createSparseSurfacesPlugin = function createSparseSurfacesPlugin(api)
33
33
  }
34
34
  },
35
35
  view: function view(_view) {
36
- return createSparseSurfacesView({
36
+ return createSparseSurfacesViewWithLifecycle({
37
37
  api: api,
38
38
  pluginKey: sparseSurfacesKey,
39
39
  view: _view
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Runs `callback` once after the next frame renders (`requestAnimationFrame`, then `setTimeout`).
3
+ * Deferring position reads gives the browser an opportunity to update layout first; other work
4
+ * can still invalidate layout before the callback. Calls made while a run is scheduled are ignored.
5
+ */
6
+ export var createAfterRenderScheduler = function createAfterRenderScheduler(win, callback) {
7
+ var frame;
8
+ var timeout;
9
+ return {
10
+ schedule: function schedule() {
11
+ if (frame !== undefined || timeout !== undefined) {
12
+ return;
13
+ }
14
+ frame = win.requestAnimationFrame(function () {
15
+ frame = undefined;
16
+ timeout = win.setTimeout(function () {
17
+ timeout = undefined;
18
+ callback();
19
+ }, 0);
20
+ });
21
+ },
22
+ cancel: function cancel() {
23
+ if (frame !== undefined) {
24
+ win.cancelAnimationFrame(frame);
25
+ frame = undefined;
26
+ }
27
+ if (timeout !== undefined) {
28
+ win.clearTimeout(timeout);
29
+ timeout = undefined;
30
+ }
31
+ }
32
+ };
33
+ };
@@ -3,28 +3,13 @@ import "./block-controls-left-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
5
5
  import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
6
- import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
7
- import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
8
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
6
  import { BlockControlsSurfaceWithClsFix } from '../surface-lifecycle/block-controls-surface-with-cls-fix';
10
- import { BlockControlsVisibilityProvider } from './block-controls-surface-components';
11
- import { getBlockControlsSurfaceControlSide } from './block-controls-surface-context';
12
- import { useBlockControlsVisibility } from './visibility-container';
13
7
  var leftSurfaceHiddenWrapperStyles = null;
14
8
  var leftSurfaceOuterStyles = null;
15
9
  var leftSurfaceGutterStyles = {
16
10
  container: "_1f38ffwv _7cca15wb _lcxvglyw",
17
11
  row: "_1bahesu3 _lcxvglyw _w1y61wug _19vrglyw"
18
12
  };
19
-
20
- // Nested surfaces (e.g. a table inside an expand) can span the target node's full height and sit
21
- // over controls rendered in the node's own gutter, such as the table row insert button. Let pointer
22
- // events pass through the wrapper and row so those controls stay interactive, matching the top-level
23
- // gutter behaviour without applying its container query sizing.
24
- var nestedSurfacePointerEventsStyles = {
25
- container: "_lcxvglyw",
26
- row: "_lcxvglyw _w1y61wug"
27
- };
28
13
  var leftSurfaceRowStyles = null;
29
14
 
30
15
  // Applied in addition to leftSurfaceRowStyles when the target node is sticky-eligible (e.g. long
@@ -35,50 +20,12 @@ var leftSurfaceStickyStyles = null;
35
20
 
36
21
  // Keep in sync with STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER in ./consts (must be a static literal here)
37
22
  var leftSurfaceStickyTableHeaderStyles = null;
38
- var BlockControlsLeftSurfaceContent = function BlockControlsLeftSurfaceContent(_ref) {
39
- var api = _ref.api,
40
- components = _ref.components,
41
- forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
23
+ var BlockControlsLeftSurfaceWrapper = function BlockControlsLeftSurfaceWrapper(_ref) {
24
+ var children = _ref.children,
42
25
  placement = _ref.placement,
43
26
  source = _ref.source,
44
27
  surfaceContext = _ref.surfaceContext;
45
28
  var blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
46
- var controlSide = getBlockControlsSurfaceControlSide(blockControlsContext, isExperimentEnabled('platform_editor_controls_reliable_anchor'));
47
- var _useBlockControlsVisi = useBlockControlsVisibility({
48
- api: api,
49
- controlSide: controlSide,
50
- forceVisibleOnMouseOut: forceVisibleOnMouseOut
51
- }),
52
- shouldHideHoverControls = _useBlockControlsVisi.shouldHide,
53
- useCssStyles = _useBlockControlsVisi.useCssStyles;
54
- var isSticky = placement.isSticky;
55
- var isTopLevel = (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.parentType) === 'doc';
56
- var shouldPassThroughNestedPointerEvents = !isTopLevel && isExperimentEnabled('platform_editor_nested_left_surface_pointer_fix');
57
- return /*#__PURE__*/React.createElement("div", {
58
- "data-editor-block-controls-surface": true,
59
- "data-editor-block-controls-side": "left",
60
- "data-testid": source === 'stored' ? 'block-controls-left-surface-stored' : source === 'active' ? 'block-controls-left-surface-active' : 'block-controls-left-surface'
61
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved per target node, from its runtime DOM geometry or from its CSS anchor.
62
- ,
63
- style: placement.style,
64
- className: ax(["_kqswstnw _17c61i8t _1pbyb4wl", isTopLevel && leftSurfaceGutterStyles.container, shouldPassThroughNestedPointerEvents && nestedSurfacePointerEventsStyles.container])
65
- }, /*#__PURE__*/React.createElement("div", {
66
- className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isTopLevel && leftSurfaceGutterStyles.row, shouldPassThroughNestedPointerEvents && nestedSurfacePointerEventsStyles.row, isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && "_154i1ejb"])
67
- }, /*#__PURE__*/React.createElement(BlockControlsVisibilityProvider, {
68
- shouldHideHoverControls: shouldHideHoverControls,
69
- useCssStyles: useCssStyles
70
- }, /*#__PURE__*/React.createElement(SurfaceRenderer, {
71
- components: components,
72
- surface: BLOCK_CONTROLS_LEFT_SURFACE,
73
- surfaceContext: surfaceContext
74
- }))));
75
- };
76
- var BlockControlsLeftSurfaceWrapper = function BlockControlsLeftSurfaceWrapper(_ref2) {
77
- var children = _ref2.children,
78
- placement = _ref2.placement,
79
- source = _ref2.source,
80
- surfaceContext = _ref2.surfaceContext;
81
- var blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
82
29
  var isSticky = placement.isSticky;
83
30
  var isTopLevel = (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.parentType) === 'doc';
84
31
  return /*#__PURE__*/React.createElement("div", {
@@ -95,35 +42,24 @@ var BlockControlsLeftSurfaceWrapper = function BlockControlsLeftSurfaceWrapper(_
95
42
  };
96
43
 
97
44
  /** Renders one left block-controls surface at a document position. */
98
- export var BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref3) {
99
- var api = _ref3.api,
100
- components = _ref3.components,
101
- forceVisibleOnMouseOut = _ref3.forceVisibleOnMouseOut,
102
- placement = _ref3.placement,
103
- source = _ref3.source,
104
- surfaceContext = _ref3.surfaceContext;
45
+ export var BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref2) {
46
+ var api = _ref2.api,
47
+ components = _ref2.components,
48
+ forceVisibleOnMouseOut = _ref2.forceVisibleOnMouseOut,
49
+ placement = _ref2.placement,
50
+ source = _ref2.source,
51
+ surfaceContext = _ref2.surfaceContext;
105
52
  if (!placement) {
106
53
  return null;
107
54
  }
108
- if (isExperimentEnabled('platform_editor_block_controls_cls_fix')) {
109
- return /*#__PURE__*/React.createElement(BlockControlsSurfaceWithClsFix, {
110
- side: "left",
111
- SurfaceWrapper: BlockControlsLeftSurfaceWrapper,
112
- api: api,
113
- components: components,
114
- forceVisibleOnMouseOut: forceVisibleOnMouseOut,
115
- placement: placement,
116
- source: source,
117
- surfaceContext: surfaceContext
118
- });
119
- } else {
120
- return /*#__PURE__*/React.createElement(BlockControlsLeftSurfaceContent, {
121
- api: api,
122
- components: components,
123
- forceVisibleOnMouseOut: forceVisibleOnMouseOut,
124
- placement: placement,
125
- source: source,
126
- surfaceContext: surfaceContext
127
- });
128
- }
55
+ return /*#__PURE__*/React.createElement(BlockControlsSurfaceWithClsFix, {
56
+ side: "left",
57
+ SurfaceWrapper: BlockControlsLeftSurfaceWrapper,
58
+ api: api,
59
+ components: components,
60
+ forceVisibleOnMouseOut: forceVisibleOnMouseOut,
61
+ placement: placement,
62
+ source: source,
63
+ surfaceContext: surfaceContext
64
+ });
129
65
  };