/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/audio/transforms.js
61 строка
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
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( 'audio/' ) === 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 audio block. const block = createBlock( 'core/audio', { blob: createBlobURL( file ), } ); return block; }, }, { type: 'shortcode', tag: 'audio', attributes: { src: { type: 'string', shortcode: ( { named: { src, mp3, m4a, ogg, wav, wma }, } ) => { return src || mp3 || m4a || ogg || wav || wma; }, }, loop: { type: 'string', shortcode: ( { named: { loop } } ) => { return loop; }, }, autoplay: { type: 'string', shortcode: ( { named: { autoplay } } ) => { return autoplay; }, }, preload: { type: 'string', shortcode: ( { named: { preload } } ) => { return preload; }, }, }, }, ], }; export default transforms;