@wordpress/block-library
Version:
Block library for the WordPress editor.
92 lines (84 loc) • 1.84 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _blob = require("@wordpress/blob");
var _blocks = require("@wordpress/blocks");
/**
* WordPress dependencies
*/
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 = (0, _blocks.createBlock)('core/audio', {
src: (0, _blob.createBlobURL)(file)
});
return block;
}
}, {
type: 'shortcode',
tag: 'audio',
attributes: {
src: {
type: 'string',
shortcode: _ref => {
let {
named: {
src,
mp3,
m4a,
ogg,
wav,
wma
}
} = _ref;
return src || mp3 || m4a || ogg || wav || wma;
}
},
loop: {
type: 'string',
shortcode: _ref2 => {
let {
named: {
loop
}
} = _ref2;
return loop;
}
},
autoplay: {
type: 'string',
shortcode: _ref3 => {
let {
named: {
autoplay
}
} = _ref3;
return autoplay;
}
},
preload: {
type: 'string',
shortcode: _ref4 => {
let {
named: {
preload
}
} = _ref4;
return preload;
}
}
}
}]
};
var _default = transforms;
exports.default = _default;
//# sourceMappingURL=transforms.js.map
;