UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 2.26 kB
{ "version": 3, "sources": ["../../../src/components/block-settings-menu/block-parent-selector-menu-item.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { useShowHoveredOrFocusedGestures } from '../block-toolbar/utils';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockParentSelectorMenuItem( {\n\tparentClientId,\n\tparentBlockType,\n} ) {\n\tconst isSmallViewport = useViewportMatch( 'medium', '<' );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\t// Allows highlighting the parent block outline when focusing or hovering\n\t// the parent block selector within the child.\n\tconst menuItemRef = useRef();\n\tconst gesturesProps = useShowHoveredOrFocusedGestures( {\n\t\tref: menuItemRef,\n\t\thighlightParent: true,\n\t} );\n\n\tif ( ! isSmallViewport ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...gesturesProps }\n\t\t\tref={ menuItemRef }\n\t\t\ticon={ <BlockIcon icon={ parentBlockType.icon } /> }\n\t\t\tonClick={ () => selectBlock( parentClientId ) }\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %s: Name of the block's parent. */\n\t\t\t\t__( 'Select parent block (%s)' ),\n\t\t\t\tparentBlockType.title\n\t\t\t) }\n\t\t</MenuItem>\n\t);\n}\n"], "mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,IAAI,eAAe;AAK5B,OAAO,eAAe;AACtB,SAAS,uCAAuC;AAChD,SAAS,SAAS,wBAAwB;AAyBhC;AAvBK,SAAR,4BAA8C;AAAA,EACpD;AAAA,EACA;AACD,GAAI;AACH,QAAM,kBAAkB,iBAAkB,UAAU,GAAI;AACxD,QAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AAItD,QAAM,cAAc,OAAO;AAC3B,QAAM,gBAAgB,gCAAiC;AAAA,IACtD,KAAK;AAAA,IACL,iBAAiB;AAAA,EAClB,CAAE;AAEF,MAAK,CAAE,iBAAkB;AACxB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL,KAAM;AAAA,MACN,MAAO,oBAAC,aAAU,MAAO,gBAAgB,MAAO;AAAA,MAChD,SAAU,MAAM,YAAa,cAAe;AAAA,MAE1C;AAAA;AAAA,QAED,GAAI,0BAA2B;AAAA,QAC/B,gBAAgB;AAAA,MACjB;AAAA;AAAA,EACD;AAEF;", "names": [] }