diff --git a/src/block/button/edit.js b/src/block/button/edit.js index 8fc08c1c0..56127cdb5 100644 --- a/src/block/button/edit.js +++ b/src/block/button/edit.js @@ -31,7 +31,6 @@ import { */ import { __ } from '@wordpress/i18n' import { compose } from '@wordpress/compose' -import { createBlock } from '@wordpress/blocks' import { AlignmentToolbar, BlockControls } from '@wordpress/block-editor' import { memo } from '@wordpress/element' @@ -113,12 +112,6 @@ const Edit = props => { placeholder={ __( 'Button text', i18n ) } withoutInteractiveFormatting={ true } onReplace={ onReplace } - onSplit={ value => createBlock( - 'stackable/button', - { - ...props.attributes, text: value, - } - ) } /> diff --git a/src/block/button/index.js b/src/block/button/index.js index 11609bddf..051a55e92 100644 --- a/src/block/button/index.js +++ b/src/block/button/index.js @@ -28,6 +28,7 @@ export const settings = { attributes: schema, supports: { anchor: true, + splitting: true, }, transforms, diff --git a/src/block/icon-list-item/edit.js b/src/block/icon-list-item/edit.js index 4e464e42f..f7dfe616e 100644 --- a/src/block/icon-list-item/edit.js +++ b/src/block/icon-list-item/edit.js @@ -5,7 +5,6 @@ import blockStyles from './style' import { getUseSvgDef } from '../icon-list/util' import { convertToListItems, - useOnSplit, useOnPaste, useEnter, } from './util' @@ -106,7 +105,6 @@ const Edit = props => { ] ) const useEnterRef = useEnter( text, clientId ) - const onSplit = useOnSplit( clientId, attributes ) const onPaste = useOnPaste( clientId, parentBlock?.clientId, attributes, setAttributes ) const onMerge = forward => { @@ -169,7 +167,6 @@ const Edit = props => { ref={ useEnterRef } tagName="span" className={ textClassNames } - onSplit={ onSplit } onMerge={ onMerge } onPaste={ onPaste } onReplace={ onReplace diff --git a/src/block/icon-list-item/index.js b/src/block/icon-list-item/index.js index 496734572..b30d17468 100644 --- a/src/block/icon-list-item/index.js +++ b/src/block/icon-list-item/index.js @@ -22,6 +22,7 @@ export const settings = { __experimentalSelector: 'li', reusable: false, stkSaveBlockStyle: false, + splitting: true, }, example, edit, diff --git a/src/block/icon-list-item/util.js b/src/block/icon-list-item/util.js index ede130acc..f869f43dd 100644 --- a/src/block/icon-list-item/util.js +++ b/src/block/icon-list-item/util.js @@ -47,33 +47,6 @@ export function convertToListItems( blocks ) { return listItems } -export const useOnSplit = ( clientId, attributes ) => { - const { getBlock } = useSelect( 'core/block-editor' ) - - return useCallback( ( value, isOriginal ) => { - const block = getBlock( clientId ) - let newBlock - - if ( isOriginal || value ) { - newBlock = cloneBlock( block, { - ...attributes, - text: value, - } ) - } else { - newBlock = cloneBlock( block, { - ...attributes, - text: '', - } ) - } - - if ( isOriginal ) { - newBlock.clientId = clientId - } - - return newBlock - }, [ clientId, attributes ] ) -} - export const useEnter = ( text, clientId ) => { const { removeBlocks, selectionChange, insertBlocks, diff --git a/src/block/subtitle/edit.js b/src/block/subtitle/edit.js index 03b5e5769..cd3e88785 100644 --- a/src/block/subtitle/edit.js +++ b/src/block/subtitle/edit.js @@ -35,7 +35,6 @@ import { createBlockCompleter } from '~stackable/util' * WordPress dependencies */ import { compose } from '@wordpress/compose' -import { createBlock } from '@wordpress/blocks' import { addFilter } from '@wordpress/hooks' import { sprintf, __ } from '@wordpress/i18n' import { memo } from '@wordpress/element' @@ -106,25 +105,6 @@ const Edit = props => { onMerge={ mergeBlocks } onRemove={ onRemove } onReplace={ onReplace } - onSplit={ ( value, isOriginal ) => { - // @see https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/paragraph/edit.js - let newAttributes - - if ( isOriginal || value ) { - newAttributes = { - ...props.attributes, - text: value, - } - } - - const block = createBlock( 'stackable/subtitle', newAttributes ) - - if ( isOriginal ) { - block.clientId = props.clientId - } - - return block - } } /> { props.isHovered && } diff --git a/src/block/subtitle/index.js b/src/block/subtitle/index.js index c47979b7a..77575ad27 100644 --- a/src/block/subtitle/index.js +++ b/src/block/subtitle/index.js @@ -24,6 +24,7 @@ export const settings = { supports: { anchor: true, spacing: true, + splitting: true, }, example, deprecated,