@atlaskit/editor-plugin-block-controls 31.0.5 → 31.1.1

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 (52) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/blockControlsPlugin.js +6 -2
  3. package/dist/cjs/pm-plugins/sparse-gutter-hover.js +23 -2
  4. package/dist/cjs/pm-plugins/sparse-surfaces-view.js +10 -1
  5. package/dist/cjs/surface-lifecycle/are-block-controls-surface-contexts-equal.js +39 -0
  6. package/dist/cjs/surface-lifecycle/block-controls-surface-descriptors.js +83 -0
  7. package/dist/cjs/surface-lifecycle/block-controls-surface-with-cls-fix.js +46 -0
  8. package/dist/cjs/surface-lifecycle/block-controls-surfaces.js +80 -0
  9. package/dist/cjs/surface-lifecycle/sparse-surfaces-view-with-lifecycle.js +287 -0
  10. package/dist/cjs/surface-lifecycle/surface-lifecycle.js +206 -0
  11. package/dist/cjs/surface-lifecycle/use-measured-surface-placements.js +199 -0
  12. package/dist/cjs/ui/block-controls-left-surface.compiled.css +1 -0
  13. package/dist/cjs/ui/block-controls-left-surface.js +61 -16
  14. package/dist/cjs/ui/block-controls-right-surface.compiled.css +1 -0
  15. package/dist/cjs/ui/block-controls-right-surface.js +48 -14
  16. package/dist/es2019/blockControlsPlugin.js +6 -2
  17. package/dist/es2019/pm-plugins/sparse-gutter-hover.js +23 -2
  18. package/dist/es2019/pm-plugins/sparse-surfaces-view.js +10 -1
  19. package/dist/es2019/surface-lifecycle/are-block-controls-surface-contexts-equal.js +31 -0
  20. package/dist/es2019/surface-lifecycle/block-controls-surface-descriptors.js +67 -0
  21. package/dist/es2019/surface-lifecycle/block-controls-surface-with-cls-fix.js +41 -0
  22. package/dist/es2019/surface-lifecycle/block-controls-surfaces.js +69 -0
  23. package/dist/es2019/surface-lifecycle/sparse-surfaces-view-with-lifecycle.js +256 -0
  24. package/dist/es2019/surface-lifecycle/surface-lifecycle.js +125 -0
  25. package/dist/es2019/surface-lifecycle/use-measured-surface-placements.js +163 -0
  26. package/dist/es2019/ui/block-controls-left-surface.compiled.css +1 -0
  27. package/dist/es2019/ui/block-controls-left-surface.js +56 -10
  28. package/dist/es2019/ui/block-controls-right-surface.compiled.css +1 -0
  29. package/dist/es2019/ui/block-controls-right-surface.js +43 -8
  30. package/dist/esm/blockControlsPlugin.js +6 -2
  31. package/dist/esm/pm-plugins/sparse-gutter-hover.js +23 -2
  32. package/dist/esm/pm-plugins/sparse-surfaces-view.js +10 -1
  33. package/dist/esm/surface-lifecycle/are-block-controls-surface-contexts-equal.js +33 -0
  34. package/dist/esm/surface-lifecycle/block-controls-surface-descriptors.js +76 -0
  35. package/dist/esm/surface-lifecycle/block-controls-surface-with-cls-fix.js +39 -0
  36. package/dist/esm/surface-lifecycle/block-controls-surfaces.js +72 -0
  37. package/dist/esm/surface-lifecycle/sparse-surfaces-view-with-lifecycle.js +280 -0
  38. package/dist/esm/surface-lifecycle/surface-lifecycle.js +199 -0
  39. package/dist/esm/surface-lifecycle/use-measured-surface-placements.js +192 -0
  40. package/dist/esm/ui/block-controls-left-surface.compiled.css +1 -0
  41. package/dist/esm/ui/block-controls-left-surface.js +61 -16
  42. package/dist/esm/ui/block-controls-right-surface.compiled.css +1 -0
  43. package/dist/esm/ui/block-controls-right-surface.js +48 -14
  44. package/dist/types/pm-plugins/sparse-surfaces-view.d.ts +2 -1
  45. package/dist/types/surface-lifecycle/are-block-controls-surface-contexts-equal.d.ts +19 -0
  46. package/dist/types/surface-lifecycle/block-controls-surface-descriptors.d.ts +28 -0
  47. package/dist/types/surface-lifecycle/block-controls-surface-with-cls-fix.d.ts +26 -0
  48. package/dist/types/surface-lifecycle/block-controls-surfaces.d.ts +10 -0
  49. package/dist/types/surface-lifecycle/sparse-surfaces-view-with-lifecycle.d.ts +21 -0
  50. package/dist/types/surface-lifecycle/surface-lifecycle.d.ts +46 -0
  51. package/dist/types/surface-lifecycle/use-measured-surface-placements.d.ts +12 -0
  52. package/package.json +2 -2
@@ -5,6 +5,7 @@
5
5
  ._1e0c1txw{display:flex}
6
6
  ._1f38ffwv{container-name:block-controls-left-gutter}
7
7
  ._1pbyb4wl{z-index:100}
8
+ ._3um015vq{visibility:hidden}
8
9
  ._4cvr1h6o{align-items:center}
9
10
  ._7cca15wb{container-type:inline-size}
10
11
  ._kqsw1if8{position:sticky}
@@ -6,14 +6,25 @@ import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls
6
6
  import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
7
7
  import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
8
8
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
+ import { BlockControlsSurfaceWithClsFix } from '../surface-lifecycle/block-controls-surface-with-cls-fix';
9
10
  import { BlockControlsVisibilityProvider } from './block-controls-surface-components';
10
11
  import { getBlockControlsSurfaceControlSide } from './block-controls-surface-context';
11
12
  import { useBlockControlsVisibility } from './visibility-container';
13
+ var leftSurfaceHiddenWrapperStyles = null;
12
14
  var leftSurfaceOuterStyles = null;
13
15
  var leftSurfaceGutterStyles = {
14
16
  container: "_1f38ffwv _7cca15wb _lcxvglyw",
15
17
  row: "_1bahesu3 _lcxvglyw _w1y61wug _19vrglyw"
16
18
  };
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
+ };
17
28
  var leftSurfaceRowStyles = null;
18
29
 
19
30
  // Applied in addition to leftSurfaceRowStyles when the target node is sticky-eligible (e.g. long
@@ -42,6 +53,7 @@ var BlockControlsLeftSurfaceContent = function BlockControlsLeftSurfaceContent(_
42
53
  useCssStyles = _useBlockControlsVisi.useCssStyles;
43
54
  var isSticky = placement.isSticky;
44
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');
45
57
  return /*#__PURE__*/React.createElement("div", {
46
58
  "data-editor-block-controls-surface": true,
47
59
  "data-editor-block-controls-side": "left",
@@ -49,9 +61,9 @@ var BlockControlsLeftSurfaceContent = function BlockControlsLeftSurfaceContent(_
49
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.
50
62
  ,
51
63
  style: placement.style,
52
- className: ax(["_kqswstnw _17c61i8t _1pbyb4wl", isTopLevel && leftSurfaceGutterStyles.container])
64
+ className: ax(["_kqswstnw _17c61i8t _1pbyb4wl", isTopLevel && leftSurfaceGutterStyles.container, shouldPassThroughNestedPointerEvents && nestedSurfacePointerEventsStyles.container])
53
65
  }, /*#__PURE__*/React.createElement("div", {
54
- className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isTopLevel && leftSurfaceGutterStyles.row, isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && isExperimentEnabled('platform_editor_block_controls_sticky_header_fix') && "_154i1ejb"])
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' && isExperimentEnabled('platform_editor_block_controls_sticky_header_fix') && "_154i1ejb"])
55
67
  }, /*#__PURE__*/React.createElement(BlockControlsVisibilityProvider, {
56
68
  shouldHideHoverControls: shouldHideHoverControls,
57
69
  useCssStyles: useCssStyles
@@ -61,24 +73,57 @@ var BlockControlsLeftSurfaceContent = function BlockControlsLeftSurfaceContent(_
61
73
  surfaceContext: surfaceContext
62
74
  }))));
63
75
  };
64
-
65
- /** Renders one left block-controls surface at a document position. */
66
- export var BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref2) {
67
- var api = _ref2.api,
68
- components = _ref2.components,
69
- forceVisibleOnMouseOut = _ref2.forceVisibleOnMouseOut,
76
+ var BlockControlsLeftSurfaceWrapper = function BlockControlsLeftSurfaceWrapper(_ref2) {
77
+ var children = _ref2.children,
70
78
  placement = _ref2.placement,
71
79
  source = _ref2.source,
72
80
  surfaceContext = _ref2.surfaceContext;
81
+ var blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
82
+ var isSticky = placement.isSticky;
83
+ var isTopLevel = (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.parentType) === 'doc';
84
+ return /*#__PURE__*/React.createElement("div", {
85
+ "data-editor-block-controls-surface": true,
86
+ "data-editor-block-controls-side": "left",
87
+ "data-testid": source === 'stored' ? 'block-controls-left-surface-stored' : source === 'active' ? 'block-controls-left-surface-active' : 'block-controls-left-surface'
88
+ // 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.
89
+ ,
90
+ style: placement.style,
91
+ className: ax(["_kqswstnw _17c61i8t _1pbyb4wl", isTopLevel && leftSurfaceGutterStyles.container, "_3um015vq"])
92
+ }, /*#__PURE__*/React.createElement("div", {
93
+ className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isTopLevel && leftSurfaceGutterStyles.row, isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && isExperimentEnabled('platform_editor_block_controls_sticky_header_fix') && "_154i1ejb"])
94
+ }, children));
95
+ };
96
+
97
+ /** 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;
73
105
  if (!placement) {
74
106
  return null;
75
107
  }
76
- return /*#__PURE__*/React.createElement(BlockControlsLeftSurfaceContent, {
77
- api: api,
78
- components: components,
79
- forceVisibleOnMouseOut: forceVisibleOnMouseOut,
80
- placement: placement,
81
- source: source,
82
- surfaceContext: surfaceContext
83
- });
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
+ }
84
129
  };
@@ -3,6 +3,7 @@
3
3
  ._17c61i8t{position-visibility:anchors-valid}
4
4
  ._1e0c1txw{display:flex}
5
5
  ._1pbyb4wl{z-index:100}
6
+ ._3um015vq{visibility:hidden}
6
7
  ._4cvr1h6o{align-items:center}
7
8
  ._kqsw1if8{position:sticky}
8
9
  ._kqswstnw{position:absolute}
@@ -6,8 +6,10 @@ import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls
6
6
  import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
7
7
  import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
8
8
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
9
+ import { BlockControlsSurfaceWithClsFix } from '../surface-lifecycle/block-controls-surface-with-cls-fix';
9
10
  import { BlockControlsVisibilityProvider } from './block-controls-surface-components';
10
11
  import { useBlockControlsVisibility } from './visibility-container';
12
+ var rightSurfaceHiddenWrapperStyles = null;
11
13
  var rightSurfaceOuterStyles = null;
12
14
  var rightSurfaceRowStyles = null;
13
15
 
@@ -54,24 +56,56 @@ var BlockControlsRightSurfaceContent = function BlockControlsRightSurfaceContent
54
56
  surfaceContext: surfaceContext
55
57
  }))));
56
58
  };
57
-
58
- /** Renders one right block-controls surface at a document position. */
59
- export var BlockControlsRightSurface = function BlockControlsRightSurface(_ref2) {
60
- var api = _ref2.api,
61
- components = _ref2.components,
62
- forceVisibleOnMouseOut = _ref2.forceVisibleOnMouseOut,
59
+ var BlockControlsRightSurfaceWrapper = function BlockControlsRightSurfaceWrapper(_ref2) {
60
+ var children = _ref2.children,
63
61
  placement = _ref2.placement,
64
62
  source = _ref2.source,
65
63
  surfaceContext = _ref2.surfaceContext;
64
+ var blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
65
+ var isSticky = placement.isSticky;
66
+ return /*#__PURE__*/React.createElement("div", {
67
+ "data-editor-block-controls-surface": true,
68
+ "data-editor-block-controls-side": "right",
69
+ "data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
70
+ // 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.
71
+ ,
72
+ style: placement.style,
73
+ className: ax(["_kqswstnw _17c61i8t _1pbyb4wl", "_3um015vq"])
74
+ }, /*#__PURE__*/React.createElement("div", {
75
+ className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && isExperimentEnabled('platform_editor_block_controls_sticky_header_fix') && "_154i1ejb"])
76
+ }, children));
77
+ };
78
+
79
+ /** Renders one right block-controls surface at a document position. */
80
+ export var BlockControlsRightSurface = function BlockControlsRightSurface(_ref3) {
81
+ var api = _ref3.api,
82
+ components = _ref3.components,
83
+ forceVisibleOnMouseOut = _ref3.forceVisibleOnMouseOut,
84
+ placement = _ref3.placement,
85
+ source = _ref3.source,
86
+ surfaceContext = _ref3.surfaceContext;
66
87
  if (!placement) {
67
88
  return null;
68
89
  }
69
- return /*#__PURE__*/React.createElement(BlockControlsRightSurfaceContent, {
70
- api: api,
71
- components: components,
72
- forceVisibleOnMouseOut: forceVisibleOnMouseOut,
73
- placement: placement,
74
- source: source,
75
- surfaceContext: surfaceContext
76
- });
90
+ if (isExperimentEnabled('platform_editor_block_controls_cls_fix')) {
91
+ return /*#__PURE__*/React.createElement(BlockControlsSurfaceWithClsFix, {
92
+ side: "right",
93
+ SurfaceWrapper: BlockControlsRightSurfaceWrapper,
94
+ api: api,
95
+ components: components,
96
+ forceVisibleOnMouseOut: forceVisibleOnMouseOut,
97
+ placement: placement,
98
+ source: source,
99
+ surfaceContext: surfaceContext
100
+ });
101
+ } else {
102
+ return /*#__PURE__*/React.createElement(BlockControlsRightSurfaceContent, {
103
+ api: api,
104
+ components: components,
105
+ forceVisibleOnMouseOut: forceVisibleOnMouseOut,
106
+ placement: placement,
107
+ source: source,
108
+ surfaceContext: surfaceContext
109
+ });
110
+ }
77
111
  };
@@ -7,9 +7,10 @@ type SparseSurfacesPluginView = {
7
7
  destroy: () => void;
8
8
  update: (view: EditorView, previousState: EditorState) => void;
9
9
  };
10
- export declare const createSparseSurfacesView: ({ api, pluginKey, view, }: {
10
+ declare const createLegacySparseSurfacesView: ({ api, pluginKey, view, }: {
11
11
  api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
12
12
  pluginKey: PluginKey<SparseSurfacesState>;
13
13
  view: EditorView;
14
14
  }) => SparseSurfacesPluginView;
15
+ export declare const createSparseSurfacesView: (options: Parameters<typeof createLegacySparseSurfacesView>[0]) => SparseSurfacesPluginView;
15
16
  export {};
@@ -0,0 +1,19 @@
1
+ import type { BlockControlUIContext } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
2
+ /**
3
+ * Resolves to `T` only when `Compared` lists every key of `T`. Adding a field to the context types
4
+ * turns the comparators' parameters into `never`, so callers stop compiling until the comparison
5
+ * handles the new field.
6
+ */
7
+ type ComparedFields<T, Compared extends keyof T> = Exclude<keyof T, Compared> extends never ? T : never;
8
+ /**
9
+ * `controlVisibility` is derived from component predicates after the context is created, never by
10
+ * `createBlockControlsSurfaceContextForPosition`, so it is not compared.
11
+ */
12
+ type ComparedContext = ComparedFields<Omit<BlockControlUIContext, 'controlVisibility'>, 'activeControlKey' | 'activeNode' | 'rootNode' | 'targetNode'>;
13
+ /**
14
+ * Compares contexts produced by `createBlockControlsSurfaceContextForPosition`. Includes root and
15
+ * active-node context because controls can depend on more than the target itself, for example a
16
+ * changed containing block or a different active control.
17
+ */
18
+ export declare const areBlockControlsSurfaceContextsEqual: (a: ComparedContext, b: ComparedContext) => boolean;
19
+ export {};
@@ -0,0 +1,28 @@
1
+ import { type BlockControlUIContext } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { RegisterComponent, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
4
+ import type { ActiveNode } from '../blockControlsPluginType';
5
+ import type { BlockControlsSurfaceTarget } from '../ui/block-controls-surface-targets';
6
+ export type SurfaceDescriptor = BlockControlsSurfaceTarget & {
7
+ readonly anchorName: string;
8
+ readonly blockControlsContext: BlockControlUIContext;
9
+ readonly isTopLevel: boolean;
10
+ readonly surfaceComponents: RegisterComponent[];
11
+ readonly surfaceContext: SurfaceContext;
12
+ };
13
+ type Input = {
14
+ activeNode: ActiveNode | undefined;
15
+ components: RegisterComponent[];
16
+ state: EditorState;
17
+ surfaceActiveNodes: ReadonlyMap<number, ActiveNode> | undefined;
18
+ surfaceAnchors: ReadonlyMap<number, string>;
19
+ targets: readonly BlockControlsSurfaceTarget[];
20
+ };
21
+ /**
22
+ * Creates a cache owned by one editor view and surface side on the gated CLS fix path.
23
+ * Unchanged descriptors let memoized surfaces skip rendering; preserving the array reference also
24
+ * lets SurfaceLifecycle skip publishing an otherwise unchanged snapshot. Registry changes or
25
+ * explicit invalidation force predicates to run again, even if the document context is unchanged.
26
+ */
27
+ export declare const createSurfaceDescriptorResolver: (side: 'left' | 'right') => ((input: Input, invalidated: boolean) => SurfaceDescriptor[]);
28
+ export {};
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
3
+ import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
4
+ import type { SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
5
+ import type { BlockControlsPlugin } from '../blockControlsPluginType';
6
+ import type { BlockControlsSurfaceTarget } from '../ui/block-controls-surface-targets';
7
+ import type { SurfaceSide, SurfaceWrapperPlacement } from '../ui/utils/get-surface-placement';
8
+ export type BlockControlsSurfaceWrapperProps = {
9
+ children: React.ReactNode;
10
+ placement: SurfaceWrapperPlacement;
11
+ source: BlockControlsSurfaceTarget['source'];
12
+ surfaceContext: SurfaceContext;
13
+ };
14
+ type Props = {
15
+ api: ExtractInjectionAPI<BlockControlsPlugin>;
16
+ components: React.ComponentProps<typeof SurfaceRenderer>['components'];
17
+ forceVisibleOnMouseOut: boolean;
18
+ placement: SurfaceWrapperPlacement;
19
+ side: SurfaceSide;
20
+ source: BlockControlsSurfaceTarget['source'];
21
+ surfaceContext: SurfaceContext;
22
+ SurfaceWrapper: React.ComponentType<BlockControlsSurfaceWrapperProps>;
23
+ };
24
+ /** Renders one block-controls surface for either side on the CLS fix path. */
25
+ export declare const BlockControlsSurfaceWithClsFix: ({ api, components, forceVisibleOnMouseOut, placement, side, source, surfaceContext, SurfaceWrapper, }: Props) => React.JSX.Element;
26
+ export {};
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { BlockControlsPlugin } from '../blockControlsPluginType';
5
+ type Props = {
6
+ api: ExtractInjectionAPI<BlockControlsPlugin>;
7
+ editorView: EditorView;
8
+ };
9
+ export declare const CommittedBlockControlsSurfaces: (props: Props) => React.JSX.Element | null;
10
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
2
+ import type { EditorState, PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { BlockControlsPlugin } from '../blockControlsPluginType';
5
+ import type { SparseSurfacesState } from '../pm-plugins/utils/sparse-surfaces-state';
6
+ type Api = ExtractInjectionAPI<BlockControlsPlugin> | undefined;
7
+ type SparseSurfacesPluginView = {
8
+ destroy: () => void;
9
+ update: (view: EditorView, previousState: EditorState) => void;
10
+ };
11
+ /**
12
+ * Sparse surfaces plugin view for the CLS fix. Each animation frame reconciles which blocks have
13
+ * surfaces, commits their anchor decorations, and publishes the surfaces React renders through
14
+ * `SurfaceLifecycle`, which retains anchors until React commits their replacement.
15
+ */
16
+ export declare const createSparseSurfacesViewWithLifecycle: ({ api, pluginKey, view, }: {
17
+ api: Api;
18
+ pluginKey: PluginKey<SparseSurfacesState>;
19
+ view: EditorView;
20
+ }) => SparseSurfacesPluginView;
21
+ export {};
@@ -0,0 +1,46 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { SurfaceDescriptor } from './block-controls-surface-descriptors';
4
+ export type SurfaceSnapshot = {
5
+ readonly forceVisibleOnMouseOut: boolean;
6
+ readonly left: readonly SurfaceDescriptor[];
7
+ readonly revision: number;
8
+ readonly right: readonly SurfaceDescriptor[];
9
+ };
10
+ /**
11
+ * Keeps anchor decorations in step with the block-control surfaces React renders.
12
+ * - An anchor stays until React has committed a tree that no longer uses it.
13
+ * - Surfaces whose anchor is gone (deleted block, drag, limited mode) are left out of the snapshot,
14
+ * so React removes them before the browser paints.
15
+ */
16
+ export declare class SurfaceLifecycle {
17
+ private published;
18
+ private snapshot;
19
+ private committedRevision;
20
+ private revision;
21
+ private lastUsedRevision;
22
+ private listeners;
23
+ private availableAnchors;
24
+ private publishedAnchors;
25
+ private decorations;
26
+ private suppressed;
27
+ private onCommit;
28
+ getSnapshot: () => SurfaceSnapshot | undefined;
29
+ subscribe: (listener: () => void) => (() => void);
30
+ setOnCommit(onCommit: () => void): void;
31
+ publish(snapshot: Omit<SurfaceSnapshot, 'revision'>, anchors: ReadonlyMap<number, string>): void;
32
+ acknowledge: (revision: number) => void;
33
+ retainAnchors(doc: PMNode, desired: DecorationSet, previous: DecorationSet): DecorationSet;
34
+ /** Whether a reconcile would drop anchors that no committed or pending tree still uses. */
35
+ hasRetirableAnchors(decorations: DecorationSet): boolean;
36
+ private isRetained;
37
+ /**
38
+ * Records which anchors the browser can currently resolve. Removes surfaces for missing or
39
+ * suppressed anchors from the snapshot synchronously, ahead of the next reconcile.
40
+ */
41
+ updateAnchors(decorations: DecorationSet, suppressed: boolean): void;
42
+ /** Derives the snapshot React reads, replacing it only when the rendered surfaces change. */
43
+ private updateSnapshot;
44
+ destroy(): void;
45
+ }
46
+ export declare const getSurfaceLifecycle: (view: EditorView) => SurfaceLifecycle;
@@ -0,0 +1,12 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ import { type SurfaceSide, type SurfaceWrapperPlacement } from '../ui/utils/get-surface-placement';
3
+ import type { SurfaceDescriptor } from './block-controls-surface-descriptors';
4
+ export type MeasuredSurfacePlacements = ReadonlyMap<string, SurfaceWrapperPlacement>;
5
+ export declare const getSurfaceKey: (side: SurfaceSide, descriptor: SurfaceDescriptor) => string;
6
+ /**
7
+ * Measures surface placements from DOM geometry when the browser cannot position surfaces with CSS
8
+ * anchors. Returns an empty map and binds nothing when anchors are supported. Both sides share one
9
+ * set of listeners, and measuring reruns only when a side's descriptor list changes, which the
10
+ * descriptor resolver keeps stable across unrelated updates.
11
+ */
12
+ export declare const useMeasuredSurfacePlacements: (editorView: EditorView, left: readonly SurfaceDescriptor[] | undefined, right: readonly SurfaceDescriptor[] | undefined) => MeasuredSurfacePlacements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "31.0.5",
3
+ "version": "31.1.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -60,7 +60,7 @@
60
60
  "@atlaskit/primitives": "^22.6.0",
61
61
  "@atlaskit/section-message": "^10.2.0",
62
62
  "@atlaskit/theme": "^28.2.0",
63
- "@atlaskit/tmp-editor-statsig": "^248.0.0",
63
+ "@atlaskit/tmp-editor-statsig": "^249.0.0",
64
64
  "@atlaskit/tokens": "^20.8.0",
65
65
  "@atlaskit/tooltip": "^24.4.0",
66
66
  "@babel/runtime": "^7.0.0",