@atlaskit/editor-plugin-block-controls 17.2.4 → 17.3.0

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 (113) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/blockControlsPlugin.js +28 -8
  3. package/dist/cjs/editor-commands/move-node-with-block-menu.js +2 -2
  4. package/dist/cjs/editor-commands/move-node.js +6 -6
  5. package/dist/cjs/editor-commands/utils/move-node-utils.js +4 -4
  6. package/dist/cjs/pm-plugins/decorations-anchor.js +4 -4
  7. package/dist/cjs/pm-plugins/decorations-drag-handle.js +3 -3
  8. package/dist/cjs/pm-plugins/decorations-drop-target-active.js +2 -2
  9. package/dist/cjs/pm-plugins/decorations-drop-target.js +2 -2
  10. package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +2 -2
  11. package/dist/cjs/pm-plugins/handle-mouse-down.js +3 -3
  12. package/dist/cjs/pm-plugins/handle-mouse-over.js +7 -7
  13. package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +3 -3
  14. package/dist/cjs/pm-plugins/main.js +23 -21
  15. package/dist/cjs/pm-plugins/react-root-registry.js +7 -7
  16. package/dist/cjs/pm-plugins/utils/active-anchor-tracker.js +2 -2
  17. package/dist/cjs/pm-plugins/utils/consts.js +2 -2
  18. package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +6 -6
  19. package/dist/cjs/pm-plugins/utils/expand-and-update-selection.js +2 -2
  20. package/dist/cjs/pm-plugins/utils/getSelection.js +5 -5
  21. package/dist/cjs/pm-plugins/utils/inline-drop-target.js +2 -2
  22. package/dist/cjs/pm-plugins/utils/remove-from-source.js +2 -2
  23. package/dist/cjs/pm-plugins/utils/surface-node-positions.js +45 -19
  24. package/dist/cjs/pm-plugins/utils/validation.js +2 -2
  25. package/dist/cjs/ui/block-controls-left-surfaces.js +5 -4
  26. package/dist/cjs/ui/block-controls-right-surface.compiled.css +4 -0
  27. package/dist/cjs/ui/block-controls-right-surface.js +45 -0
  28. package/dist/cjs/ui/block-controls-right-surfaces.js +222 -0
  29. package/dist/{esm/ui/block-controls-left-surface-targets.js → cjs/ui/block-controls-surface-targets.js} +14 -2
  30. package/dist/cjs/ui/consts.js +4 -4
  31. package/dist/cjs/ui/drag-handle.js +20 -19
  32. package/dist/cjs/ui/drop-target.js +2 -2
  33. package/dist/cjs/ui/global-styles.js +5 -5
  34. package/dist/cjs/ui/utils/get-surface-placement.js +20 -6
  35. package/dist/cjs/ui/visibility-container.js +2 -2
  36. package/dist/es2019/blockControlsPlugin.js +28 -4
  37. package/dist/es2019/editor-commands/move-node-with-block-menu.js +1 -1
  38. package/dist/es2019/editor-commands/move-node.js +1 -1
  39. package/dist/es2019/editor-commands/utils/move-node-utils.js +1 -1
  40. package/dist/es2019/pm-plugins/decorations-anchor.js +1 -1
  41. package/dist/es2019/pm-plugins/decorations-drag-handle.js +1 -1
  42. package/dist/es2019/pm-plugins/decorations-drop-target-active.js +1 -1
  43. package/dist/es2019/pm-plugins/decorations-drop-target.js +1 -1
  44. package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +1 -1
  45. package/dist/es2019/pm-plugins/handle-mouse-down.js +1 -1
  46. package/dist/es2019/pm-plugins/handle-mouse-over.js +1 -1
  47. package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +1 -1
  48. package/dist/es2019/pm-plugins/main.js +10 -10
  49. package/dist/es2019/pm-plugins/react-root-registry.js +7 -7
  50. package/dist/es2019/pm-plugins/utils/active-anchor-tracker.js +1 -1
  51. package/dist/es2019/pm-plugins/utils/consts.js +1 -1
  52. package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +1 -1
  53. package/dist/es2019/pm-plugins/utils/expand-and-update-selection.js +1 -1
  54. package/dist/es2019/pm-plugins/utils/getSelection.js +1 -1
  55. package/dist/es2019/pm-plugins/utils/inline-drop-target.js +1 -1
  56. package/dist/es2019/pm-plugins/utils/remove-from-source.js +1 -1
  57. package/dist/es2019/pm-plugins/utils/surface-node-positions.js +34 -15
  58. package/dist/es2019/pm-plugins/utils/validation.js +1 -1
  59. package/dist/es2019/ui/block-controls-left-surfaces.js +5 -4
  60. package/dist/es2019/ui/block-controls-right-surface.compiled.css +4 -0
  61. package/dist/es2019/ui/block-controls-right-surface.js +39 -0
  62. package/dist/es2019/ui/block-controls-right-surfaces.js +187 -0
  63. package/dist/es2019/ui/{block-controls-left-surface-targets.js → block-controls-surface-targets.js} +8 -2
  64. package/dist/es2019/ui/consts.js +1 -1
  65. package/dist/es2019/ui/drag-handle.js +4 -3
  66. package/dist/es2019/ui/drop-target.js +1 -1
  67. package/dist/es2019/ui/global-styles.js +1 -1
  68. package/dist/es2019/ui/utils/get-surface-placement.js +20 -6
  69. package/dist/es2019/ui/visibility-container.js +1 -1
  70. package/dist/esm/blockControlsPlugin.js +24 -4
  71. package/dist/esm/editor-commands/move-node-with-block-menu.js +1 -1
  72. package/dist/esm/editor-commands/move-node.js +1 -1
  73. package/dist/esm/editor-commands/utils/move-node-utils.js +1 -1
  74. package/dist/esm/pm-plugins/decorations-anchor.js +1 -1
  75. package/dist/esm/pm-plugins/decorations-drag-handle.js +1 -1
  76. package/dist/esm/pm-plugins/decorations-drop-target-active.js +1 -1
  77. package/dist/esm/pm-plugins/decorations-drop-target.js +1 -1
  78. package/dist/esm/pm-plugins/decorations-quick-insert-button.js +1 -1
  79. package/dist/esm/pm-plugins/handle-mouse-down.js +1 -1
  80. package/dist/esm/pm-plugins/handle-mouse-over.js +1 -1
  81. package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +1 -1
  82. package/dist/esm/pm-plugins/main.js +11 -9
  83. package/dist/esm/pm-plugins/react-root-registry.js +7 -7
  84. package/dist/esm/pm-plugins/utils/active-anchor-tracker.js +1 -1
  85. package/dist/esm/pm-plugins/utils/consts.js +1 -1
  86. package/dist/esm/pm-plugins/utils/drag-handle-positions.js +1 -1
  87. package/dist/esm/pm-plugins/utils/expand-and-update-selection.js +1 -1
  88. package/dist/esm/pm-plugins/utils/getSelection.js +1 -1
  89. package/dist/esm/pm-plugins/utils/inline-drop-target.js +1 -1
  90. package/dist/esm/pm-plugins/utils/remove-from-source.js +1 -1
  91. package/dist/esm/pm-plugins/utils/surface-node-positions.js +45 -19
  92. package/dist/esm/pm-plugins/utils/validation.js +1 -1
  93. package/dist/esm/ui/block-controls-left-surfaces.js +5 -4
  94. package/dist/esm/ui/block-controls-right-surface.compiled.css +4 -0
  95. package/dist/esm/ui/block-controls-right-surface.js +38 -0
  96. package/dist/esm/ui/block-controls-right-surfaces.js +213 -0
  97. package/dist/{cjs/ui/block-controls-left-surface-targets.js → esm/ui/block-controls-surface-targets.js} +8 -8
  98. package/dist/esm/ui/consts.js +1 -1
  99. package/dist/esm/ui/drag-handle.js +4 -3
  100. package/dist/esm/ui/drop-target.js +1 -1
  101. package/dist/esm/ui/global-styles.js +1 -1
  102. package/dist/esm/ui/utils/get-surface-placement.js +20 -6
  103. package/dist/esm/ui/visibility-container.js +1 -1
  104. package/dist/types/pm-plugins/main.d.ts +2 -2
  105. package/dist/types/pm-plugins/react-root-registry.d.ts +4 -4
  106. package/dist/types/pm-plugins/utils/surface-node-positions.d.ts +3 -3
  107. package/dist/types/ui/block-controls-left-surface.d.ts +2 -2
  108. package/dist/types/ui/block-controls-right-surface.d.ts +23 -0
  109. package/dist/types/ui/block-controls-right-surfaces.d.ts +20 -0
  110. package/dist/types/ui/block-controls-surface-targets.d.ts +13 -0
  111. package/dist/types/ui/utils/get-surface-placement.d.ts +12 -4
  112. package/package.json +23 -26
  113. package/dist/types/ui/block-controls-left-surface-targets.d.ts +0 -7
@@ -0,0 +1,187 @@
1
+ /* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
2
+ import { ax, ix } from "@compiled/react/runtime";
3
+ import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
4
+ import { bind } from 'bind-event-listener';
5
+ import { getDocument } from '@atlaskit/browser-apis';
6
+ import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
7
+ import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
8
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
9
+ import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/types';
10
+ import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
11
+ import { BlockControlsRightSurface } from './block-controls-right-surface';
12
+ import { createBlockControlsSurfaceContext, createBlockControlsSurfaceContextForPosition } from './block-controls-surface-context';
13
+ import { getBlockControlsSurfaceTargets } from './block-controls-surface-targets';
14
+ import { getNodeContentElement } from './utils/get-node-content-element';
15
+ import { getAbsoluteSurfacePlacement, getSurfacePlacement } from './utils/get-surface-placement';
16
+ const EMPTY_SURFACE_POSITIONS = [];
17
+ const EMPTY_SURFACE_COMPONENTS = [];
18
+ /**
19
+ * Registry-backed right surface tree. Mirrors the left surface's single-tree, measured-placement
20
+ * approach, but keeps its own components lookup, targets, placements and measurement lifecycle so
21
+ * the right surface never depends on the left surface's render pass.
22
+ */
23
+ export const BlockControlsRightSurfaces = ({
24
+ api,
25
+ editorView
26
+ }) => {
27
+ var _api$uiControlRegistr, _api$uiControlRegistr2;
28
+ const {
29
+ activeNode,
30
+ surfaceNodePositions
31
+ } = useSharedPluginStateWithSelector(api, ['blockControls'], states => {
32
+ var _states$blockControls, _states$blockControls2, _states$blockControls3;
33
+ return {
34
+ activeNode: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.activeNode,
35
+ surfaceNodePositions: (_states$blockControls2 = (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : _states$blockControls3.surfaceNodePositions) !== null && _states$blockControls2 !== void 0 ? _states$blockControls2 : EMPTY_SURFACE_POSITIONS
36
+ };
37
+ });
38
+ const components = (_api$uiControlRegistr = (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : EMPTY_SURFACE_COMPONENTS;
39
+ const targets = useMemo(() => getBlockControlsSurfaceTargets(activeNode, surfaceNodePositions), [activeNode, surfaceNodePositions]);
40
+ const surfaces = useMemo(() => targets.flatMap(target => {
41
+ const context = target.source === 'stored' ? createBlockControlsSurfaceContextForPosition(editorView.state, target.position, activeNode) : createBlockControlsSurfaceContext(editorView, activeNode, target.source);
42
+ if (!context) {
43
+ return [];
44
+ }
45
+ const surfaceContext = createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, context);
46
+ return [{
47
+ ...target,
48
+ blockControlsContext: context,
49
+ surfaceContext
50
+ }];
51
+ }), [activeNode, editorView, targets]);
52
+ const [placements, setPlacements] = useState(new Map());
53
+ const animationFrameRef = useRef(undefined);
54
+ useLayoutEffect(() => {
55
+ var _getDocument;
56
+ if (surfaces.length === 0) {
57
+ setPlacements(new Map());
58
+ return;
59
+ }
60
+ const measurementTargets = surfaces.flatMap(({
61
+ blockControlsContext,
62
+ position
63
+ }) => {
64
+ const targetNodeElement = editorView.nodeDOM(blockControlsContext.targetNode.pos);
65
+ const targetElementRoot = targetNodeElement instanceof HTMLElement ? targetNodeElement : targetNodeElement === null || targetNodeElement === void 0 ? void 0 : targetNodeElement.parentElement;
66
+ if (!targetElementRoot) {
67
+ return [];
68
+ }
69
+ return [{
70
+ blockControlsContext,
71
+ position,
72
+ targetElement: getNodeContentElement(targetElementRoot, blockControlsContext.targetNode.type.name),
73
+ targetElementRoot
74
+ }];
75
+ });
76
+ const offsetParent = editorView.dom.offsetParent;
77
+ const isDocumentOffsetParent = !offsetParent || offsetParent === ((_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.body);
78
+ const scrollingOffsetParent = offsetParent instanceof HTMLElement && !isDocumentOffsetParent ? offsetParent : undefined;
79
+ const updatePositions = () => {
80
+ var _scrollingOffsetParen, _scrollingOffsetParen2;
81
+ animationFrameRef.current = undefined;
82
+ const offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
83
+ const offsetParentScrollTop = (_scrollingOffsetParen = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollTop) !== null && _scrollingOffsetParen !== void 0 ? _scrollingOffsetParen : window.scrollY;
84
+ const offsetParentScrollLeft = (_scrollingOffsetParen2 = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollLeft) !== null && _scrollingOffsetParen2 !== void 0 ? _scrollingOffsetParen2 : window.scrollX;
85
+ const nextPlacements = new Map();
86
+ for (const {
87
+ blockControlsContext,
88
+ position,
89
+ targetElement,
90
+ targetElementRoot
91
+ } of measurementTargets) {
92
+ var _targetElementRoot$ge;
93
+ if (!targetElementRoot.isConnected || !targetElement.isConnected) {
94
+ continue;
95
+ }
96
+ const placement = getSurfacePlacement({
97
+ layout: (_targetElementRoot$ge = targetElementRoot.getAttribute('layout')) !== null && _targetElementRoot$ge !== void 0 ? _targetElementRoot$ge : '',
98
+ nodeRect: targetElement.getBoundingClientRect(),
99
+ nodeType: blockControlsContext.targetNode.type.name,
100
+ nodeTypeWithLevel: getNodeTypeWithLevel(blockControlsContext.targetNode.node),
101
+ parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
102
+ side: 'right'
103
+ });
104
+ nextPlacements.set(position, getAbsoluteSurfacePlacement({
105
+ offsetParentRect,
106
+ offsetParentScrollLeft,
107
+ offsetParentScrollTop,
108
+ placement
109
+ }));
110
+ }
111
+ setPlacements(nextPlacements);
112
+ };
113
+ const schedulePositionUpdate = () => {
114
+ if (animationFrameRef.current === undefined) {
115
+ animationFrameRef.current = requestAnimationFrame(updatePositions);
116
+ }
117
+ };
118
+ updatePositions();
119
+ const resizeObserver = new ResizeObserver(schedulePositionUpdate);
120
+ const observedElements = new Set([editorView.dom]);
121
+ for (const {
122
+ targetElement
123
+ } of measurementTargets) {
124
+ observedElements.add(targetElement);
125
+ }
126
+ if (offsetParent instanceof HTMLElement) {
127
+ observedElements.add(offsetParent);
128
+ }
129
+ observedElements.forEach(element => resizeObserver.observe(element));
130
+ const unbindWindowResize = bind(window, {
131
+ type: 'resize',
132
+ listener: schedulePositionUpdate
133
+ });
134
+ const unbindWindowScroll = bind(window, {
135
+ type: 'scroll',
136
+ listener: schedulePositionUpdate,
137
+ options: {
138
+ capture: true,
139
+ passive: true
140
+ }
141
+ });
142
+ const visualViewport = window.visualViewport;
143
+ const unbindVisualViewportResize = visualViewport ? bind(visualViewport, {
144
+ type: 'resize',
145
+ listener: schedulePositionUpdate
146
+ }) : undefined;
147
+ const unbindVisualViewportScroll = visualViewport ? bind(visualViewport, {
148
+ type: 'scroll',
149
+ listener: schedulePositionUpdate
150
+ }) : undefined;
151
+ const unbindTransitionEnd = bind(editorView.dom, {
152
+ type: 'transitionend',
153
+ listener: schedulePositionUpdate,
154
+ options: {
155
+ capture: true
156
+ }
157
+ });
158
+ return () => {
159
+ if (animationFrameRef.current !== undefined) {
160
+ cancelAnimationFrame(animationFrameRef.current);
161
+ animationFrameRef.current = undefined;
162
+ }
163
+ resizeObserver.disconnect();
164
+ unbindWindowResize();
165
+ unbindWindowScroll();
166
+ unbindVisualViewportResize === null || unbindVisualViewportResize === void 0 ? void 0 : unbindVisualViewportResize();
167
+ unbindVisualViewportScroll === null || unbindVisualViewportScroll === void 0 ? void 0 : unbindVisualViewportScroll();
168
+ unbindTransitionEnd();
169
+ };
170
+ }, [editorView, surfaces]);
171
+ return /*#__PURE__*/React.createElement(React.Fragment, null, surfaces.map(({
172
+ position,
173
+ source,
174
+ surfaceContext
175
+ }) => {
176
+ var _activeNode$handleOpt;
177
+ return /*#__PURE__*/React.createElement(BlockControlsRightSurface, {
178
+ api: api,
179
+ components: components,
180
+ forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 ? void 0 : (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
181
+ key: position,
182
+ placement: placements.get(position),
183
+ source: source,
184
+ surfaceContext: surfaceContext
185
+ });
186
+ }));
187
+ };
@@ -1,5 +1,11 @@
1
- /** Combines hover-driven and stored surface positions into one deduplicated list. */
2
- export const getBlockControlsLeftSurfaceTargets = (activeNode, storedPositions) => {
1
+ /**
2
+ * Combines hover-driven and stored surface positions into one deduplicated list.
3
+ * Shared by both the left and right surfaces: this is pure position bookkeeping with no
4
+ * surface-specific behavior, so there's nothing to keep independent between them. What *is*
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.
7
+ */
8
+ export const getBlockControlsSurfaceTargets = (activeNode, storedPositions) => {
3
9
  const targetsByPosition = new Map();
4
10
  for (const position of storedPositions) {
5
11
  targetsByPosition.set(position, {
@@ -4,7 +4,7 @@ import { akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-sh
4
4
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
5
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
6
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
7
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
8
8
  export const ACTIVE_DRAG_HANDLE_ATTR = 'data-active-drag-handle';
9
9
  export const ACTIVE_QUICK_INSERT_ATTR = 'data-active-quick-insert';
10
10
  export const BLOCK_CONTROLS_SURFACE_SELECTOR = '[data-editor-block-controls-surface]';
@@ -18,6 +18,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
18
18
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
19
19
  import { akEditorFullPageNarrowBreakout, akEditorTableToolbarSize, relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/consts';
20
20
  import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
21
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
21
22
  import { fg } from '@atlaskit/platform-feature-flags/fg';
22
23
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
23
24
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/utils/set-custom-native-drag-preview';
@@ -25,7 +26,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/ut
25
26
  import { Box, xcss } from '@atlaskit/primitives';
26
27
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
27
28
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
28
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
29
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
29
30
  import Tooltip from '@atlaskit/tooltip/Tooltip';
30
31
  import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
31
32
  import { key } from '../pm-plugins/main';
@@ -960,7 +961,7 @@ export const DragHandle = ({
960
961
  }, [isReliableAnchorEnabled, calculatePositionOld, view.dom, anchorName, nodeType, docDepForReliableAnchor]);
961
962
  const isHandleShown = positionStylesOld.display !== 'none';
962
963
  useEffect(() => {
963
- if (fg('nike_r19_render_unmount')) {
964
+ if (isExperimentEnabled('platform_editor_react19_migration')) {
964
965
  return;
965
966
  }
966
967
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
@@ -975,7 +976,7 @@ export const DragHandle = ({
975
976
  }
976
977
  }, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
977
978
  useEffect(() => {
978
- if (!fg('nike_r19_render_unmount')) {
979
+ if (!isExperimentEnabled('platform_editor_react19_migration')) {
979
980
  return;
980
981
  }
981
982
  if (!(handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && isHandleShown && buttonRef.current)) {
@@ -12,7 +12,7 @@ import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indi
12
12
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
13
13
  import { layers } from '@atlaskit/theme/constants';
14
14
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
16
16
  import { getNodeAnchor } from '../pm-plugins/decorations-common';
17
17
  import { useActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
18
18
  import { isAnchorSupported } from '../pm-plugins/utils/anchor-utils';
@@ -10,7 +10,7 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
10
10
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
11
11
  import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
12
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
13
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
14
14
  import { ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME, ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME, DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
15
15
  import { NODE_ANCHOR_ATTR_NAME } from './utils/dom-attr-name';
16
16
 
@@ -14,26 +14,40 @@ export const getAbsoluteSurfacePlacement = ({
14
14
  };
15
15
 
16
16
  /**
17
- * Positions the Task 1 left surface beside the legacy drag-handle slot.
18
- * The surface's own width is handled by the transform, so later controls do not require measuring it.
17
+ * Positions the surface beside the legacy drag-handle slot, on either the left or right edge
18
+ * of the target node. Node-type-specific gap/top-adjustment maths (layouts, tables, media, cards,
19
+ * extensions, etc.) live in one place so left/right edge cases can't drift out of sync.
20
+ *
21
+ * The left side grows away from the node without knowing its own width, so it needs
22
+ * `translateX(-100%)` to anchor its right edge at `nodeRect.left` and extend backward. The right
23
+ * side grows in the normal box-flow direction (away from the node, into the margin), so the gap
24
+ * can be folded straight into `left` with no transform needed.
19
25
  */
20
26
  export const getSurfacePlacement = ({
21
27
  layout,
22
28
  nodeRect,
23
29
  nodeType,
24
30
  nodeTypeWithLevel,
25
- parentNodeType
31
+ parentNodeType,
32
+ side
26
33
  }) => {
27
34
  if (nodeType === 'layoutColumn') {
35
+ // nodeRect.left + width/2 === nodeRect.right - width/2 — side-independent.
28
36
  return {
29
37
  left: nodeRect.left + nodeRect.width / 2,
30
38
  top: nodeRect.top,
31
39
  transform: 'translate(-50%, -50%)'
32
40
  };
33
41
  }
34
- return {
42
+ const gap = dragHandleGap(nodeType, parentNodeType);
43
+ const top = nodeRect.top + topPositionAdjustment(nodeTypeWithLevel, layout);
44
+ return side === 'right' ? {
45
+ left: nodeRect.right + gap,
46
+ top,
47
+ transform: ''
48
+ } : {
35
49
  left: nodeRect.left,
36
- top: nodeRect.top + topPositionAdjustment(nodeTypeWithLevel, layout),
37
- transform: `translateX(calc(-100% - ${dragHandleGap(nodeType, parentNodeType)}px))`
50
+ top,
51
+ transform: `translateX(calc(-100% - ${gap}px))`
38
52
  };
39
53
  };
@@ -11,7 +11,7 @@ import { akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles';
11
11
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
12
12
  import { Box, xcss } from '@atlaskit/primitives';
13
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
15
15
  const RIGHT_CONTROL_HIDE_DELAY_MS = 150;
16
16
  const baseStyles = xcss({
17
17
  transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out'
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  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; }
4
4
  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; }
5
5
  import React from 'react';
6
- import { BLOCK_CONTROLS_LEFT_GROUP, BLOCK_CONTROLS_LEFT_SECTION, BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
6
+ import { BLOCK_CONTROLS_LEFT_GROUP, BLOCK_CONTROLS_LEFT_SECTION, BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_GROUP, BLOCK_CONTROLS_RIGHT_SECTION, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
7
7
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
8
8
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
9
9
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -11,7 +11,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
11
11
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
12
12
  import { fg } from '@atlaskit/platform-feature-flags/fg';
13
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
15
15
  import { handleKeyDownWithPreservedSelection } from './editor-commands/handle-key-down-with-preserved-selection';
16
16
  import { mapPreservedSelection as _mapPreservedSelection } from './editor-commands/map-preserved-selection';
17
17
  import { moveNode } from './editor-commands/move-node';
@@ -27,6 +27,7 @@ import { createSelectionPreservationPlugin } from './pm-plugins/selection-preser
27
27
  import { expandAndUpdateSelection as _expandAndUpdateSelection } from './pm-plugins/utils/expand-and-update-selection';
28
28
  import { selectNode } from './pm-plugins/utils/getSelection';
29
29
  import { BlockControlsLeftSurfaces } from './ui/block-controls-left-surfaces';
30
+ import { BlockControlsRightSurfaces } from './ui/block-controls-right-surfaces';
30
31
  import { getBlockControlsSurfaceDragHandleComponents } from './ui/block-controls-surface-drag-handle-registration';
31
32
  import { GlobalStylesWrapper } from './ui/global-styles';
32
33
  import { SurfaceEditorViewContext } from './ui/surface-editor-view-context';
@@ -40,6 +41,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
40
41
  var registryBlockControlsEnabled = isExperimentEnabled('platform_editor_block_control_migration');
41
42
  var surfaceNodePositionsEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_collapsible_headings');
42
43
  var legacyBlockControlsEnabled = !registryBlockControlsEnabled;
44
+ var rightSurfaceEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_block_control_right_surface');
43
45
  if (registryBlockControlsEnabled) {
44
46
  var _api$uiControlRegistr;
45
47
  api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register([BLOCK_CONTROLS_LEFT_SURFACE, _objectSpread(_objectSpread({}, BLOCK_CONTROLS_LEFT_SECTION), {}, {
@@ -53,6 +55,21 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
53
55
  })].concat(_toConsumableArray(getBlockControlsSurfaceDragHandleComponents({
54
56
  api: api
55
57
  }))));
58
+ if (rightSurfaceEnabled) {
59
+ var _api$uiControlRegistr2;
60
+ // The right surface host stays generic: it only registers the toolbar/section/group
61
+ // hierarchy. Individual features contribute their own buttons into
62
+ // BLOCK_CONTROLS_RIGHT_GROUP from their own plugins, same as the left surface.
63
+ api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 || _api$uiControlRegistr2.actions.register([BLOCK_CONTROLS_RIGHT_SURFACE, _objectSpread(_objectSpread({}, BLOCK_CONTROLS_RIGHT_SECTION), {}, {
64
+ parents: [_objectSpread(_objectSpread({}, BLOCK_CONTROLS_RIGHT_SURFACE), {}, {
65
+ rank: 100
66
+ })]
67
+ }), _objectSpread(_objectSpread({}, BLOCK_CONTROLS_RIGHT_GROUP), {}, {
68
+ parents: [_objectSpread(_objectSpread({}, BLOCK_CONTROLS_RIGHT_SECTION), {}, {
69
+ rank: 100
70
+ })]
71
+ })]);
72
+ }
56
73
  }
57
74
  return {
58
75
  name: 'blockControls',
@@ -122,7 +139,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
122
139
  plugin: function plugin(_ref2) {
123
140
  var getIntl = _ref2.getIntl,
124
141
  nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
125
- return createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled, surfaceNodePositionsEnabled);
142
+ return createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled, surfaceNodePositionsEnabled, rightSurfaceEnabled);
126
143
  }
127
144
  }];
128
145
  if (editorExperiment('platform_editor_controls', 'variant1')) {
@@ -450,7 +467,10 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
450
467
  }, /*#__PURE__*/React.createElement(BlockControlsLeftSurfaces, {
451
468
  api: api,
452
469
  editorView: editorView
453
- })) : null);
470
+ }), rightSurfaceEnabled ? /*#__PURE__*/React.createElement(BlockControlsRightSurfaces, {
471
+ api: api,
472
+ editorView: editorView
473
+ }) : null) : null);
454
474
  }
455
475
  };
456
476
  };
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
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
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
5
  import { DIRECTION } from '@atlaskit/editor-common/types';
6
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
7
7
  import { key } from '../pm-plugins/main';
8
8
  import { mapPreservedSelection } from '../pm-plugins/utils/selection';
9
9
  import { moveNode } from './move-node';
@@ -17,7 +17,7 @@ import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/u
17
17
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
18
18
  import { fg } from '@atlaskit/platform-feature-flags/fg';
19
19
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
20
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
21
21
  import { key } from '../pm-plugins/main';
22
22
  import { attachMoveNodeAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
23
23
  import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition';
@@ -1,6 +1,6 @@
1
1
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
3
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
4
4
  import { createPreservedSelection } from '../../pm-plugins/utils/selection';
5
5
 
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
5
5
  import { getNodeAnchor, getNodeTypeWithLevel, NESTED_DEPTH, TYPE_NODE_DEC } from './decorations-common';
6
6
  var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
7
7
  export var IGNORE_NODES_NEXT = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'];
@@ -5,7 +5,7 @@ import uuid from 'uuid';
5
5
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
6
  import { fg } from '@atlaskit/platform-feature-flags/fg';
7
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
9
9
  import { ACTIVE_DRAG_HANDLE_ATTR } from '../ui/consts';
10
10
  import { DragHandle, DragHandleWithVisibility } from '../ui/drag-handle';
11
11
  import { TYPE_HANDLE_DEC, TYPE_NODE_DEC, unmountDecorations } from './decorations-common';
@@ -5,7 +5,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
5
  import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
6
6
  import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
9
9
  import { getNodeAnchor } from './decorations-common';
10
10
  import { createDropTargetDecoration, createLayoutDropTargetDecoration } from './decorations-drop-target';
11
11
  import { findSurroundingNodes } from './decorations-find-surrounding-nodes';
@@ -11,7 +11,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
11
11
  import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
12
12
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
13
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
15
15
  import { nodeMargins } from '../ui/consts';
16
16
  import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
17
17
  import { DropTargetLayout, DropTargetLayoutNativeAnchorSupport } from '../ui/drop-target-layout';
@@ -5,7 +5,7 @@ import uuid from 'uuid';
5
5
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
6
  import { fg } from '@atlaskit/platform-feature-flags/fg';
7
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
9
9
  import { ACTIVE_QUICK_INSERT_ATTR } from '../ui/consts';
10
10
  import { QuickInsertWithVisibility } from '../ui/quick-insert-button';
11
11
  import { getMatchingBlockMarks } from './utils/marks';
@@ -1,6 +1,6 @@
1
1
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
2
2
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
4
4
  export var handleMouseDown = function handleMouseDown(api) {
5
5
  return function (view, event) {
6
6
  if (!(event.target instanceof HTMLElement)) {
@@ -5,7 +5,7 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
5
5
  import { fg } from '@atlaskit/platform-feature-flags/fg';
6
6
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
7
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
9
9
  import { getAnchorAttrName, getTypeNameAttrName, getTypeNameFromDom, NODE_ANCHOR_ATTR_NAME } from '../ui/utils/dom-attr-name';
10
10
  import { IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT, IGNORE_NODES_NEXT } from './decorations-anchor';
11
11
  import { selectionPreservationPluginKey } from './selection-preservation/plugin-key';
@@ -7,7 +7,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
8
  import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
9
9
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
10
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
11
11
  import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
12
12
  import { handleKeyDown } from './handle-key-down';
13
13
  import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  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; } } }; }
3
4
  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; } }
@@ -7,7 +8,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
8
  import rafSchedule from 'raf-schd';
8
9
  import { getDocument } from '@atlaskit/browser-apis';
9
10
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
10
- import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
11
+ import { BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
11
12
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
12
13
  import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor';
13
14
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
@@ -24,7 +25,7 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
24
25
  import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
25
26
  import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
26
27
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
27
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
28
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
28
29
  import { BLOCK_CONTROLS_SURFACE_SELECTOR } from '../ui/consts';
29
30
  import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
30
31
  import { findNodeDecs, nodeDecorations } from './decorations-anchor';
@@ -239,7 +240,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
239
240
  var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
240
241
  var resizeObserverWidth = arguments.length > 11 ? arguments[11] : undefined;
241
242
  var pragmaticCleanup = arguments.length > 12 ? arguments[12] : undefined;
242
- var resolvedSurface = arguments.length > 13 ? arguments[13] : undefined;
243
+ var resolvedSurfaces = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : [];
243
244
  var activeNode = currentState.activeNode,
244
245
  decorations = currentState.decorations,
245
246
  isResizerResizing = currentState.isResizerResizing,
@@ -810,14 +811,14 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
810
811
  var _latestActiveNode13, _latestActiveNode14;
811
812
  newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && flags.legacyDragHandleEnabled && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
812
813
  }
813
- if (flags.surfaceNodePositionsEnabled && resolvedSurface) {
814
+ if (flags.surfaceNodePositionsEnabled && resolvedSurfaces.length > 0) {
814
815
  surfaceNodePositions = updateSurfaceNodePositions({
815
816
  activeNode: newActiveNode,
816
817
  currentPositions: surfaceNodePositions,
817
818
  from: from,
818
819
  newState: newState,
819
820
  previousActiveNode: previousActiveNode,
820
- resolvedSurface: resolvedSurface,
821
+ resolvedSurfaces: resolvedSurfaces,
821
822
  to: to,
822
823
  tr: tr
823
824
  });
@@ -867,11 +868,12 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
867
868
  };
868
869
  export { _apply as apply };
869
870
  export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
870
- var _api$uiControlRegistr, _api$uiControlRegistr2;
871
+ var _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
871
872
  var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
872
873
  var quickInsertButtonEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
873
874
  var legacyDragHandleEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
874
875
  var surfaceNodePositionsEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
876
+ var rightSurfaceEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
875
877
  var _getIntl = getIntl(),
876
878
  formatMessage = _getIntl.formatMessage;
877
879
  var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
@@ -883,7 +885,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
883
885
  surfaceNodePositionsEnabled: surfaceNodePositionsEnabled,
884
886
  toolbarFlagsEnabled: toolbarFlagsEnabled
885
887
  };
886
- var resolvedSurface = surfaceNodePositionsEnabled ? resolveSurface((_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [], BLOCK_CONTROLS_LEFT_SURFACE) : undefined;
888
+ var resolvedSurfaces = surfaceNodePositionsEnabled ? [resolveSurface((_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [], BLOCK_CONTROLS_LEFT_SURFACE)].concat(_toConsumableArray(rightSurfaceEnabled ? [resolveSurface((_api$uiControlRegistr3 = api === null || api === void 0 || (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [], BLOCK_CONTROLS_RIGHT_SURFACE)] : [])) : [];
887
889
  var anchorRectCache;
888
890
  if (!isAnchorSupported()) {
889
891
  anchorRectCache = new AnchorRectCache();
@@ -895,11 +897,11 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
895
897
  state: {
896
898
  init: function init(_config, editorState) {
897
899
  return _objectSpread(_objectSpread({}, initialState), {}, {
898
- surfaceNodePositions: resolvedSurface ? getSurfaceNodePositions(editorState, resolvedSurface) : []
900
+ surfaceNodePositions: resolvedSurfaces.length > 0 ? getSurfaceNodePositions(editorState, resolvedSurfaces) : []
899
901
  });
900
902
  },
901
903
  apply: function apply(tr, currentState, _, newState) {
902
- return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurface);
904
+ return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces);
903
905
  }
904
906
  },
905
907
  props: {