@atlaskit/editor-plugin-block-controls 17.3.8 → 17.3.10
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 +26 -0
- package/dist/cjs/blockControlsPlugin.js +2 -3
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -6
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +5 -2
- package/dist/cjs/pm-plugins/main.js +4 -2
- package/dist/cjs/ui/block-controls-left-surface.js +25 -8
- package/dist/cjs/ui/block-controls-right-surface.js +21 -7
- package/dist/cjs/ui/block-controls-surface-context.js +4 -1
- package/dist/cjs/ui/consts.js +13 -5
- package/dist/cjs/ui/utils/partition-components-by-persistence.js +65 -0
- package/dist/cjs/ui/visibility-container.js +6 -2
- package/dist/es2019/blockControlsPlugin.js +2 -3
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +6 -3
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +3 -2
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/ui/block-controls-left-surface.js +26 -8
- package/dist/es2019/ui/block-controls-right-surface.js +22 -7
- package/dist/es2019/ui/block-controls-surface-context.js +1 -0
- package/dist/es2019/ui/consts.js +10 -4
- package/dist/es2019/ui/utils/partition-components-by-persistence.js +48 -0
- package/dist/es2019/ui/visibility-container.js +6 -2
- package/dist/esm/blockControlsPlugin.js +2 -3
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -6
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +5 -2
- package/dist/esm/pm-plugins/main.js +4 -2
- package/dist/esm/ui/block-controls-left-surface.js +25 -8
- package/dist/esm/ui/block-controls-right-surface.js +21 -7
- package/dist/esm/ui/block-controls-surface-context.js +3 -0
- package/dist/esm/ui/consts.js +12 -4
- package/dist/esm/ui/utils/partition-components-by-persistence.js +59 -0
- package/dist/esm/ui/visibility-container.js +6 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/ui/block-controls-surface-context.d.ts +1 -0
- package/dist/types/ui/consts.d.ts +0 -1
- package/dist/types/ui/utils/partition-components-by-persistence.d.ts +15 -0
- package/dist/types/ui/visibility-container.d.ts +2 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 17.3.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`42ff8dffbdf01`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/42ff8dffbdf01) -
|
|
8
|
+
EDITOR-8771: Buttons registered on the same surface position now stay visible independently of
|
|
9
|
+
eachother: a button that renders without hover (e.g. an AI suggestions icon) no longer
|
|
10
|
+
hides/showstogether with a hover-only button (e.g. Remix) that shares its position.Increase the
|
|
11
|
+
default drag-handle/surface gap for non-resizable, default-sized nodes from 8px to12px, matching
|
|
12
|
+
the gap already used for resizable/breakout nodes, so spacing is consistent acrossnode
|
|
13
|
+
types.Simplify `surfaceNodePositionsEnabled` (which controls whether the "stored" whole-doc
|
|
14
|
+
surface scanruns) to depend only on `platform_editor_block_control_migration`, dropping the
|
|
15
|
+
extra`platform_editor_collapsible_headings` OR-condition now
|
|
16
|
+
that`platform_editor_block_control_right_surface` consumers need the same behavior.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 17.3.9
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`09b54fe3854bd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/09b54fe3854bd) -
|
|
24
|
+
Keep Quick Insert stationary when the drag handle moves to a nested block under
|
|
25
|
+
`platform_editor_block_control_migration`, and keep layout-column drag handles visible across the
|
|
26
|
+
full editor width.
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
|
|
3
29
|
## 17.3.8
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -46,7 +46,6 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
46
46
|
var rightSideControlsEnabled = (_config$rightSideCont = config === null || config === void 0 ? void 0 : config.rightSideControlsEnabled) !== null && _config$rightSideCont !== void 0 ? _config$rightSideCont : false;
|
|
47
47
|
var quickInsertButtonEnabled = (_config$quickInsertBu = config === null || config === void 0 ? void 0 : config.quickInsertButtonEnabled) !== null && _config$quickInsertBu !== void 0 ? _config$quickInsertBu : true;
|
|
48
48
|
var registryBlockControlsEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration');
|
|
49
|
-
var surfaceNodePositionsEnabled = registryBlockControlsEnabled && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings');
|
|
50
49
|
var legacyBlockControlsEnabled = !registryBlockControlsEnabled;
|
|
51
50
|
var rightSurfaceEnabled = registryBlockControlsEnabled && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_right_surface');
|
|
52
51
|
if (registryBlockControlsEnabled) {
|
|
@@ -146,7 +145,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
146
145
|
plugin: function plugin(_ref2) {
|
|
147
146
|
var getIntl = _ref2.getIntl,
|
|
148
147
|
nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
|
|
149
|
-
return (0, _main.createPlugin)(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled,
|
|
148
|
+
return (0, _main.createPlugin)(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled, rightSurfaceEnabled);
|
|
150
149
|
}
|
|
151
150
|
}];
|
|
152
151
|
if ((0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
@@ -448,7 +447,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
448
447
|
isEditing: (_interactionTrackingP = _pmPlugin.interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
449
448
|
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState10 = _main.key.getState(editorState)) === null || _key$getState10 === void 0 ? void 0 : _key$getState10.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
450
449
|
};
|
|
451
|
-
if (
|
|
450
|
+
if (registryBlockControlsEnabled) {
|
|
452
451
|
var _key$getState$surface, _key$getState11;
|
|
453
452
|
sharedState.surfaceNodePositions = (_key$getState$surface = (_key$getState11 = _main.key.getState(editorState)) === null || _key$getState11 === void 0 ? void 0 : _key$getState11.surfaceNodePositions) !== null && _key$getState$surface !== void 0 ? _key$getState$surface : [];
|
|
454
453
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseEnter = void 0;
|
|
7
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
7
8
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
8
9
|
var _handleMouseOver = require("../handle-mouse-over");
|
|
9
10
|
var _commands = require("./commands");
|
|
@@ -30,6 +31,10 @@ var clearPendingHoverSide = function clearPendingHoverSide(view) {
|
|
|
30
31
|
};
|
|
31
32
|
var BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
|
|
32
33
|
var RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
|
|
34
|
+
var LEGACY_LEFT_CONTROL_SELECTOR = '[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
|
|
35
|
+
var getLeftControlSelector = function getLeftControlSelector() {
|
|
36
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_LEFT_CONTROL_SELECTOR) : LEGACY_LEFT_CONTROL_SELECTOR;
|
|
37
|
+
};
|
|
33
38
|
|
|
34
39
|
// Top-level blocks (no block ancestor), matched by anchor attribute so it works under both the
|
|
35
40
|
// legacy and native-anchor schemes.
|
|
@@ -128,7 +133,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
128
133
|
}
|
|
129
134
|
return;
|
|
130
135
|
}
|
|
131
|
-
var leftControlElement = target === null || target === void 0 ? void 0 : target.closest(
|
|
136
|
+
var leftControlElement = target === null || target === void 0 ? void 0 : target.closest(getLeftControlSelector());
|
|
132
137
|
if (leftControlElement) {
|
|
133
138
|
if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'left') {
|
|
134
139
|
(0, _commands.setHoverSide)(view, 'left');
|
|
@@ -186,9 +191,7 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
186
191
|
(0, _commands.setHoverSide)(view, nextHoverSide);
|
|
187
192
|
}
|
|
188
193
|
};
|
|
189
|
-
var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, event) {
|
|
190
|
-
var rightSideControlsEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
191
|
-
var api = arguments.length > 3 ? arguments[3] : undefined;
|
|
194
|
+
var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, event, rightSideControlsEnabled, api) {
|
|
192
195
|
var state = (0, _pmPlugin.getInteractionTrackingState)(view.state);
|
|
193
196
|
// if user has stopped editing and moved their mouse, show block controls again
|
|
194
197
|
if (state !== null && state !== void 0 && state.isEditing) {
|
|
@@ -210,8 +213,7 @@ var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, e
|
|
|
210
213
|
rafIdByView.set(view, id);
|
|
211
214
|
return false;
|
|
212
215
|
};
|
|
213
|
-
var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view) {
|
|
214
|
-
var rightSideControlsEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
216
|
+
var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view, rightSideControlsEnabled) {
|
|
215
217
|
if (rightSideControlsEnabled) {
|
|
216
218
|
clearPendingHoverSide(view);
|
|
217
219
|
}
|
|
@@ -19,13 +19,16 @@ var _handleMouseMove = require("./handle-mouse-move");
|
|
|
19
19
|
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; }
|
|
20
20
|
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; }
|
|
21
21
|
/** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
|
|
22
|
-
var
|
|
22
|
+
var LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
|
|
23
|
+
var getBlockControlsHoverAreaSelector = function getBlockControlsHoverAreaSelector() {
|
|
24
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? "[data-editor-block-ctrl-drag-handle], ".concat(LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR) : LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR;
|
|
25
|
+
};
|
|
23
26
|
var MOUSE_LEAVE_DEBOUNCE_MS = 200;
|
|
24
27
|
|
|
25
28
|
/** ClickAreaBlock overlay that wraps the editor content and covers the right margin. */
|
|
26
29
|
var CLICK_AREA_SELECTOR = '[data-editor-click-wrapper]';
|
|
27
30
|
var isMovingToBlockControlsArea = function isMovingToBlockControlsArea(target) {
|
|
28
|
-
return target instanceof Element && !!target.closest(
|
|
31
|
+
return target instanceof Element && !!target.closest(getBlockControlsHoverAreaSelector());
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
/**
|
|
@@ -890,14 +890,16 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
890
890
|
var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
891
891
|
var quickInsertButtonEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
892
892
|
var legacyDragHandleEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
|
|
893
|
-
var
|
|
894
|
-
var rightSurfaceEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
893
|
+
var rightSurfaceEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
895
894
|
var _getIntl = getIntl(),
|
|
896
895
|
formatMessage = _getIntl.formatMessage;
|
|
897
896
|
var isAdvancedLayoutEnabled = (0, _editorExperiment.editorExperiment)('advanced_layouts', true, {
|
|
898
897
|
exposure: true
|
|
899
898
|
});
|
|
900
899
|
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
900
|
+
// Mirrors `registryBlockControlsEnabled` in blockControlsPlugin.tsx: `legacyDragHandleEnabled` is
|
|
901
|
+
// only false once that gate is on.
|
|
902
|
+
var surfaceNodePositionsEnabled = !legacyDragHandleEnabled;
|
|
901
903
|
var flags = {
|
|
902
904
|
legacyDragHandleEnabled: legacyDragHandleEnabled,
|
|
903
905
|
surfaceNodePositionsEnabled: surfaceNodePositionsEnabled,
|
|
@@ -9,8 +9,12 @@ exports.BlockControlsLeftSurface = void 0;
|
|
|
9
9
|
require("./block-controls-left-surface.compiled.css");
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
|
|
12
13
|
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
13
14
|
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
15
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
16
|
+
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
17
|
+
var _partitionComponentsByPersistence = require("./utils/partition-components-by-persistence");
|
|
14
18
|
var _visibilityContainer = require("./visibility-container");
|
|
15
19
|
var leftSurfaceOuterStyles = null;
|
|
16
20
|
var leftSurfaceRowStyles = null;
|
|
@@ -31,11 +35,11 @@ var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function Block
|
|
|
31
35
|
if (!placement || !(0, _surfaceRenderer.willSurfaceRender)(components, _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext)) {
|
|
32
36
|
return null;
|
|
33
37
|
}
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
var _partitionComponentsB = (0, _partitionComponentsByPersistence.partitionComponentsByPersistence)(components, _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext),
|
|
39
|
+
hoverOnlyComponents = _partitionComponentsB.hoverOnlyComponents,
|
|
40
|
+
persistentComponents = _partitionComponentsB.persistentComponents;
|
|
41
|
+
var willRenderPersistent = (0, _surfaceRenderer.willSurfaceRender)(persistentComponents, _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext);
|
|
42
|
+
var willRenderHoverOnly = (0, _surfaceRenderer.willSurfaceRender)(hoverOnlyComponents, _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext);
|
|
39
43
|
var isSticky = placement.height !== undefined;
|
|
40
44
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
41
45
|
"data-editor-block-controls-surface": true,
|
|
@@ -46,10 +50,23 @@ var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function Block
|
|
|
46
50
|
className: (0, _runtime.ax)(["_kqswstnw _1pbyb4wl"])
|
|
47
51
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
48
52
|
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
49
|
-
}, /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
53
|
+
}, willRenderPersistent && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
50
54
|
api: api,
|
|
51
|
-
controlSide:
|
|
55
|
+
controlSide: (0, _blockControlsSurfaceContext.getBlockControlsSurfaceControlSide)(surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT), (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_controls_reliable_anchor')),
|
|
52
56
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
53
57
|
shouldUseDisplayContents: true
|
|
54
|
-
},
|
|
58
|
+
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
59
|
+
components: persistentComponents,
|
|
60
|
+
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
61
|
+
surfaceContext: surfaceContext
|
|
62
|
+
})), willRenderHoverOnly && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
63
|
+
api: api,
|
|
64
|
+
controlSide: (0, _blockControlsSurfaceContext.getBlockControlsSurfaceControlSide)(surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT), (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_controls_reliable_anchor')),
|
|
65
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
66
|
+
shouldUseDisplayContents: true
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
68
|
+
components: hoverOnlyComponents,
|
|
69
|
+
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
70
|
+
surfaceContext: surfaceContext
|
|
71
|
+
}))));
|
|
55
72
|
};
|
|
@@ -11,6 +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 _partitionComponentsByPersistence = require("./utils/partition-components-by-persistence");
|
|
14
15
|
var _visibilityContainer = require("./visibility-container");
|
|
15
16
|
var rightSurfaceOuterStyles = null;
|
|
16
17
|
var rightSurfaceRowStyles = null;
|
|
@@ -31,11 +32,11 @@ var BlockControlsRightSurface = exports.BlockControlsRightSurface = function Blo
|
|
|
31
32
|
if (!placement || !(0, _surfaceRenderer.willSurfaceRender)(components, _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext)) {
|
|
32
33
|
return null;
|
|
33
34
|
}
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
var _partitionComponentsB = (0, _partitionComponentsByPersistence.partitionComponentsByPersistence)(components, _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext),
|
|
36
|
+
hoverOnlyComponents = _partitionComponentsB.hoverOnlyComponents,
|
|
37
|
+
persistentComponents = _partitionComponentsB.persistentComponents;
|
|
38
|
+
var willRenderPersistent = (0, _surfaceRenderer.willSurfaceRender)(persistentComponents, _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
39
|
+
var willRenderHoverOnly = (0, _surfaceRenderer.willSurfaceRender)(hoverOnlyComponents, _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext);
|
|
39
40
|
var isSticky = placement.height !== undefined;
|
|
40
41
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
41
42
|
"data-editor-block-controls-surface": true,
|
|
@@ -46,10 +47,23 @@ var BlockControlsRightSurface = exports.BlockControlsRightSurface = function Blo
|
|
|
46
47
|
className: (0, _runtime.ax)(["_kqswstnw _1pbyb4wl"])
|
|
47
48
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
48
49
|
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
49
|
-
}, /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
50
|
+
}, willRenderPersistent && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
51
|
+
api: api,
|
|
52
|
+
controlSide: "right",
|
|
53
|
+
isPersistent: true,
|
|
54
|
+
shouldUseDisplayContents: true
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
56
|
+
components: persistentComponents,
|
|
57
|
+
surface: _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
58
|
+
surfaceContext: surfaceContext
|
|
59
|
+
})), willRenderHoverOnly && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
50
60
|
api: api,
|
|
51
61
|
controlSide: "right",
|
|
52
62
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
53
63
|
shouldUseDisplayContents: true
|
|
54
|
-
},
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
65
|
+
components: hoverOnlyComponents,
|
|
66
|
+
surface: _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
67
|
+
surfaceContext: surfaceContext
|
|
68
|
+
}))));
|
|
55
69
|
};
|
|
@@ -4,10 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.createBlockControlsSurfaceContextForPosition = exports.createBlockControlsSurfaceContext = void 0;
|
|
7
|
+
exports.getBlockControlsSurfaceControlSide = exports.createBlockControlsSurfaceContextForPosition = exports.createBlockControlsSurfaceContext = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
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; }
|
|
10
10
|
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; }
|
|
11
|
+
var getBlockControlsSurfaceControlSide = exports.getBlockControlsSurfaceControlSide = function getBlockControlsSurfaceControlSide(context, reliableAnchorEnabled) {
|
|
12
|
+
return (context === null || context === void 0 ? void 0 : context.targetNode.type.name) === 'layoutColumn' || Boolean(context) && reliableAnchorEnabled && (context === null || context === void 0 ? void 0 : context.targetNode.parentType) !== 'doc' ? undefined : 'left';
|
|
13
|
+
};
|
|
11
14
|
var getNodeContext = function getNodeContext(state, pos) {
|
|
12
15
|
var node = state.doc.nodeAt(pos);
|
|
13
16
|
if (!node) {
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = exports.STICKY_CONTROLS_TOP_MARGIN = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.
|
|
7
|
+
exports.topPositionAdjustment = exports.spacingBetweenNodesForPreview = exports.spaceLookupMap = exports.rootElementGap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER = exports.STICKY_CONTROLS_TOP_MARGIN = exports.QUICK_INSERT_WIDTH = exports.QUICK_INSERT_LEFT_OFFSET = exports.QUICK_INSERT_HEIGHT = exports.QUICK_INSERT_DIMENSIONS = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WRAPPED_MEDIA_EMBED_TOP_ADJUSTMENT = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT = exports.DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_LAYOUT_SECTION_TOP_ADJUSTMENT = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_H6_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H5_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H4_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H3_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_BORDER_RADIUS = exports.DEFAULT_COLUMN_DISTRIBUTIONS = exports.BLOCK_CONTROLS_SURFACE_SELECTOR = exports.ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = exports.ACTIVE_QUICK_INSERT_ATTR = exports.ACTIVE_DRAG_HANDLE_FALLBACK_ANCHOR_NAME = exports.ACTIVE_DRAG_HANDLE_ATTR = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
@@ -23,11 +23,19 @@ var ACTIVE_QUICK_INSERT_FALLBACK_ANCHOR_NAME = exports.ACTIVE_QUICK_INSERT_FALLB
|
|
|
23
23
|
var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
|
|
24
24
|
var DRAG_HANDLE_BORDER_RADIUS = exports.DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
25
25
|
var DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_ZINDEX = _editorSharedStyles.akRichMediaResizeZIndex + _editorSharedStyles.akEditorUnitZIndex; //place above legacy resizer
|
|
26
|
-
var
|
|
26
|
+
var LEGACY_DRAG_HANDLE_DEFAULT_GAP = 8;
|
|
27
|
+
var MIGRATED_DRAG_HANDLE_DEFAULT_GAP = 12;
|
|
27
28
|
var DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_NARROW_GAP = 4;
|
|
28
29
|
var DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_MAX_GAP = 12;
|
|
29
30
|
var DRAG_HANDLE_SYNCED_BLOCK_GAP = exports.DRAG_HANDLE_SYNCED_BLOCK_GAP = 2.5;
|
|
30
31
|
var DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = _styles.DRAG_HANDLE_WIDTH + DRAG_HANDLE_MAX_GAP;
|
|
32
|
+
|
|
33
|
+
// Non-resizable/default-sized nodes get the same gap as resizable/breakout nodes
|
|
34
|
+
// (DRAG_HANDLE_MAX_GAP) once the registry-backed surfaces are on; kept at the legacy value
|
|
35
|
+
// otherwise to avoid an unrelated visual change for consumers still on the old decoration path.
|
|
36
|
+
var getDragHandleDefaultGap = function getDragHandleDefaultGap() {
|
|
37
|
+
return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') ? MIGRATED_DRAG_HANDLE_DEFAULT_GAP : LEGACY_DRAG_HANDLE_DEFAULT_GAP;
|
|
38
|
+
};
|
|
31
39
|
var DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = 4 + 2; // 4px for the divider vertical padding and 2px for the divider height
|
|
32
40
|
var DRAG_HANDLE_H1_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H1_TOP_ADJUSTMENT = 5;
|
|
33
41
|
var DRAG_HANDLE_H2_TOP_ADJUSTMENT = exports.DRAG_HANDLE_H2_TOP_ADJUSTMENT = 2;
|
|
@@ -78,12 +86,12 @@ var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType, par
|
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
if (nodeType === 'layoutSection') {
|
|
81
|
-
return
|
|
89
|
+
return getDragHandleDefaultGap() + 20;
|
|
82
90
|
}
|
|
83
91
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
84
92
|
return DRAG_HANDLE_MAX_GAP;
|
|
85
93
|
}
|
|
86
|
-
return
|
|
94
|
+
return getDragHandleDefaultGap();
|
|
87
95
|
};
|
|
88
96
|
|
|
89
97
|
// use for returning gap only for root level elements
|
|
@@ -104,7 +112,7 @@ var rootElementGap = exports.rootElementGap = function rootElementGap(nodeType)
|
|
|
104
112
|
if (nodeType === 'layoutSection') {
|
|
105
113
|
return DRAG_HANDLE_MAX_GAP + 12;
|
|
106
114
|
}
|
|
107
|
-
return
|
|
115
|
+
return getDragHandleDefaultGap();
|
|
108
116
|
};
|
|
109
117
|
var getNestedNodeLeftPaddingMargin = exports.getNestedNodeLeftPaddingMargin = function getNestedNodeLeftPaddingMargin(nodeType) {
|
|
110
118
|
switch (nodeType) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.partitionComponentsByPersistence = void 0;
|
|
7
|
+
var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
|
|
8
|
+
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
9
|
+
var _createSurfaceContext = require("@atlaskit/editor-ui-control-model/create-surface-context");
|
|
10
|
+
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; } } }; }
|
|
11
|
+
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; } }
|
|
12
|
+
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; }
|
|
13
|
+
/**
|
|
14
|
+
* Split registered components into two groups:
|
|
15
|
+
* those that should be rendered persistently and those that should only be rendered on hover.
|
|
16
|
+
*/
|
|
17
|
+
var partitionComponentsByPersistence = exports.partitionComponentsByPersistence = function partitionComponentsByPersistence(components, surface, surfaceContext) {
|
|
18
|
+
var _resolveSurface = (0, _surfaceRenderer.resolveSurface)(components, surface),
|
|
19
|
+
childrenMap = _resolveSurface.childrenMap,
|
|
20
|
+
root = _resolveSurface.root,
|
|
21
|
+
topLevelChildren = _resolveSurface.topLevelChildren;
|
|
22
|
+
if (!root || !topLevelChildren || topLevelChildren.length === 0) {
|
|
23
|
+
return {
|
|
24
|
+
hoverOnlyComponents: [],
|
|
25
|
+
persistentComponents: components
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var context = surfaceContext === null || surfaceContext === void 0 ? void 0 : surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
|
|
29
|
+
var storedSurfaceContext = context ? (0, _createSurfaceContext.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, {
|
|
30
|
+
activeNode: undefined,
|
|
31
|
+
rootNode: context.targetNode,
|
|
32
|
+
targetNode: context.targetNode
|
|
33
|
+
}) : undefined;
|
|
34
|
+
var isLeaf = function isLeaf(component) {
|
|
35
|
+
var children = childrenMap.get((0, _surfaceRenderer.getComponentIdentity)(component));
|
|
36
|
+
return !children || children.length === 0;
|
|
37
|
+
};
|
|
38
|
+
var persistentComponents = [];
|
|
39
|
+
var hoverOnlyComponents = [];
|
|
40
|
+
var _iterator = _createForOfIteratorHelper(components),
|
|
41
|
+
_step;
|
|
42
|
+
try {
|
|
43
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
44
|
+
var component = _step.value;
|
|
45
|
+
if (!isLeaf(component)) {
|
|
46
|
+
persistentComponents.push(component);
|
|
47
|
+
hoverOnlyComponents.push(component);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if ((0, _surfaceRenderer.willComponentRender)(component, childrenMap, storedSurfaceContext)) {
|
|
51
|
+
persistentComponents.push(component);
|
|
52
|
+
} else {
|
|
53
|
+
hoverOnlyComponents.push(component);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} catch (err) {
|
|
57
|
+
_iterator.e(err);
|
|
58
|
+
} finally {
|
|
59
|
+
_iterator.f();
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
hoverOnlyComponents: hoverOnlyComponents,
|
|
63
|
+
persistentComponents: persistentComponents
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -62,6 +62,7 @@ var VisibilityContainer = exports.VisibilityContainer = function VisibilityConta
|
|
|
62
62
|
children = _ref.children,
|
|
63
63
|
controlSide = _ref.controlSide,
|
|
64
64
|
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
65
|
+
isPersistent = _ref.isPersistent,
|
|
65
66
|
shouldUseDisplayContents = _ref.shouldUseDisplayContents;
|
|
66
67
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['typeAhead', 'blockControls', 'editorViewMode', 'userIntent', 'showDiff'], function (states) {
|
|
67
68
|
var _states$typeAheadStat, _states$blockControls, _states$blockControls2, _states$blockControls3, _states$editorViewMod, _states$userIntentSta, _states$showDiffState, _states$blockControls4;
|
|
@@ -99,9 +100,12 @@ var VisibilityContainer = exports.VisibilityContainer = function VisibilityConta
|
|
|
99
100
|
// When forceVisibleOnMouseOut is true (e.g. drag handle focused via keyboard Shift+Ctrl+H),
|
|
100
101
|
// override the mouse-out condition so the control stays visible regardless of mouse position.
|
|
101
102
|
var shouldHideWhenMouseOut = forceVisibleOnMouseOut ? false : hideOnMouseOut;
|
|
102
|
-
|
|
103
|
+
// Persistent controls (e.g. an AI suggestion icon on every qualifying node) aren't hover-driven,
|
|
104
|
+
// so none of the hover/typing/mouse-out/diff-review reasons below apply to them — they're never
|
|
105
|
+
// hidden by this container.
|
|
106
|
+
var shouldHideImmediate = !isPersistent && (isTypeAheadOpen || isEditing || shouldHideWhenMouseOut || userIntent === 'aiStreaming' ||
|
|
103
107
|
// EDITOR-7926: hide the drag handle while a diff is on screen or a suggestion card is open.
|
|
104
|
-
(isDisplayingDiff || userIntent === 'reviewing') && (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) || sideHidden;
|
|
108
|
+
(isDisplayingDiff || userIntent === 'reviewing') && (0, _expValEquals.expValEquals)('platform_editor_diff_plugin_extended', 'isEnabled', true) || sideHidden);
|
|
105
109
|
|
|
106
110
|
// Delay hiding the right control in view mode to reduce flickering when moving from block
|
|
107
111
|
// toward the right-edge button (avoids rapid show/hide as mouse crosses boundaries).
|
|
@@ -36,7 +36,6 @@ export const blockControlsPlugin = ({
|
|
|
36
36
|
const rightSideControlsEnabled = (_config$rightSideCont = config === null || config === void 0 ? void 0 : config.rightSideControlsEnabled) !== null && _config$rightSideCont !== void 0 ? _config$rightSideCont : false;
|
|
37
37
|
const quickInsertButtonEnabled = (_config$quickInsertBu = config === null || config === void 0 ? void 0 : config.quickInsertButtonEnabled) !== null && _config$quickInsertBu !== void 0 ? _config$quickInsertBu : true;
|
|
38
38
|
const registryBlockControlsEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
39
|
-
const surfaceNodePositionsEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_collapsible_headings');
|
|
40
39
|
const legacyBlockControlsEnabled = !registryBlockControlsEnabled;
|
|
41
40
|
const rightSurfaceEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_block_control_right_surface');
|
|
42
41
|
if (registryBlockControlsEnabled) {
|
|
@@ -144,7 +143,7 @@ export const blockControlsPlugin = ({
|
|
|
144
143
|
plugin: ({
|
|
145
144
|
getIntl,
|
|
146
145
|
nodeViewPortalProviderAPI
|
|
147
|
-
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled,
|
|
146
|
+
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled, rightSurfaceEnabled)
|
|
148
147
|
}];
|
|
149
148
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
150
149
|
pmPlugins.push({
|
|
@@ -440,7 +439,7 @@ export const blockControlsPlugin = ({
|
|
|
440
439
|
isEditing: (_interactionTrackingP = interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
|
|
441
440
|
isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState10 = key.getState(editorState)) === null || _key$getState10 === void 0 ? void 0 : _key$getState10.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
|
|
442
441
|
};
|
|
443
|
-
if (
|
|
442
|
+
if (registryBlockControlsEnabled) {
|
|
444
443
|
var _key$getState$surface, _key$getState11;
|
|
445
444
|
sharedState.surfaceNodePositions = (_key$getState$surface = (_key$getState11 = key.getState(editorState)) === null || _key$getState11 === void 0 ? void 0 : _key$getState11.surfaceNodePositions) !== null && _key$getState$surface !== void 0 ? _key$getState$surface : [];
|
|
446
445
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
1
2
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
2
3
|
import { handleMouseOver } from '../handle-mouse-over';
|
|
3
4
|
import { clearHoverSide, mouseEnter, mouseLeave, setHoverSide, stopEditing } from './commands';
|
|
@@ -22,6 +23,8 @@ const clearPendingHoverSide = view => {
|
|
|
22
23
|
};
|
|
23
24
|
const BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
|
|
24
25
|
const RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
|
|
26
|
+
const LEGACY_LEFT_CONTROL_SELECTOR = '[data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
|
|
27
|
+
const getLeftControlSelector = () => isExperimentEnabled('platform_editor_block_control_migration') ? `[data-editor-block-ctrl-drag-handle], ${LEGACY_LEFT_CONTROL_SELECTOR}` : LEGACY_LEFT_CONTROL_SELECTOR;
|
|
25
28
|
|
|
26
29
|
// Top-level blocks (no block ancestor), matched by anchor attribute so it works under both the
|
|
27
30
|
// legacy and native-anchor schemes.
|
|
@@ -109,7 +112,7 @@ const processHoverSide = (view, api) => {
|
|
|
109
112
|
}
|
|
110
113
|
return;
|
|
111
114
|
}
|
|
112
|
-
const leftControlElement = target === null || target === void 0 ? void 0 : target.closest(
|
|
115
|
+
const leftControlElement = target === null || target === void 0 ? void 0 : target.closest(getLeftControlSelector());
|
|
113
116
|
if (leftControlElement) {
|
|
114
117
|
if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'left') {
|
|
115
118
|
setHoverSide(view, 'left');
|
|
@@ -168,7 +171,7 @@ const processHoverSide = (view, api) => {
|
|
|
168
171
|
setHoverSide(view, nextHoverSide);
|
|
169
172
|
}
|
|
170
173
|
};
|
|
171
|
-
export const handleMouseMove = (view, event, rightSideControlsEnabled
|
|
174
|
+
export const handleMouseMove = (view, event, rightSideControlsEnabled, api) => {
|
|
172
175
|
const state = getInteractionTrackingState(view.state);
|
|
173
176
|
// if user has stopped editing and moved their mouse, show block controls again
|
|
174
177
|
if (state !== null && state !== void 0 && state.isEditing) {
|
|
@@ -190,7 +193,7 @@ export const handleMouseMove = (view, event, rightSideControlsEnabled = false, a
|
|
|
190
193
|
rafIdByView.set(view, id);
|
|
191
194
|
return false;
|
|
192
195
|
};
|
|
193
|
-
export const handleMouseLeave = (view, rightSideControlsEnabled
|
|
196
|
+
export const handleMouseLeave = (view, rightSideControlsEnabled) => {
|
|
194
197
|
if (rightSideControlsEnabled) {
|
|
195
198
|
clearPendingHoverSide(view);
|
|
196
199
|
}
|
|
@@ -10,12 +10,13 @@ import { handleKeyDown } from './handle-key-down';
|
|
|
10
10
|
import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
|
|
11
11
|
|
|
12
12
|
/** Elements that extend the editor hover area (block controls, right-edge button, etc.) */
|
|
13
|
-
const
|
|
13
|
+
const LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR = '[data-blocks-right-edge-button-container], [data-blocks-drag-handle-container], [data-testid="block-ctrl-drag-handle"], [data-testid="block-ctrl-drag-handle-container"], [data-testid="block-ctrl-decorator-widget"], [data-testid="block-ctrl-quick-insert-button"]';
|
|
14
|
+
const getBlockControlsHoverAreaSelector = () => isExperimentEnabled('platform_editor_block_control_migration') ? `[data-editor-block-ctrl-drag-handle], ${LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR}` : LEGACY_BLOCK_CONTROLS_HOVER_AREA_SELECTOR;
|
|
14
15
|
const MOUSE_LEAVE_DEBOUNCE_MS = 200;
|
|
15
16
|
|
|
16
17
|
/** ClickAreaBlock overlay that wraps the editor content and covers the right margin. */
|
|
17
18
|
const CLICK_AREA_SELECTOR = '[data-editor-click-wrapper]';
|
|
18
|
-
const isMovingToBlockControlsArea = target => target instanceof Element && !!target.closest(
|
|
19
|
+
const isMovingToBlockControlsArea = target => target instanceof Element && !!target.closest(getBlockControlsHoverAreaSelector());
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* The right margin is covered by the ClickAreaBlock overlay, which sits outside .ak-editor-content-area.
|
|
@@ -784,7 +784,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
784
784
|
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
785
785
|
};
|
|
786
786
|
};
|
|
787
|
-
export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, legacyDragHandleEnabled = true,
|
|
787
|
+
export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, legacyDragHandleEnabled = true, rightSurfaceEnabled = false) => {
|
|
788
788
|
var _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
|
|
789
789
|
const {
|
|
790
790
|
formatMessage
|
|
@@ -793,6 +793,9 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
793
793
|
exposure: true
|
|
794
794
|
});
|
|
795
795
|
const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
796
|
+
// Mirrors `registryBlockControlsEnabled` in blockControlsPlugin.tsx: `legacyDragHandleEnabled` is
|
|
797
|
+
// only false once that gate is on.
|
|
798
|
+
const surfaceNodePositionsEnabled = !legacyDragHandleEnabled;
|
|
796
799
|
const flags = {
|
|
797
800
|
legacyDragHandleEnabled,
|
|
798
801
|
surfaceNodePositionsEnabled,
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
import "./block-controls-left-surface.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
5
6
|
import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
6
7
|
import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
|
+
import { getBlockControlsSurfaceControlSide } from './block-controls-surface-context';
|
|
10
|
+
import { partitionComponentsByPersistence } from './utils/partition-components-by-persistence';
|
|
7
11
|
import { VisibilityContainer } from './visibility-container';
|
|
8
12
|
const leftSurfaceOuterStyles = null;
|
|
9
13
|
const leftSurfaceRowStyles = null;
|
|
@@ -25,11 +29,12 @@ export const BlockControlsLeftSurface = ({
|
|
|
25
29
|
if (!placement || !willSurfaceRender(components, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext)) {
|
|
26
30
|
return null;
|
|
27
31
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const {
|
|
33
|
+
hoverOnlyComponents,
|
|
34
|
+
persistentComponents
|
|
35
|
+
} = partitionComponentsByPersistence(components, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext);
|
|
36
|
+
const willRenderPersistent = willSurfaceRender(persistentComponents, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext);
|
|
37
|
+
const willRenderHoverOnly = willSurfaceRender(hoverOnlyComponents, BLOCK_CONTROLS_LEFT_SURFACE, surfaceContext);
|
|
33
38
|
const isSticky = placement.height !== undefined;
|
|
34
39
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
40
|
"data-editor-block-controls-surface": true,
|
|
@@ -40,10 +45,23 @@ export const BlockControlsLeftSurface = ({
|
|
|
40
45
|
className: ax(["_kqswstnw _1pbyb4wl"])
|
|
41
46
|
}, /*#__PURE__*/React.createElement("div", {
|
|
42
47
|
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
43
|
-
}, /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
48
|
+
}, willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
44
49
|
api: api,
|
|
45
|
-
controlSide:
|
|
50
|
+
controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
|
|
46
51
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
47
52
|
shouldUseDisplayContents: true
|
|
48
|
-
},
|
|
53
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
54
|
+
components: persistentComponents,
|
|
55
|
+
surface: BLOCK_CONTROLS_LEFT_SURFACE,
|
|
56
|
+
surfaceContext: surfaceContext
|
|
57
|
+
})), willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
58
|
+
api: api,
|
|
59
|
+
controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
|
|
60
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
61
|
+
shouldUseDisplayContents: true
|
|
62
|
+
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
63
|
+
components: hoverOnlyComponents,
|
|
64
|
+
surface: BLOCK_CONTROLS_LEFT_SURFACE,
|
|
65
|
+
surfaceContext: surfaceContext
|
|
66
|
+
}))));
|
|
49
67
|
};
|