From 8814cef075e446ba17fd691ad821a2e35525e97d Mon Sep 17 00:00:00 2001 From: Adam Turner Date: Wed, 17 Jul 2024 09:19:45 -0700 Subject: [PATCH] Fix #150 replace onSplit with block.json support key --- src/blocks/button/block.json | 20 +++++++++++++++----- src/blocks/button/edit.js | 7 ------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/blocks/button/block.json b/src/blocks/button/block.json index c484240..ab17b98 100644 --- a/src/blocks/button/block.json +++ b/src/blocks/button/block.json @@ -1,5 +1,6 @@ { - "apiVersion": 2, + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, "name": "hrswp/button", "title": "Button", "category": "design", @@ -55,14 +56,23 @@ }, "supports": { "anchor": true, + "splitting": true, "align": true, "alignWide": false, - "color": false, - "typography": false, + "color": { + "gradients": false, + "background": false, + "text": false + }, + "typography": { + "fontSize": false, + "lineHeight": false, + "textAlign": false + }, "reusable": false, - "spacing": false, + "spacing": {}, "__experimentalBorder": false, - "__experimentalSelector": ".wp-block-button__link" + "__experimentalSelector": ".wp-block-button .wp-block-button__link" }, "styles": [ { "name": "fill", "label": "Fill", "isDefault": true }, diff --git a/src/blocks/button/edit.js b/src/blocks/button/edit.js index 9a8484e..ca2b220 100644 --- a/src/blocks/button/edit.js +++ b/src/blocks/button/edit.js @@ -27,7 +27,6 @@ import { __experimentalLinkControl as LinkControl, } from '@wordpress/block-editor'; import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes'; -import { createBlock } from '@wordpress/blocks'; /** * Internal dependencies @@ -183,12 +182,6 @@ function ButtonEdit( props ) { ...colorProps.style, ...spacingProps.style, } } - onSplit={ ( value ) => - createBlock( 'hrswp/button', { - ...attributes, - text: value, - } ) - } onReplace={ onReplace } onMerge={ mergeBlocks } identifier="text"