useBlockAttributes.js
2 years ago
useFields.js
2 years ago
useIsAdvancedValidation.js
2 years ago
useIsUniqueFieldName.js
2 years ago
useSupport.js
2 years ago
useUniqKey.js
2 years ago
useUniqueNameOnDuplicate.js
2 years ago
useSupport.js
24 lines
| 1 | const { |
| 2 | useSelect, |
| 3 | } = wp.data; |
| 4 | |
| 5 | const { |
| 6 | useBlockEditContext, |
| 7 | } = wp.blockEditor; |
| 8 | |
| 9 | const { get } = window._; |
| 10 | |
| 11 | function useSupport( supportName ) { |
| 12 | const { clientId, name } = useBlockEditContext(); |
| 13 | |
| 14 | return useSelect( |
| 15 | select => { |
| 16 | const blockType = select( 'core/blocks' ).getBlockType( name ); |
| 17 | |
| 18 | return get( blockType, [ 'supports', supportName ], false ); |
| 19 | }, |
| 20 | [ clientId ], |
| 21 | ); |
| 22 | } |
| 23 | |
| 24 | export default useSupport; |