diff --git a/blocks/block-w/.gitkeep b/blocks/block-w/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/blocks/block-w/block.json b/blocks/block-w/block.json new file mode 100644 index 0000000..e205ae9 --- /dev/null +++ b/blocks/block-w/block.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "title": "Block W", + "name": "xywz-blocks/block-w", + "description": "Block X", + "version": "1.0.0-beta", + "category": "xywz-blocks", + "icon": "feedback", + "supports": { + "html": true + }, + "attributes": { + "exampleAttribute": { + "type": "string" + } + }, + "keywords": ["basic", "model"], + "editorScript": "file:./build/index.js", + "editorStyle": "file:./src/style.css" +} diff --git a/blocks/block-w/build/index.asset.php b/blocks/block-w/build/index.asset.php new file mode 100644 index 0000000..0ffe47c --- /dev/null +++ b/blocks/block-w/build/index.asset.php @@ -0,0 +1 @@ + array('react', 'wp-block-editor', 'wp-blocks', 'wp-element', 'wp-i18n'), 'version' => '0b7ff61aac7e64581ba9'); diff --git a/blocks/block-w/build/index.js b/blocks/block-w/build/index.js new file mode 100644 index 0000000..9ea2b18 --- /dev/null +++ b/blocks/block-w/build/index.js @@ -0,0 +1 @@ +(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,l=(window.React,window.wp.i18n),i=window.wp.blockEditor,r=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"title":"Block W","name":"xywz-blocks/block-w","description":"Block X","version":"1.0.0-beta","category":"xywz-blocks","icon":"feedback","supports":{"html":true},"attributes":{"exampleAttribute":{"type":"string"}},"keywords":["basic","model"],"editorScript":"file:./build/index.js","editorStyle":"file:./src/style.css"}');(0,e.registerBlockType)(r,{edit:function(e){return(0,t.createElement)("div",{...(0,i.useBlockProps)()},(0,t.createElement)("div",null,(0,t.createElement)("h4",null,"Block W"),(0,t.createElement)("p",null,"Insert the attribute value below"),(0,t.createElement)("input",{type:"text",value:e.attributes.exampleAttribute,onChange:function(t){e.setAttributes({exampleAttribute:t.target.value})},placeholder:"Attribute value that will be displayed in the frontend"})))},save:function(e){return(0,t.createElement)("p",{...i.useBlockProps.save()},(0,l.__)((0,t.createElement)("div",null,e.attributes.exampleAttribute)))}})})(); \ No newline at end of file diff --git a/blocks/block-w/src/edit.js b/blocks/block-w/src/edit.js new file mode 100644 index 0000000..55eb364 --- /dev/null +++ b/blocks/block-w/src/edit.js @@ -0,0 +1,26 @@ +import React from "react"; +import { __ } from "@wordpress/i18n"; +import { useBlockProps } from "@wordpress/block-editor"; + +function Edit(props) { + function setExampleAttribute(e) { + props.setAttributes({ exampleAttribute: e.target.value }); + } + + return ( +
Insert the attribute value below
+ ++ {__(