@wordpress/block-editor
Version:
44 lines (43 loc) • 1.47 kB
JavaScript
// packages/block-editor/src/components/block-settings-menu/block-parent-selector-menu-item.js
import { useRef } from "@wordpress/element";
import { MenuItem } from "@wordpress/components";
import { useViewportMatch } from "@wordpress/compose";
import { useDispatch } from "@wordpress/data";
import { __, sprintf } from "@wordpress/i18n";
import BlockIcon from "../block-icon/index.mjs";
import { useShowHoveredOrFocusedGestures } from "../block-toolbar/utils.mjs";
import { store as blockEditorStore } from "../../store/index.mjs";
import { jsx } from "react/jsx-runtime";
function BlockParentSelectorMenuItem({
parentClientId,
parentBlockType
}) {
const isSmallViewport = useViewportMatch("medium", "<");
const { selectBlock } = useDispatch(blockEditorStore);
const menuItemRef = useRef();
const gesturesProps = useShowHoveredOrFocusedGestures({
ref: menuItemRef,
highlightParent: true
});
if (!isSmallViewport) {
return null;
}
return /* @__PURE__ */ jsx(
MenuItem,
{
...gesturesProps,
ref: menuItemRef,
icon: /* @__PURE__ */ jsx(BlockIcon, { icon: parentBlockType.icon }),
onClick: () => selectBlock(parentClientId),
children: sprintf(
/* translators: %s: Name of the block's parent. */
__("Select parent block (%s)"),
parentBlockType.title
)
}
);
}
export {
BlockParentSelectorMenuItem as default
};
//# sourceMappingURL=block-parent-selector-menu-item.mjs.map