@atlaskit/editor-plugin-block-controls 20.1.2 → 20.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/pm-plugins/selection-preservation/pm-plugin.js +17 -34
- package/dist/cjs/ui/block-controls-left-surface.compiled.css +7 -1
- package/dist/cjs/ui/block-controls-left-surface.js +41 -27
- package/dist/cjs/ui/block-controls-left-surfaces.js +32 -12
- package/dist/cjs/ui/block-controls-right-surface.js +32 -24
- package/dist/cjs/ui/block-controls-right-surfaces.js +6 -4
- package/dist/cjs/ui/block-controls-surface-components.js +142 -0
- package/dist/cjs/ui/utils/get-surface-placement.js +63 -16
- package/dist/cjs/ui/visibility-container.js +42 -7
- package/dist/es2019/pm-plugins/selection-preservation/pm-plugin.js +17 -34
- package/dist/es2019/ui/block-controls-left-surface.compiled.css +7 -1
- package/dist/es2019/ui/block-controls-left-surface.js +44 -29
- package/dist/es2019/ui/block-controls-left-surfaces.js +41 -16
- package/dist/es2019/ui/block-controls-right-surface.js +35 -26
- package/dist/es2019/ui/block-controls-right-surfaces.js +6 -4
- package/dist/es2019/ui/block-controls-surface-components.js +129 -0
- package/dist/es2019/ui/utils/get-surface-placement.js +59 -7
- package/dist/es2019/ui/visibility-container.js +44 -6
- package/dist/esm/pm-plugins/selection-preservation/pm-plugin.js +17 -34
- package/dist/esm/ui/block-controls-left-surface.compiled.css +7 -1
- package/dist/esm/ui/block-controls-left-surface.js +43 -29
- package/dist/esm/ui/block-controls-left-surfaces.js +33 -13
- package/dist/esm/ui/block-controls-right-surface.js +34 -26
- package/dist/esm/ui/block-controls-right-surfaces.js +6 -4
- package/dist/esm/ui/block-controls-surface-components.js +133 -0
- package/dist/esm/ui/utils/get-surface-placement.js +62 -15
- package/dist/esm/ui/visibility-container.js +41 -6
- package/dist/types/ui/block-controls-surface-components.d.ts +13 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +13 -0
- package/dist/types/ui/visibility-container.d.ts +14 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 20.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`48f6e385c3e64`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/48f6e385c3e64) -
|
|
8
|
+
Wrap visible left and right block controls in registry order and, under
|
|
9
|
+
platform_editor_collapsible_headings, hide lower-ranked left controls when a top-level gutter only
|
|
10
|
+
has room for two.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 20.1.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`2a3bb6864b8fe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a3bb6864b8fe) -
|
|
18
|
+
Clean up the `platform_editor_fix_selection_text_color_change` experiment.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 20.1.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -10,7 +10,6 @@ var _bindEventListener = require("bind-event-listener");
|
|
|
10
10
|
var _browserApis = require("@atlaskit/browser-apis");
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
13
|
var _main = require("../main");
|
|
15
14
|
var _selection = require("../utils/selection");
|
|
16
15
|
var _editorCommands = require("./editor-commands");
|
|
@@ -54,37 +53,25 @@ var createSelectionPreservationPlugin = exports.createSelectionPreservationPlugi
|
|
|
54
53
|
key: _pluginKey.selectionPreservationPluginKey,
|
|
55
54
|
state: {
|
|
56
55
|
init: function init() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
return {
|
|
64
|
-
preservedSelection: undefined
|
|
65
|
-
};
|
|
66
|
-
}
|
|
56
|
+
return {
|
|
57
|
+
preservedSelection: undefined,
|
|
58
|
+
syncDomSelectionForDoc: undefined
|
|
59
|
+
};
|
|
67
60
|
},
|
|
68
61
|
apply: function apply(tr, pluginState) {
|
|
69
62
|
var meta = (0, _utils.getSelectionPreservationMeta)(tr);
|
|
70
63
|
var newState = _objectSpread({}, pluginState);
|
|
71
64
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'startPreserving') {
|
|
72
65
|
newState.preservedSelection = (0, _selection.createPreservedSelection)(tr.doc.resolve(tr.selection.from), tr.doc.resolve(tr.selection.to));
|
|
73
|
-
|
|
74
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
75
|
-
}
|
|
66
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
76
67
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'stopPreserving') {
|
|
77
68
|
newState.preservedSelection = undefined;
|
|
78
|
-
|
|
79
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
80
|
-
}
|
|
69
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
81
70
|
} else if (tr.docChanged) {
|
|
82
71
|
if (newState.preservedSelection) {
|
|
83
72
|
newState.preservedSelection = (0, _selection.mapPreservedSelection)(newState.preservedSelection, tr);
|
|
84
73
|
}
|
|
85
|
-
|
|
86
|
-
newState.syncDomSelectionForDoc = (0, _utils.hasFormatSelectionSyncMeta)(tr) ? tr.doc : undefined;
|
|
87
|
-
}
|
|
74
|
+
newState.syncDomSelectionForDoc = (0, _utils.hasFormatSelectionSyncMeta)(tr) ? tr.doc : undefined;
|
|
88
75
|
}
|
|
89
76
|
if (!(0, _utils.compareSelections)(newState.preservedSelection, pluginState.preservedSelection)) {
|
|
90
77
|
if (newState.preservedSelection) {
|
|
@@ -194,23 +181,19 @@ var createSelectionPreservationPlugin = exports.createSelectionPreservationPlugi
|
|
|
194
181
|
var activeNodeChanged = prevActiveNode !== currActiveNode;
|
|
195
182
|
var docChanged = prevState.doc !== view.state.doc;
|
|
196
183
|
var hasFormatSyncRequestForCurrentDoc = (currPluginState === null || currPluginState === void 0 ? void 0 : currPluginState.syncDomSelectionForDoc) === view.state.doc;
|
|
197
|
-
var shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) ||
|
|
184
|
+
var shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) || hasFormatSyncRequestForCurrentDoc) && docChanged;
|
|
198
185
|
if (shouldSyncDOMSelection) {
|
|
199
186
|
var syncSelection = view.state.selection;
|
|
200
|
-
if (
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
204
|
-
}
|
|
205
|
-
pendingFormatSelectionSyncFrame = requestAnimationFrame(function () {
|
|
206
|
-
pendingFormatSelectionSyncFrame = undefined;
|
|
207
|
-
(0, _utils.syncDOMSelection)(syncSelection, view, {
|
|
208
|
-
focusEditor: true
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
} else {
|
|
212
|
-
(0, _utils.syncDOMSelection)(syncSelection, view);
|
|
187
|
+
if (hasFormatSyncRequestForCurrentDoc) {
|
|
188
|
+
if (pendingFormatSelectionSyncFrame !== undefined) {
|
|
189
|
+
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
213
190
|
}
|
|
191
|
+
pendingFormatSelectionSyncFrame = requestAnimationFrame(function () {
|
|
192
|
+
pendingFormatSelectionSyncFrame = undefined;
|
|
193
|
+
(0, _utils.syncDOMSelection)(syncSelection, view, {
|
|
194
|
+
focusEditor: true
|
|
195
|
+
});
|
|
196
|
+
});
|
|
214
197
|
} else {
|
|
215
198
|
(0, _utils.syncDOMSelection)(syncSelection, view);
|
|
216
199
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
._zulpv77o{gap:var(--ds-space-025,2px)}._154iu2gc{top:var(--ds-space-100,8px)}
|
|
2
2
|
._17c61i8t{position-visibility:anchors-valid}
|
|
3
|
+
._1bahesu3{justify-content:flex-end}
|
|
3
4
|
._1e0c1txw{display:flex}
|
|
5
|
+
._1f38ffwv{container-name:block-controls-left-gutter}
|
|
4
6
|
._1pbyb4wl{z-index:100}
|
|
5
7
|
._4cvr1h6o{align-items:center}
|
|
8
|
+
._7cca15wb{container-type:inline-size}
|
|
6
9
|
._kqsw1if8{position:sticky}
|
|
7
|
-
._kqswstnw{position:absolute}
|
|
10
|
+
._kqswstnw{position:absolute}
|
|
11
|
+
._lcxvglyw{pointer-events:none}
|
|
12
|
+
._w1y61wug>*{pointer-events:auto}
|
|
13
|
+
@container block-controls-left-gutter (max-width: 67px){._19vrglyw>[data-editor-block-control-item]:nth-last-child(n+3){display:none}}
|
|
@@ -13,10 +13,14 @@ var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/blo
|
|
|
13
13
|
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
14
14
|
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
15
15
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
16
|
+
var _blockControlsSurfaceComponents = require("./block-controls-surface-components");
|
|
16
17
|
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
17
|
-
var _partitionComponentsByPersistence = require("./utils/partition-components-by-persistence");
|
|
18
18
|
var _visibilityContainer = require("./visibility-container");
|
|
19
19
|
var leftSurfaceOuterStyles = null;
|
|
20
|
+
var leftSurfaceGutterStyles = {
|
|
21
|
+
container: "_1f38ffwv _7cca15wb _lcxvglyw",
|
|
22
|
+
row: "_1bahesu3 _lcxvglyw _w1y61wug _19vrglyw"
|
|
23
|
+
};
|
|
20
24
|
var leftSurfaceRowStyles = null;
|
|
21
25
|
|
|
22
26
|
// Applied in addition to leftSurfaceRowStyles when the target node is sticky-eligible (e.g. long
|
|
@@ -24,23 +28,24 @@ var leftSurfaceRowStyles = null;
|
|
|
24
28
|
// can stick near the top of the viewport instead of scrolling off with the node's top edge.
|
|
25
29
|
// Keep in sync with STICKY_CONTROLS_TOP_MARGIN in ./consts (must be a static literal here).
|
|
26
30
|
var leftSurfaceStickyStyles = null;
|
|
27
|
-
|
|
28
|
-
var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref) {
|
|
31
|
+
var BlockControlsLeftSurfaceContent = function BlockControlsLeftSurfaceContent(_ref) {
|
|
29
32
|
var api = _ref.api,
|
|
30
33
|
components = _ref.components,
|
|
31
34
|
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
32
35
|
placement = _ref.placement,
|
|
33
36
|
source = _ref.source,
|
|
34
37
|
surfaceContext = _ref.surfaceContext;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
var blockControlsContext = surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
|
|
39
|
+
var controlSide = (0, _blockControlsSurfaceContext.getBlockControlsSurfaceControlSide)(blockControlsContext, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_controls_reliable_anchor'));
|
|
40
|
+
var _useBlockControlsVisi = (0, _visibilityContainer.useBlockControlsVisibility)({
|
|
41
|
+
api: api,
|
|
42
|
+
controlSide: controlSide,
|
|
43
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut
|
|
44
|
+
}),
|
|
45
|
+
shouldHideHoverControls = _useBlockControlsVisi.shouldHide,
|
|
46
|
+
useCssStyles = _useBlockControlsVisi.useCssStyles;
|
|
43
47
|
var isSticky = placement.isSticky;
|
|
48
|
+
var isTopLevel = (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.parentType) === 'doc';
|
|
44
49
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
45
50
|
"data-editor-block-controls-surface": true,
|
|
46
51
|
"data-editor-block-controls-side": "left",
|
|
@@ -48,27 +53,36 @@ var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function Block
|
|
|
48
53
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved per target node, from its runtime DOM geometry or from its CSS anchor.
|
|
49
54
|
,
|
|
50
55
|
style: placement.style,
|
|
51
|
-
className: (0, _runtime.ax)(["_kqswstnw _17c61i8t _1pbyb4wl"])
|
|
56
|
+
className: (0, _runtime.ax)(["_kqswstnw _17c61i8t _1pbyb4wl", isTopLevel && leftSurfaceGutterStyles.container])
|
|
52
57
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
53
|
-
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
58
|
-
shouldUseDisplayContents: true
|
|
58
|
+
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isTopLevel && leftSurfaceGutterStyles.row, isSticky && "_kqsw1if8 _154iu2gc"])
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement(_blockControlsSurfaceComponents.BlockControlsVisibilityProvider, {
|
|
60
|
+
shouldHideHoverControls: shouldHideHoverControls,
|
|
61
|
+
useCssStyles: useCssStyles
|
|
59
62
|
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
60
|
-
components:
|
|
63
|
+
components: components,
|
|
61
64
|
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
62
65
|
surfaceContext: surfaceContext
|
|
63
|
-
}))
|
|
66
|
+
}))));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/** Renders one left block-controls surface at a document position. */
|
|
70
|
+
var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref2) {
|
|
71
|
+
var api = _ref2.api,
|
|
72
|
+
components = _ref2.components,
|
|
73
|
+
forceVisibleOnMouseOut = _ref2.forceVisibleOnMouseOut,
|
|
74
|
+
placement = _ref2.placement,
|
|
75
|
+
source = _ref2.source,
|
|
76
|
+
surfaceContext = _ref2.surfaceContext;
|
|
77
|
+
if (!placement) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(BlockControlsLeftSurfaceContent, {
|
|
64
81
|
api: api,
|
|
65
|
-
|
|
82
|
+
components: components,
|
|
66
83
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
70
|
-
components: persistentComponents,
|
|
71
|
-
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
84
|
+
placement: placement,
|
|
85
|
+
source: source,
|
|
72
86
|
surfaceContext: surfaceContext
|
|
73
|
-
})
|
|
87
|
+
});
|
|
74
88
|
};
|
|
@@ -18,14 +18,13 @@ var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys"
|
|
|
18
18
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
19
19
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
20
20
|
var _createSurfaceContext = require("@atlaskit/editor-ui-control-model/create-surface-context");
|
|
21
|
-
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
22
21
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
23
22
|
var _blockControlsLeftSurface = require("./block-controls-left-surface");
|
|
23
|
+
var _blockControlsSurfaceComponents = require("./block-controls-surface-components");
|
|
24
24
|
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
25
25
|
var _blockControlsSurfaceTargets = require("./block-controls-surface-targets");
|
|
26
26
|
var _getNodeContentElement = require("./utils/get-node-content-element");
|
|
27
27
|
var _getSurfacePlacement = require("./utils/get-surface-placement");
|
|
28
|
-
var _hasSurfaceControls = require("./utils/has-surface-controls");
|
|
29
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); }
|
|
30
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; } } }; }
|
|
31
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; } }
|
|
@@ -69,14 +68,20 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
69
68
|
return [];
|
|
70
69
|
}
|
|
71
70
|
var surfaceContext = (0, _createSurfaceContext.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, context);
|
|
72
|
-
|
|
71
|
+
var surfaceComponents = (0, _blockControlsSurfaceComponents.getBlockControlsLeftSurfaceComponents)(components, surfaceContext);
|
|
72
|
+
if (!surfaceComponents) {
|
|
73
73
|
return [];
|
|
74
74
|
}
|
|
75
75
|
// The cache supplies the same anchor names used by ProseMirror decorations.
|
|
76
76
|
var anchorName = (0, _styles.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';
|
|
77
80
|
return [_objectSpread(_objectSpread({}, target), {}, {
|
|
78
81
|
anchorName: anchorName,
|
|
79
82
|
blockControlsContext: context,
|
|
83
|
+
isTopLevel: isTopLevel,
|
|
84
|
+
surfaceComponents: surfaceComponents,
|
|
80
85
|
surfaceContext: surfaceContext
|
|
81
86
|
})];
|
|
82
87
|
});
|
|
@@ -89,15 +94,22 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
89
94
|
return new Map(surfaces.flatMap(function (_ref3) {
|
|
90
95
|
var anchorName = _ref3.anchorName,
|
|
91
96
|
blockControlsContext = _ref3.blockControlsContext,
|
|
97
|
+
isTopLevel = _ref3.isTopLevel,
|
|
92
98
|
position = _ref3.position;
|
|
93
|
-
|
|
99
|
+
if (!anchorName) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
var options = {
|
|
94
103
|
anchorName: anchorName,
|
|
104
|
+
layout: blockControlsContext.targetNode.node.attrs.layout,
|
|
95
105
|
nodeType: blockControlsContext.targetNode.type.name,
|
|
96
106
|
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
97
|
-
|
|
98
|
-
|
|
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), {}, {
|
|
99
110
|
side: 'left'
|
|
100
|
-
})
|
|
111
|
+
}));
|
|
112
|
+
return [[position, placement]];
|
|
101
113
|
}));
|
|
102
114
|
}, [surfaces]);
|
|
103
115
|
// Only the surfaces that still need measuring drive the effect below, so a document of anchored
|
|
@@ -131,6 +143,7 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
131
143
|
}
|
|
132
144
|
var measurementTargets = measuredSurfaces.flatMap(function (_ref5) {
|
|
133
145
|
var blockControlsContext = _ref5.blockControlsContext,
|
|
146
|
+
isTopLevel = _ref5.isTopLevel,
|
|
134
147
|
position = _ref5.position;
|
|
135
148
|
var targetNodeElement = editorView.nodeDOM(blockControlsContext.targetNode.pos);
|
|
136
149
|
var targetElementRoot = targetNodeElement instanceof HTMLElement ? targetNodeElement : targetNodeElement === null || targetNodeElement === void 0 ? void 0 : targetNodeElement.parentElement;
|
|
@@ -139,6 +152,7 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
139
152
|
}
|
|
140
153
|
return [{
|
|
141
154
|
blockControlsContext: blockControlsContext,
|
|
155
|
+
isTopLevel: isTopLevel,
|
|
142
156
|
position: position,
|
|
143
157
|
targetElement: (0, _getNodeContentElement.getNodeContentElement)(targetElementRoot, blockControlsContext.targetNode.type.name),
|
|
144
158
|
targetElementRoot: targetElementRoot
|
|
@@ -158,23 +172,28 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
158
172
|
_step;
|
|
159
173
|
try {
|
|
160
174
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
161
|
-
var _targetElementRoot$ge;
|
|
175
|
+
var _targetElementRoot$ge, _offsetParentRect$lef;
|
|
162
176
|
var _step$value = _step.value,
|
|
163
177
|
blockControlsContext = _step$value.blockControlsContext,
|
|
178
|
+
isTopLevel = _step$value.isTopLevel,
|
|
164
179
|
position = _step$value.position,
|
|
165
180
|
targetElement = _step$value.targetElement,
|
|
166
181
|
targetElementRoot = _step$value.targetElementRoot;
|
|
167
182
|
if (!targetElementRoot.isConnected || !targetElement.isConnected) {
|
|
168
183
|
continue;
|
|
169
184
|
}
|
|
170
|
-
var
|
|
185
|
+
var options = {
|
|
171
186
|
layout: (_targetElementRoot$ge = targetElementRoot.getAttribute('layout')) !== null && _targetElementRoot$ge !== void 0 ? _targetElementRoot$ge : '',
|
|
172
187
|
nodeRect: targetElement.getBoundingClientRect(),
|
|
173
188
|
nodeType: blockControlsContext.targetNode.type.name,
|
|
174
189
|
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
175
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType
|
|
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), {}, {
|
|
176
195
|
side: 'left'
|
|
177
|
-
});
|
|
196
|
+
}));
|
|
178
197
|
nextPlacements.set(position, (0, _getSurfacePlacement.toMeasuredSurfaceWrapperPlacement)((0, _getSurfacePlacement.getAbsoluteSurfacePlacement)({
|
|
179
198
|
offsetParentRect: offsetParentRect,
|
|
180
199
|
offsetParentScrollLeft: offsetParentScrollLeft,
|
|
@@ -260,10 +279,11 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
260
279
|
var _activeNode$handleOpt, _anchoredPlacements$g;
|
|
261
280
|
var position = _ref6.position,
|
|
262
281
|
source = _ref6.source,
|
|
282
|
+
surfaceComponents = _ref6.surfaceComponents,
|
|
263
283
|
surfaceContext = _ref6.surfaceContext;
|
|
264
284
|
return /*#__PURE__*/_react.default.createElement(_blockControlsLeftSurface.BlockControlsLeftSurface, {
|
|
265
285
|
api: api,
|
|
266
|
-
components:
|
|
286
|
+
components: surfaceComponents,
|
|
267
287
|
forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 || (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
268
288
|
key: position,
|
|
269
289
|
placement: (_anchoredPlacements$g = anchoredPlacements.get(position)) !== null && _anchoredPlacements$g !== void 0 ? _anchoredPlacements$g : placements.get(position),
|
|
@@ -11,7 +11,7 @@ var _runtime = require("@compiled/react/runtime");
|
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
13
13
|
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
14
|
-
var
|
|
14
|
+
var _blockControlsSurfaceComponents = require("./block-controls-surface-components");
|
|
15
15
|
var _visibilityContainer = require("./visibility-container");
|
|
16
16
|
var rightSurfaceOuterStyles = null;
|
|
17
17
|
var rightSurfaceRowStyles = null;
|
|
@@ -21,22 +21,20 @@ var rightSurfaceRowStyles = null;
|
|
|
21
21
|
// can stick near the top of the viewport instead of scrolling off with the node's top edge.
|
|
22
22
|
// Keep in sync with STICKY_CONTROLS_TOP_MARGIN in ./consts (must be a static literal here).
|
|
23
23
|
var rightSurfaceStickyStyles = null;
|
|
24
|
-
|
|
25
|
-
var BlockControlsRightSurface = exports.BlockControlsRightSurface = function BlockControlsRightSurface(_ref) {
|
|
24
|
+
var BlockControlsRightSurfaceContent = function BlockControlsRightSurfaceContent(_ref) {
|
|
26
25
|
var api = _ref.api,
|
|
27
26
|
components = _ref.components,
|
|
28
27
|
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
29
28
|
placement = _ref.placement,
|
|
30
29
|
source = _ref.source,
|
|
31
30
|
surfaceContext = _ref.surfaceContext;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var willRenderHoverOnly = (0, _surfaceRenderer.willSurfaceRender)(hoverOnlyComponents, _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
31
|
+
var _useBlockControlsVisi = (0, _visibilityContainer.useBlockControlsVisibility)({
|
|
32
|
+
api: api,
|
|
33
|
+
controlSide: 'right',
|
|
34
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut
|
|
35
|
+
}),
|
|
36
|
+
shouldHideHoverControls = _useBlockControlsVisi.shouldHide,
|
|
37
|
+
useCssStyles = _useBlockControlsVisi.useCssStyles;
|
|
40
38
|
var isSticky = placement.isSticky;
|
|
41
39
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
42
40
|
"data-editor-block-controls-surface": true,
|
|
@@ -48,23 +46,33 @@ var BlockControlsRightSurface = exports.BlockControlsRightSurface = function Blo
|
|
|
48
46
|
className: (0, _runtime.ax)(["_kqswstnw _17c61i8t _1pbyb4wl"])
|
|
49
47
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
50
48
|
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
isPersistent: true,
|
|
55
|
-
shouldUseDisplayContents: true
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_blockControlsSurfaceComponents.BlockControlsVisibilityProvider, {
|
|
50
|
+
shouldHideHoverControls: shouldHideHoverControls,
|
|
51
|
+
useCssStyles: useCssStyles
|
|
56
52
|
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
57
|
-
components:
|
|
53
|
+
components: components,
|
|
58
54
|
surface: _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
59
55
|
surfaceContext: surfaceContext
|
|
60
|
-
}))
|
|
56
|
+
}))));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Renders one right block-controls surface at a document position. */
|
|
60
|
+
var BlockControlsRightSurface = exports.BlockControlsRightSurface = function BlockControlsRightSurface(_ref2) {
|
|
61
|
+
var api = _ref2.api,
|
|
62
|
+
components = _ref2.components,
|
|
63
|
+
forceVisibleOnMouseOut = _ref2.forceVisibleOnMouseOut,
|
|
64
|
+
placement = _ref2.placement,
|
|
65
|
+
source = _ref2.source,
|
|
66
|
+
surfaceContext = _ref2.surfaceContext;
|
|
67
|
+
if (!placement) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement(BlockControlsRightSurfaceContent, {
|
|
61
71
|
api: api,
|
|
62
|
-
|
|
72
|
+
components: components,
|
|
63
73
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
components: hoverOnlyComponents,
|
|
67
|
-
surface: _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
74
|
+
placement: placement,
|
|
75
|
+
source: source,
|
|
68
76
|
surfaceContext: surfaceContext
|
|
69
|
-
})
|
|
77
|
+
});
|
|
70
78
|
};
|
|
@@ -18,14 +18,13 @@ var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys"
|
|
|
18
18
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
19
19
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
20
20
|
var _createSurfaceContext = require("@atlaskit/editor-ui-control-model/create-surface-context");
|
|
21
|
-
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
22
21
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
23
22
|
var _blockControlsRightSurface = require("./block-controls-right-surface");
|
|
23
|
+
var _blockControlsSurfaceComponents = require("./block-controls-surface-components");
|
|
24
24
|
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
25
25
|
var _blockControlsSurfaceTargets = require("./block-controls-surface-targets");
|
|
26
26
|
var _getNodeContentElement = require("./utils/get-node-content-element");
|
|
27
27
|
var _getSurfacePlacement = require("./utils/get-surface-placement");
|
|
28
|
-
var _hasSurfaceControls = require("./utils/has-surface-controls");
|
|
29
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); }
|
|
30
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; } } }; }
|
|
31
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; } }
|
|
@@ -78,7 +77,8 @@ var BlockControlsRightSurfaces = exports.BlockControlsRightSurfaces = function B
|
|
|
78
77
|
return [];
|
|
79
78
|
}
|
|
80
79
|
var surfaceContext = (0, _createSurfaceContext.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, context);
|
|
81
|
-
|
|
80
|
+
var surfaceComponents = (0, _blockControlsSurfaceComponents.getBlockControlsRightSurfaceComponents)(components, surfaceContext);
|
|
81
|
+
if (!surfaceComponents) {
|
|
82
82
|
return [];
|
|
83
83
|
}
|
|
84
84
|
// The cache supplies the same anchor names used by ProseMirror decorations.
|
|
@@ -86,6 +86,7 @@ var BlockControlsRightSurfaces = exports.BlockControlsRightSurfaces = function B
|
|
|
86
86
|
return [_objectSpread(_objectSpread({}, target), {}, {
|
|
87
87
|
anchorName: anchorName,
|
|
88
88
|
blockControlsContext: context,
|
|
89
|
+
surfaceComponents: surfaceComponents,
|
|
89
90
|
surfaceContext: surfaceContext
|
|
90
91
|
})];
|
|
91
92
|
});
|
|
@@ -269,10 +270,11 @@ var BlockControlsRightSurfaces = exports.BlockControlsRightSurfaces = function B
|
|
|
269
270
|
var _activeNode$handleOpt, _anchoredPlacements$g;
|
|
270
271
|
var position = _ref6.position,
|
|
271
272
|
source = _ref6.source,
|
|
273
|
+
surfaceComponents = _ref6.surfaceComponents,
|
|
272
274
|
surfaceContext = _ref6.surfaceContext;
|
|
273
275
|
return /*#__PURE__*/_react.default.createElement(_blockControlsRightSurface.BlockControlsRightSurface, {
|
|
274
276
|
api: api,
|
|
275
|
-
components:
|
|
277
|
+
components: surfaceComponents,
|
|
276
278
|
forceVisibleOnMouseOut: Boolean(activeNode === null || activeNode === void 0 || (_activeNode$handleOpt = activeNode.handleOptions) === null || _activeNode$handleOpt === void 0 ? void 0 : _activeNode$handleOpt.isFocused),
|
|
277
279
|
key: position,
|
|
278
280
|
placement: (_anchoredPlacements$g = anchoredPlacements.get(position)) !== null && _anchoredPlacements$g !== void 0 ? _anchoredPlacements$g : placements.get(position),
|