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