@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 2.33 kB
Source Map (JSON)
{"version":3,"file":"transforms.cjs","names":["createBlock","createBlobURL"],"sources":["../../src/audio/transforms.js"],"sourcesContent":["import { 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\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":";;;;;;;;AAGA,MAAM,aAAa,EAClB,MAAM,CACL;CACC,MAAM;CACN,QAAS,OAAQ;EAChB,OACC,MAAM,WAAW,KACjB,MAAO,EAAG,CAAC,KAAK,QAAS,QAAS,MAAM;CAE1C;CACA,UAAW,OAAQ;EAClB,MAAM,OAAO,MAAO;EAQpB,QAAA,GAJcA,kBAAAA,YAAAA,CAAa,cAAc,EACxC,OAAA,GAAMC,gBAAAA,cAAAA,CAAe,IAAK,EAC3B,CAEW;CACZ;AACD,GACA;CACC,MAAM;CACN,KAAK;CACL,YAAY;EACX,KAAK;GACJ,MAAM;GACN,YAAa,EACZ,OAAO,EAAE,KAAK,KAAK,KAAK,KAAK,KAAK,YAC5B;IACN,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO;GAC3C;EACD;EACA,MAAM;GACL,MAAM;GACN,YAAa,EAAE,OAAO,EAAE,aAAc;IACrC,OAAO;GACR;EACD;EACA,UAAU;GACT,MAAM;GACN,YAAa,EAAE,OAAO,EAAE,iBAAkB;IACzC,OAAO;GACR;EACD;EACA,SAAS;GACR,MAAM;GACN,YAAa,EAAE,OAAO,EAAE,gBAAiB;IACxC,OAAO;GACR;EACD;CACD;AACD,CACD,EACD"}