@wordpress/block-library
Version:
Block library for the WordPress editor.
100 lines (93 loc) • 2.09 kB
JavaScript
import { createElement } from "@wordpress/element";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* Internal dependencies
*/
const metadata = {
$schema: "https://schemas.wp.org/trunk/block.json",
apiVersion: 2,
name: "core/embed",
title: "Embed",
category: "embed",
description: "Add a block that displays content pulled from other sites, like Twitter or YouTube.",
textdomain: "default",
attributes: {
url: {
type: "string",
__experimentalRole: "content"
},
caption: {
type: "string",
source: "html",
selector: "figcaption",
__experimentalRole: "content"
},
type: {
type: "string",
__experimentalRole: "content"
},
providerNameSlug: {
type: "string",
__experimentalRole: "content"
},
allowResponsive: {
type: "boolean",
"default": true
},
responsive: {
type: "boolean",
"default": false,
__experimentalRole: "content"
},
previewable: {
type: "boolean",
"default": true,
__experimentalRole: "content"
}
},
supports: {
align: true
},
editorStyle: "wp-block-embed-editor",
style: "wp-block-embed"
};
/**
* WordPress dependencies
*/
import { RichText } from '@wordpress/block-editor';
const {
attributes: blockAttributes
} = metadata;
const deprecated = [{
attributes: blockAttributes,
save(_ref) {
let {
attributes: {
url,
caption,
type,
providerNameSlug
}
} = _ref;
if (!url) {
return null;
}
const embedClassName = classnames('wp-block-embed', {
[`is-type-${type}`]: type,
[`is-provider-${providerNameSlug}`]: providerNameSlug
});
return createElement("figure", {
className: embedClassName
}, `\n${url}\n`
/* URL needs to be on its own line. */
, !RichText.isEmpty(caption) && createElement(RichText.Content, {
tagName: "figcaption",
value: caption
}));
}
}];
export default deprecated;
//# sourceMappingURL=deprecated.js.map