@atlaskit/editor-plugin-block-controls
Version:
Block controls plugin for @atlaskit/editor-core
115 lines (112 loc) • 5.46 kB
JavaScript
/* block-controls-right-surface.tsx generated by @compiled/babel-plugin v3.0.2 */
import "./block-controls-right-surface.compiled.css";
import { ax, ix } from "@compiled/react/runtime";
import React from 'react';
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model/surface-renderer';
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
import { BlockControlsSurfaceWithClsFix } from '../surface-lifecycle/block-controls-surface-with-cls-fix';
import { BlockControlsVisibilityProvider } from './block-controls-surface-components';
import { useBlockControlsVisibility } from './visibility-container';
const rightSurfaceHiddenWrapperStyles = null;
const rightSurfaceOuterStyles = null;
const rightSurfaceRowStyles = null;
// Applied in addition to rightSurfaceRowStyles when the target node is sticky-eligible (e.g. long
// tables): the outer wrapper spans the node's full height (see `placement.height`), so the content
// can stick near the top of the viewport instead of scrolling off with the node's top edge.
// Keep in sync with STICKY_CONTROLS_TOP_MARGIN in ./consts (must be a static literal here).
const rightSurfaceStickyStyles = null;
// Keep in sync with STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER in ./consts (must be a static literal here)
const rightSurfaceStickyTableHeaderStyles = null;
const BlockControlsRightSurfaceContent = ({
api,
components,
forceVisibleOnMouseOut,
placement,
source,
surfaceContext
}) => {
const blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
const {
shouldHide: shouldHideHoverControls,
useCssStyles
} = useBlockControlsVisibility({
api,
controlSide: 'right',
forceVisibleOnMouseOut
});
const isSticky = placement.isSticky;
return /*#__PURE__*/React.createElement("div", {
"data-editor-block-controls-surface": true,
"data-editor-block-controls-side": "right",
"data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
// 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.
,
style: placement.style,
className: ax(["_kqswstnw _17c61i8t _1pbyb4wl"])
}, /*#__PURE__*/React.createElement("div", {
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && isExperimentEnabled('platform_editor_block_controls_sticky_header_fix') && "_154i1ejb"])
}, /*#__PURE__*/React.createElement(BlockControlsVisibilityProvider, {
shouldHideHoverControls: shouldHideHoverControls,
useCssStyles: useCssStyles
}, /*#__PURE__*/React.createElement(SurfaceRenderer, {
components: components,
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
surfaceContext: surfaceContext
}))));
};
const BlockControlsRightSurfaceWrapper = ({
children,
placement,
source,
surfaceContext
}) => {
const blockControlsContext = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
const isSticky = placement.isSticky;
return /*#__PURE__*/React.createElement("div", {
"data-editor-block-controls-surface": true,
"data-editor-block-controls-side": "right",
"data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
// 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.
,
style: placement.style,
className: ax(["_kqswstnw _17c61i8t _1pbyb4wl", "_3um015vq"])
}, /*#__PURE__*/React.createElement("div", {
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && isExperimentEnabled('platform_editor_block_controls_sticky_header_fix') && "_154i1ejb"])
}, children));
};
/** Renders one right block-controls surface at a document position. */
export const BlockControlsRightSurface = ({
api,
components,
forceVisibleOnMouseOut,
placement,
source,
surfaceContext
}) => {
if (!placement) {
return null;
}
if (isExperimentEnabled('platform_editor_block_controls_cls_fix')) {
return /*#__PURE__*/React.createElement(BlockControlsSurfaceWithClsFix, {
side: "right",
SurfaceWrapper: BlockControlsRightSurfaceWrapper,
api: api,
components: components,
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
placement: placement,
source: source,
surfaceContext: surfaceContext
});
} else {
return /*#__PURE__*/React.createElement(BlockControlsRightSurfaceContent, {
api: api,
components: components,
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
placement: placement,
source: source,
surfaceContext: surfaceContext
});
}
};