UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 2.32 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAuB;AACvB,wBAAyB;AACzB,qBAAiC;AACjC,kBAA4B;AAC5B,kBAA4B;AAK5B,wBAAsB;AACtB,mBAAgD;AAChD,mBAA0C;AAyBhC;AAvBK,SAAR,4BAA8C;AAAA,EACpD;AAAA,EACA;AACD,GAAI;AACH,QAAM,sBAAkB,iCAAkB,UAAU,GAAI;AACxD,QAAM,EAAE,YAAY,QAAI,yBAAa,aAAAA,KAAiB;AAItD,QAAM,kBAAc,uBAAO;AAC3B,QAAM,oBAAgB,8CAAiC;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,4CAAC,kBAAAC,SAAA,EAAU,MAAO,gBAAgB,MAAO;AAAA,MAChD,SAAU,MAAM,YAAa,cAAe;AAAA,MAE1C;AAAA;AAAA,YAED,gBAAI,0BAA2B;AAAA,QAC/B,gBAAgB;AAAA,MACjB;AAAA;AAAA,EACD;AAEF;", "names": ["blockEditorStore", "BlockIcon"] }