diff --git a/packages/block-library/src/list-item/hooks/index.js b/packages/block-library/src/list-item/hooks/index.js index 1687adbe740d0a..6220f92851a327 100644 --- a/packages/block-library/src/list-item/hooks/index.js +++ b/packages/block-library/src/list-item/hooks/index.js @@ -2,5 +2,4 @@ export { default as useOutdentListItem } from './use-outdent-list-item'; export { default as useIndentListItem } from './use-indent-list-item'; export { default as useEnter } from './use-enter'; export { default as useSpace } from './use-space'; -export { default as useSplit } from './use-split'; export { default as useMerge } from './use-merge'; diff --git a/packages/block-library/src/list-item/hooks/use-split.js b/packages/block-library/src/list-item/hooks/use-split.js deleted file mode 100644 index 51ede7de45c453..00000000000000 --- a/packages/block-library/src/list-item/hooks/use-split.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * WordPress dependencies - */ -import { useCallback, useRef } from '@wordpress/element'; -import { useSelect } from '@wordpress/data'; -import { store as blockEditorStore } from '@wordpress/block-editor'; -import { cloneBlock, createBlock } from '@wordpress/blocks'; - -export default function useSplit( clientId ) { - // We can not rely on the isAfterOriginal parameter of the callback, - // because if the value after the split is empty isAfterOriginal is false - // while the value is in fact after the original. So to avoid that issue we use - // a flag where the first execution of the callback is false (it is the before value) - // and the second execution is true, it is the after value. - const isAfter = useRef( false ); - const { getBlock } = useSelect( blockEditorStore ); - return useCallback( - ( value ) => { - const block = getBlock( clientId ); - if ( isAfter.current ) { - return cloneBlock( block, { - content: value, - } ); - } - isAfter.current = true; - return createBlock( block.name, { - ...block.attributes, - content: value, - } ); - }, - [ clientId, getBlock ] - ); -}