@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
32 lines (31 loc) • 1.03 kB
JavaScript
// packages/editor/src/components/provider/navigation-block-editing-mode.js
import { useEffect } from "@wordpress/element";
import { useRegistry, useSelect } from "@wordpress/data";
import { store as blockEditorStore } from "@wordpress/block-editor";
function NavigationBlockEditingMode() {
const registry = useRegistry();
const blockClientId = useSelect(
(select) => select(blockEditorStore).getBlockOrder()?.[0],
[]
);
useEffect(() => {
if (!blockClientId) {
return;
}
const {
setBlockEditingMode,
unsetBlockEditingMode,
__unstableMarkNextChangeAsNotPersistent
} = registry.dispatch(blockEditorStore);
__unstableMarkNextChangeAsNotPersistent();
setBlockEditingMode(blockClientId, "contentOnly");
return () => {
__unstableMarkNextChangeAsNotPersistent();
unsetBlockEditingMode(blockClientId);
};
}, [registry, blockClientId]);
}
export {
NavigationBlockEditingMode as default
};
//# sourceMappingURL=navigation-block-editing-mode.mjs.map