edit.js
6 years ago
editor.scss
6 years ago
index.js
5 years ago
index.php
6 years ago
style.scss
6 years ago
index.js
78 lines
| 1 | /** |
| 2 | * BLOCK: embedpress-blocks |
| 3 | * |
| 4 | * Registering a basic block with Gutenberg. |
| 5 | * Simple block, renders and saves the same content without any interactivity. |
| 6 | */ |
| 7 | |
| 8 | // Import CSS. |
| 9 | import './style.scss'; |
| 10 | import './editor.scss'; |
| 11 | import edit from './edit'; |
| 12 | import { wistiaIcon } from '../common/icons'; |
| 13 | const { __ } = wp.i18n; // Import __() from wp.i18n |
| 14 | const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks |
| 15 | |
| 16 | /** |
| 17 | * Register: aa Gutenberg Block. |
| 18 | * |
| 19 | * Registers a new block provided a unique name and an object defining its |
| 20 | * behavior. Once registered, the block is made editor as an option to any |
| 21 | * editor interface where blocks are implemented. |
| 22 | * |
| 23 | * @link https://wordpress.org/gutenberg/handbook/block-api/ |
| 24 | * @param {string} name Block name. |
| 25 | * @param {Object} settings Block settings. |
| 26 | * @return {?WPBlock} The block, if it has been successfully |
| 27 | * registered; otherwise `undefined`. |
| 28 | */ |
| 29 | registerBlockType('embedpress/wistia-block', { |
| 30 | // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
| 31 | title: __('Wistia'), // Block title. |
| 32 | icon: wistiaIcon, // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 33 | category: 'embedpress', // Block category — Group blocks together based on common traits E.g. common, formatting, layout Widgets, embed. |
| 34 | keywords: [ |
| 35 | __('embedpress'), |
| 36 | __('wistia'), |
| 37 | ], |
| 38 | supports: {align: ["wide", "full","right","left"], default: ''}, |
| 39 | edit, |
| 40 | save: function(props) { |
| 41 | return null; |
| 42 | }, |
| 43 | deprecated: [{ |
| 44 | attributes: { |
| 45 | url: { |
| 46 | type: 'string', |
| 47 | default: '' |
| 48 | }, |
| 49 | iframeSrc: { |
| 50 | type: 'string', |
| 51 | default: '' |
| 52 | } |
| 53 | }, |
| 54 | edit, |
| 55 | /** |
| 56 | * The save function defines the way in which the different attributes should be combined |
| 57 | * into the final markup, which is then serialized by Gutenberg into post_content. |
| 58 | * |
| 59 | * The "save" property must be specified and must be a valid function. |
| 60 | * |
| 61 | * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ |
| 62 | */ |
| 63 | save: function (props) { |
| 64 | const { iframeSrc } = props.attributes |
| 65 | return ( |
| 66 | <div class="ose-wistia"> |
| 67 | <iframe src={iframeSrc} |
| 68 | allowtransparency="true" |
| 69 | frameborder="0" |
| 70 | class="wistia_embed" |
| 71 | name="wistia_embed" |
| 72 | width="600" height="330"></iframe> |
| 73 | </div> |
| 74 | ); |
| 75 | }, |
| 76 | }] |
| 77 | }); |
| 78 |