@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 1.77 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/provider/navigation-block-editing-mode.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * For the Navigation block editor, we need to force the block editor to contentOnly for that block.\n *\n * Set block editing mode to contentOnly when entering Navigation focus mode.\n * this ensures that non-content controls on the block will be hidden and thus\n * the user can focus on editing the Navigation Menu content only.\n */\n\nexport default function NavigationBlockEditingMode() {\n\t// In the navigation block editor,\n\t// the navigation block is the only root block.\n\tconst blockClientId = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockOrder()?.[ 0 ],\n\t\t[]\n\t);\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! blockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetBlockEditingMode( blockClientId, 'contentOnly' );\n\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( blockClientId );\n\t\t};\n\t}, [ blockClientId, unsetBlockEditingMode, setBlockEditingMode ] );\n}\n"],
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,wBAAwB;AAU3B,SAAR,6BAA8C;AAGpD,QAAM,gBAAgB;AAAA,IACrB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,cAAc,IAAK,CAAE;AAAA,IAC9D,CAAC;AAAA,EACF;AACA,QAAM,EAAE,qBAAqB,sBAAsB,IAClD,YAAa,gBAAiB;AAE/B,YAAW,MAAM;AAChB,QAAK,CAAE,eAAgB;AACtB;AAAA,IACD;AAEA,wBAAqB,eAAe,aAAc;AAElD,WAAO,MAAM;AACZ,4BAAuB,aAAc;AAAA,IACtC;AAAA,EACD,GAAG,CAAE,eAAe,uBAAuB,mBAAoB,CAAE;AAClE;",
"names": []
}