@atlaskit/editor-plugin-block-controls 34.0.3 → 34.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/blockControlsPlugin.js +2 -10
- package/dist/cjs/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +121 -2
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +3 -0
- package/dist/cjs/pm-plugins/sparse-gutter-hover.js +17 -57
- package/dist/cjs/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/cjs/pm-plugins/utils/after-render-scheduler.js +39 -0
- package/dist/cjs/ui/block-controls-left-surface.js +19 -83
- package/dist/cjs/ui/block-controls-right-surface.js +19 -70
- package/dist/cjs/ui/block-controls-surface-targets.js +1 -1
- package/dist/es2019/blockControlsPlugin.js +2 -10
- package/dist/es2019/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +118 -1
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
- package/dist/es2019/pm-plugins/sparse-gutter-hover.js +16 -56
- package/dist/es2019/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/es2019/pm-plugins/utils/after-render-scheduler.js +33 -0
- package/dist/es2019/ui/block-controls-left-surface.js +10 -76
- package/dist/es2019/ui/block-controls-right-surface.js +10 -63
- package/dist/es2019/ui/block-controls-surface-targets.js +1 -1
- package/dist/esm/blockControlsPlugin.js +2 -10
- package/dist/esm/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +120 -1
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
- package/dist/esm/pm-plugins/sparse-gutter-hover.js +16 -56
- package/dist/esm/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/esm/pm-plugins/utils/after-render-scheduler.js +33 -0
- package/dist/esm/ui/block-controls-left-surface.js +19 -83
- package/dist/esm/ui/block-controls-right-surface.js +19 -70
- package/dist/esm/ui/block-controls-surface-targets.js +1 -1
- package/dist/types/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +1 -0
- package/dist/types/pm-plugins/utils/after-render-scheduler.d.ts +9 -0
- package/dist/types/ui/block-controls-left-surface.d.ts +1 -1
- package/dist/types/ui/block-controls-right-surface.d.ts +1 -1
- package/dist/types/ui/block-controls-surface-targets.d.ts +1 -1
- package/package.json +4 -4
- package/dist/cjs/pm-plugins/sparse-surfaces-view.js +0 -149
- package/dist/cjs/ui/block-controls-left-surfaces.js +0 -294
- package/dist/cjs/ui/block-controls-right-surfaces.js +0 -285
- package/dist/es2019/pm-plugins/sparse-surfaces-view.js +0 -136
- package/dist/es2019/ui/block-controls-left-surfaces.js +0 -259
- package/dist/es2019/ui/block-controls-right-surfaces.js +0 -245
- package/dist/esm/pm-plugins/sparse-surfaces-view.js +0 -142
- package/dist/esm/ui/block-controls-left-surfaces.js +0 -285
- package/dist/esm/ui/block-controls-right-surfaces.js +0 -276
- package/dist/types/pm-plugins/sparse-surfaces-view.d.ts +0 -16
- package/dist/types/ui/block-controls-left-surfaces.d.ts +0 -15
- package/dist/types/ui/block-controls-right-surfaces.d.ts +0 -24
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
/* block-controls-left-surfaces.tsx generated by @compiled/babel-plugin v3.0.4 */
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
exports.BlockControlsLeftSurfaces = void 0;
|
|
10
|
-
var _runtime = require("@compiled/react/runtime");
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
-
var _bindEventListener = require("bind-event-listener");
|
|
15
|
-
var _browserApis = require("@atlaskit/browser-apis");
|
|
16
|
-
var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
|
|
17
|
-
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
18
|
-
var _nativeAnchor = require("@atlaskit/editor-common/styles/native-anchor");
|
|
19
|
-
var _useSharedPluginStateWithSelector = require("@atlaskit/editor-common/useSharedPluginStateWithSelector");
|
|
20
|
-
var _createSurfaceContext = require("@atlaskit/editor-ui-control-model/create-surface-context");
|
|
21
|
-
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
22
|
-
var _blockControlsLeftSurface = require("./block-controls-left-surface");
|
|
23
|
-
var _blockControlsSurfaceComponents = require("./block-controls-surface-components");
|
|
24
|
-
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
25
|
-
var _blockControlsSurfaceTargets = require("./block-controls-surface-targets");
|
|
26
|
-
var _getNodeContentElement = require("./utils/get-node-content-element");
|
|
27
|
-
var _getSurfacePlacement = require("./utils/get-surface-placement");
|
|
28
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
29
|
-
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; } } }; }
|
|
30
|
-
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; } }
|
|
31
|
-
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; }
|
|
32
|
-
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; }
|
|
33
|
-
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) { (0, _defineProperty2.default)(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; }
|
|
34
|
-
var EMPTY_SURFACE_POSITIONS = [];
|
|
35
|
-
var EMPTY_SURFACE_ANCHORS = new Map();
|
|
36
|
-
var EMPTY_SURFACE_COMPONENTS = [];
|
|
37
|
-
var EMPTY_MEASURED_SURFACES = [];
|
|
38
|
-
var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function BlockControlsLeftSurfaces(_ref) {
|
|
39
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
40
|
-
var api = _ref.api,
|
|
41
|
-
editorView = _ref.editorView;
|
|
42
|
-
var _useSharedPluginState = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
43
|
-
var _states$blockControls, _states$blockControls2, _states$blockControls3, _states$blockControls4, _states$blockControls5, _states$blockControls6;
|
|
44
|
-
return {
|
|
45
|
-
activeNode: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.activeNode,
|
|
46
|
-
surfaceActiveNodes: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.surfaceActiveNodes,
|
|
47
|
-
surfaceAnchors: (_states$blockControls3 = (_states$blockControls4 = states.blockControlsState) === null || _states$blockControls4 === void 0 ? void 0 : _states$blockControls4.surfaceAnchors) !== null && _states$blockControls3 !== void 0 ? _states$blockControls3 : EMPTY_SURFACE_ANCHORS,
|
|
48
|
-
surfaceNodePositions: (_states$blockControls5 = (_states$blockControls6 = states.blockControlsState) === null || _states$blockControls6 === void 0 ? void 0 : _states$blockControls6.surfaceNodePositions) !== null && _states$blockControls5 !== void 0 ? _states$blockControls5 : EMPTY_SURFACE_POSITIONS
|
|
49
|
-
};
|
|
50
|
-
}),
|
|
51
|
-
activeNode = _useSharedPluginState.activeNode,
|
|
52
|
-
surfaceAnchors = _useSharedPluginState.surfaceAnchors,
|
|
53
|
-
surfaceActiveNodes = _useSharedPluginState.surfaceActiveNodes,
|
|
54
|
-
surfaceNodePositions = _useSharedPluginState.surfaceNodePositions;
|
|
55
|
-
var components = (_api$uiControlRegistr = (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : EMPTY_SURFACE_COMPONENTS;
|
|
56
|
-
var targets = (0, _react.useMemo)(function () {
|
|
57
|
-
var candidates = new Set(surfaceNodePositions);
|
|
58
|
-
return (0, _blockControlsSurfaceTargets.getBlockControlsSurfaceTargets)(activeNode, surfaceNodePositions).filter(function (_ref2) {
|
|
59
|
-
var position = _ref2.position;
|
|
60
|
-
return candidates.has(position);
|
|
61
|
-
});
|
|
62
|
-
}, [activeNode, surfaceNodePositions]);
|
|
63
|
-
var surfaces = (0, _react.useMemo)(function () {
|
|
64
|
-
return targets.flatMap(function (target) {
|
|
65
|
-
var _surfaceActiveNodes$g;
|
|
66
|
-
var context = (0, _blockControlsSurfaceContext.createBlockControlsSurfaceContextForPosition)(editorView.state, target.position, (_surfaceActiveNodes$g = surfaceActiveNodes === null || surfaceActiveNodes === void 0 ? void 0 : surfaceActiveNodes.get(target.position)) !== null && _surfaceActiveNodes$g !== void 0 ? _surfaceActiveNodes$g : activeNode);
|
|
67
|
-
if (!context) {
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
var surfaceContext = (0, _createSurfaceContext.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, context);
|
|
71
|
-
var surfaceComponents = (0, _blockControlsSurfaceComponents.getBlockControlsLeftSurfaceComponents)(components, surfaceContext);
|
|
72
|
-
if (!surfaceComponents) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
// The cache supplies the same anchor names used by ProseMirror decorations.
|
|
76
|
-
var anchorName = (0, _nativeAnchor.isCSSAnchorSupported)() ? surfaceAnchors.get(target.position) : undefined;
|
|
77
|
-
// Top-level controls can respond to the available left gutter without the surface
|
|
78
|
-
// host knowing which controls are registered or how they adapt.
|
|
79
|
-
var isTopLevel = context.targetNode.parentType === 'doc';
|
|
80
|
-
return [_objectSpread(_objectSpread({}, target), {}, {
|
|
81
|
-
anchorName: anchorName,
|
|
82
|
-
blockControlsContext: context,
|
|
83
|
-
isTopLevel: isTopLevel,
|
|
84
|
-
surfaceComponents: surfaceComponents,
|
|
85
|
-
surfaceContext: surfaceContext
|
|
86
|
-
})];
|
|
87
|
-
});
|
|
88
|
-
}, [activeNode, components, editorView, targets, surfaceAnchors, surfaceActiveNodes]);
|
|
89
|
-
/**
|
|
90
|
-
* Placements that need no measuring, so they are derived rather than stored: every inset is an
|
|
91
|
-
* `anchor()` the browser re-resolves on every layout change.
|
|
92
|
-
*/
|
|
93
|
-
var anchoredPlacements = (0, _react.useMemo)(function () {
|
|
94
|
-
return new Map(surfaces.flatMap(function (_ref3) {
|
|
95
|
-
var anchorName = _ref3.anchorName,
|
|
96
|
-
blockControlsContext = _ref3.blockControlsContext,
|
|
97
|
-
isTopLevel = _ref3.isTopLevel,
|
|
98
|
-
position = _ref3.position;
|
|
99
|
-
if (!anchorName) {
|
|
100
|
-
return [];
|
|
101
|
-
}
|
|
102
|
-
var options = {
|
|
103
|
-
anchorName: anchorName,
|
|
104
|
-
layout: blockControlsContext.targetNode.node.attrs.layout,
|
|
105
|
-
nodeType: blockControlsContext.targetNode.type.name,
|
|
106
|
-
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
107
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType
|
|
108
|
-
};
|
|
109
|
-
var placement = isTopLevel ? (0, _getSurfacePlacement.getAnchoredLeftGutterSurfacePlacement)(options) : (0, _getSurfacePlacement.getAnchoredSurfacePlacement)(_objectSpread(_objectSpread({}, options), {}, {
|
|
110
|
-
side: 'left'
|
|
111
|
-
}));
|
|
112
|
-
return [[position, placement]];
|
|
113
|
-
}));
|
|
114
|
-
}, [surfaces]);
|
|
115
|
-
// Only the surfaces that still need measuring drive the effect below, so a document of anchored
|
|
116
|
-
// blocks binds no scroll or resize listeners at all.
|
|
117
|
-
//
|
|
118
|
-
// The shared empty array matters: `surfaces` gets a new identity on every hover, since
|
|
119
|
-
// `activeNode` is one of its dependencies. Returning a fresh `[]` would give the effect a
|
|
120
|
-
// changed dependency each time and re-run it for nothing, which is the cost the anchored path
|
|
121
|
-
// exists to avoid.
|
|
122
|
-
var measuredSurfaces = (0, _react.useMemo)(function () {
|
|
123
|
-
var measured = surfaces.filter(function (_ref4) {
|
|
124
|
-
var anchorName = _ref4.anchorName;
|
|
125
|
-
return !anchorName;
|
|
126
|
-
});
|
|
127
|
-
return measured.length === 0 ? EMPTY_MEASURED_SURFACES : measured;
|
|
128
|
-
}, [surfaces]);
|
|
129
|
-
var _useState = (0, _react.useState)(new Map()),
|
|
130
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
131
|
-
placements = _useState2[0],
|
|
132
|
-
setPlacements = _useState2[1];
|
|
133
|
-
var animationFrameRef = (0, _react.useRef)(undefined);
|
|
134
|
-
(0, _react.useLayoutEffect)(function () {
|
|
135
|
-
var _getDocument;
|
|
136
|
-
if (measuredSurfaces.length === 0) {
|
|
137
|
-
// Clear only when there is something to clear. Handing React a fresh Map every time would
|
|
138
|
-
// fail its identity check and commit a render to replace one empty map with another.
|
|
139
|
-
setPlacements(function (previous) {
|
|
140
|
-
return previous.size > 0 ? new Map() : previous;
|
|
141
|
-
});
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
var measurementTargets = measuredSurfaces.flatMap(function (_ref5) {
|
|
145
|
-
var blockControlsContext = _ref5.blockControlsContext,
|
|
146
|
-
isTopLevel = _ref5.isTopLevel,
|
|
147
|
-
position = _ref5.position;
|
|
148
|
-
var targetNodeElement = editorView.nodeDOM(blockControlsContext.targetNode.pos);
|
|
149
|
-
var targetElementRoot = targetNodeElement instanceof HTMLElement ? targetNodeElement : targetNodeElement === null || targetNodeElement === void 0 ? void 0 : targetNodeElement.parentElement;
|
|
150
|
-
if (!targetElementRoot) {
|
|
151
|
-
return [];
|
|
152
|
-
}
|
|
153
|
-
return [{
|
|
154
|
-
blockControlsContext: blockControlsContext,
|
|
155
|
-
isTopLevel: isTopLevel,
|
|
156
|
-
position: position,
|
|
157
|
-
targetElement: (0, _getNodeContentElement.getNodeContentElement)(targetElementRoot, blockControlsContext.targetNode.type.name),
|
|
158
|
-
targetElementRoot: targetElementRoot
|
|
159
|
-
}];
|
|
160
|
-
});
|
|
161
|
-
var offsetParent = editorView.dom.offsetParent;
|
|
162
|
-
var isDocumentOffsetParent = !offsetParent || offsetParent === ((_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.body);
|
|
163
|
-
var scrollingOffsetParent = offsetParent instanceof HTMLElement && !isDocumentOffsetParent ? offsetParent : undefined;
|
|
164
|
-
var updatePositions = function updatePositions() {
|
|
165
|
-
var _scrollingOffsetParen, _scrollingOffsetParen2;
|
|
166
|
-
animationFrameRef.current = undefined;
|
|
167
|
-
var offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
168
|
-
var offsetParentScrollTop = (_scrollingOffsetParen = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollTop) !== null && _scrollingOffsetParen !== void 0 ? _scrollingOffsetParen : window.scrollY;
|
|
169
|
-
var offsetParentScrollLeft = (_scrollingOffsetParen2 = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollLeft) !== null && _scrollingOffsetParen2 !== void 0 ? _scrollingOffsetParen2 : window.scrollX;
|
|
170
|
-
var nextPlacements = new Map();
|
|
171
|
-
var _iterator = _createForOfIteratorHelper(measurementTargets),
|
|
172
|
-
_step;
|
|
173
|
-
try {
|
|
174
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
175
|
-
var _targetElementRoot$ge, _offsetParentRect$lef;
|
|
176
|
-
var _step$value = _step.value,
|
|
177
|
-
blockControlsContext = _step$value.blockControlsContext,
|
|
178
|
-
isTopLevel = _step$value.isTopLevel,
|
|
179
|
-
position = _step$value.position,
|
|
180
|
-
targetElement = _step$value.targetElement,
|
|
181
|
-
targetElementRoot = _step$value.targetElementRoot;
|
|
182
|
-
if (!targetElementRoot.isConnected || !targetElement.isConnected) {
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
var options = {
|
|
186
|
-
layout: (_targetElementRoot$ge = targetElementRoot.getAttribute('layout')) !== null && _targetElementRoot$ge !== void 0 ? _targetElementRoot$ge : '',
|
|
187
|
-
nodeRect: targetElement.getBoundingClientRect(),
|
|
188
|
-
nodeType: blockControlsContext.targetNode.type.name,
|
|
189
|
-
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
190
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType
|
|
191
|
-
};
|
|
192
|
-
var placement = isTopLevel ? (0, _getSurfacePlacement.getLeftGutterSurfacePlacement)(_objectSpread(_objectSpread({}, options), {}, {
|
|
193
|
-
leftGutterBoundary: (_offsetParentRect$lef = offsetParentRect === null || offsetParentRect === void 0 ? void 0 : offsetParentRect.left) !== null && _offsetParentRect$lef !== void 0 ? _offsetParentRect$lef : 0
|
|
194
|
-
})) : (0, _getSurfacePlacement.getSurfacePlacement)(_objectSpread(_objectSpread({}, options), {}, {
|
|
195
|
-
side: 'left'
|
|
196
|
-
}));
|
|
197
|
-
nextPlacements.set(position, (0, _getSurfacePlacement.toMeasuredSurfaceWrapperPlacement)((0, _getSurfacePlacement.getAbsoluteSurfacePlacement)({
|
|
198
|
-
offsetParentRect: offsetParentRect,
|
|
199
|
-
offsetParentScrollLeft: offsetParentScrollLeft,
|
|
200
|
-
offsetParentScrollTop: offsetParentScrollTop,
|
|
201
|
-
placement: placement
|
|
202
|
-
})));
|
|
203
|
-
}
|
|
204
|
-
} catch (err) {
|
|
205
|
-
_iterator.e(err);
|
|
206
|
-
} finally {
|
|
207
|
-
_iterator.f();
|
|
208
|
-
}
|
|
209
|
-
setPlacements(nextPlacements);
|
|
210
|
-
};
|
|
211
|
-
var schedulePositionUpdate = function schedulePositionUpdate() {
|
|
212
|
-
if (animationFrameRef.current === undefined) {
|
|
213
|
-
animationFrameRef.current = requestAnimationFrame(updatePositions);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
updatePositions();
|
|
217
|
-
var resizeObserver = new ResizeObserver(schedulePositionUpdate);
|
|
218
|
-
var observedElements = new Set([editorView.dom]);
|
|
219
|
-
var _iterator2 = _createForOfIteratorHelper(measurementTargets),
|
|
220
|
-
_step2;
|
|
221
|
-
try {
|
|
222
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
223
|
-
var targetElement = _step2.value.targetElement;
|
|
224
|
-
observedElements.add(targetElement);
|
|
225
|
-
}
|
|
226
|
-
} catch (err) {
|
|
227
|
-
_iterator2.e(err);
|
|
228
|
-
} finally {
|
|
229
|
-
_iterator2.f();
|
|
230
|
-
}
|
|
231
|
-
if (offsetParent instanceof HTMLElement) {
|
|
232
|
-
observedElements.add(offsetParent);
|
|
233
|
-
}
|
|
234
|
-
observedElements.forEach(function (element) {
|
|
235
|
-
return resizeObserver.observe(element);
|
|
236
|
-
});
|
|
237
|
-
var unbindWindowResize = (0, _bindEventListener.bind)(window, {
|
|
238
|
-
type: 'resize',
|
|
239
|
-
listener: schedulePositionUpdate
|
|
240
|
-
});
|
|
241
|
-
var unbindWindowScroll = (0, _bindEventListener.bind)(window, {
|
|
242
|
-
type: 'scroll',
|
|
243
|
-
listener: schedulePositionUpdate,
|
|
244
|
-
options: {
|
|
245
|
-
capture: true,
|
|
246
|
-
passive: true
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
var visualViewport = window.visualViewport;
|
|
250
|
-
var unbindVisualViewportResize = visualViewport ? (0, _bindEventListener.bind)(visualViewport, {
|
|
251
|
-
type: 'resize',
|
|
252
|
-
listener: schedulePositionUpdate
|
|
253
|
-
}) : undefined;
|
|
254
|
-
var unbindVisualViewportScroll = visualViewport ? (0, _bindEventListener.bind)(visualViewport, {
|
|
255
|
-
type: 'scroll',
|
|
256
|
-
listener: schedulePositionUpdate
|
|
257
|
-
}) : undefined;
|
|
258
|
-
var unbindTransitionEnd = (0, _bindEventListener.bind)(editorView.dom, {
|
|
259
|
-
type: 'transitionend',
|
|
260
|
-
listener: schedulePositionUpdate,
|
|
261
|
-
options: {
|
|
262
|
-
capture: true
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
return function () {
|
|
266
|
-
if (animationFrameRef.current !== undefined) {
|
|
267
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
268
|
-
animationFrameRef.current = undefined;
|
|
269
|
-
}
|
|
270
|
-
resizeObserver.disconnect();
|
|
271
|
-
unbindWindowResize();
|
|
272
|
-
unbindWindowScroll();
|
|
273
|
-
unbindVisualViewportResize === null || unbindVisualViewportResize === void 0 || unbindVisualViewportResize();
|
|
274
|
-
unbindVisualViewportScroll === null || unbindVisualViewportScroll === void 0 || unbindVisualViewportScroll();
|
|
275
|
-
unbindTransitionEnd();
|
|
276
|
-
};
|
|
277
|
-
}, [editorView, measuredSurfaces]);
|
|
278
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, surfaces.map(function (_ref6) {
|
|
279
|
-
var _activeNode$handleOpt, _anchoredPlacements$g;
|
|
280
|
-
var position = _ref6.position,
|
|
281
|
-
source = _ref6.source,
|
|
282
|
-
surfaceComponents = _ref6.surfaceComponents,
|
|
283
|
-
surfaceContext = _ref6.surfaceContext;
|
|
284
|
-
return /*#__PURE__*/_react.default.createElement(_blockControlsLeftSurface.BlockControlsLeftSurface, {
|
|
285
|
-
api: api,
|
|
286
|
-
components: surfaceComponents,
|
|
287
|
-
forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 || (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
288
|
-
key: position,
|
|
289
|
-
placement: (_anchoredPlacements$g = anchoredPlacements.get(position)) !== null && _anchoredPlacements$g !== void 0 ? _anchoredPlacements$g : placements.get(position),
|
|
290
|
-
source: source,
|
|
291
|
-
surfaceContext: surfaceContext
|
|
292
|
-
});
|
|
293
|
-
}));
|
|
294
|
-
};
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v3.0.4 */
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
exports.BlockControlsRightSurfaces = void 0;
|
|
10
|
-
var _runtime = require("@compiled/react/runtime");
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
-
var _bindEventListener = require("bind-event-listener");
|
|
15
|
-
var _browserApis = require("@atlaskit/browser-apis");
|
|
16
|
-
var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
|
|
17
|
-
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
18
|
-
var _nativeAnchor = require("@atlaskit/editor-common/styles/native-anchor");
|
|
19
|
-
var _useSharedPluginStateWithSelector = require("@atlaskit/editor-common/useSharedPluginStateWithSelector");
|
|
20
|
-
var _createSurfaceContext = require("@atlaskit/editor-ui-control-model/create-surface-context");
|
|
21
|
-
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
22
|
-
var _blockControlsRightSurface = require("./block-controls-right-surface");
|
|
23
|
-
var _blockControlsSurfaceComponents = require("./block-controls-surface-components");
|
|
24
|
-
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
25
|
-
var _blockControlsSurfaceTargets = require("./block-controls-surface-targets");
|
|
26
|
-
var _getNodeContentElement = require("./utils/get-node-content-element");
|
|
27
|
-
var _getSurfacePlacement = require("./utils/get-surface-placement");
|
|
28
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
29
|
-
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; } } }; }
|
|
30
|
-
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; } }
|
|
31
|
-
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; }
|
|
32
|
-
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; }
|
|
33
|
-
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) { (0, _defineProperty2.default)(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; }
|
|
34
|
-
var EMPTY_SURFACE_POSITIONS = [];
|
|
35
|
-
var EMPTY_SURFACE_ANCHORS = new Map();
|
|
36
|
-
var EMPTY_SURFACE_COMPONENTS = [];
|
|
37
|
-
var EMPTY_MEASURED_SURFACES = [];
|
|
38
|
-
/**
|
|
39
|
-
* Registry-backed right surface tree. Mirrors the left surface's single-tree approach, but keeps its
|
|
40
|
-
* own components lookup, targets, placements and measurement lifecycle so the right surface never
|
|
41
|
-
* depends on the left surface's render pass.
|
|
42
|
-
*
|
|
43
|
-
* Targets are placed one of two ways. Where the node's anchor name can be relied on, the surface is
|
|
44
|
-
* positioned with `anchor()` and the browser keeps it attached with nothing re-rendering. Everything
|
|
45
|
-
* else is measured and kept honest by the observers below. See `hasInnerContentContainer`.
|
|
46
|
-
*/
|
|
47
|
-
var BlockControlsRightSurfaces = exports.BlockControlsRightSurfaces = function BlockControlsRightSurfaces(_ref) {
|
|
48
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
49
|
-
var api = _ref.api,
|
|
50
|
-
editorView = _ref.editorView;
|
|
51
|
-
var _useSharedPluginState = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
52
|
-
var _states$blockControls, _states$blockControls2, _states$blockControls3, _states$blockControls4, _states$blockControls5, _states$blockControls6;
|
|
53
|
-
return {
|
|
54
|
-
activeNode: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.activeNode,
|
|
55
|
-
surfaceActiveNodes: (_states$blockControls2 = states.blockControlsState) === null || _states$blockControls2 === void 0 ? void 0 : _states$blockControls2.surfaceActiveNodes,
|
|
56
|
-
surfaceAnchors: (_states$blockControls3 = (_states$blockControls4 = states.blockControlsState) === null || _states$blockControls4 === void 0 ? void 0 : _states$blockControls4.surfaceAnchors) !== null && _states$blockControls3 !== void 0 ? _states$blockControls3 : EMPTY_SURFACE_ANCHORS,
|
|
57
|
-
surfaceNodePositions: (_states$blockControls5 = (_states$blockControls6 = states.blockControlsState) === null || _states$blockControls6 === void 0 ? void 0 : _states$blockControls6.surfaceNodePositions) !== null && _states$blockControls5 !== void 0 ? _states$blockControls5 : EMPTY_SURFACE_POSITIONS
|
|
58
|
-
};
|
|
59
|
-
}),
|
|
60
|
-
activeNode = _useSharedPluginState.activeNode,
|
|
61
|
-
surfaceAnchors = _useSharedPluginState.surfaceAnchors,
|
|
62
|
-
surfaceActiveNodes = _useSharedPluginState.surfaceActiveNodes,
|
|
63
|
-
surfaceNodePositions = _useSharedPluginState.surfaceNodePositions;
|
|
64
|
-
var components = (_api$uiControlRegistr = (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : EMPTY_SURFACE_COMPONENTS;
|
|
65
|
-
var targets = (0, _react.useMemo)(function () {
|
|
66
|
-
var candidates = new Set(surfaceNodePositions);
|
|
67
|
-
return (0, _blockControlsSurfaceTargets.getBlockControlsSurfaceTargets)(activeNode, surfaceNodePositions).filter(function (_ref2) {
|
|
68
|
-
var position = _ref2.position;
|
|
69
|
-
return candidates.has(position);
|
|
70
|
-
});
|
|
71
|
-
}, [activeNode, surfaceNodePositions]);
|
|
72
|
-
var surfaces = (0, _react.useMemo)(function () {
|
|
73
|
-
return targets.flatMap(function (target) {
|
|
74
|
-
var _surfaceActiveNodes$g;
|
|
75
|
-
var context = (0, _blockControlsSurfaceContext.createBlockControlsSurfaceContextForPosition)(editorView.state, target.position, (_surfaceActiveNodes$g = surfaceActiveNodes === null || surfaceActiveNodes === void 0 ? void 0 : surfaceActiveNodes.get(target.position)) !== null && _surfaceActiveNodes$g !== void 0 ? _surfaceActiveNodes$g : activeNode);
|
|
76
|
-
if (!context) {
|
|
77
|
-
return [];
|
|
78
|
-
}
|
|
79
|
-
var surfaceContext = (0, _createSurfaceContext.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, context);
|
|
80
|
-
var surfaceComponents = (0, _blockControlsSurfaceComponents.getBlockControlsRightSurfaceComponents)(components, surfaceContext);
|
|
81
|
-
if (!surfaceComponents) {
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
// The cache supplies the same anchor names used by ProseMirror decorations.
|
|
85
|
-
var anchorName = (0, _nativeAnchor.isCSSAnchorSupported)() ? surfaceAnchors.get(target.position) : undefined;
|
|
86
|
-
return [_objectSpread(_objectSpread({}, target), {}, {
|
|
87
|
-
anchorName: anchorName,
|
|
88
|
-
blockControlsContext: context,
|
|
89
|
-
surfaceComponents: surfaceComponents,
|
|
90
|
-
surfaceContext: surfaceContext
|
|
91
|
-
})];
|
|
92
|
-
});
|
|
93
|
-
}, [activeNode, components, editorView, targets, surfaceAnchors, surfaceActiveNodes]);
|
|
94
|
-
/**
|
|
95
|
-
* Placements that need no measuring, so they are derived rather than stored: every inset is an
|
|
96
|
-
* `anchor()` the browser re-resolves on every layout change.
|
|
97
|
-
*/
|
|
98
|
-
var anchoredPlacements = (0, _react.useMemo)(function () {
|
|
99
|
-
return new Map(surfaces.flatMap(function (_ref3) {
|
|
100
|
-
var anchorName = _ref3.anchorName,
|
|
101
|
-
blockControlsContext = _ref3.blockControlsContext,
|
|
102
|
-
position = _ref3.position;
|
|
103
|
-
return anchorName ? [[position, (0, _getSurfacePlacement.getAnchoredSurfacePlacement)({
|
|
104
|
-
anchorName: anchorName,
|
|
105
|
-
nodeType: blockControlsContext.targetNode.type.name,
|
|
106
|
-
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
107
|
-
layout: blockControlsContext.targetNode.node.attrs.layout,
|
|
108
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
|
|
109
|
-
side: 'right'
|
|
110
|
-
})]] : [];
|
|
111
|
-
}));
|
|
112
|
-
}, [surfaces]);
|
|
113
|
-
// Only the surfaces that still need measuring drive the effect below, so a document of anchored
|
|
114
|
-
// blocks binds no scroll or resize listeners at all.
|
|
115
|
-
//
|
|
116
|
-
// The shared empty array matters: `surfaces` gets a new identity on every hover, since
|
|
117
|
-
// `activeNode` is one of its dependencies. Returning a fresh `[]` would give the effect a
|
|
118
|
-
// changed dependency each time and re-run it for nothing, which is the cost the anchored path
|
|
119
|
-
// exists to avoid.
|
|
120
|
-
var measuredSurfaces = (0, _react.useMemo)(function () {
|
|
121
|
-
var measured = surfaces.filter(function (_ref4) {
|
|
122
|
-
var anchorName = _ref4.anchorName;
|
|
123
|
-
return !anchorName;
|
|
124
|
-
});
|
|
125
|
-
return measured.length === 0 ? EMPTY_MEASURED_SURFACES : measured;
|
|
126
|
-
}, [surfaces]);
|
|
127
|
-
var _useState = (0, _react.useState)(new Map()),
|
|
128
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
129
|
-
placements = _useState2[0],
|
|
130
|
-
setPlacements = _useState2[1];
|
|
131
|
-
var animationFrameRef = (0, _react.useRef)(undefined);
|
|
132
|
-
(0, _react.useLayoutEffect)(function () {
|
|
133
|
-
var _getDocument;
|
|
134
|
-
if (measuredSurfaces.length === 0) {
|
|
135
|
-
// Clear only when there is something to clear. Handing React a fresh Map every time would
|
|
136
|
-
// fail its identity check and commit a render to replace one empty map with another.
|
|
137
|
-
setPlacements(function (previous) {
|
|
138
|
-
return previous.size > 0 ? new Map() : previous;
|
|
139
|
-
});
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
var measurementTargets = measuredSurfaces.flatMap(function (_ref5) {
|
|
143
|
-
var blockControlsContext = _ref5.blockControlsContext,
|
|
144
|
-
position = _ref5.position;
|
|
145
|
-
var targetNodeElement = editorView.nodeDOM(blockControlsContext.targetNode.pos);
|
|
146
|
-
var targetElementRoot = targetNodeElement instanceof HTMLElement ? targetNodeElement : targetNodeElement === null || targetNodeElement === void 0 ? void 0 : targetNodeElement.parentElement;
|
|
147
|
-
if (!targetElementRoot) {
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
150
|
-
return [{
|
|
151
|
-
blockControlsContext: blockControlsContext,
|
|
152
|
-
position: position,
|
|
153
|
-
targetElement: (0, _getNodeContentElement.getNodeContentElement)(targetElementRoot, blockControlsContext.targetNode.type.name),
|
|
154
|
-
targetElementRoot: targetElementRoot
|
|
155
|
-
}];
|
|
156
|
-
});
|
|
157
|
-
var offsetParent = editorView.dom.offsetParent;
|
|
158
|
-
var isDocumentOffsetParent = !offsetParent || offsetParent === ((_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.body);
|
|
159
|
-
var scrollingOffsetParent = offsetParent instanceof HTMLElement && !isDocumentOffsetParent ? offsetParent : undefined;
|
|
160
|
-
var updatePositions = function updatePositions() {
|
|
161
|
-
var _scrollingOffsetParen, _scrollingOffsetParen2;
|
|
162
|
-
animationFrameRef.current = undefined;
|
|
163
|
-
var offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
164
|
-
var offsetParentScrollTop = (_scrollingOffsetParen = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollTop) !== null && _scrollingOffsetParen !== void 0 ? _scrollingOffsetParen : window.scrollY;
|
|
165
|
-
var offsetParentScrollLeft = (_scrollingOffsetParen2 = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollLeft) !== null && _scrollingOffsetParen2 !== void 0 ? _scrollingOffsetParen2 : window.scrollX;
|
|
166
|
-
var nextPlacements = new Map();
|
|
167
|
-
var _iterator = _createForOfIteratorHelper(measurementTargets),
|
|
168
|
-
_step;
|
|
169
|
-
try {
|
|
170
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
171
|
-
var _targetElementRoot$ge;
|
|
172
|
-
var _step$value = _step.value,
|
|
173
|
-
blockControlsContext = _step$value.blockControlsContext,
|
|
174
|
-
position = _step$value.position,
|
|
175
|
-
targetElement = _step$value.targetElement,
|
|
176
|
-
targetElementRoot = _step$value.targetElementRoot;
|
|
177
|
-
if (!targetElementRoot.isConnected || !targetElement.isConnected) {
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
var placement = (0, _getSurfacePlacement.getSurfacePlacement)({
|
|
181
|
-
layout: (_targetElementRoot$ge = targetElementRoot.getAttribute('layout')) !== null && _targetElementRoot$ge !== void 0 ? _targetElementRoot$ge : '',
|
|
182
|
-
nodeRect: targetElement.getBoundingClientRect(),
|
|
183
|
-
nodeType: blockControlsContext.targetNode.type.name,
|
|
184
|
-
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
185
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
|
|
186
|
-
side: 'right'
|
|
187
|
-
});
|
|
188
|
-
nextPlacements.set(position, (0, _getSurfacePlacement.toMeasuredSurfaceWrapperPlacement)((0, _getSurfacePlacement.getAbsoluteSurfacePlacement)({
|
|
189
|
-
offsetParentRect: offsetParentRect,
|
|
190
|
-
offsetParentScrollLeft: offsetParentScrollLeft,
|
|
191
|
-
offsetParentScrollTop: offsetParentScrollTop,
|
|
192
|
-
placement: placement
|
|
193
|
-
})));
|
|
194
|
-
}
|
|
195
|
-
} catch (err) {
|
|
196
|
-
_iterator.e(err);
|
|
197
|
-
} finally {
|
|
198
|
-
_iterator.f();
|
|
199
|
-
}
|
|
200
|
-
setPlacements(nextPlacements);
|
|
201
|
-
};
|
|
202
|
-
var schedulePositionUpdate = function schedulePositionUpdate() {
|
|
203
|
-
if (animationFrameRef.current === undefined) {
|
|
204
|
-
animationFrameRef.current = requestAnimationFrame(updatePositions);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
updatePositions();
|
|
208
|
-
var resizeObserver = new ResizeObserver(schedulePositionUpdate);
|
|
209
|
-
var observedElements = new Set([editorView.dom]);
|
|
210
|
-
var _iterator2 = _createForOfIteratorHelper(measurementTargets),
|
|
211
|
-
_step2;
|
|
212
|
-
try {
|
|
213
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
214
|
-
var targetElement = _step2.value.targetElement;
|
|
215
|
-
observedElements.add(targetElement);
|
|
216
|
-
}
|
|
217
|
-
} catch (err) {
|
|
218
|
-
_iterator2.e(err);
|
|
219
|
-
} finally {
|
|
220
|
-
_iterator2.f();
|
|
221
|
-
}
|
|
222
|
-
if (offsetParent instanceof HTMLElement) {
|
|
223
|
-
observedElements.add(offsetParent);
|
|
224
|
-
}
|
|
225
|
-
observedElements.forEach(function (element) {
|
|
226
|
-
return resizeObserver.observe(element);
|
|
227
|
-
});
|
|
228
|
-
var unbindWindowResize = (0, _bindEventListener.bind)(window, {
|
|
229
|
-
type: 'resize',
|
|
230
|
-
listener: schedulePositionUpdate
|
|
231
|
-
});
|
|
232
|
-
var unbindWindowScroll = (0, _bindEventListener.bind)(window, {
|
|
233
|
-
type: 'scroll',
|
|
234
|
-
listener: schedulePositionUpdate,
|
|
235
|
-
options: {
|
|
236
|
-
capture: true,
|
|
237
|
-
passive: true
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
var visualViewport = window.visualViewport;
|
|
241
|
-
var unbindVisualViewportResize = visualViewport ? (0, _bindEventListener.bind)(visualViewport, {
|
|
242
|
-
type: 'resize',
|
|
243
|
-
listener: schedulePositionUpdate
|
|
244
|
-
}) : undefined;
|
|
245
|
-
var unbindVisualViewportScroll = visualViewport ? (0, _bindEventListener.bind)(visualViewport, {
|
|
246
|
-
type: 'scroll',
|
|
247
|
-
listener: schedulePositionUpdate
|
|
248
|
-
}) : undefined;
|
|
249
|
-
var unbindTransitionEnd = (0, _bindEventListener.bind)(editorView.dom, {
|
|
250
|
-
type: 'transitionend',
|
|
251
|
-
listener: schedulePositionUpdate,
|
|
252
|
-
options: {
|
|
253
|
-
capture: true
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
return function () {
|
|
257
|
-
if (animationFrameRef.current !== undefined) {
|
|
258
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
259
|
-
animationFrameRef.current = undefined;
|
|
260
|
-
}
|
|
261
|
-
resizeObserver.disconnect();
|
|
262
|
-
unbindWindowResize();
|
|
263
|
-
unbindWindowScroll();
|
|
264
|
-
unbindVisualViewportResize === null || unbindVisualViewportResize === void 0 || unbindVisualViewportResize();
|
|
265
|
-
unbindVisualViewportScroll === null || unbindVisualViewportScroll === void 0 || unbindVisualViewportScroll();
|
|
266
|
-
unbindTransitionEnd();
|
|
267
|
-
};
|
|
268
|
-
}, [editorView, measuredSurfaces]);
|
|
269
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, surfaces.map(function (_ref6) {
|
|
270
|
-
var _activeNode$handleOpt, _anchoredPlacements$g;
|
|
271
|
-
var position = _ref6.position,
|
|
272
|
-
source = _ref6.source,
|
|
273
|
-
surfaceComponents = _ref6.surfaceComponents,
|
|
274
|
-
surfaceContext = _ref6.surfaceContext;
|
|
275
|
-
return /*#__PURE__*/_react.default.createElement(_blockControlsRightSurface.BlockControlsRightSurface, {
|
|
276
|
-
api: api,
|
|
277
|
-
components: surfaceComponents,
|
|
278
|
-
forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 || (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
279
|
-
key: position,
|
|
280
|
-
placement: (_anchoredPlacements$g = anchoredPlacements.get(position)) !== null && _anchoredPlacements$g !== void 0 ? _anchoredPlacements$g : placements.get(position),
|
|
281
|
-
source: source,
|
|
282
|
-
surfaceContext: surfaceContext
|
|
283
|
-
});
|
|
284
|
-
}));
|
|
285
|
-
};
|