UNPKG

1.47 kBJavaScriptView Raw
1import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
2
3/**
4 * Internal dependencies
5 */
6import { common as commonEmbeds, others as otherEmbeds } from './core-embeds';
7import { embedContentIcon } from './icons';
8import { getEmbedBlockSettings } from './settings';
9/**
10 * WordPress dependencies
11 */
12
13import { __, _x } from '@wordpress/i18n';
14import { createBlock } from '@wordpress/blocks';
15export var name = 'core/embed';
16export var settings = getEmbedBlockSettings({
17 title: _x('Embed', 'block title'),
18 description: __('Embed videos, images, tweets, audio, and other content from external sources.'),
19 icon: embedContentIcon,
20 // Unknown embeds should not be responsive by default.
21 responsive: false,
22 transforms: {
23 from: [{
24 type: 'raw',
25 isMatch: function isMatch(node) {
26 return node.nodeName === 'P' && /^\s*(https?:\/\/\S+)\s*$/i.test(node.textContent);
27 },
28 transform: function transform(node) {
29 return createBlock('core/embed', {
30 url: node.textContent.trim()
31 });
32 }
33 }]
34 }
35});
36export var common = commonEmbeds.map(function (embedDefinition) {
37 return _objectSpread({}, embedDefinition, {
38 settings: getEmbedBlockSettings(embedDefinition.settings)
39 });
40});
41export var others = otherEmbeds.map(function (embedDefinition) {
42 return _objectSpread({}, embedDefinition, {
43 settings: getEmbedBlockSettings(embedDefinition.settings)
44 });
45});
46//# sourceMappingURL=index.js.map
\No newline at end of file