@atlaskit/editor-plugin-block-controls 34.0.3 → 34.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/blockControlsPlugin.js +2 -10
- package/dist/cjs/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +121 -2
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +3 -0
- package/dist/cjs/pm-plugins/sparse-gutter-hover.js +17 -57
- package/dist/cjs/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/cjs/pm-plugins/utils/after-render-scheduler.js +39 -0
- package/dist/cjs/ui/block-controls-left-surface.js +19 -83
- package/dist/cjs/ui/block-controls-right-surface.js +19 -70
- package/dist/cjs/ui/block-controls-surface-targets.js +1 -1
- package/dist/es2019/blockControlsPlugin.js +2 -10
- package/dist/es2019/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +118 -1
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
- package/dist/es2019/pm-plugins/sparse-gutter-hover.js +16 -56
- package/dist/es2019/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/es2019/pm-plugins/utils/after-render-scheduler.js +33 -0
- package/dist/es2019/ui/block-controls-left-surface.js +10 -76
- package/dist/es2019/ui/block-controls-right-surface.js +10 -63
- package/dist/es2019/ui/block-controls-surface-targets.js +1 -1
- package/dist/esm/blockControlsPlugin.js +2 -10
- package/dist/esm/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +120 -1
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
- package/dist/esm/pm-plugins/sparse-gutter-hover.js +16 -56
- package/dist/esm/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/esm/pm-plugins/utils/after-render-scheduler.js +33 -0
- package/dist/esm/ui/block-controls-left-surface.js +19 -83
- package/dist/esm/ui/block-controls-right-surface.js +19 -70
- package/dist/esm/ui/block-controls-surface-targets.js +1 -1
- package/dist/types/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +1 -0
- package/dist/types/pm-plugins/utils/after-render-scheduler.d.ts +9 -0
- package/dist/types/ui/block-controls-left-surface.d.ts +1 -1
- package/dist/types/ui/block-controls-right-surface.d.ts +1 -1
- package/dist/types/ui/block-controls-surface-targets.d.ts +1 -1
- package/package.json +4 -4
- package/dist/cjs/pm-plugins/sparse-surfaces-view.js +0 -149
- package/dist/cjs/ui/block-controls-left-surfaces.js +0 -294
- package/dist/cjs/ui/block-controls-right-surfaces.js +0 -285
- package/dist/es2019/pm-plugins/sparse-surfaces-view.js +0 -136
- package/dist/es2019/ui/block-controls-left-surfaces.js +0 -259
- package/dist/es2019/ui/block-controls-right-surfaces.js +0 -245
- package/dist/esm/pm-plugins/sparse-surfaces-view.js +0 -142
- package/dist/esm/ui/block-controls-left-surfaces.js +0 -285
- package/dist/esm/ui/block-controls-right-surfaces.js +0 -276
- package/dist/types/pm-plugins/sparse-surfaces-view.d.ts +0 -16
- package/dist/types/ui/block-controls-left-surfaces.d.ts +0 -15
- package/dist/types/ui/block-controls-right-surfaces.d.ts +0 -24
|
@@ -3,12 +3,7 @@ import "./block-controls-right-surface.compiled.css";
|
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
6
|
-
import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
7
|
-
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
8
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
6
|
import { BlockControlsSurfaceWithClsFix } from '../surface-lifecycle/block-controls-surface-with-cls-fix';
|
|
10
|
-
import { BlockControlsVisibilityProvider } from './block-controls-surface-components';
|
|
11
|
-
import { useBlockControlsVisibility } from './visibility-container';
|
|
12
7
|
var rightSurfaceHiddenWrapperStyles = null;
|
|
13
8
|
var rightSurfaceOuterStyles = null;
|
|
14
9
|
var rightSurfaceRowStyles = null;
|
|
@@ -21,47 +16,12 @@ var rightSurfaceStickyStyles = null;
|
|
|
21
16
|
|
|
22
17
|
// Keep in sync with STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER in ./consts (must be a static literal here)
|
|
23
18
|
var rightSurfaceStickyTableHeaderStyles = null;
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
components = _ref.components,
|
|
27
|
-
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
19
|
+
var BlockControlsRightSurfaceWrapper = function BlockControlsRightSurfaceWrapper(_ref) {
|
|
20
|
+
var children = _ref.children,
|
|
28
21
|
placement = _ref.placement,
|
|
29
22
|
source = _ref.source,
|
|
30
23
|
surfaceContext = _ref.surfaceContext;
|
|
31
24
|
var blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
32
|
-
var _useBlockControlsVisi = useBlockControlsVisibility({
|
|
33
|
-
api: api,
|
|
34
|
-
controlSide: 'right',
|
|
35
|
-
forceVisibleOnMouseOut: forceVisibleOnMouseOut
|
|
36
|
-
}),
|
|
37
|
-
shouldHideHoverControls = _useBlockControlsVisi.shouldHide,
|
|
38
|
-
useCssStyles = _useBlockControlsVisi.useCssStyles;
|
|
39
|
-
var isSticky = placement.isSticky;
|
|
40
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
41
|
-
"data-editor-block-controls-surface": true,
|
|
42
|
-
"data-editor-block-controls-side": "right",
|
|
43
|
-
"data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
|
|
44
|
-
// 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.
|
|
45
|
-
,
|
|
46
|
-
style: placement.style,
|
|
47
|
-
className: ax(["_kqswstnw _17c61i8t _1pbyb4wl"])
|
|
48
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
49
|
-
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && "_154i1ejb"])
|
|
50
|
-
}, /*#__PURE__*/React.createElement(BlockControlsVisibilityProvider, {
|
|
51
|
-
shouldHideHoverControls: shouldHideHoverControls,
|
|
52
|
-
useCssStyles: useCssStyles
|
|
53
|
-
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
54
|
-
components: components,
|
|
55
|
-
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
56
|
-
surfaceContext: surfaceContext
|
|
57
|
-
}))));
|
|
58
|
-
};
|
|
59
|
-
var BlockControlsRightSurfaceWrapper = function BlockControlsRightSurfaceWrapper(_ref2) {
|
|
60
|
-
var children = _ref2.children,
|
|
61
|
-
placement = _ref2.placement,
|
|
62
|
-
source = _ref2.source,
|
|
63
|
-
surfaceContext = _ref2.surfaceContext;
|
|
64
|
-
var blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
65
25
|
var isSticky = placement.isSticky;
|
|
66
26
|
return /*#__PURE__*/React.createElement("div", {
|
|
67
27
|
"data-editor-block-controls-surface": true,
|
|
@@ -77,35 +37,24 @@ var BlockControlsRightSurfaceWrapper = function BlockControlsRightSurfaceWrapper
|
|
|
77
37
|
};
|
|
78
38
|
|
|
79
39
|
/** Renders one right block-controls surface at a document position. */
|
|
80
|
-
export var BlockControlsRightSurface = function BlockControlsRightSurface(
|
|
81
|
-
var api =
|
|
82
|
-
components =
|
|
83
|
-
forceVisibleOnMouseOut =
|
|
84
|
-
placement =
|
|
85
|
-
source =
|
|
86
|
-
surfaceContext =
|
|
40
|
+
export var BlockControlsRightSurface = function BlockControlsRightSurface(_ref2) {
|
|
41
|
+
var api = _ref2.api,
|
|
42
|
+
components = _ref2.components,
|
|
43
|
+
forceVisibleOnMouseOut = _ref2.forceVisibleOnMouseOut,
|
|
44
|
+
placement = _ref2.placement,
|
|
45
|
+
source = _ref2.source,
|
|
46
|
+
surfaceContext = _ref2.surfaceContext;
|
|
87
47
|
if (!placement) {
|
|
88
48
|
return null;
|
|
89
49
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
} else {
|
|
102
|
-
return /*#__PURE__*/React.createElement(BlockControlsRightSurfaceContent, {
|
|
103
|
-
api: api,
|
|
104
|
-
components: components,
|
|
105
|
-
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
106
|
-
placement: placement,
|
|
107
|
-
source: source,
|
|
108
|
-
surfaceContext: surfaceContext
|
|
109
|
-
});
|
|
110
|
-
}
|
|
50
|
+
return /*#__PURE__*/React.createElement(BlockControlsSurfaceWithClsFix, {
|
|
51
|
+
side: "right",
|
|
52
|
+
SurfaceWrapper: BlockControlsRightSurfaceWrapper,
|
|
53
|
+
api: api,
|
|
54
|
+
components: components,
|
|
55
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
56
|
+
placement: placement,
|
|
57
|
+
source: source,
|
|
58
|
+
surfaceContext: surfaceContext
|
|
59
|
+
});
|
|
111
60
|
};
|
|
@@ -6,7 +6,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
6
6
|
* Shared by both the left and right surfaces: this is pure position bookkeeping with no
|
|
7
7
|
* surface-specific behavior, so there's nothing to keep independent between them. What *is*
|
|
8
8
|
* kept independent is each surface's own React tree (component lookup, measurement effects,
|
|
9
|
-
* observers) — see
|
|
9
|
+
* observers) — see ../surface-lifecycle/block-controls-surfaces.tsx.
|
|
10
10
|
*/
|
|
11
11
|
export var getBlockControlsSurfaceTargets = function getBlockControlsSurfaceTargets(activeNode, storedPositions) {
|
|
12
12
|
var targetsByPosition = new Map();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
|
|
2
2
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
import type { BlockControlsPlugin } from '../../blockControlsPluginType';
|
|
4
|
+
export declare const clearPendingHoverSide: (view: EditorView) => void;
|
|
4
5
|
export declare const handleMouseMove: (view: EditorView, event: Event, rightSideControlsEnabled?: boolean, api?: ExtractInjectionAPI<BlockControlsPlugin>) => boolean;
|
|
5
6
|
export declare const handleMouseLeave: (view: EditorView, rightSideControlsEnabled?: boolean) => boolean;
|
|
6
7
|
export declare const handleMouseEnter: (view: EditorView) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `callback` once after the next frame renders (`requestAnimationFrame`, then `setTimeout`).
|
|
3
|
+
* Deferring position reads gives the browser an opportunity to update layout first; other work
|
|
4
|
+
* can still invalidate layout before the callback. Calls made while a run is scheduled are ignored.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createAfterRenderScheduler: (win: Window, callback: () => void) => {
|
|
7
|
+
cancel: () => void;
|
|
8
|
+
schedule: () => void;
|
|
9
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
|
|
8
|
-
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
8
|
+
import type { 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
11
|
import type { BlockControlsSurfaceTarget } from './block-controls-surface-targets';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
|
|
8
|
-
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
8
|
+
import type { 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
11
|
import type { BlockControlsSurfaceTarget } from './block-controls-surface-targets';
|
|
@@ -8,6 +8,6 @@ export type BlockControlsSurfaceTarget = {
|
|
|
8
8
|
* Shared by both the left and right surfaces: this is pure position bookkeeping with no
|
|
9
9
|
* surface-specific behavior, so there's nothing to keep independent between them. What *is*
|
|
10
10
|
* kept independent is each surface's own React tree (component lookup, measurement effects,
|
|
11
|
-
* observers) — see
|
|
11
|
+
* observers) — see ../surface-lifecycle/block-controls-surfaces.tsx.
|
|
12
12
|
*/
|
|
13
13
|
export declare const getBlockControlsSurfaceTargets: (activeNode: ActiveNode | undefined, storedPositions: readonly number[]) => readonly BlockControlsSurfaceTarget[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "34.0.
|
|
3
|
+
"version": "34.0.5",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@atlaskit/editor-plugin-metrics": "^34.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-quick-insert": "^33.0.0",
|
|
42
42
|
"@atlaskit/editor-plugin-selection": "^33.0.0",
|
|
43
|
-
"@atlaskit/editor-plugin-show-diff": "^33.
|
|
43
|
+
"@atlaskit/editor-plugin-show-diff": "^33.1.0",
|
|
44
44
|
"@atlaskit/editor-plugin-toolbar": "^30.0.0",
|
|
45
45
|
"@atlaskit/editor-plugin-type-ahead": "^34.0.0",
|
|
46
46
|
"@atlaskit/editor-plugin-ui-control-registry": "^27.0.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"uuid": "^11.1.1"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@atlaskit/editor-common": "^137.
|
|
75
|
+
"@atlaskit/editor-common": "^137.4.0",
|
|
76
76
|
"react": "^18.2.0 || ^19.2.0",
|
|
77
77
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
78
78
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@af/editor-examples-helpers": "workspace:^",
|
|
100
|
-
"@atlaskit/editor-common": "^137.
|
|
100
|
+
"@atlaskit/editor-common": "^137.4.0",
|
|
101
101
|
"@atlaskit/editor-plugins": "^17.0.0",
|
|
102
102
|
"@atlaskit/synchrony-test-helpers": "workspace:^",
|
|
103
103
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createSparseSurfacesView = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
11
|
-
var _nodeAnchorProvider = require("@atlaskit/editor-common/node-anchor-provider");
|
|
12
|
-
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
13
|
-
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
14
|
-
var _sparseSurfacesViewWithLifecycle = require("../surface-lifecycle/sparse-surfaces-view-with-lifecycle");
|
|
15
|
-
var _decorationsSurfaceAnchor = require("./decorations-surface-anchor");
|
|
16
|
-
var _main = require("./main");
|
|
17
|
-
var _sparseGutterHover = require("./sparse-gutter-hover");
|
|
18
|
-
var _sparseSurfaceCandidates = require("./utils/sparse-surface-candidates");
|
|
19
|
-
var _surfaceViewport = require("./utils/surface-viewport");
|
|
20
|
-
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; }
|
|
21
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
-
var haveAnchorPositionsChanged = function haveAnchorPositionsChanged(positions, anchors) {
|
|
23
|
-
return positions.length !== anchors.size || positions.some(function (position) {
|
|
24
|
-
return !anchors.has(position);
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
var createLegacySparseSurfacesView = function createLegacySparseSurfacesView(_ref) {
|
|
28
|
-
var _api$uiControlRegistr3, _api$editorDisabled, _api$editorViewMode, _api$limitedMode2, _api$showDiff, _api$userIntent;
|
|
29
|
-
var api = _ref.api,
|
|
30
|
-
pluginKey = _ref.pluginKey,
|
|
31
|
-
view = _ref.view;
|
|
32
|
-
var win = view.dom.ownerDocument.defaultView;
|
|
33
|
-
var frame;
|
|
34
|
-
var visiblePositions = [];
|
|
35
|
-
var registryChanged = true;
|
|
36
|
-
var reconcile = function reconcile() {
|
|
37
|
-
var _api$limitedMode;
|
|
38
|
-
frame = undefined;
|
|
39
|
-
var previous = pluginKey.getState(view.state);
|
|
40
|
-
if (!previous || api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && _api$limitedMode.enabled) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var controls = _main.key.getState(view.state);
|
|
44
|
-
var activeNode = controls === null || controls === void 0 ? void 0 : controls.activeNode;
|
|
45
|
-
var activeNodesByPosition = new Map();
|
|
46
|
-
var menu = controls !== null && controls !== void 0 && controls.isMenuOpen ? controls.menuTriggerByNode : undefined;
|
|
47
|
-
if (menu && controls !== null && controls !== void 0 && controls.menuTriggerBy && view.state.doc.nodeAt(menu.pos)) {
|
|
48
|
-
var _menu$rootPos;
|
|
49
|
-
var menuNode = _objectSpread(_objectSpread({}, menu), {}, {
|
|
50
|
-
anchorName: controls.menuTriggerBy
|
|
51
|
-
});
|
|
52
|
-
activeNodesByPosition.set(menu.pos, menuNode);
|
|
53
|
-
activeNodesByPosition.set((_menu$rootPos = menu.rootPos) !== null && _menu$rootPos !== void 0 ? _menu$rootPos : menu.pos, menuNode);
|
|
54
|
-
}
|
|
55
|
-
var resolvedSurfaces = [_surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE, _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE].map(function (surface) {
|
|
56
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
57
|
-
return (0, _surfaceRenderer.resolveSurface)((_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(surface)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [], surface);
|
|
58
|
-
});
|
|
59
|
-
var candidates = (0, _sparseSurfaceCandidates.reconcileSparseSurfaceCandidates)({
|
|
60
|
-
activeNode: activeNode,
|
|
61
|
-
activeNodesByPosition: activeNodesByPosition,
|
|
62
|
-
newState: view.state,
|
|
63
|
-
state: previous.candidates,
|
|
64
|
-
visiblePositions: visiblePositions,
|
|
65
|
-
protectedPositions: (0, _toConsumableArray2.default)(activeNodesByPosition.keys()),
|
|
66
|
-
resolvedSurfaces: resolvedSurfaces,
|
|
67
|
-
documentChanged: previous.documentChanged,
|
|
68
|
-
invalidation: _objectSpread(_objectSpread({}, previous.invalidation), {}, {
|
|
69
|
-
all: registryChanged
|
|
70
|
-
})
|
|
71
|
-
});
|
|
72
|
-
var visibilityChanged = registryChanged;
|
|
73
|
-
registryChanged = false;
|
|
74
|
-
var anchorPositions = candidates.positions;
|
|
75
|
-
if (!visibilityChanged && !haveAnchorPositionsChanged(anchorPositions, previous.anchors) && candidates === previous.candidates && !previous.documentChanged && !previous.invalidation) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
var nodeIdProvider = (0, _nodeAnchorProvider.getNodeIdProvider)(view);
|
|
79
|
-
var _createSurfaceAnchorD = (0, _decorationsSurfaceAnchor.createSurfaceAnchorDecorations)(view.state, anchorPositions, function (node, position, previousAnchorName) {
|
|
80
|
-
if (previousAnchorName) {
|
|
81
|
-
nodeIdProvider.setIdForNode(node, previousAnchorName);
|
|
82
|
-
return previousAnchorName;
|
|
83
|
-
}
|
|
84
|
-
return nodeIdProvider.getOrGenerateId(node, position);
|
|
85
|
-
}, previous.anchors),
|
|
86
|
-
anchors = _createSurfaceAnchorD.anchors,
|
|
87
|
-
decorations = _createSurfaceAnchorD.decorations;
|
|
88
|
-
view.dispatch(view.state.tr.setMeta(pluginKey, {
|
|
89
|
-
reconciliation: {
|
|
90
|
-
activeNodesByPosition: activeNodesByPosition,
|
|
91
|
-
anchors: anchors,
|
|
92
|
-
candidates: candidates,
|
|
93
|
-
decorations: decorations
|
|
94
|
-
},
|
|
95
|
-
type: 'commitReconciliation'
|
|
96
|
-
}));
|
|
97
|
-
};
|
|
98
|
-
var schedule = function schedule() {
|
|
99
|
-
if (frame === undefined && win) {
|
|
100
|
-
frame = win.requestAnimationFrame(reconcile);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
var observer = (0, _surfaceViewport.observeSurfaceViewport)(view, function (positions) {
|
|
104
|
-
visiblePositions = positions;
|
|
105
|
-
schedule();
|
|
106
|
-
});
|
|
107
|
-
var invalidate = function invalidate() {
|
|
108
|
-
registryChanged = true;
|
|
109
|
-
schedule();
|
|
110
|
-
};
|
|
111
|
-
var unsubscribe = api === null || api === void 0 || (_api$uiControlRegistr3 = api.uiControlRegistry) === null || _api$uiControlRegistr3 === void 0 ? void 0 : _api$uiControlRegistr3.actions.subscribe(invalidate);
|
|
112
|
-
var unbindGutterHover = (0, _sparseGutterHover.bindSparseGutterHover)({
|
|
113
|
-
api: api,
|
|
114
|
-
view: view
|
|
115
|
-
});
|
|
116
|
-
var unsubscribers = [api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.sharedState.onChange(invalidate), api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.onChange(invalidate), api === null || api === void 0 || (_api$limitedMode2 = api.limitedMode) === null || _api$limitedMode2 === void 0 ? void 0 : _api$limitedMode2.sharedState.onChange(invalidate), api === null || api === void 0 || (_api$showDiff = api.showDiff) === null || _api$showDiff === void 0 ? void 0 : _api$showDiff.sharedState.onChange(invalidate), api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.sharedState.onChange(invalidate)];
|
|
117
|
-
return {
|
|
118
|
-
update: function update(currentView, previousState) {
|
|
119
|
-
observer.update();
|
|
120
|
-
var sparse = pluginKey.getState(currentView.state);
|
|
121
|
-
var controls = _main.key.getState(currentView.state);
|
|
122
|
-
var previousControls = _main.key.getState(previousState);
|
|
123
|
-
if ((controls === null || controls === void 0 ? void 0 : controls.isDragging) !== (previousControls === null || previousControls === void 0 ? void 0 : previousControls.isDragging) || (controls === null || controls === void 0 ? void 0 : controls.isResizerResizing) !== (previousControls === null || previousControls === void 0 ? void 0 : previousControls.isResizerResizing)) {
|
|
124
|
-
invalidate();
|
|
125
|
-
}
|
|
126
|
-
if (sparse !== null && sparse !== void 0 && sparse.documentChanged || sparse !== null && sparse !== void 0 && sparse.invalidation || (controls === null || controls === void 0 ? void 0 : controls.activeNode) !== (previousControls === null || previousControls === void 0 ? void 0 : previousControls.activeNode) || (controls === null || controls === void 0 ? void 0 : controls.isMenuOpen) !== (previousControls === null || previousControls === void 0 ? void 0 : previousControls.isMenuOpen) || (controls === null || controls === void 0 ? void 0 : controls.menuTriggerByNode) !== (previousControls === null || previousControls === void 0 ? void 0 : previousControls.menuTriggerByNode)) {
|
|
127
|
-
schedule();
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
destroy: function destroy() {
|
|
131
|
-
if (frame !== undefined) {
|
|
132
|
-
win === null || win === void 0 || win.cancelAnimationFrame(frame);
|
|
133
|
-
}
|
|
134
|
-
observer.destroy();
|
|
135
|
-
unbindGutterHover === null || unbindGutterHover === void 0 || unbindGutterHover();
|
|
136
|
-
unsubscribe === null || unsubscribe === void 0 || unsubscribe();
|
|
137
|
-
unsubscribers.forEach(function (unsubscribe) {
|
|
138
|
-
return unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
var createSparseSurfacesView = exports.createSparseSurfacesView = function createSparseSurfacesView(options) {
|
|
144
|
-
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_controls_cls_fix')) {
|
|
145
|
-
return (0, _sparseSurfacesViewWithLifecycle.createSparseSurfacesViewWithLifecycle)(options);
|
|
146
|
-
} else {
|
|
147
|
-
return createLegacySparseSurfacesView(options);
|
|
148
|
-
}
|
|
149
|
-
};
|