@atlaskit/editor-plugin-block-controls 20.1.3 → 20.1.4
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 +10 -0
- package/dist/cjs/ui/block-controls-left-surface.compiled.css +7 -1
- package/dist/cjs/ui/block-controls-left-surface.js +41 -27
- package/dist/cjs/ui/block-controls-left-surfaces.js +32 -12
- package/dist/cjs/ui/block-controls-right-surface.js +32 -24
- package/dist/cjs/ui/block-controls-right-surfaces.js +6 -4
- package/dist/cjs/ui/block-controls-surface-components.js +142 -0
- package/dist/cjs/ui/utils/get-surface-placement.js +63 -16
- package/dist/cjs/ui/visibility-container.js +42 -7
- package/dist/es2019/ui/block-controls-left-surface.compiled.css +7 -1
- package/dist/es2019/ui/block-controls-left-surface.js +44 -29
- package/dist/es2019/ui/block-controls-left-surfaces.js +41 -16
- package/dist/es2019/ui/block-controls-right-surface.js +35 -26
- package/dist/es2019/ui/block-controls-right-surfaces.js +6 -4
- package/dist/es2019/ui/block-controls-surface-components.js +129 -0
- package/dist/es2019/ui/utils/get-surface-placement.js +59 -7
- package/dist/es2019/ui/visibility-container.js +44 -6
- package/dist/esm/ui/block-controls-left-surface.compiled.css +7 -1
- package/dist/esm/ui/block-controls-left-surface.js +43 -29
- package/dist/esm/ui/block-controls-left-surfaces.js +33 -13
- package/dist/esm/ui/block-controls-right-surface.js +34 -26
- package/dist/esm/ui/block-controls-right-surfaces.js +6 -4
- package/dist/esm/ui/block-controls-surface-components.js +133 -0
- package/dist/esm/ui/utils/get-surface-placement.js +62 -15
- package/dist/esm/ui/visibility-container.js +41 -6
- package/dist/types/ui/block-controls-surface-components.d.ts +13 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +13 -0
- package/dist/types/ui/visibility-container.d.ts +14 -0
- package/package.json +2 -2
|
@@ -15,14 +15,13 @@ import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-cont
|
|
|
15
15
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
16
16
|
import { isCSSAnchorSupported } from '@atlaskit/editor-common/styles';
|
|
17
17
|
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/create-surface-context';
|
|
18
|
-
import { willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
19
18
|
import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
|
|
20
19
|
import { BlockControlsRightSurface } from './block-controls-right-surface';
|
|
20
|
+
import { getBlockControlsRightSurfaceComponents } from './block-controls-surface-components';
|
|
21
21
|
import { createBlockControlsSurfaceContextForPosition } from './block-controls-surface-context';
|
|
22
22
|
import { getBlockControlsSurfaceTargets } from './block-controls-surface-targets';
|
|
23
23
|
import { getNodeContentElement } from './utils/get-node-content-element';
|
|
24
24
|
import { getAbsoluteSurfacePlacement, getAnchoredSurfacePlacement, getSurfacePlacement, toMeasuredSurfaceWrapperPlacement } from './utils/get-surface-placement';
|
|
25
|
-
import { hasSurfaceControls } from './utils/has-surface-controls';
|
|
26
25
|
var EMPTY_SURFACE_POSITIONS = [];
|
|
27
26
|
var EMPTY_SURFACE_ANCHORS = new Map();
|
|
28
27
|
var EMPTY_SURFACE_COMPONENTS = [];
|
|
@@ -69,7 +68,8 @@ export var BlockControlsRightSurfaces = function BlockControlsRightSurfaces(_ref
|
|
|
69
68
|
return [];
|
|
70
69
|
}
|
|
71
70
|
var surfaceContext = createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, context);
|
|
72
|
-
|
|
71
|
+
var surfaceComponents = getBlockControlsRightSurfaceComponents(components, surfaceContext);
|
|
72
|
+
if (!surfaceComponents) {
|
|
73
73
|
return [];
|
|
74
74
|
}
|
|
75
75
|
// The cache supplies the same anchor names used by ProseMirror decorations.
|
|
@@ -77,6 +77,7 @@ export var BlockControlsRightSurfaces = function BlockControlsRightSurfaces(_ref
|
|
|
77
77
|
return [_objectSpread(_objectSpread({}, target), {}, {
|
|
78
78
|
anchorName: anchorName,
|
|
79
79
|
blockControlsContext: context,
|
|
80
|
+
surfaceComponents: surfaceComponents,
|
|
80
81
|
surfaceContext: surfaceContext
|
|
81
82
|
})];
|
|
82
83
|
});
|
|
@@ -260,10 +261,11 @@ export var BlockControlsRightSurfaces = function BlockControlsRightSurfaces(_ref
|
|
|
260
261
|
var _activeNode$handleOpt, _anchoredPlacements$g;
|
|
261
262
|
var position = _ref6.position,
|
|
262
263
|
source = _ref6.source,
|
|
264
|
+
surfaceComponents = _ref6.surfaceComponents,
|
|
263
265
|
surfaceContext = _ref6.surfaceContext;
|
|
264
266
|
return /*#__PURE__*/React.createElement(BlockControlsRightSurface, {
|
|
265
267
|
api: api,
|
|
266
|
-
components:
|
|
268
|
+
components: surfaceComponents,
|
|
267
269
|
forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 || (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
268
270
|
key: position,
|
|
269
271
|
placement: (_anchoredPlacements$g = anchoredPlacements.get(position)) !== null && _anchoredPlacements$g !== void 0 ? _anchoredPlacements$g : placements.get(position),
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["isHidden"];
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
import React, { createContext, useContext, useMemo } from 'react';
|
|
8
|
+
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';
|
|
9
|
+
import { getComponentIdentity, resolveSurface } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
10
|
+
import { partitionComponentsByPersistence } from './utils/partition-components-by-persistence';
|
|
11
|
+
import { VisibilityWrapper } from './visibility-container';
|
|
12
|
+
var BlockControlsVisibilityContext = /*#__PURE__*/createContext({
|
|
13
|
+
shouldHideHoverControls: false,
|
|
14
|
+
useCssStyles: false
|
|
15
|
+
});
|
|
16
|
+
var BlockControlItem = function BlockControlItem(_ref) {
|
|
17
|
+
var children = _ref.children;
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
"data-editor-block-control-item": true
|
|
20
|
+
}, children);
|
|
21
|
+
};
|
|
22
|
+
var HoverBlockControlItem = function HoverBlockControlItem(_ref2) {
|
|
23
|
+
var children = _ref2.children;
|
|
24
|
+
var _useContext = useContext(BlockControlsVisibilityContext),
|
|
25
|
+
shouldHideHoverControls = _useContext.shouldHideHoverControls,
|
|
26
|
+
useCssStyles = _useContext.useCssStyles;
|
|
27
|
+
return /*#__PURE__*/React.createElement(BlockControlItem, null, /*#__PURE__*/React.createElement(VisibilityWrapper, {
|
|
28
|
+
shouldHide: shouldHideHoverControls,
|
|
29
|
+
useCssStyles: useCssStyles
|
|
30
|
+
}, children));
|
|
31
|
+
};
|
|
32
|
+
var PersistentBlockControlItem = function PersistentBlockControlItem(_ref3) {
|
|
33
|
+
var children = _ref3.children;
|
|
34
|
+
var _useContext2 = useContext(BlockControlsVisibilityContext),
|
|
35
|
+
useCssStyles = _useContext2.useCssStyles;
|
|
36
|
+
return /*#__PURE__*/React.createElement(BlockControlItem, null, /*#__PURE__*/React.createElement(VisibilityWrapper, {
|
|
37
|
+
shouldHide: false,
|
|
38
|
+
useCssStyles: useCssStyles
|
|
39
|
+
}, children));
|
|
40
|
+
};
|
|
41
|
+
export var BlockControlsVisibilityProvider = function BlockControlsVisibilityProvider(_ref4) {
|
|
42
|
+
var children = _ref4.children,
|
|
43
|
+
shouldHideHoverControls = _ref4.shouldHideHoverControls,
|
|
44
|
+
useCssStyles = _ref4.useCssStyles;
|
|
45
|
+
var value = useMemo(function () {
|
|
46
|
+
return {
|
|
47
|
+
shouldHideHoverControls: shouldHideHoverControls,
|
|
48
|
+
useCssStyles: useCssStyles
|
|
49
|
+
};
|
|
50
|
+
}, [shouldHideHoverControls, useCssStyles]);
|
|
51
|
+
return /*#__PURE__*/React.createElement(BlockControlsVisibilityContext.Provider, {
|
|
52
|
+
value: value
|
|
53
|
+
}, children);
|
|
54
|
+
};
|
|
55
|
+
var withoutVisibilityPredicate = function withoutVisibilityPredicate(component) {
|
|
56
|
+
var _isHidden = component.isHidden,
|
|
57
|
+
visibleComponent = _objectWithoutProperties(component, _excluded);
|
|
58
|
+
return visibleComponent;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Replaces the shared surface group with one stable wrapper group per visible control. The wrappers
|
|
63
|
+
* inherit each control's rank, so SurfaceRenderer keeps the registry order without re-evaluating
|
|
64
|
+
* the controls' visibility predicates.
|
|
65
|
+
*/
|
|
66
|
+
var getBlockControlsSurfaceComponents = function getBlockControlsSurfaceComponents(components, _ref5, surfaceContext) {
|
|
67
|
+
var _resolvedSurface$chil;
|
|
68
|
+
var group = _ref5.group,
|
|
69
|
+
section = _ref5.section,
|
|
70
|
+
surface = _ref5.surface;
|
|
71
|
+
var resolvedSurface = resolveSurface(components, surface);
|
|
72
|
+
var groupIdentity = getComponentIdentity(group);
|
|
73
|
+
var controls = (_resolvedSurface$chil = resolvedSurface.childrenMap.get(groupIdentity)) !== null && _resolvedSurface$chil !== void 0 ? _resolvedSurface$chil : [];
|
|
74
|
+
var visibleControls = controls.filter(function (control) {
|
|
75
|
+
var _control$isHidden, _control$isHidden2;
|
|
76
|
+
return !((_control$isHidden = (_control$isHidden2 = control.isHidden) === null || _control$isHidden2 === void 0 ? void 0 : _control$isHidden2.call(control, {
|
|
77
|
+
surfaceContext: surfaceContext
|
|
78
|
+
})) !== null && _control$isHidden !== void 0 ? _control$isHidden : false);
|
|
79
|
+
});
|
|
80
|
+
if (!resolvedSurface.root || visibleControls.length === 0) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
var controlIdentities = new Set(controls.map(getComponentIdentity));
|
|
84
|
+
var visibleControlIdentities = new Set(visibleControls.map(getComponentIdentity));
|
|
85
|
+
var _partitionComponentsB = partitionComponentsByPersistence(resolvedSurface.components.filter(function (component) {
|
|
86
|
+
var identity = getComponentIdentity(component);
|
|
87
|
+
return !controlIdentities.has(identity) || visibleControlIdentities.has(identity);
|
|
88
|
+
}), surface, surfaceContext),
|
|
89
|
+
persistentComponents = _partitionComponentsB.persistentComponents;
|
|
90
|
+
var persistentIdentities = new Set(persistentComponents.map(getComponentIdentity));
|
|
91
|
+
var structuralComponents = resolvedSurface.components.filter(function (component) {
|
|
92
|
+
var identity = getComponentIdentity(component);
|
|
93
|
+
return identity !== groupIdentity && !controlIdentities.has(identity);
|
|
94
|
+
}).map(withoutVisibilityPredicate);
|
|
95
|
+
var wrappedControls = visibleControls.flatMap(function (control) {
|
|
96
|
+
var _control$parents$find, _control$parents;
|
|
97
|
+
var identity = getComponentIdentity(control);
|
|
98
|
+
var rank = (_control$parents$find = (_control$parents = control.parents) === null || _control$parents === void 0 || (_control$parents = _control$parents.find(function (parent) {
|
|
99
|
+
return getComponentIdentity(parent) === groupIdentity;
|
|
100
|
+
})) === null || _control$parents === void 0 ? void 0 : _control$parents.rank) !== null && _control$parents$find !== void 0 ? _control$parents$find : 0;
|
|
101
|
+
var wrapper = {
|
|
102
|
+
component: persistentIdentities.has(identity) ? PersistentBlockControlItem : HoverBlockControlItem,
|
|
103
|
+
key: "block-control-item:".concat(identity),
|
|
104
|
+
parents: [_objectSpread(_objectSpread({}, section), {}, {
|
|
105
|
+
rank: rank
|
|
106
|
+
})],
|
|
107
|
+
type: 'group'
|
|
108
|
+
};
|
|
109
|
+
var visibleControl = _objectSpread(_objectSpread({}, withoutVisibilityPredicate(control)), {}, {
|
|
110
|
+
parents: [{
|
|
111
|
+
key: wrapper.key,
|
|
112
|
+
rank: 0,
|
|
113
|
+
type: wrapper.type
|
|
114
|
+
}]
|
|
115
|
+
});
|
|
116
|
+
return [wrapper, visibleControl];
|
|
117
|
+
});
|
|
118
|
+
return [].concat(_toConsumableArray(structuralComponents), _toConsumableArray(wrappedControls));
|
|
119
|
+
};
|
|
120
|
+
export var getBlockControlsLeftSurfaceComponents = function getBlockControlsLeftSurfaceComponents(components, surfaceContext) {
|
|
121
|
+
return getBlockControlsSurfaceComponents(components, {
|
|
122
|
+
group: BLOCK_CONTROLS_LEFT_GROUP,
|
|
123
|
+
section: BLOCK_CONTROLS_LEFT_SECTION,
|
|
124
|
+
surface: BLOCK_CONTROLS_LEFT_SURFACE
|
|
125
|
+
}, surfaceContext);
|
|
126
|
+
};
|
|
127
|
+
export var getBlockControlsRightSurfaceComponents = function getBlockControlsRightSurfaceComponents(components, surfaceContext) {
|
|
128
|
+
return getBlockControlsSurfaceComponents(components, {
|
|
129
|
+
group: BLOCK_CONTROLS_RIGHT_GROUP,
|
|
130
|
+
section: BLOCK_CONTROLS_RIGHT_SECTION,
|
|
131
|
+
surface: BLOCK_CONTROLS_RIGHT_SURFACE
|
|
132
|
+
}, surfaceContext);
|
|
133
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
var _excluded = ["leftGutterBoundary"];
|
|
2
4
|
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
5
|
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
6
|
import { shouldBeSticky } from '../../pm-plugins/utils/drag-handle-positions';
|
|
@@ -43,18 +45,40 @@ export var getSurfacePlacement = function getSurfacePlacement(_ref2) {
|
|
|
43
45
|
var gap = dragHandleGap(nodeType, parentNodeType);
|
|
44
46
|
var top = nodeRect.top + topPositionAdjustment(nodeTypeWithLevel, layout);
|
|
45
47
|
var height = shouldBeSticky(nodeType) ? nodeRect.height : undefined;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
if (side === 'right') {
|
|
49
|
+
return {
|
|
50
|
+
left: nodeRect.right + gap,
|
|
51
|
+
top: top,
|
|
52
|
+
transform: '',
|
|
53
|
+
height: height
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
52
57
|
left: nodeRect.left,
|
|
53
58
|
top: top,
|
|
54
59
|
transform: "translateX(calc(-100% - ".concat(gap, "px))"),
|
|
55
60
|
height: height
|
|
56
61
|
};
|
|
57
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Expands a measured left surface from the available gutter boundary to the target node.
|
|
65
|
+
*/
|
|
66
|
+
export var getLeftGutterSurfacePlacement = function getLeftGutterSurfacePlacement(_ref3) {
|
|
67
|
+
var leftGutterBoundary = _ref3.leftGutterBoundary,
|
|
68
|
+
options = _objectWithoutProperties(_ref3, _excluded);
|
|
69
|
+
var placement = getSurfacePlacement(_objectSpread(_objectSpread({}, options), {}, {
|
|
70
|
+
side: 'left'
|
|
71
|
+
}));
|
|
72
|
+
if (options.nodeType === 'layoutColumn') {
|
|
73
|
+
return placement;
|
|
74
|
+
}
|
|
75
|
+
var gap = dragHandleGap(options.nodeType, options.parentNodeType);
|
|
76
|
+
return _objectSpread(_objectSpread({}, placement), {}, {
|
|
77
|
+
left: leftGutterBoundary,
|
|
78
|
+
transform: '',
|
|
79
|
+
width: Math.max(0, options.nodeRect.left - leftGutterBoundary - gap)
|
|
80
|
+
});
|
|
81
|
+
};
|
|
58
82
|
|
|
59
83
|
/**
|
|
60
84
|
* The insets to apply to a surface wrapper, plus whether that wrapper spans its target node.
|
|
@@ -75,12 +99,14 @@ export var getSurfacePlacement = function getSurfacePlacement(_ref2) {
|
|
|
75
99
|
export var toMeasuredSurfaceWrapperPlacement = function toMeasuredSurfaceWrapperPlacement(placement) {
|
|
76
100
|
return {
|
|
77
101
|
isSticky: placement.height !== undefined,
|
|
78
|
-
style: {
|
|
102
|
+
style: _objectSpread({
|
|
79
103
|
height: placement.height,
|
|
80
104
|
left: placement.left,
|
|
81
105
|
top: placement.top,
|
|
82
106
|
transform: placement.transform
|
|
83
|
-
}
|
|
107
|
+
}, placement.width !== undefined ? {
|
|
108
|
+
width: placement.width
|
|
109
|
+
} : {})
|
|
84
110
|
};
|
|
85
111
|
};
|
|
86
112
|
|
|
@@ -96,13 +122,13 @@ export var toMeasuredSurfaceWrapperPlacement = function toMeasuredSurfaceWrapper
|
|
|
96
122
|
var INVALID_ANCHOR_OFFSCREEN_PX = 9999;
|
|
97
123
|
var INVALID_ANCHOR_FALLBACK_TOP = "-".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
|
|
98
124
|
var INVALID_ANCHOR_FALLBACK_BOTTOM = "".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
|
|
99
|
-
export var getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(
|
|
100
|
-
var anchorName =
|
|
101
|
-
layout =
|
|
102
|
-
nodeType =
|
|
103
|
-
nodeTypeWithLevel =
|
|
104
|
-
parentNodeType =
|
|
105
|
-
side =
|
|
125
|
+
export var getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(_ref4) {
|
|
126
|
+
var anchorName = _ref4.anchorName,
|
|
127
|
+
layout = _ref4.layout,
|
|
128
|
+
nodeType = _ref4.nodeType,
|
|
129
|
+
nodeTypeWithLevel = _ref4.nodeTypeWithLevel,
|
|
130
|
+
parentNodeType = _ref4.parentNodeType,
|
|
131
|
+
side = _ref4.side;
|
|
106
132
|
if (nodeType === 'layoutColumn') {
|
|
107
133
|
// The column's horizontal midpoint, matching the measured `nodeRect.left + width / 2` and the
|
|
108
134
|
// legacy drag handle's own layout-column formula. Side-independent.
|
|
@@ -132,4 +158,25 @@ export var getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(_r
|
|
|
132
158
|
transform: side === 'right' ? '' : "translateX(calc(-100% - ".concat(gap, "px))")
|
|
133
159
|
})
|
|
134
160
|
};
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Expands an anchored left surface across the available gutter without runtime measurement.
|
|
164
|
+
*/
|
|
165
|
+
export var getAnchoredLeftGutterSurfacePlacement = function getAnchoredLeftGutterSurfacePlacement(options) {
|
|
166
|
+
var placement = getAnchoredSurfacePlacement(_objectSpread(_objectSpread({}, options), {}, {
|
|
167
|
+
side: 'left'
|
|
168
|
+
}));
|
|
169
|
+
if (options.nodeType === 'layoutColumn') {
|
|
170
|
+
return placement;
|
|
171
|
+
}
|
|
172
|
+
var gap = dragHandleGap(options.nodeType, options.parentNodeType);
|
|
173
|
+
return _objectSpread(_objectSpread({}, placement), {}, {
|
|
174
|
+
style: _objectSpread(_objectSpread({}, placement.style), {}, {
|
|
175
|
+
left: 0,
|
|
176
|
+
// In a `right` inset, `anchor(... left)` resolves from the containing block's right edge
|
|
177
|
+
// to the anchor's left edge. Adding the gap ends this wrapper just before the node.
|
|
178
|
+
right: "calc(anchor(".concat(options.anchorName, " left) + ").concat(gap, "px)"),
|
|
179
|
+
transform: ''
|
|
180
|
+
})
|
|
181
|
+
});
|
|
135
182
|
};
|
|
@@ -46,13 +46,16 @@ var hiddenStylesCSS = css({
|
|
|
46
46
|
var displayContentsStylesCSS = css({
|
|
47
47
|
display: 'contents'
|
|
48
48
|
});
|
|
49
|
-
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resolves visibility once so a surface can apply the same state to each rendered control without
|
|
52
|
+
* creating a plugin-state subscription and hide-delay timer for every control wrapper.
|
|
53
|
+
*/
|
|
54
|
+
export var useBlockControlsVisibility = function useBlockControlsVisibility(_ref) {
|
|
50
55
|
var api = _ref.api,
|
|
51
|
-
children = _ref.children,
|
|
52
56
|
controlSide = _ref.controlSide,
|
|
53
57
|
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
54
|
-
isPersistent = _ref.isPersistent
|
|
55
|
-
shouldUseDisplayContents = _ref.shouldUseDisplayContents;
|
|
58
|
+
isPersistent = _ref.isPersistent;
|
|
56
59
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['typeAhead', 'blockControls', 'editorViewMode', 'userIntent', 'showDiff'], function (states) {
|
|
57
60
|
var _states$typeAheadStat, _states$blockControls, _states$blockControls2, _states$blockControls3, _states$editorViewMod, _states$userIntentSta, _states$showDiffState, _states$blockControls4;
|
|
58
61
|
return {
|
|
@@ -128,9 +131,20 @@ export var VisibilityContainer = function VisibilityContainer(_ref) {
|
|
|
128
131
|
};
|
|
129
132
|
}, [shouldHideImmediate, isRightControlViewMode]);
|
|
130
133
|
var shouldHide = isRightControlViewMode ? delayedShouldHide : shouldHideImmediate;
|
|
131
|
-
|
|
134
|
+
var useCssStyles = editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
132
135
|
exposure: true
|
|
133
|
-
})
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
shouldHide: shouldHide,
|
|
139
|
+
useCssStyles: useCssStyles
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
export var VisibilityWrapper = function VisibilityWrapper(_ref2) {
|
|
143
|
+
var children = _ref2.children,
|
|
144
|
+
shouldHide = _ref2.shouldHide,
|
|
145
|
+
shouldUseDisplayContents = _ref2.shouldUseDisplayContents,
|
|
146
|
+
useCssStyles = _ref2.useCssStyles;
|
|
147
|
+
if (useCssStyles) {
|
|
134
148
|
return jsx("div", {
|
|
135
149
|
css: [baseStylesCSS, shouldHide ? hiddenStylesCSS : visibleStylesCSS, shouldUseDisplayContents && displayContentsStylesCSS]
|
|
136
150
|
}, children);
|
|
@@ -140,4 +154,25 @@ export var VisibilityContainer = function VisibilityContainer(_ref) {
|
|
|
140
154
|
, {
|
|
141
155
|
xcss: [baseStyles, shouldHide ? hiddenStyles : visibleStyles, shouldUseDisplayContents && displayContentsStyles]
|
|
142
156
|
}, children);
|
|
157
|
+
};
|
|
158
|
+
export var VisibilityContainer = function VisibilityContainer(_ref3) {
|
|
159
|
+
var api = _ref3.api,
|
|
160
|
+
children = _ref3.children,
|
|
161
|
+
controlSide = _ref3.controlSide,
|
|
162
|
+
forceVisibleOnMouseOut = _ref3.forceVisibleOnMouseOut,
|
|
163
|
+
isPersistent = _ref3.isPersistent,
|
|
164
|
+
shouldUseDisplayContents = _ref3.shouldUseDisplayContents;
|
|
165
|
+
var _useBlockControlsVisi = useBlockControlsVisibility({
|
|
166
|
+
api: api,
|
|
167
|
+
controlSide: controlSide,
|
|
168
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
169
|
+
isPersistent: isPersistent
|
|
170
|
+
}),
|
|
171
|
+
shouldHide = _useBlockControlsVisi.shouldHide,
|
|
172
|
+
useCssStyles = _useBlockControlsVisi.useCssStyles;
|
|
173
|
+
return jsx(VisibilityWrapper, {
|
|
174
|
+
shouldHide: shouldHide,
|
|
175
|
+
shouldUseDisplayContents: shouldUseDisplayContents,
|
|
176
|
+
useCssStyles: useCssStyles
|
|
177
|
+
}, children);
|
|
143
178
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RegisterComponent, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
3
|
+
type BlockControlsVisibility = {
|
|
4
|
+
shouldHideHoverControls: boolean;
|
|
5
|
+
useCssStyles: boolean;
|
|
6
|
+
};
|
|
7
|
+
type BlockControlsVisibilityProviderProps = BlockControlsVisibility & {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export declare const BlockControlsVisibilityProvider: ({ children, shouldHideHoverControls, useCssStyles, }: BlockControlsVisibilityProviderProps) => React.JSX.Element;
|
|
11
|
+
export declare const getBlockControlsLeftSurfaceComponents: (components: RegisterComponent[], surfaceContext: SurfaceContext) => RegisterComponent[] | undefined;
|
|
12
|
+
export declare const getBlockControlsRightSurfaceComponents: (components: RegisterComponent[], surfaceContext: SurfaceContext) => RegisterComponent[] | undefined;
|
|
13
|
+
export {};
|
|
@@ -10,6 +10,7 @@ export type SurfacePlacement = {
|
|
|
10
10
|
left: number;
|
|
11
11
|
top: number;
|
|
12
12
|
transform: string;
|
|
13
|
+
width?: number;
|
|
13
14
|
};
|
|
14
15
|
export type SurfaceSide = 'left' | 'right';
|
|
15
16
|
export type SurfacePlacementOptions = {
|
|
@@ -37,6 +38,13 @@ export declare const getAbsoluteSurfacePlacement: ({ offsetParentRect, offsetPar
|
|
|
37
38
|
* can be folded straight into `left` with no transform needed.
|
|
38
39
|
*/
|
|
39
40
|
export declare const getSurfacePlacement: ({ layout, nodeRect, nodeType, nodeTypeWithLevel, parentNodeType, side, }: SurfacePlacementOptions) => SurfacePlacement;
|
|
41
|
+
export type LeftGutterSurfacePlacementOptions = Omit<SurfacePlacementOptions, 'side'> & {
|
|
42
|
+
leftGutterBoundary: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Expands a measured left surface from the available gutter boundary to the target node.
|
|
46
|
+
*/
|
|
47
|
+
export declare const getLeftGutterSurfacePlacement: ({ leftGutterBoundary, ...options }: LeftGutterSurfacePlacementOptions) => SurfacePlacement;
|
|
40
48
|
/**
|
|
41
49
|
* The insets to apply to a surface wrapper, plus whether that wrapper spans its target node.
|
|
42
50
|
*
|
|
@@ -67,3 +75,8 @@ export type AnchoredSurfacePlacementOptions = {
|
|
|
67
75
|
side: SurfaceSide;
|
|
68
76
|
};
|
|
69
77
|
export declare const getAnchoredSurfacePlacement: ({ anchorName, layout, nodeType, nodeTypeWithLevel, parentNodeType, side, }: AnchoredSurfacePlacementOptions) => SurfaceWrapperPlacement;
|
|
78
|
+
export type AnchoredLeftGutterSurfacePlacementOptions = Omit<AnchoredSurfacePlacementOptions, 'side'>;
|
|
79
|
+
/**
|
|
80
|
+
* Expands an anchored left surface across the available gutter without runtime measurement.
|
|
81
|
+
*/
|
|
82
|
+
export declare const getAnchoredLeftGutterSurfacePlacement: (options: AnchoredLeftGutterSurfacePlacementOptions) => SurfaceWrapperPlacement;
|
|
@@ -17,5 +17,19 @@ interface VisibilityContainerProps {
|
|
|
17
17
|
*/
|
|
18
18
|
shouldUseDisplayContents?: boolean;
|
|
19
19
|
}
|
|
20
|
+
type VisibilityWrapperProps = Pick<VisibilityContainerProps, 'children' | 'shouldUseDisplayContents'> & {
|
|
21
|
+
shouldHide: boolean;
|
|
22
|
+
useCssStyles: boolean;
|
|
23
|
+
};
|
|
24
|
+
type BlockControlsVisibilityOptions = Omit<VisibilityContainerProps, 'children' | 'shouldUseDisplayContents'>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves visibility once so a surface can apply the same state to each rendered control without
|
|
27
|
+
* creating a plugin-state subscription and hide-delay timer for every control wrapper.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useBlockControlsVisibility: ({ api, controlSide, forceVisibleOnMouseOut, isPersistent, }: BlockControlsVisibilityOptions) => {
|
|
30
|
+
shouldHide: boolean;
|
|
31
|
+
useCssStyles: boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare const VisibilityWrapper: ({ children, shouldHide, shouldUseDisplayContents, useCssStyles, }: VisibilityWrapperProps) => jsx.JSX.Element;
|
|
20
34
|
export declare const VisibilityContainer: ({ api, children, controlSide, forceVisibleOnMouseOut, isPersistent, shouldUseDisplayContents, }: VisibilityContainerProps) => jsx.JSX.Element;
|
|
21
35
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "20.1.
|
|
3
|
+
"version": "20.1.4",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@atlaskit/primitives": "^22.5.0",
|
|
62
62
|
"@atlaskit/section-message": "^10.2.0",
|
|
63
63
|
"@atlaskit/theme": "^28.2.0",
|
|
64
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
64
|
+
"@atlaskit/tmp-editor-statsig": "^204.0.0",
|
|
65
65
|
"@atlaskit/tokens": "^19.0.0",
|
|
66
66
|
"@atlaskit/tooltip": "^24.3.0",
|
|
67
67
|
"@babel/runtime": "^7.0.0",
|