UNPKG

@wordpress/block-library

Version:
93 lines (89 loc) 1.9 kB
/** * WordPress dependencies */ import { createBlobURL } from '@wordpress/blob'; import { createBlock } from '@wordpress/blocks'; const transforms = { from: [{ type: 'files', isMatch(files) { return files.length === 1 && files[0].type.indexOf('video/') === 0; }, transform(files) { const file = files[0]; // We don't need to upload the media directly here // It's already done as part of the `componentDidMount` // in the video block const block = createBlock('core/video', { src: createBlobURL(file) }); return block; } }, { type: 'shortcode', tag: 'video', attributes: { src: { type: 'string', shortcode: _ref => { let { named: { src, mp4, m4v, webm, ogv, flv } } = _ref; return src || mp4 || m4v || webm || ogv || flv; } }, poster: { type: 'string', shortcode: _ref2 => { let { named: { poster } } = _ref2; return poster; } }, loop: { type: 'string', shortcode: _ref3 => { let { named: { loop } } = _ref3; return loop; } }, autoplay: { type: 'string', shortcode: _ref4 => { let { named: { autoplay } } = _ref4; return autoplay; } }, preload: { type: 'string', shortcode: _ref5 => { let { named: { preload } } = _ref5; return preload; } } } }] }; export default transforms; //# sourceMappingURL=transforms.js.map