@atlaskit/editor-plugin-block-controls 17.3.8 → 17.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/cjs/blockControlsPlugin.js +2 -3
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -6
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +5 -2
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/ui/block-controls-left-surface.js +25 -8
- package/dist/cjs/ui/block-controls-right-surface.js +21 -7
- package/dist/cjs/ui/block-controls-surface-context.js +4 -1
- package/dist/cjs/ui/consts.js +13 -5
- package/dist/cjs/ui/utils/partition-components-by-persistence.js +65 -0
- package/dist/cjs/ui/visibility-container.js +6 -2
- package/dist/es2019/blockControlsPlugin.js +2 -3
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +6 -3
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +3 -2
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/ui/block-controls-left-surface.js +26 -8
- package/dist/es2019/ui/block-controls-right-surface.js +22 -7
- package/dist/es2019/ui/block-controls-surface-context.js +1 -0
- package/dist/es2019/ui/consts.js +10 -4
- package/dist/es2019/ui/utils/partition-components-by-persistence.js +48 -0
- package/dist/es2019/ui/visibility-container.js +6 -2
- package/dist/esm/blockControlsPlugin.js +2 -3
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -6
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +5 -2
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/ui/block-controls-left-surface.js +25 -8
- package/dist/esm/ui/block-controls-right-surface.js +21 -7
- package/dist/esm/ui/block-controls-surface-context.js +3 -0
- package/dist/esm/ui/consts.js +12 -4
- package/dist/esm/ui/utils/partition-components-by-persistence.js +59 -0
- package/dist/esm/ui/visibility-container.js +6 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/ui/block-controls-surface-context.d.ts +1 -0
- package/dist/types/ui/consts.d.ts +0 -1
- package/dist/types/ui/utils/partition-components-by-persistence.d.ts +15 -0
- package/dist/types/ui/visibility-container.d.ts +2 -1
- package/package.json +5 -5
|
@@ -4,6 +4,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
6
6
|
import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
7
|
+
import { partitionComponentsByPersistence } from './utils/partition-components-by-persistence';
|
|
7
8
|
import { VisibilityContainer } from './visibility-container';
|
|
8
9
|
const rightSurfaceOuterStyles = null;
|
|
9
10
|
const rightSurfaceRowStyles = null;
|
|
@@ -25,11 +26,12 @@ export const BlockControlsRightSurface = ({
|
|
|
25
26
|
if (!placement || !willSurfaceRender(components, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext)) {
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const {
|
|
30
|
+
hoverOnlyComponents,
|
|
31
|
+
persistentComponents
|
|
32
|
+
} = partitionComponentsByPersistence(components, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
33
|
+
const willRenderPersistent = willSurfaceRender(persistentComponents, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
34
|
+
const willRenderHoverOnly = willSurfaceRender(hoverOnlyComponents, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
33
35
|
const isSticky = placement.height !== undefined;
|
|
34
36
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
37
|
"data-editor-block-controls-surface": true,
|
|
@@ -40,10 +42,23 @@ export const BlockControlsRightSurface = ({
|
|
|
40
42
|
className: ax(["_kqswstnw _1pbyb4wl"])
|
|
41
43
|
}, /*#__PURE__*/React.createElement("div", {
|
|
42
44
|
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
43
|
-
}, /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
45
|
+
}, willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
46
|
+
api: api,
|
|
47
|
+
controlSide: "right",
|
|
48
|
+
isPersistent: true,
|
|
49
|
+
shouldUseDisplayContents: true
|
|
50
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
51
|
+
components: persistentComponents,
|
|
52
|
+
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
53
|
+
surfaceContext: surfaceContext
|
|
54
|
+
})), willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
44
55
|
api: api,
|
|
45
56
|
controlSide: "right",
|
|
46
57
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
47
58
|
shouldUseDisplayContents: true
|
|
48
|
-
},
|
|
59
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
60
|
+
components: hoverOnlyComponents,
|
|
61
|
+
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
62
|
+
surfaceContext: surfaceContext
|
|
63
|
+
}))));
|
|
49
64
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const getBlockControlsSurfaceControlSide = (context, reliableAnchorEnabled) => (context === null || context === void 0 ? void 0 : context.targetNode.type.name) === 'layoutColumn' || Boolean(context) && reliableAnchorEnabled && (context === null || context === void 0 ? void 0 : context.targetNode.parentType) !== 'doc' ? undefined : 'left';
|
|
1
2
|
const getNodeContext = (state, pos) => {
|
|
2
3
|
const node = state.doc.nodeAt(pos);
|
|
3
4
|
if (!node) {
|
package/dist/es2019/ui/consts.js
CHANGED
|
@@ -13,11 +13,17 @@ export const ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = '--editor-block-controls
|
|
|
13
13
|
export const DRAG_HANDLE_HEIGHT = 24;
|
|
14
14
|
export const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
15
15
|
export const DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
|
|
16
|
-
|
|
16
|
+
const LEGACY_DRAG_HANDLE_DEFAULT_GAP = 8;
|
|
17
|
+
const MIGRATED_DRAG_HANDLE_DEFAULT_GAP = 12;
|
|
17
18
|
export const DRAG_HANDLE_NARROW_GAP = 4;
|
|
18
19
|
export const DRAG_HANDLE_MAX_GAP = 12;
|
|
19
20
|
export const DRAG_HANDLE_SYNCED_BLOCK_GAP = 2.5;
|
|
20
21
|
export const DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = DRAG_HANDLE_WIDTH + DRAG_HANDLE_MAX_GAP;
|
|
22
|
+
|
|
23
|
+
// Non-resizable/default-sized nodes get the same gap as resizable/breakout nodes
|
|
24
|
+
// (DRAG_HANDLE_MAX_GAP) once the registry-backed surfaces are on; kept at the legacy value
|
|
25
|
+
// otherwise to avoid an unrelated visual change for consumers still on the old decoration path.
|
|
26
|
+
const getDragHandleDefaultGap = () => isExperimentEnabled('platform_editor_block_control_migration') ? MIGRATED_DRAG_HANDLE_DEFAULT_GAP : LEGACY_DRAG_HANDLE_DEFAULT_GAP;
|
|
21
27
|
export const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = 4 + 2; // 4px for the divider vertical padding and 2px for the divider height
|
|
22
28
|
export const DRAG_HANDLE_H1_TOP_ADJUSTMENT = 5;
|
|
23
29
|
export const DRAG_HANDLE_H2_TOP_ADJUSTMENT = 2;
|
|
@@ -68,12 +74,12 @@ export const dragHandleGap = (nodeType, parentNodeType) => {
|
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
if (nodeType === 'layoutSection') {
|
|
71
|
-
return
|
|
77
|
+
return getDragHandleDefaultGap() + 20;
|
|
72
78
|
}
|
|
73
79
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
74
80
|
return DRAG_HANDLE_MAX_GAP;
|
|
75
81
|
}
|
|
76
|
-
return
|
|
82
|
+
return getDragHandleDefaultGap();
|
|
77
83
|
};
|
|
78
84
|
|
|
79
85
|
// use for returning gap only for root level elements
|
|
@@ -94,7 +100,7 @@ export const rootElementGap = nodeType => {
|
|
|
94
100
|
if (nodeType === 'layoutSection') {
|
|
95
101
|
return DRAG_HANDLE_MAX_GAP + 12;
|
|
96
102
|
}
|
|
97
|
-
return
|
|
103
|
+
return getDragHandleDefaultGap();
|
|
98
104
|
};
|
|
99
105
|
export const getNestedNodeLeftPaddingMargin = nodeType => {
|
|
100
106
|
switch (nodeType) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
2
|
+
import { getComponentIdentity, resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
3
|
+
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/create-surface-context';
|
|
4
|
+
/**
|
|
5
|
+
* Split registered components into two groups:
|
|
6
|
+
* those that should be rendered persistently and those that should only be rendered on hover.
|
|
7
|
+
*/
|
|
8
|
+
export const partitionComponentsByPersistence = (components, surface, surfaceContext) => {
|
|
9
|
+
const {
|
|
10
|
+
childrenMap,
|
|
11
|
+
root,
|
|
12
|
+
topLevelChildren
|
|
13
|
+
} = resolveSurface(components, surface);
|
|
14
|
+
if (!root || !topLevelChildren || topLevelChildren.length === 0) {
|
|
15
|
+
return {
|
|
16
|
+
hoverOnlyComponents: [],
|
|
17
|
+
persistentComponents: components
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
21
|
+
const storedSurfaceContext = context ? createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, {
|
|
22
|
+
activeNode: undefined,
|
|
23
|
+
rootNode: context.targetNode,
|
|
24
|
+
targetNode: context.targetNode
|
|
25
|
+
}) : undefined;
|
|
26
|
+
const isLeaf = component => {
|
|
27
|
+
const children = childrenMap.get(getComponentIdentity(component));
|
|
28
|
+
return !children || children.length === 0;
|
|
29
|
+
};
|
|
30
|
+
const persistentComponents = [];
|
|
31
|
+
const hoverOnlyComponents = [];
|
|
32
|
+
for (const component of components) {
|
|
33
|
+
if (!isLeaf(component)) {
|
|
34
|
+
persistentComponents.push(component);
|
|
35
|
+
hoverOnlyComponents.push(component);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (willComponentRender(component, childrenMap, storedSurfaceContext)) {
|
|
39
|
+
persistentComponents.push(component);
|
|
40
|
+
} else {
|
|
41
|
+
hoverOnlyComponents.push(component);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
hoverOnlyComponents,
|
|
46
|
+
persistentComponents
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -51,6 +51,7 @@ export const VisibilityContainer = ({
|
|
|
51
51
|
children,
|
|
52
52
|
controlSide,
|
|
53
53
|
forceVisibleOnMouseOut,
|
|
54
|
+
isPersistent,
|
|
54
55
|
shouldUseDisplayContents
|
|
55
56
|
}) => {
|
|
56
57
|
const {
|
|
@@ -90,9 +91,12 @@ export const VisibilityContainer = ({
|
|
|
90
91
|
// When forceVisibleOnMouseOut is true (e.g. drag handle focused via keyboard Shift+Ctrl+H),
|
|
91
92
|
// override the mouse-out condition so the control stays visible regardless of mouse position.
|
|
92
93
|
const shouldHideWhenMouseOut = forceVisibleOnMouseOut ? false : hideOnMouseOut;
|
|
93
|
-
|
|
94
|
+
// Persistent controls (e.g. an AI suggestion icon on every qualifying node) aren't hover-driven,
|
|
95
|
+
// so none of the hover/typing/mouse-out/diff-review reasons below apply to them — they're never
|
|
96
|
+
// hidden by this container.
|
|
97
|
+
const shouldHideImmediate = !isPersistent && (isTypeAheadOpen || isEditing || shouldHideWhenMouseOut || userIntent === 'aiStreaming' ||
|
|
94
98
|
// EDITOR-7926: hide the drag handle while a diff is on screen or a suggestion card is open.
|
|
95
|
-
(isDisplayingDiff || userIntent === 'reviewing') && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || sideHidden;
|
|
99
|
+
(isDisplayingDiff || userIntent === 'reviewing') && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || sideHidden);
|
|
96
100
|
|
|
97
101
|
// Delay hiding the right control in view mode to reduce flickering when moving from block
|
|
98
102
|
// toward the right-edge button (avoids rapid show/hide as mouse crosses boundaries).
|
|
@@ -39,7 +39,6 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
39
39
|
var rightSideControlsEnabled = (_config$rightSideCont = config === null || config === void 0 ? void 0 : config.rightSideControlsEnabled) !== null && _config$rightSideCont !== void 0 ? _config$rightSideCont : false;
|
|
40
40
|
var quickInsertButtonEnabled = (_config$quickInsertBu = config === null || config === void 0 ? void 0 : config.quickInsertButtonEnabled) !== null && _config$quickInsertBu !== void 0 ? _config$quickInsertBu : true;
|
|
41
41
|
var registryBlockControlsEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
42
|
-
var surfaceNodePositionsEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_collapsible_headings');
|
|
43
42
|
var legacyBlockControlsEnabled = !registryBlockControlsEnabled;
|
|
44
43
|
var rightSurfaceEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_block_control_right_surface');
|
|
45
44
|
if (registryBlockControlsEnabled) {
|
|
@@ -139,7 +138,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
139
138
|
plugin: function plugin(_ref2) {
|
|
140
139
|
var getIntl = _ref2.getIntl,
|
|
141
140
|
nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
|
|
142
|
-
return createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled,
|
|
141
|
+
return createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled, rightSurfaceEnabled);
|
|
143
142
|
}
|
|
144
143
|
}];
|
|
145
144
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
@@ -441,7 +440,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
441
440
|
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
442
441
|
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState10 = key.getState(editorState)) === null || _key$getState10 === void 0 ? void 0 : _key$getState10.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
443
442
|
};
|
|
444
|
-
if (
|
|
443
|
+
if (registryBlockControlsEnabled) {
|
|
445
444
|
var _key$getState$surface, _key$getState11;
|
|
446
445
|
sharedState.surfaceNodePositions = (_key$getState$surface = (_key$getState11 = key.getState(editorState)) === null || _key$getState11 === void 0 ? void 0 : _key$getState11.surfaceNodePositions) !== null && _key$getState$surface !== void 0 ? _key$getState$surface : [];
|
|
447
446
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
2
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
3
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
4
5
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
5
6
|
import { handleMouseOver } from '../handle-mouse-over';
|
|
6
7
|
import { clearHoverSide, mouseEnter, mouseLeave, setHoverSide, stopEditing } from './commands';
|
|
@@ -25,6 +26,10 @@ var clearPendingHoverSide = function clearPendingHoverSide(view) {
|
|
|
25
26
|
};
|
|
26
27
|
var BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
|
|
27
28
|
var RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
|
|
29
|
+
var LEGACY_LEFT_CONTROL_SELECTOR = '[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
|
|
30
|
+
var getLeftControlSelector = function getLeftControlSelector() {
|
|
31
|
+
return isExperimentEnabled('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_LEFT_CONTROL_SELECTOR) : LEGACY_LEFT_CONTROL_SELECTOR;
|
|
32
|
+
};
|
|
28
33
|
|
|
29
34
|
// Top-level blocks (no block ancestor), matched by anchor attribute so it works under both the
|
|
30
35
|
// legacy and native-anchor schemes.
|
|
@@ -123,7 +128,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
123
128
|
}
|
|
124
129
|
return;
|
|
125
130
|
}
|
|
126
|
-
var leftControlElement = target === null || target === void 0 ? void 0 : target.closest(
|
|
131
|
+
var leftControlElement = target === null || target === void 0 ? void 0 : target.closest(getLeftControlSelector());
|
|
127
132
|
if (leftControlElement) {
|
|
128
133
|
if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'left') {
|
|
129
134
|
setHoverSide(view, 'left');
|
|
@@ -181,9 +186,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
181
186
|
setHoverSide(view, nextHoverSide);
|
|
182
187
|
}
|
|
183
188
|
};
|
|
184
|
-
export var handleMouseMove = function handleMouseMove(view, event) {
|
|
185
|
-
var rightSideControlsEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
186
|
-
var api = arguments.length > 3 ? arguments[3] : undefined;
|
|
189
|
+
export var handleMouseMove = function handleMouseMove(view, event, rightSideControlsEnabled, api) {
|
|
187
190
|
var state = getInteractionTrackingState(view.state);
|
|
188
191
|
// if user has stopped editing and moved their mouse, show block controls again
|
|
189
192
|
if (state !== null && state !== void 0 && state.isEditing) {
|
|
@@ -205,8 +208,7 @@ export var handleMouseMove = function handleMouseMove(view, event) {
|
|
|
205
208
|
rafIdByView.set(view, id);
|
|
206
209
|
return false;
|
|
207
210
|
};
|
|
208
|
-
export var handleMouseLeave = function handleMouseLeave(view) {
|
|
209
|
-
var rightSideControlsEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
211
|
+
export var handleMouseLeave = function handleMouseLeave(view, rightSideControlsEnabled) {
|
|
210
212
|
if (rightSideControlsEnabled) {
|
|
211
213
|
clearPendingHoverSide(view);
|
|
212
214
|
}
|
|
@@ -13,13 +13,16 @@ import { handleKeyDown } from './handle-key-down';
|
|
|
13
13
|
import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
|
|
14
14
|
|
|
15
15
|
/** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
|
|
16
|
-
var
|
|
16
|
+
var LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
|
|
17
|
+
var getBlockControlsHoverAreaSelector = function getBlockControlsHoverAreaSelector() {
|
|
18
|
+
return isExperimentEnabled('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR) : LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR;
|
|
19
|
+
};
|
|
17
20
|
var MOUSE_LEAVE_DEBOUNCE_MS = 200;
|
|
18
21
|
|
|
19
22
|
/** ClickAreaBlock overlay that wraps the editor content and covers the right margin. */
|
|
20
23
|
var CLICK_AREA_SELECTOR = '[data-editor-click-wrapper]';
|
|
21
24
|
var isMovingToBlockControlsArea = function isMovingToBlockControlsArea(target) {
|
|
22
|
-
return target instanceof Element && !!target.closest(
|
|
25
|
+
return target instanceof Element && !!target.closest(getBlockControlsHoverAreaSelector());
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -884,14 +884,16 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
884
884
|
var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
885
885
|
var quickInsertButtonEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
886
886
|
var legacyDragHandleEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
|
|
887
|
-
var
|
|
888
|
-
var rightSurfaceEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
887
|
+
var rightSurfaceEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
889
888
|
var _getIntl = getIntl(),
|
|
890
889
|
formatMessage = _getIntl.formatMessage;
|
|
891
890
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
892
891
|
exposure: true
|
|
893
892
|
});
|
|
894
893
|
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
894
|
+
// Mirrors `registryBlockControlsEnabled` in blockControlsPlugin.tsx: `legacyDragHandleEnabled` is
|
|
895
|
+
// only false once that gate is on.
|
|
896
|
+
var surfaceNodePositionsEnabled = !legacyDragHandleEnabled;
|
|
895
897
|
var flags = {
|
|
896
898
|
legacyDragHandleEnabled: legacyDragHandleEnabled,
|
|
897
899
|
surfaceNodePositionsEnabled: surfaceNodePositionsEnabled,
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
import "./block-controls-left-surface.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
5
6
|
import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
6
7
|
import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
|
+
import { getBlockControlsSurfaceControlSide } from './block-controls-surface-context';
|
|
10
|
+
import { partitionComponentsByPersistence } from './utils/partition-components-by-persistence';
|
|
7
11
|
import { VisibilityContainer } from './visibility-container';
|
|
8
12
|
var leftSurfaceOuterStyles = null;
|
|
9
13
|
var leftSurfaceRowStyles = null;
|
|
@@ -24,11 +28,11 @@ export var BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref) {
|
|
|
24
28
|
if (!placement || !willSurfaceRender(components, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext)) {
|
|
25
29
|
return null;
|
|
26
30
|
}
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
var _partitionComponentsB = partitionComponentsByPersistence(components, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext),
|
|
32
|
+
hoverOnlyComponents = _partitionComponentsB.hoverOnlyComponents,
|
|
33
|
+
persistentComponents = _partitionComponentsB.persistentComponents;
|
|
34
|
+
var willRenderPersistent = willSurfaceRender(persistentComponents, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext);
|
|
35
|
+
var willRenderHoverOnly = willSurfaceRender(hoverOnlyComponents, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext);
|
|
32
36
|
var isSticky = placement.height !== undefined;
|
|
33
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
38
|
"data-editor-block-controls-surface": true,
|
|
@@ -39,10 +43,23 @@ export var BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref) {
|
|
|
39
43
|
className: ax(["_kqswstnw _1pbyb4wl"])
|
|
40
44
|
}, /*#__PURE__*/React.createElement("div", {
|
|
41
45
|
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
42
|
-
}, /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
46
|
+
}, willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
43
47
|
api: api,
|
|
44
|
-
controlSide:
|
|
48
|
+
controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
|
|
45
49
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
46
50
|
shouldUseDisplayContents: true
|
|
47
|
-
},
|
|
51
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
52
|
+
components: persistentComponents,
|
|
53
|
+
surface: BLOCK_CONTROLS_LEFT_SURFACE,
|
|
54
|
+
surfaceContext: surfaceContext
|
|
55
|
+
})), willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
56
|
+
api: api,
|
|
57
|
+
controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
|
|
58
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
59
|
+
shouldUseDisplayContents: true
|
|
60
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
61
|
+
components: hoverOnlyComponents,
|
|
62
|
+
surface: BLOCK_CONTROLS_LEFT_SURFACE,
|
|
63
|
+
surfaceContext: surfaceContext
|
|
64
|
+
}))));
|
|
48
65
|
};
|
|
@@ -4,6 +4,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
6
6
|
import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
7
|
+
import { partitionComponentsByPersistence } from './utils/partition-components-by-persistence';
|
|
7
8
|
import { VisibilityContainer } from './visibility-container';
|
|
8
9
|
var rightSurfaceOuterStyles = null;
|
|
9
10
|
var rightSurfaceRowStyles = null;
|
|
@@ -24,11 +25,11 @@ export var BlockControlsRightSurface = function BlockControlsRightSurface(_ref)
|
|
|
24
25
|
if (!placement || !willSurfaceRender(components, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext)) {
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
var _partitionComponentsB = partitionComponentsByPersistence(components, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext),
|
|
29
|
+
hoverOnlyComponents = _partitionComponentsB.hoverOnlyComponents,
|
|
30
|
+
persistentComponents = _partitionComponentsB.persistentComponents;
|
|
31
|
+
var willRenderPersistent = willSurfaceRender(persistentComponents, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
32
|
+
var willRenderHoverOnly = willSurfaceRender(hoverOnlyComponents, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
32
33
|
var isSticky = placement.height !== undefined;
|
|
33
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
35
|
"data-editor-block-controls-surface": true,
|
|
@@ -39,10 +40,23 @@ export var BlockControlsRightSurface = function BlockControlsRightSurface(_ref)
|
|
|
39
40
|
className: ax(["_kqswstnw _1pbyb4wl"])
|
|
40
41
|
}, /*#__PURE__*/React.createElement("div", {
|
|
41
42
|
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
42
|
-
}, /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
43
|
+
}, willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
44
|
+
api: api,
|
|
45
|
+
controlSide: "right",
|
|
46
|
+
isPersistent: true,
|
|
47
|
+
shouldUseDisplayContents: true
|
|
48
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
49
|
+
components: persistentComponents,
|
|
50
|
+
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
51
|
+
surfaceContext: surfaceContext
|
|
52
|
+
})), willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
43
53
|
api: api,
|
|
44
54
|
controlSide: "right",
|
|
45
55
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
46
56
|
shouldUseDisplayContents: true
|
|
47
|
-
},
|
|
57
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
58
|
+
components: hoverOnlyComponents,
|
|
59
|
+
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
60
|
+
surfaceContext: surfaceContext
|
|
61
|
+
}))));
|
|
48
62
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
export var getBlockControlsSurfaceControlSide = function getBlockControlsSurfaceControlSide(context, reliableAnchorEnabled) {
|
|
5
|
+
return (context === null || context === void 0 ? void 0 : context.targetNode.type.name) === 'layoutColumn' || Boolean(context) && reliableAnchorEnabled && (context === null || context === void 0 ? void 0 : context.targetNode.parentType) !== 'doc' ? undefined : 'left';
|
|
6
|
+
};
|
|
4
7
|
var getNodeContext = function getNodeContext(state, pos) {
|
|
5
8
|
var node = state.doc.nodeAt(pos);
|
|
6
9
|
if (!node) {
|
package/dist/esm/ui/consts.js
CHANGED
|
@@ -16,11 +16,19 @@ export var ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = '--editor-block-controls-a
|
|
|
16
16
|
export var DRAG_HANDLE_HEIGHT = 24;
|
|
17
17
|
export var DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
18
18
|
export var DRAG_HANDLE_ZINDEX = akRichMediaResizeZIndex + akEditorUnitZIndex; //place above legacy resizer
|
|
19
|
-
|
|
19
|
+
var LEGACY_DRAG_HANDLE_DEFAULT_GAP = 8;
|
|
20
|
+
var MIGRATED_DRAG_HANDLE_DEFAULT_GAP = 12;
|
|
20
21
|
export var DRAG_HANDLE_NARROW_GAP = 4;
|
|
21
22
|
export var DRAG_HANDLE_MAX_GAP = 12;
|
|
22
23
|
export var DRAG_HANDLE_SYNCED_BLOCK_GAP = 2.5;
|
|
23
24
|
export var DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = DRAG_HANDLE_WIDTH + DRAG_HANDLE_MAX_GAP;
|
|
25
|
+
|
|
26
|
+
// Non-resizable/default-sized nodes get the same gap as resizable/breakout nodes
|
|
27
|
+
// (DRAG_HANDLE_MAX_GAP) once the registry-backed surfaces are on; kept at the legacy value
|
|
28
|
+
// otherwise to avoid an unrelated visual change for consumers still on the old decoration path.
|
|
29
|
+
var getDragHandleDefaultGap = function getDragHandleDefaultGap() {
|
|
30
|
+
return isExperimentEnabled('platform_editor_block_control_migration') ? MIGRATED_DRAG_HANDLE_DEFAULT_GAP : LEGACY_DRAG_HANDLE_DEFAULT_GAP;
|
|
31
|
+
};
|
|
24
32
|
export var DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = 4 + 2; // 4px for the divider vertical padding and 2px for the divider height
|
|
25
33
|
export var DRAG_HANDLE_H1_TOP_ADJUSTMENT = 5;
|
|
26
34
|
export var DRAG_HANDLE_H2_TOP_ADJUSTMENT = 2;
|
|
@@ -71,12 +79,12 @@ export var dragHandleGap = function dragHandleGap(nodeType, parentNodeType) {
|
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
81
|
if (nodeType === 'layoutSection') {
|
|
74
|
-
return
|
|
82
|
+
return getDragHandleDefaultGap() + 20;
|
|
75
83
|
}
|
|
76
84
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
77
85
|
return DRAG_HANDLE_MAX_GAP;
|
|
78
86
|
}
|
|
79
|
-
return
|
|
87
|
+
return getDragHandleDefaultGap();
|
|
80
88
|
};
|
|
81
89
|
|
|
82
90
|
// use for returning gap only for root level elements
|
|
@@ -97,7 +105,7 @@ export var rootElementGap = function rootElementGap(nodeType) {
|
|
|
97
105
|
if (nodeType === 'layoutSection') {
|
|
98
106
|
return DRAG_HANDLE_MAX_GAP + 12;
|
|
99
107
|
}
|
|
100
|
-
return
|
|
108
|
+
return getDragHandleDefaultGap();
|
|
101
109
|
};
|
|
102
110
|
export var getNestedNodeLeftPaddingMargin = function getNestedNodeLeftPaddingMargin(nodeType) {
|
|
103
111
|
switch (nodeType) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
5
|
+
import { getComponentIdentity, resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
6
|
+
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/create-surface-context';
|
|
7
|
+
/**
|
|
8
|
+
* Split registered components into two groups:
|
|
9
|
+
* those that should be rendered persistently and those that should only be rendered on hover.
|
|
10
|
+
*/
|
|
11
|
+
export var partitionComponentsByPersistence = function partitionComponentsByPersistence(components, surface, surfaceContext) {
|
|
12
|
+
var _resolveSurface = resolveSurface(components, surface),
|
|
13
|
+
childrenMap = _resolveSurface.childrenMap,
|
|
14
|
+
root = _resolveSurface.root,
|
|
15
|
+
topLevelChildren = _resolveSurface.topLevelChildren;
|
|
16
|
+
if (!root || !topLevelChildren || topLevelChildren.length === 0) {
|
|
17
|
+
return {
|
|
18
|
+
hoverOnlyComponents: [],
|
|
19
|
+
persistentComponents: components
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
23
|
+
var storedSurfaceContext = context ? createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, {
|
|
24
|
+
activeNode: undefined,
|
|
25
|
+
rootNode: context.targetNode,
|
|
26
|
+
targetNode: context.targetNode
|
|
27
|
+
}) : undefined;
|
|
28
|
+
var isLeaf = function isLeaf(component) {
|
|
29
|
+
var children = childrenMap.get(getComponentIdentity(component));
|
|
30
|
+
return !children || children.length === 0;
|
|
31
|
+
};
|
|
32
|
+
var persistentComponents = [];
|
|
33
|
+
var hoverOnlyComponents = [];
|
|
34
|
+
var _iterator = _createForOfIteratorHelper(components),
|
|
35
|
+
_step;
|
|
36
|
+
try {
|
|
37
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
+
var component = _step.value;
|
|
39
|
+
if (!isLeaf(component)) {
|
|
40
|
+
persistentComponents.push(component);
|
|
41
|
+
hoverOnlyComponents.push(component);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (willComponentRender(component, childrenMap, storedSurfaceContext)) {
|
|
45
|
+
persistentComponents.push(component);
|
|
46
|
+
} else {
|
|
47
|
+
hoverOnlyComponents.push(component);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_iterator.e(err);
|
|
52
|
+
} finally {
|
|
53
|
+
_iterator.f();
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
hoverOnlyComponents: hoverOnlyComponents,
|
|
57
|
+
persistentComponents: persistentComponents
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -51,6 +51,7 @@ export var VisibilityContainer = function VisibilityContainer(_ref) {
|
|
|
51
51
|
children = _ref.children,
|
|
52
52
|
controlSide = _ref.controlSide,
|
|
53
53
|
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
54
|
+
isPersistent = _ref.isPersistent,
|
|
54
55
|
shouldUseDisplayContents = _ref.shouldUseDisplayContents;
|
|
55
56
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['typeAhead', 'blockControls', 'editorViewMode', 'userIntent', 'showDiff'], function (states) {
|
|
56
57
|
var _states$typeAheadStat, _states$blockControls, _states$blockControls2, _states$blockControls3, _states$editorViewMod, _states$userIntentSta, _states$showDiffState, _states$blockControls4;
|
|
@@ -88,9 +89,12 @@ export var VisibilityContainer = function VisibilityContainer(_ref) {
|
|
|
88
89
|
// When forceVisibleOnMouseOut is true (e.g. drag handle focused via keyboard Shift+Ctrl+H),
|
|
89
90
|
// override the mouse-out condition so the control stays visible regardless of mouse position.
|
|
90
91
|
var shouldHideWhenMouseOut = forceVisibleOnMouseOut ? false : hideOnMouseOut;
|
|
91
|
-
|
|
92
|
+
// Persistent controls (e.g. an AI suggestion icon on every qualifying node) aren't hover-driven,
|
|
93
|
+
// so none of the hover/typing/mouse-out/diff-review reasons below apply to them — they're never
|
|
94
|
+
// hidden by this container.
|
|
95
|
+
var shouldHideImmediate = !isPersistent && (isTypeAheadOpen || isEditing || shouldHideWhenMouseOut || userIntent === 'aiStreaming' ||
|
|
92
96
|
// EDITOR-7926: hide the drag handle while a diff is on screen or a suggestion card is open.
|
|
93
|
-
(isDisplayingDiff || userIntent === 'reviewing') && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || sideHidden;
|
|
97
|
+
(isDisplayingDiff || userIntent === 'reviewing') && expValEquals('platform_editor_diff_plugin_extended', 'isEnabled', true) || sideHidden);
|
|
94
98
|
|
|
95
99
|
// Delay hiding the right control in view mode to reduce flickering when moving from block
|
|
96
100
|
// toward the right-edge button (avoids rapid show/hide as mouse crosses boundaries).
|
|
@@ -44,7 +44,7 @@ export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | und
|
|
|
44
44
|
multiSelectDnD: MultiSelectDnD | undefined;
|
|
45
45
|
surfaceNodePositions: number[];
|
|
46
46
|
};
|
|
47
|
-
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, legacyDragHandleEnabled?: boolean,
|
|
47
|
+
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, legacyDragHandleEnabled?: boolean, rightSurfaceEnabled?: boolean) => SafePlugin<PluginState | {
|
|
48
48
|
activeDropTargetNode: ActiveDropTargetNode | undefined;
|
|
49
49
|
activeNode: any;
|
|
50
50
|
blockMenuOptions: {
|
|
@@ -2,5 +2,6 @@ import type { BlockControlUIContext } from '@atlaskit/editor-common/block-contro
|
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { ActiveNode } from '../blockControlsPluginType';
|
|
5
|
+
export declare const getBlockControlsSurfaceControlSide: (context: BlockControlUIContext | undefined, reliableAnchorEnabled: boolean) => 'left' | undefined;
|
|
5
6
|
export declare const createBlockControlsSurfaceContextForPosition: (state: EditorState, targetPos: number, activeNode?: ActiveNode) => BlockControlUIContext | undefined;
|
|
6
7
|
export declare const createBlockControlsSurfaceContext: (view: EditorView, activeNode: ActiveNode | undefined, target?: 'active' | 'root') => BlockControlUIContext | undefined;
|
|
@@ -6,7 +6,6 @@ export declare const ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = "--editor-block-
|
|
|
6
6
|
export declare const DRAG_HANDLE_HEIGHT = 24;
|
|
7
7
|
export declare const DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
8
8
|
export declare const DRAG_HANDLE_ZINDEX: number;
|
|
9
|
-
export declare const DRAG_HANDLE_DEFAULT_GAP = 8;
|
|
10
9
|
export declare const DRAG_HANDLE_NARROW_GAP = 4;
|
|
11
10
|
export declare const DRAG_HANDLE_MAX_GAP = 12;
|
|
12
11
|
export declare const DRAG_HANDLE_SYNCED_BLOCK_GAP = 2.5;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { RegisterComponent, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
2
|
+
type SurfaceIdentifier = {
|
|
3
|
+
key: string;
|
|
4
|
+
type: 'toolbar' | 'menu';
|
|
5
|
+
};
|
|
6
|
+
type PartitionedComponents = {
|
|
7
|
+
hoverOnlyComponents: RegisterComponent[];
|
|
8
|
+
persistentComponents: RegisterComponent[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Split registered components into two groups:
|
|
12
|
+
* those that should be rendered persistently and those that should only be rendered on hover.
|
|
13
|
+
*/
|
|
14
|
+
export declare const partitionComponentsByPersistence: (components: RegisterComponent[], surface: SurfaceIdentifier, surfaceContext: SurfaceContext | undefined) => PartitionedComponents;
|
|
15
|
+
export {};
|
|
@@ -11,10 +11,11 @@ interface VisibilityContainerProps {
|
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
controlSide?: 'left' | 'right';
|
|
13
13
|
forceVisibleOnMouseOut?: boolean;
|
|
14
|
+
isPersistent?: boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Set when the container should not create its own layout box while its descendants retain theirs.
|
|
16
17
|
*/
|
|
17
18
|
shouldUseDisplayContents?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare const VisibilityContainer: ({ api, children, controlSide, forceVisibleOnMouseOut, shouldUseDisplayContents, }: VisibilityContainerProps) => jsx.JSX.Element;
|
|
20
|
+
export declare const VisibilityContainer: ({ api, children, controlSide, forceVisibleOnMouseOut, isPersistent, shouldUseDisplayContents, }: VisibilityContainerProps) => jsx.JSX.Element;
|
|
20
21
|
export {};
|