@@ -14,7 +14,6 @@ import classnames from 'classnames';
1414 */
1515import { __ } from '@wordpress/i18n' ;
1616import { closeSmall } from '@wordpress/icons' ;
17- import { createBlock } from '@wordpress/blocks' ;
1817import { isBlobURL } from '@wordpress/blob' ;
1918import { useEffect } from '@wordpress/element' ;
2019import {
@@ -58,7 +57,7 @@ const Edit = ( props ) => {
5857 return isSelected || rootClientId === selectedRootClientId ;
5958 } ) ;
6059
61- const { updateBlockAttributes, insertBlock , removeBlocks } = useDispatch ( 'core/block-editor' ) ;
60+ const { updateBlockAttributes } = useDispatch ( 'core/block-editor' ) ;
6261
6362 const updateInnerAttributes = ( blockName , newAttributes ) => {
6463 innerItems . forEach ( ( item ) => {
@@ -71,30 +70,6 @@ const Edit = ( props ) => {
7170 } ) ;
7271 } ;
7372
74- const manageInnerBlock = ( blockName , blockAttributes , show = true ) => {
75- const migrateButton = innerItems . filter ( ( item ) => item . name === 'core/button' ) ;
76-
77- // Migrate core/button to core/buttons block
78- if ( ! ! migrateButton . length ) {
79- removeBlocks ( migrateButton . map ( ( item ) => item . clientId ) , false ) ;
80- const newBlock = createBlock ( blockName , blockAttributes , migrateButton ) ;
81- insertBlock ( newBlock , innerItems . length , clientId , false ) ;
82- return ;
83- }
84-
85- const targetBlock = innerItems . filter ( ( item ) => item . name === blockName ) ;
86-
87- if ( ! targetBlock . length && show ) {
88- const newButton = createBlock ( 'core/button' , { } ) ;
89- const newBlock = createBlock ( blockName , blockAttributes , [ newButton ] ) ;
90- insertBlock ( newBlock , innerItems . length , clientId , false ) ;
91- }
92-
93- if ( targetBlock . length && ! show ) {
94- removeBlocks ( targetBlock . map ( ( item ) => item . clientId ) , false ) ;
95- }
96- } ;
97-
9873 /* istanbul ignore next */
9974 useEffect ( ( ) => {
10075 updateInnerAttributes ( 'core/heading' , { level : attributes . headingLevel } ) ;
@@ -105,15 +80,6 @@ const Edit = ( props ) => {
10580 updateInnerAttributes ( 'core/buttons' , { contentJustification : attributes . alignment } ) ;
10681 } , [ attributes . alignment ] ) ;
10782
108- /* istanbul ignore next */
109- useEffect ( ( ) => {
110- manageInnerBlock ( 'core/buttons' , { contentJustification : attributes . alignment } , attributes . showCta ) ;
111- } , [ attributes . showCta ] ) ;
112-
113- const toggleCta = ( ) => {
114- setAttributes ( { showCta : ! showCta } ) ;
115- } ;
116-
11783 const replaceImage = ( file ) => {
11884 setAttributes ( { imageAlt : file . alt , imageId : file . id , imageUrl : file . url } ) ;
11985 } ;
@@ -197,7 +163,6 @@ const Edit = ( props ) => {
197163 linkDestination,
198164 linkTarget,
199165 rel,
200- showCta,
201166 alignment,
202167 } = attributes ;
203168
@@ -255,7 +220,6 @@ const Edit = ( props ) => {
255220 </ BlockControls >
256221 < InspectorControls
257222 attributes = { attributes }
258- onToggleCta = { toggleCta }
259223 setAttributes = { setAttributes }
260224 />
261225 < div className = { className } >
0 commit comments