| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
import { registerBlockType } from '@wordpress/blocks'; |
| 5 |
import { useBlockProps } from '@wordpress/block-editor'; |
| 6 |
import { Placeholder } from '@wordpress/components'; |
| 7 |
import { __ } from '@wordpress/i18n'; |
| 8 |
|
| 9 |
/** |
| 10 |
* Internal dependencies |
| 11 |
*/ |
| 12 |
import { BeyondwordsIcon } from '../icon'; |
| 13 |
|
| 14 |
registerBlockType( 'beyondwords/player', { |
| 15 |
icon: <BeyondwordsIcon />, |
| 16 |
edit: function Edit() { |
| 17 |
const blockProps = useBlockProps(); |
| 18 |
|
| 19 |
// The live player only renders on the front end; show a static |
| 20 |
// Placeholder marking where it will appear. |
| 21 |
return ( |
| 22 |
<div { ...blockProps }> |
| 23 |
<Placeholder |
| 24 |
icon={ <BeyondwordsIcon /> } |
| 25 |
label={ __( 'BeyondWords Player', 'speechkit' ) } |
| 26 |
instructions={ __( |
| 27 |
'The BeyondWords audio player will appear here.', |
| 28 |
'speechkit' |
| 29 |
) } |
| 30 |
/> |
| 31 |
</div> |
| 32 |
); |
| 33 |
}, |
| 34 |
save: function Save() { |
| 35 |
const blockProps = useBlockProps.save( { contentEditable: false } ); |
| 36 |
|
| 37 |
return ( |
| 38 |
<div { ...blockProps }> |
| 39 |
<div |
| 40 |
data-beyondwords-player="true" |
| 41 |
contentEditable="false" |
| 42 |
></div> |
| 43 |
</div> |
| 44 |
); |
| 45 |
}, |
| 46 |
} ); |
| 47 |
|