| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import { __ } from '@wordpress/i18n'; |
| 5 |
import { SelectControl, Flex, FlexBlock } from '@wordpress/components'; |
| 6 |
import { useEntityProp } from '@wordpress/core-data'; |
| 7 |
import { useSelect } from '@wordpress/data'; |
| 8 |
import { Fragment } from '@wordpress/element'; |
| 9 |
|
| 10 |
export function PlayerContent( { wrapper } ) { |
| 11 |
const Wrapper = wrapper || Fragment; |
| 12 |
|
| 13 |
const postType = useSelect( |
| 14 |
( select ) => select( 'core/editor' ).getCurrentPostType(), |
| 15 |
[] |
| 16 |
); |
| 17 |
|
| 18 |
const [ meta, setMeta ] = useEntityProp( 'postType', postType, 'meta' ); |
| 19 |
|
| 20 |
const playerContent = meta.beyondwords_player_content || ''; |
| 21 |
|
| 22 |
const setPlayerContent = ( value ) => { |
| 23 |
setMeta( { |
| 24 |
...meta, |
| 25 |
beyondwords_player_content: value, |
| 26 |
} ); |
| 27 |
}; |
| 28 |
|
| 29 |
return ( |
| 30 |
<Wrapper> |
| 31 |
<Flex> |
| 32 |
<FlexBlock> |
| 33 |
<SelectControl |
| 34 |
className="beyondwords--player-content" |
| 35 |
label={ __( 'Player content', 'speechkit' ) } |
| 36 |
options={ [ |
| 37 |
{ |
| 38 |
label: 'Article', |
| 39 |
value: '', |
| 40 |
}, |
| 41 |
{ |
| 42 |
label: 'Summary', |
| 43 |
value: 'summary', |
| 44 |
}, |
| 45 |
] } |
| 46 |
onChange={ ( val ) => setPlayerContent( val ) } |
| 47 |
value={ playerContent } |
| 48 |
__nextHasNoMarginBottom |
| 49 |
__next40pxDefaultSize |
| 50 |
/> |
| 51 |
</FlexBlock> |
| 52 |
</Flex> |
| 53 |
</Wrapper> |
| 54 |
); |
| 55 |
} |
| 56 |
|
| 57 |
export default PlayerContent; |
| 58 |
|