@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
40 lines (37 loc) • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = NavigationBlockEditingMode;
var _element = require("@wordpress/element");
var _data = require("@wordpress/data");
var _blockEditor = require("@wordpress/block-editor");
/**
* WordPress dependencies
*/
/**
* For the Navigation block editor, we need to force the block editor to contentOnly for that block.
*
* Set block editing mode to contentOnly when entering Navigation focus mode.
* this ensures that non-content controls on the block will be hidden and thus
* the user can focus on editing the Navigation Menu content only.
*/
function NavigationBlockEditingMode() {
// In the navigation block editor,
// the navigation block is the only root block.
const blockClientId = (0, _data.useSelect)(select => select(_blockEditor.store).getBlockOrder()?.[0], []);
const {
setBlockEditingMode,
unsetBlockEditingMode
} = (0, _data.useDispatch)(_blockEditor.store);
(0, _element.useEffect)(() => {
if (!blockClientId) {
return;
}
setBlockEditingMode(blockClientId, 'contentOnly');
return () => {
unsetBlockEditingMode(blockClientId);
};
}, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
}
//# sourceMappingURL=navigation-block-editing-mode.js.map