edit.js
6 years ago
editor.scss
6 years ago
index.js
6 years ago
index.php
6 years ago
style.scss
6 years ago
index.js
64 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 { youtubeIcon } 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/youtube-block', { |
| 30 | // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
| 31 | title: __( 'Youtube' ), // Block title. |
| 32 | icon: youtubeIcon, |
| 33 | category: 'embedpress', // Block category — Group blocks together based on common traits E.g. common, formatting, layout Widgets, embed. |
| 34 | keywords: [ |
| 35 | __( 'embedpress' ), |
| 36 | __( 'youtube' ), |
| 37 | ], |
| 38 | supports: { |
| 39 | align: true, |
| 40 | lightBlockWrapper: true, |
| 41 | }, |
| 42 | /** |
| 43 | * The edit function describes the structure of your block in the context of the editor. |
| 44 | * This represents what the editor will render when the block is used. |
| 45 | * |
| 46 | * The "edit" property must be a valid function. |
| 47 | * |
| 48 | * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ |
| 49 | */ |
| 50 | edit, |
| 51 | |
| 52 | /** |
| 53 | * The save function defines the way in which the different attributes should be combined |
| 54 | * into the final markup, which is then serialized by Gutenberg into post_content. |
| 55 | * |
| 56 | * The "save" property must be specified and must be a valid function. |
| 57 | * |
| 58 | * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ |
| 59 | */ |
| 60 | save: () => { |
| 61 | return null |
| 62 | } |
| 63 | } ); |
| 64 |