PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / trunk
Adminify – White Label, Admin Menu Editor, Login Customizer vtrunk
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Libs / adminify-framework / assets / js / gutenberg.js

gutenberg.js in Adminify – White Label, Admin Menu Editor, Login Customizer trunk, at Libs/adminify-framework/assets/js/gutenberg.js

80 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 *
3 * -----------------------------------------------------------
4 *
5 * Adminify Framework Gutenberg Block
6 * A Simple and Lightweight WordPress Option Framework
7 *
8 * -----------------------------------------------------------
9 *
10 */
11 ( function( blocks, blockEditor, element, components ) {
12
13 if ( !window.adminify_gutenberg_blocks ) { return; }
14
15 Object.values(window.adminify_gutenberg_blocks).forEach( function( block ) {
16
17 var registerBlockType = blocks.registerBlockType;
18 var PlainText = blockEditor.PlainText;
19 var createElement = element.createElement;
20 var RawHTML = element.RawHTML;
21 var Button = components.Button;
22
23 registerBlockType(block.name, {
24 title: block.gutenberg.title,
25 description: block.gutenberg.description,
26 icon: block.gutenberg.icon || 'screenoptions',
27 category: block.gutenberg.category || 'widgets',
28 keywords: block.gutenberg.keywords,
29 supports: {
30 html: false,
31 className: false,
32 customClassName: false,
33 },
34 attributes: {
35 shortcode: {
36 string: 'string',
37 source: 'text',
38 }
39 },
40 edit: function (props) {
41 return (
42 createElement('div', {className: 'adminify-shortcode-block'},
43
44 createElement(Button, {
45 'data-modal-id': block.modal_id,
46 'data-gutenberg-id': block.name,
47 className: 'is-secondary adminify-shortcode-button',
48 onClick: function () {
49 window.adminify_gutenberg_props = props;
50 },
51 }, block.button_title ),
52
53 createElement(PlainText, {
54 placeholder: block.gutenberg.placeholder,
55 className: 'input-control blocks-shortcode__textarea',
56 onChange: function (value) {
57 props.setAttributes({
58 shortcode: value
59 });
60 },
61 value: props.attributes.shortcode
62 })
63
64 )
65 );
66 },
67 save: function (props) {
68 return createElement(RawHTML, {}, props.attributes.shortcode);
69 }
70 });
71
72 });
73
74 })(
75 window.wp.blocks,
76 window.wp.blockEditor,
77 window.wp.element,
78 window.wp.components
79 );
80