@atlaskit/editor-plugin-block-controls 17.2.5 → 17.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/blockControlsPlugin.js +22 -2
- package/dist/cjs/pm-plugins/main.js +9 -7
- package/dist/cjs/pm-plugins/utils/surface-node-positions.js +45 -19
- package/dist/cjs/ui/block-controls-left-surfaces.js +5 -4
- package/dist/cjs/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/cjs/ui/block-controls-right-surface.js +45 -0
- package/dist/cjs/ui/block-controls-right-surfaces.js +222 -0
- package/dist/{esm/ui/block-controls-left-surface-targets.js → cjs/ui/block-controls-surface-targets.js} +14 -2
- package/dist/cjs/ui/utils/get-surface-placement.js +20 -6
- package/dist/es2019/blockControlsPlugin.js +27 -3
- package/dist/es2019/pm-plugins/main.js +9 -9
- package/dist/es2019/pm-plugins/utils/surface-node-positions.js +34 -15
- package/dist/es2019/ui/block-controls-left-surfaces.js +5 -4
- package/dist/es2019/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/es2019/ui/block-controls-right-surface.js +39 -0
- package/dist/es2019/ui/block-controls-right-surfaces.js +187 -0
- package/dist/es2019/ui/{block-controls-left-surface-targets.js → block-controls-surface-targets.js} +8 -2
- package/dist/es2019/ui/utils/get-surface-placement.js +20 -6
- package/dist/esm/blockControlsPlugin.js +23 -3
- package/dist/esm/pm-plugins/main.js +10 -8
- package/dist/esm/pm-plugins/utils/surface-node-positions.js +45 -19
- package/dist/esm/ui/block-controls-left-surfaces.js +5 -4
- package/dist/esm/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/esm/ui/block-controls-right-surface.js +38 -0
- package/dist/esm/ui/block-controls-right-surfaces.js +213 -0
- package/dist/{cjs/ui/block-controls-left-surface-targets.js → esm/ui/block-controls-surface-targets.js} +8 -8
- package/dist/esm/ui/utils/get-surface-placement.js +20 -6
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/pm-plugins/utils/surface-node-positions.d.ts +3 -3
- package/dist/types/ui/block-controls-left-surface.d.ts +2 -2
- package/dist/types/ui/block-controls-right-surface.d.ts +23 -0
- package/dist/types/ui/block-controls-right-surfaces.d.ts +20 -0
- package/dist/types/ui/block-controls-surface-targets.d.ts +13 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +12 -4
- package/package.json +22 -22
- package/dist/types/ui/block-controls-left-surface-targets.d.ts +0 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
4
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -7,7 +8,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
8
|
import rafSchedule from 'raf-schd';
|
|
8
9
|
import { getDocument } from '@atlaskit/browser-apis';
|
|
9
10
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
10
|
-
import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
11
|
+
import { BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
11
12
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
12
13
|
import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor';
|
|
13
14
|
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
@@ -239,7 +240,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
239
240
|
var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
|
|
240
241
|
var resizeObserverWidth = arguments.length > 11 ? arguments[11] : undefined;
|
|
241
242
|
var pragmaticCleanup = arguments.length > 12 ? arguments[12] : undefined;
|
|
242
|
-
var
|
|
243
|
+
var resolvedSurfaces = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : [];
|
|
243
244
|
var activeNode = currentState.activeNode,
|
|
244
245
|
decorations = currentState.decorations,
|
|
245
246
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -810,14 +811,14 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
810
811
|
var _latestActiveNode13, _latestActiveNode14;
|
|
811
812
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && flags.legacyDragHandleEnabled && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
|
|
812
813
|
}
|
|
813
|
-
if (flags.surfaceNodePositionsEnabled &&
|
|
814
|
+
if (flags.surfaceNodePositionsEnabled && resolvedSurfaces.length > 0) {
|
|
814
815
|
surfaceNodePositions = updateSurfaceNodePositions({
|
|
815
816
|
activeNode: newActiveNode,
|
|
816
817
|
currentPositions: surfaceNodePositions,
|
|
817
818
|
from: from,
|
|
818
819
|
newState: newState,
|
|
819
820
|
previousActiveNode: previousActiveNode,
|
|
820
|
-
|
|
821
|
+
resolvedSurfaces: resolvedSurfaces,
|
|
821
822
|
to: to,
|
|
822
823
|
tr: tr
|
|
823
824
|
});
|
|
@@ -867,11 +868,12 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
867
868
|
};
|
|
868
869
|
export { _apply as apply };
|
|
869
870
|
export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
870
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
871
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
|
|
871
872
|
var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
872
873
|
var quickInsertButtonEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
873
874
|
var legacyDragHandleEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
|
|
874
875
|
var surfaceNodePositionsEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
876
|
+
var rightSurfaceEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
875
877
|
var _getIntl = getIntl(),
|
|
876
878
|
formatMessage = _getIntl.formatMessage;
|
|
877
879
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
@@ -883,7 +885,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
883
885
|
surfaceNodePositionsEnabled: surfaceNodePositionsEnabled,
|
|
884
886
|
toolbarFlagsEnabled: toolbarFlagsEnabled
|
|
885
887
|
};
|
|
886
|
-
var
|
|
888
|
+
var resolvedSurfaces = surfaceNodePositionsEnabled ? [resolveSurface((_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [], BLOCK_CONTROLS_LEFT_SURFACE)].concat(_toConsumableArray(rightSurfaceEnabled ? [resolveSurface((_api$uiControlRegistr3 = api === null || api === void 0 || (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [], BLOCK_CONTROLS_RIGHT_SURFACE)] : [])) : [];
|
|
887
889
|
var anchorRectCache;
|
|
888
890
|
if (!isAnchorSupported()) {
|
|
889
891
|
anchorRectCache = new AnchorRectCache();
|
|
@@ -895,11 +897,11 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
895
897
|
state: {
|
|
896
898
|
init: function init(_config, editorState) {
|
|
897
899
|
return _objectSpread(_objectSpread({}, initialState), {}, {
|
|
898
|
-
surfaceNodePositions:
|
|
900
|
+
surfaceNodePositions: resolvedSurfaces.length > 0 ? getSurfaceNodePositions(editorState, resolvedSurfaces) : []
|
|
899
901
|
});
|
|
900
902
|
},
|
|
901
903
|
apply: function apply(tr, currentState, _, newState) {
|
|
902
|
-
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup,
|
|
904
|
+
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces);
|
|
903
905
|
}
|
|
904
906
|
},
|
|
905
907
|
props: {
|
|
@@ -7,19 +7,39 @@ var createSurfaceContextAtPosition = function createSurfaceContextAtPosition(sta
|
|
|
7
7
|
var blockControlsContext = createBlockControlsSurfaceContextForPosition(state, position, activeNode);
|
|
8
8
|
return blockControlsContext ? createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, blockControlsContext) : undefined;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A position qualifies as soon as ANY of the given surfaces would render something for it.
|
|
13
|
+
* The surface context depends only on state/position/activeNode, not on which surface is being
|
|
14
|
+
* checked, so it's built once here rather than once per surface inside the `.some()`.
|
|
15
|
+
*/
|
|
16
|
+
var willAnySurfaceRenderAt = function willAnySurfaceRenderAt(surfaces, state, position, activeNode) {
|
|
17
|
+
var surfaceContext = createSurfaceContextAtPosition(state, position, activeNode);
|
|
18
|
+
return surfaces.some(function (_ref) {
|
|
19
|
+
var childrenMap = _ref.childrenMap,
|
|
20
|
+
root = _ref.root;
|
|
21
|
+
return willComponentRender(root, childrenMap, surfaceContext);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export var getSurfaceNodePositions = function getSurfaceNodePositions(state, resolvedSurfaces, activeNode) {
|
|
11
25
|
var from = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
12
26
|
var to = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : state.doc.content.size;
|
|
13
|
-
var
|
|
14
|
-
childrenMap =
|
|
15
|
-
|
|
27
|
+
var surfaces = resolvedSurfaces.flatMap(function (_ref2) {
|
|
28
|
+
var childrenMap = _ref2.childrenMap,
|
|
29
|
+
root = _ref2.root;
|
|
30
|
+
return root ? [{
|
|
31
|
+
childrenMap: childrenMap,
|
|
32
|
+
root: root
|
|
33
|
+
}] : [];
|
|
34
|
+
});
|
|
35
|
+
if (surfaces.length === 0) {
|
|
16
36
|
return [];
|
|
17
37
|
}
|
|
18
38
|
var positions = [];
|
|
19
39
|
var start = Math.max(0, from);
|
|
20
40
|
var end = Math.min(state.doc.content.size, Math.max(start, to));
|
|
21
41
|
state.doc.nodesBetween(start, end, function (node, position) {
|
|
22
|
-
if (node.isBlock &&
|
|
42
|
+
if (node.isBlock && willAnySurfaceRenderAt(surfaces, state, position, activeNode)) {
|
|
23
43
|
positions.push(position);
|
|
24
44
|
}
|
|
25
45
|
});
|
|
@@ -28,25 +48,31 @@ export var getSurfaceNodePositions = function getSurfaceNodePositions(state, res
|
|
|
28
48
|
var hasActiveNodeChanged = function hasActiveNodeChanged(previousActiveNode, activeNode) {
|
|
29
49
|
return (previousActiveNode === null || previousActiveNode === void 0 ? void 0 : previousActiveNode.pos) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) || (previousActiveNode === null || previousActiveNode === void 0 ? void 0 : previousActiveNode.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || (previousActiveNode === null || previousActiveNode === void 0 ? void 0 : previousActiveNode.rootPos) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos);
|
|
30
50
|
};
|
|
31
|
-
export var updateSurfaceNodePositions = function updateSurfaceNodePositions(
|
|
32
|
-
var activeNode =
|
|
33
|
-
currentPositions =
|
|
34
|
-
from =
|
|
35
|
-
newState =
|
|
36
|
-
previousActiveNode =
|
|
37
|
-
|
|
38
|
-
to =
|
|
39
|
-
tr =
|
|
51
|
+
export var updateSurfaceNodePositions = function updateSurfaceNodePositions(_ref3) {
|
|
52
|
+
var activeNode = _ref3.activeNode,
|
|
53
|
+
currentPositions = _ref3.currentPositions,
|
|
54
|
+
from = _ref3.from,
|
|
55
|
+
newState = _ref3.newState,
|
|
56
|
+
previousActiveNode = _ref3.previousActiveNode,
|
|
57
|
+
resolvedSurfaces = _ref3.resolvedSurfaces,
|
|
58
|
+
to = _ref3.to,
|
|
59
|
+
tr = _ref3.tr;
|
|
40
60
|
var activeNodeChanged = hasActiveNodeChanged(previousActiveNode, activeNode);
|
|
41
61
|
if (!tr.docChanged && !activeNodeChanged) {
|
|
42
62
|
return currentPositions;
|
|
43
63
|
}
|
|
44
64
|
var nextActiveNode = activeNode !== null && activeNode !== void 0 ? activeNode : undefined;
|
|
45
65
|
if (activeNodeChanged) {
|
|
46
|
-
return getSurfaceNodePositions(newState,
|
|
66
|
+
return getSurfaceNodePositions(newState, resolvedSurfaces, nextActiveNode);
|
|
47
67
|
}
|
|
48
|
-
var
|
|
49
|
-
childrenMap =
|
|
68
|
+
var surfaces = resolvedSurfaces.flatMap(function (_ref4) {
|
|
69
|
+
var childrenMap = _ref4.childrenMap,
|
|
70
|
+
root = _ref4.root;
|
|
71
|
+
return root ? [{
|
|
72
|
+
childrenMap: childrenMap,
|
|
73
|
+
root: root
|
|
74
|
+
}] : [];
|
|
75
|
+
});
|
|
50
76
|
var mappedPositions = currentPositions.map(function (position) {
|
|
51
77
|
return tr.mapping.mapResult(position, -1);
|
|
52
78
|
}).filter(function (result) {
|
|
@@ -55,9 +81,9 @@ export var updateSurfaceNodePositions = function updateSurfaceNodePositions(_ref
|
|
|
55
81
|
return result.pos;
|
|
56
82
|
}).filter(function (position) {
|
|
57
83
|
var node = newState.doc.nodeAt(position);
|
|
58
|
-
return Boolean((node === null || node === void 0 ? void 0 : node.isBlock) &&
|
|
84
|
+
return Boolean((node === null || node === void 0 ? void 0 : node.isBlock) && willAnySurfaceRenderAt(surfaces, newState, position, nextActiveNode));
|
|
59
85
|
});
|
|
60
|
-
var changedPositions = getSurfaceNodePositions(newState,
|
|
86
|
+
var changedPositions = getSurfaceNodePositions(newState, resolvedSurfaces, nextActiveNode, from - 1, to + 1);
|
|
61
87
|
return Array.from(new Set([].concat(_toConsumableArray(mappedPositions), _toConsumableArray(changedPositions)))).sort(function (first, second) {
|
|
62
88
|
return first - second;
|
|
63
89
|
});
|
|
@@ -15,9 +15,9 @@ import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-contr
|
|
|
15
15
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
16
16
|
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/create-surface-context';
|
|
17
17
|
import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
|
|
18
|
-
import { createBlockControlsSurfaceContext, createBlockControlsSurfaceContextForPosition } from './block-controls-surface-context';
|
|
19
18
|
import { BlockControlsLeftSurface } from './block-controls-left-surface';
|
|
20
|
-
import {
|
|
19
|
+
import { createBlockControlsSurfaceContext, createBlockControlsSurfaceContextForPosition } from './block-controls-surface-context';
|
|
20
|
+
import { getBlockControlsSurfaceTargets } from './block-controls-surface-targets';
|
|
21
21
|
import { getNodeContentElement } from './utils/get-node-content-element';
|
|
22
22
|
import { getAbsoluteSurfacePlacement, getSurfacePlacement } from './utils/get-surface-placement';
|
|
23
23
|
var EMPTY_SURFACE_POSITIONS = [];
|
|
@@ -37,7 +37,7 @@ export var BlockControlsLeftSurfaces = function BlockControlsLeftSurfaces(_ref)
|
|
|
37
37
|
surfaceNodePositions = _useSharedPluginState.surfaceNodePositions;
|
|
38
38
|
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;
|
|
39
39
|
var targets = useMemo(function () {
|
|
40
|
-
return
|
|
40
|
+
return getBlockControlsSurfaceTargets(activeNode, surfaceNodePositions);
|
|
41
41
|
}, [activeNode, surfaceNodePositions]);
|
|
42
42
|
var surfaces = useMemo(function () {
|
|
43
43
|
return targets.flatMap(function (target) {
|
|
@@ -106,7 +106,8 @@ export var BlockControlsLeftSurfaces = function BlockControlsLeftSurfaces(_ref)
|
|
|
106
106
|
nodeRect: targetElement.getBoundingClientRect(),
|
|
107
107
|
nodeType: blockControlsContext.targetNode.type.name,
|
|
108
108
|
nodeTypeWithLevel: getNodeTypeWithLevel(blockControlsContext.targetNode.node),
|
|
109
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType
|
|
109
|
+
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
|
|
110
|
+
side: 'left'
|
|
110
111
|
});
|
|
111
112
|
nextPlacements.set(position, getAbsoluteSurfacePlacement({
|
|
112
113
|
offsetParentRect: offsetParentRect,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* block-controls-right-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
import "./block-controls-right-surface.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
6
|
+
import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
7
|
+
import { VisibilityContainer } from './visibility-container';
|
|
8
|
+
var rightSurfaceStyles = null;
|
|
9
|
+
/** Renders one right block-controls surface at a document position. */
|
|
10
|
+
export var BlockControlsRightSurface = function BlockControlsRightSurface(_ref) {
|
|
11
|
+
var api = _ref.api,
|
|
12
|
+
components = _ref.components,
|
|
13
|
+
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
14
|
+
placement = _ref.placement,
|
|
15
|
+
source = _ref.source,
|
|
16
|
+
surfaceContext = _ref.surfaceContext;
|
|
17
|
+
if (!placement || !willSurfaceRender(components, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var surface = /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
21
|
+
components: components,
|
|
22
|
+
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
23
|
+
surfaceContext: surfaceContext
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
"data-editor-block-controls-surface": true,
|
|
27
|
+
"data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
|
|
28
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved from the target node's runtime DOM geometry.
|
|
29
|
+
,
|
|
30
|
+
style: placement,
|
|
31
|
+
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw _kqswstnw _1pbyb4wl"])
|
|
32
|
+
}, /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
33
|
+
api: api,
|
|
34
|
+
controlSide: "right",
|
|
35
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
36
|
+
shouldUseDisplayContents: true
|
|
37
|
+
}, surface));
|
|
38
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
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 { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
16
|
+
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
17
|
+
import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
|
|
18
|
+
import { BlockControlsRightSurface } from './block-controls-right-surface';
|
|
19
|
+
import { createBlockControlsSurfaceContext, createBlockControlsSurfaceContextForPosition } from './block-controls-surface-context';
|
|
20
|
+
import { getBlockControlsSurfaceTargets } from './block-controls-surface-targets';
|
|
21
|
+
import { getNodeContentElement } from './utils/get-node-content-element';
|
|
22
|
+
import { getAbsoluteSurfacePlacement, getSurfacePlacement } from './utils/get-surface-placement';
|
|
23
|
+
var EMPTY_SURFACE_POSITIONS = [];
|
|
24
|
+
var EMPTY_SURFACE_COMPONENTS = [];
|
|
25
|
+
/**
|
|
26
|
+
* Registry-backed right surface tree. Mirrors the left surface's single-tree, measured-placement
|
|
27
|
+
* approach, but keeps its own components lookup, targets, placements and measurement lifecycle so
|
|
28
|
+
* the right surface never depends on the left surface's render pass.
|
|
29
|
+
*/
|
|
30
|
+
export var BlockControlsRightSurfaces = function BlockControlsRightSurfaces(_ref) {
|
|
31
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
32
|
+
var api = _ref.api,
|
|
33
|
+
editorView = _ref.editorView;
|
|
34
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
35
|
+
var _states$blockControls, _states$blockControls2, _states$blockControls3;
|
|
36
|
+
return {
|
|
37
|
+
activeNode: (_states$blockControls = states.blockControlsState) === null || _states$blockControls === void 0 ? void 0 : _states$blockControls.activeNode,
|
|
38
|
+
surfaceNodePositions: (_states$blockControls2 = (_states$blockControls3 = states.blockControlsState) === null || _states$blockControls3 === void 0 ? void 0 : _states$blockControls3.surfaceNodePositions) !== null && _states$blockControls2 !== void 0 ? _states$blockControls2 : EMPTY_SURFACE_POSITIONS
|
|
39
|
+
};
|
|
40
|
+
}),
|
|
41
|
+
activeNode = _useSharedPluginState.activeNode,
|
|
42
|
+
surfaceNodePositions = _useSharedPluginState.surfaceNodePositions;
|
|
43
|
+
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;
|
|
44
|
+
var targets = useMemo(function () {
|
|
45
|
+
return getBlockControlsSurfaceTargets(activeNode, surfaceNodePositions);
|
|
46
|
+
}, [activeNode, surfaceNodePositions]);
|
|
47
|
+
var surfaces = useMemo(function () {
|
|
48
|
+
return targets.flatMap(function (target) {
|
|
49
|
+
var context = target.source === 'stored' ? createBlockControlsSurfaceContextForPosition(editorView.state, target.position, activeNode) : createBlockControlsSurfaceContext(editorView, activeNode, target.source);
|
|
50
|
+
if (!context) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
var surfaceContext = createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, context);
|
|
54
|
+
return [_objectSpread(_objectSpread({}, target), {}, {
|
|
55
|
+
blockControlsContext: context,
|
|
56
|
+
surfaceContext: surfaceContext
|
|
57
|
+
})];
|
|
58
|
+
});
|
|
59
|
+
}, [activeNode, editorView, targets]);
|
|
60
|
+
var _useState = useState(new Map()),
|
|
61
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
+
placements = _useState2[0],
|
|
63
|
+
setPlacements = _useState2[1];
|
|
64
|
+
var animationFrameRef = useRef(undefined);
|
|
65
|
+
useLayoutEffect(function () {
|
|
66
|
+
var _getDocument;
|
|
67
|
+
if (surfaces.length === 0) {
|
|
68
|
+
setPlacements(new Map());
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var measurementTargets = surfaces.flatMap(function (_ref2) {
|
|
72
|
+
var blockControlsContext = _ref2.blockControlsContext,
|
|
73
|
+
position = _ref2.position;
|
|
74
|
+
var targetNodeElement = editorView.nodeDOM(blockControlsContext.targetNode.pos);
|
|
75
|
+
var targetElementRoot = targetNodeElement instanceof HTMLElement ? targetNodeElement : targetNodeElement === null || targetNodeElement === void 0 ? void 0 : targetNodeElement.parentElement;
|
|
76
|
+
if (!targetElementRoot) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
return [{
|
|
80
|
+
blockControlsContext: blockControlsContext,
|
|
81
|
+
position: position,
|
|
82
|
+
targetElement: getNodeContentElement(targetElementRoot, blockControlsContext.targetNode.type.name),
|
|
83
|
+
targetElementRoot: targetElementRoot
|
|
84
|
+
}];
|
|
85
|
+
});
|
|
86
|
+
var offsetParent = editorView.dom.offsetParent;
|
|
87
|
+
var isDocumentOffsetParent = !offsetParent || offsetParent === ((_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.body);
|
|
88
|
+
var scrollingOffsetParent = offsetParent instanceof HTMLElement && !isDocumentOffsetParent ? offsetParent : undefined;
|
|
89
|
+
var updatePositions = function updatePositions() {
|
|
90
|
+
var _scrollingOffsetParen, _scrollingOffsetParen2;
|
|
91
|
+
animationFrameRef.current = undefined;
|
|
92
|
+
var offsetParentRect = offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.getBoundingClientRect();
|
|
93
|
+
var offsetParentScrollTop = (_scrollingOffsetParen = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollTop) !== null && _scrollingOffsetParen !== void 0 ? _scrollingOffsetParen : window.scrollY;
|
|
94
|
+
var offsetParentScrollLeft = (_scrollingOffsetParen2 = scrollingOffsetParent === null || scrollingOffsetParent === void 0 ? void 0 : scrollingOffsetParent.scrollLeft) !== null && _scrollingOffsetParen2 !== void 0 ? _scrollingOffsetParen2 : window.scrollX;
|
|
95
|
+
var nextPlacements = new Map();
|
|
96
|
+
var _iterator = _createForOfIteratorHelper(measurementTargets),
|
|
97
|
+
_step;
|
|
98
|
+
try {
|
|
99
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
100
|
+
var _targetElementRoot$ge;
|
|
101
|
+
var _step$value = _step.value,
|
|
102
|
+
blockControlsContext = _step$value.blockControlsContext,
|
|
103
|
+
position = _step$value.position,
|
|
104
|
+
targetElement = _step$value.targetElement,
|
|
105
|
+
targetElementRoot = _step$value.targetElementRoot;
|
|
106
|
+
if (!targetElementRoot.isConnected || !targetElement.isConnected) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
var placement = getSurfacePlacement({
|
|
110
|
+
layout: (_targetElementRoot$ge = targetElementRoot.getAttribute('layout')) !== null && _targetElementRoot$ge !== void 0 ? _targetElementRoot$ge : '',
|
|
111
|
+
nodeRect: targetElement.getBoundingClientRect(),
|
|
112
|
+
nodeType: blockControlsContext.targetNode.type.name,
|
|
113
|
+
nodeTypeWithLevel: getNodeTypeWithLevel(blockControlsContext.targetNode.node),
|
|
114
|
+
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
|
|
115
|
+
side: 'right'
|
|
116
|
+
});
|
|
117
|
+
nextPlacements.set(position, getAbsoluteSurfacePlacement({
|
|
118
|
+
offsetParentRect: offsetParentRect,
|
|
119
|
+
offsetParentScrollLeft: offsetParentScrollLeft,
|
|
120
|
+
offsetParentScrollTop: offsetParentScrollTop,
|
|
121
|
+
placement: placement
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
} catch (err) {
|
|
125
|
+
_iterator.e(err);
|
|
126
|
+
} finally {
|
|
127
|
+
_iterator.f();
|
|
128
|
+
}
|
|
129
|
+
setPlacements(nextPlacements);
|
|
130
|
+
};
|
|
131
|
+
var schedulePositionUpdate = function schedulePositionUpdate() {
|
|
132
|
+
if (animationFrameRef.current === undefined) {
|
|
133
|
+
animationFrameRef.current = requestAnimationFrame(updatePositions);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
updatePositions();
|
|
137
|
+
var resizeObserver = new ResizeObserver(schedulePositionUpdate);
|
|
138
|
+
var observedElements = new Set([editorView.dom]);
|
|
139
|
+
var _iterator2 = _createForOfIteratorHelper(measurementTargets),
|
|
140
|
+
_step2;
|
|
141
|
+
try {
|
|
142
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
143
|
+
var targetElement = _step2.value.targetElement;
|
|
144
|
+
observedElements.add(targetElement);
|
|
145
|
+
}
|
|
146
|
+
} catch (err) {
|
|
147
|
+
_iterator2.e(err);
|
|
148
|
+
} finally {
|
|
149
|
+
_iterator2.f();
|
|
150
|
+
}
|
|
151
|
+
if (offsetParent instanceof HTMLElement) {
|
|
152
|
+
observedElements.add(offsetParent);
|
|
153
|
+
}
|
|
154
|
+
observedElements.forEach(function (element) {
|
|
155
|
+
return resizeObserver.observe(element);
|
|
156
|
+
});
|
|
157
|
+
var unbindWindowResize = bind(window, {
|
|
158
|
+
type: 'resize',
|
|
159
|
+
listener: schedulePositionUpdate
|
|
160
|
+
});
|
|
161
|
+
var unbindWindowScroll = bind(window, {
|
|
162
|
+
type: 'scroll',
|
|
163
|
+
listener: schedulePositionUpdate,
|
|
164
|
+
options: {
|
|
165
|
+
capture: true,
|
|
166
|
+
passive: true
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
var visualViewport = window.visualViewport;
|
|
170
|
+
var unbindVisualViewportResize = visualViewport ? bind(visualViewport, {
|
|
171
|
+
type: 'resize',
|
|
172
|
+
listener: schedulePositionUpdate
|
|
173
|
+
}) : undefined;
|
|
174
|
+
var unbindVisualViewportScroll = visualViewport ? bind(visualViewport, {
|
|
175
|
+
type: 'scroll',
|
|
176
|
+
listener: schedulePositionUpdate
|
|
177
|
+
}) : undefined;
|
|
178
|
+
var unbindTransitionEnd = bind(editorView.dom, {
|
|
179
|
+
type: 'transitionend',
|
|
180
|
+
listener: schedulePositionUpdate,
|
|
181
|
+
options: {
|
|
182
|
+
capture: true
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return function () {
|
|
186
|
+
if (animationFrameRef.current !== undefined) {
|
|
187
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
188
|
+
animationFrameRef.current = undefined;
|
|
189
|
+
}
|
|
190
|
+
resizeObserver.disconnect();
|
|
191
|
+
unbindWindowResize();
|
|
192
|
+
unbindWindowScroll();
|
|
193
|
+
unbindVisualViewportResize === null || unbindVisualViewportResize === void 0 || unbindVisualViewportResize();
|
|
194
|
+
unbindVisualViewportScroll === null || unbindVisualViewportScroll === void 0 || unbindVisualViewportScroll();
|
|
195
|
+
unbindTransitionEnd();
|
|
196
|
+
};
|
|
197
|
+
}, [editorView, surfaces]);
|
|
198
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, surfaces.map(function (_ref3) {
|
|
199
|
+
var _activeNode$handleOpt;
|
|
200
|
+
var position = _ref3.position,
|
|
201
|
+
source = _ref3.source,
|
|
202
|
+
surfaceContext = _ref3.surfaceContext;
|
|
203
|
+
return /*#__PURE__*/React.createElement(BlockControlsRightSurface, {
|
|
204
|
+
api: api,
|
|
205
|
+
components: components,
|
|
206
|
+
forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 || (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
207
|
+
key: position,
|
|
208
|
+
placement: placements.get(position),
|
|
209
|
+
source: source,
|
|
210
|
+
surfaceContext: surfaceContext
|
|
211
|
+
});
|
|
212
|
+
}));
|
|
213
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBlockControlsLeftSurfaceTargets = void 0;
|
|
7
1
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
8
2
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
3
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
|
-
/**
|
|
11
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Combines hover-driven and stored surface positions into one deduplicated list.
|
|
6
|
+
* Shared by both the left and right surfaces: this is pure position bookkeeping with no
|
|
7
|
+
* surface-specific behavior, so there's nothing to keep independent between them. What *is*
|
|
8
|
+
* kept independent is each surface's own React tree (component lookup, measurement effects,
|
|
9
|
+
* observers) — see block-controls-left-surfaces.tsx / block-controls-right-surfaces.tsx.
|
|
10
|
+
*/
|
|
11
|
+
export var getBlockControlsSurfaceTargets = function getBlockControlsSurfaceTargets(activeNode, storedPositions) {
|
|
12
12
|
var targetsByPosition = new Map();
|
|
13
13
|
var _iterator = _createForOfIteratorHelper(storedPositions),
|
|
14
14
|
_step;
|
|
@@ -15,25 +15,39 @@ export var getAbsoluteSurfacePlacement = function getAbsoluteSurfacePlacement(_r
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Positions the
|
|
19
|
-
*
|
|
18
|
+
* Positions the surface beside the legacy drag-handle slot, on either the left or right edge
|
|
19
|
+
* of the target node. Node-type-specific gap/top-adjustment maths (layouts, tables, media, cards,
|
|
20
|
+
* extensions, etc.) live in one place so left/right edge cases can't drift out of sync.
|
|
21
|
+
*
|
|
22
|
+
* The left side grows away from the node without knowing its own width, so it needs
|
|
23
|
+
* `translateX(-100%)` to anchor its right edge at `nodeRect.left` and extend backward. The right
|
|
24
|
+
* side grows in the normal box-flow direction (away from the node, into the margin), so the gap
|
|
25
|
+
* can be folded straight into `left` with no transform needed.
|
|
20
26
|
*/
|
|
21
27
|
export var getSurfacePlacement = function getSurfacePlacement(_ref2) {
|
|
22
28
|
var layout = _ref2.layout,
|
|
23
29
|
nodeRect = _ref2.nodeRect,
|
|
24
30
|
nodeType = _ref2.nodeType,
|
|
25
31
|
nodeTypeWithLevel = _ref2.nodeTypeWithLevel,
|
|
26
|
-
parentNodeType = _ref2.parentNodeType
|
|
32
|
+
parentNodeType = _ref2.parentNodeType,
|
|
33
|
+
side = _ref2.side;
|
|
27
34
|
if (nodeType === 'layoutColumn') {
|
|
35
|
+
// nodeRect.left + width/2 === nodeRect.right - width/2 — side-independent.
|
|
28
36
|
return {
|
|
29
37
|
left: nodeRect.left + nodeRect.width / 2,
|
|
30
38
|
top: nodeRect.top,
|
|
31
39
|
transform: 'translate(-50%, -50%)'
|
|
32
40
|
};
|
|
33
41
|
}
|
|
34
|
-
|
|
42
|
+
var gap = dragHandleGap(nodeType, parentNodeType);
|
|
43
|
+
var top = nodeRect.top + topPositionAdjustment(nodeTypeWithLevel, layout);
|
|
44
|
+
return side === 'right' ? {
|
|
45
|
+
left: nodeRect.right + gap,
|
|
46
|
+
top: top,
|
|
47
|
+
transform: ''
|
|
48
|
+
} : {
|
|
35
49
|
left: nodeRect.left,
|
|
36
|
-
top:
|
|
37
|
-
transform: "translateX(calc(-100% - ".concat(
|
|
50
|
+
top: top,
|
|
51
|
+
transform: "translateX(calc(-100% - ".concat(gap, "px))")
|
|
38
52
|
};
|
|
39
53
|
};
|
|
@@ -19,7 +19,7 @@ export interface FlagType {
|
|
|
19
19
|
toolbarFlagsEnabled: boolean;
|
|
20
20
|
}
|
|
21
21
|
export declare const getDecorations: (state: EditorState) => DecorationSet | undefined;
|
|
22
|
-
export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, anchorRectCache?: AnchorRectCache, resizeObserverWidth?: ResizeObserver, pragmaticCleanup?: (() => void) | null,
|
|
22
|
+
export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, anchorRectCache?: AnchorRectCache, resizeObserverWidth?: ResizeObserver, pragmaticCleanup?: (() => void) | null, resolvedSurfaces?: readonly ResolvedSurface[]) => PluginState | {
|
|
23
23
|
activeDropTargetNode: ActiveDropTargetNode | undefined;
|
|
24
24
|
activeNode: any;
|
|
25
25
|
blockMenuOptions: {
|
|
@@ -44,7 +44,7 @@ export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | und
|
|
|
44
44
|
multiSelectDnD: MultiSelectDnD | undefined;
|
|
45
45
|
surfaceNodePositions: number[];
|
|
46
46
|
};
|
|
47
|
-
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, legacyDragHandleEnabled?: boolean, surfaceNodePositionsEnabled?: boolean) => SafePlugin<PluginState | {
|
|
47
|
+
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, legacyDragHandleEnabled?: boolean, surfaceNodePositionsEnabled?: boolean, rightSurfaceEnabled?: boolean) => SafePlugin<PluginState | {
|
|
48
48
|
activeDropTargetNode: ActiveDropTargetNode | undefined;
|
|
49
49
|
activeNode: any;
|
|
50
50
|
blockMenuOptions: {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { ResolvedSurface } from '@atlaskit/editor-ui-control-model/surface-renderer/types';
|
|
3
3
|
import type { ActiveNode } from '../../blockControlsPluginType';
|
|
4
|
-
export declare const getSurfaceNodePositions: (state: EditorState,
|
|
5
|
-
export declare const updateSurfaceNodePositions: ({ activeNode, currentPositions, from, newState, previousActiveNode,
|
|
4
|
+
export declare const getSurfaceNodePositions: (state: EditorState, resolvedSurfaces: readonly ResolvedSurface[], activeNode?: ActiveNode, from?: number, to?: number) => number[];
|
|
5
|
+
export declare const updateSurfaceNodePositions: ({ activeNode, currentPositions, from, newState, previousActiveNode, resolvedSurfaces, to, tr, }: {
|
|
6
6
|
activeNode: ActiveNode | null | undefined;
|
|
7
7
|
currentPositions: number[];
|
|
8
8
|
from: number;
|
|
9
9
|
newState: EditorState;
|
|
10
10
|
previousActiveNode: ActiveNode | null | undefined;
|
|
11
|
-
|
|
11
|
+
resolvedSurfaces: readonly ResolvedSurface[];
|
|
12
12
|
to: number;
|
|
13
13
|
tr: ReadonlyTransaction;
|
|
14
14
|
}) => number[];
|
|
@@ -8,14 +8,14 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
|
8
8
|
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
9
9
|
import type { SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
10
10
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
11
|
-
import type {
|
|
11
|
+
import type { BlockControlsSurfaceTarget } from './block-controls-surface-targets';
|
|
12
12
|
import type { SurfacePlacement } from './utils/get-surface-placement';
|
|
13
13
|
type BlockControlsLeftSurfaceProps = {
|
|
14
14
|
api: ExtractInjectionAPI<BlockControlsPlugin>;
|
|
15
15
|
components: React.ComponentProps<typeof SurfaceRenderer>['components'];
|
|
16
16
|
forceVisibleOnMouseOut: boolean;
|
|
17
17
|
placement: SurfacePlacement | undefined;
|
|
18
|
-
source:
|
|
18
|
+
source: BlockControlsSurfaceTarget['source'];
|
|
19
19
|
surfaceContext: SurfaceContext;
|
|
20
20
|
};
|
|
21
21
|
/** Renders one left block-controls surface at a document position. */
|
|
@@ -0,0 +1,23 @@
|
|
|
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';
|
|
8
|
+
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
9
|
+
import type { SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
|
|
10
|
+
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
11
|
+
import type { BlockControlsSurfaceTarget } from './block-controls-surface-targets';
|
|
12
|
+
import type { SurfacePlacement } from './utils/get-surface-placement';
|
|
13
|
+
type BlockControlsRightSurfaceProps = {
|
|
14
|
+
api: ExtractInjectionAPI<BlockControlsPlugin>;
|
|
15
|
+
components: React.ComponentProps<typeof SurfaceRenderer>['components'];
|
|
16
|
+
forceVisibleOnMouseOut: boolean;
|
|
17
|
+
placement: SurfacePlacement | undefined;
|
|
18
|
+
source: BlockControlsSurfaceTarget['source'];
|
|
19
|
+
surfaceContext: SurfaceContext;
|
|
20
|
+
};
|
|
21
|
+
/** Renders one right block-controls surface at a document position. */
|
|
22
|
+
export declare const BlockControlsRightSurface: ({ api, components, forceVisibleOnMouseOut, placement, source, surfaceContext, }: BlockControlsRightSurfaceProps) => React.JSX.Element | null;
|
|
23
|
+
export {};
|