Skip to content

Commit

Permalink
minimal block no build
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmaguitar committed Oct 8, 2023
1 parent 4f42c7a commit 29f0865
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
1 change: 1 addition & 0 deletions plugins/minimal-block-no-build-e621a6/block.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array( 'dependencies' => array('wp-blocks'),'version' => '0.1');
14 changes: 5 additions & 9 deletions plugins/minimal-block-no-build-e621a6/block.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
(function (blocks, element, blockEditor) {
(function (blocks, element) {
var el = element.createElement;
var useBlockProps = blockEditor.useBlockProps;

blocks.registerBlockType("gutenberg-examples/minimal-block-e621a6", {
title: 'minimal-block-e621a6',
icon: 'smiley', // Icon used for the block from Dashicons
category: 'common', // The category this block will be listed under
blocks.registerBlockType("gutenberg-examples/minimal-block-no-build-e621a6", {
edit: function () {
return el("p", useBlockProps() , "Hello World - Block Editor");
return el("p", {} , "Hello World - Block Editor");
},
save: function () {
return el("p", useBlockProps() , "Hello World - Frontend");
return el("p", {} , "Hello World - Frontend");
},
});
})(window.wp.blocks, window.wp.element, window.wp.blockEditor);
})(window.wp.blocks, window.wp.element);
9 changes: 3 additions & 6 deletions plugins/minimal-block-no-build-e621a6/block.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"$schema": "https://json.schemastore.org/block.json",
"apiVersion": 2,
"title": "Minimal Gutenberg Block e621a6",
"name": "gutenberg-examples/minimal-block-e621a6",
"apiVersion": 3,
"title": "Minimal Block No Build e621a6",
"name": "gutenberg-examples/minimal-block-no-build-e621a6",
"category": "media",
"icon": "smiley",
"textdomain": "gutenberg-examples",
"example": {},
"editorScript": "file:./block.js"
}
6 changes: 1 addition & 5 deletions plugins/minimal-block-no-build-e621a6/index.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<?php
/*
* Plugin Name: Minimal Gutenberg Block e621a6
* Plugin Name: Gutenberg Examples - Minimal Block No Build e621a6
* Description: This is a plugin demonstrating how to register a minimal block for the Gutenberg editor.
* Version: 1.0
* Author: Gutenberg Examples
*/

defined( 'ABSPATH' ) || exit;

function register_block() {
register_block_type( __DIR__ );
}

add_action( 'init', 'register_block' );

?>

0 comments on commit 29f0865

Please sign in to comment.