balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

transforms.js (723B)


      1 /**
      2  * WordPress dependencies
      3  */
      4 const { createBlock } = wp.blocks;
      5 
      6 const transforms = {
      7     from: [
      8         {
      9             type: 'files',
     10             isMatch( files ) {
     11                 return files[ 0 ].type === 'application/json';
     12             },
     13             // We define a lower priorty (higher number) than the default of 10. This
     14             // ensures that the Import block is only created as a fallback.
     15             priority: 13,
     16             transform: ( files ) => {
     17                 const blocks = [];
     18 
     19                 blocks.push( createBlock( 'redux/import', {
     20                     file: files,
     21                 } ) );
     22 
     23                 return blocks;
     24             },
     25         },
     26     ],
     27 };
     28 
     29 export default transforms;