UNPKG

@wordpress/block-library

Version:
8 lines (7 loc) 2.65 kB
{ "version": 3, "sources": ["../../src/audio/transforms.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlobURL } from '@wordpress/blob';\nimport { createBlock } from '@wordpress/blocks';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'files',\n\t\t\tisMatch( files ) {\n\t\t\t\treturn (\n\t\t\t\t\tfiles.length === 1 &&\n\t\t\t\t\tfiles[ 0 ].type.indexOf( 'audio/' ) === 0\n\t\t\t\t);\n\t\t\t},\n\t\t\ttransform( files ) {\n\t\t\t\tconst file = files[ 0 ];\n\t\t\t\t// We don't need to upload the media directly here\n\t\t\t\t// It's already done as part of the `componentDidMount`\n\t\t\t\t// in the audio block.\n\t\t\t\tconst block = createBlock( 'core/audio', {\n\t\t\t\t\tblob: createBlobURL( file ),\n\t\t\t\t} );\n\n\t\t\t\treturn block;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'shortcode',\n\t\t\ttag: 'audio',\n\t\t\tattributes: {\n\t\t\t\tsrc: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tshortcode: ( {\n\t\t\t\t\t\tnamed: { src, mp3, m4a, ogg, wav, wma },\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\treturn src || mp3 || m4a || ogg || wav || wma;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tloop: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tshortcode: ( { named: { loop } } ) => {\n\t\t\t\t\t\treturn loop;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tautoplay: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tshortcode: ( { named: { autoplay } } ) => {\n\t\t\t\t\t\treturn autoplay;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tpreload: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tshortcode: ( { named: { preload } } ) => {\n\t\t\t\t\t\treturn preload;\n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