From 1aca4b55166bd722d47aa2396feb2d29754a5046 Mon Sep 17 00:00:00 2001 From: Ella Date: Thu, 5 Dec 2024 15:06:28 +0100 Subject: [PATCH] Remove onSplitAtEnd --- .../src/components/rich-text/event-listeners/enter.js | 1 + packages/block-library/src/post-title/edit.js | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/event-listeners/enter.js b/packages/block-editor/src/components/rich-text/event-listeners/enter.js index f2308deddd676..75a265f8da9b2 100644 --- a/packages/block-editor/src/components/rich-text/event-listeners/enter.js +++ b/packages/block-editor/src/components/rich-text/event-listeners/enter.js @@ -29,6 +29,7 @@ export default ( props ) => ( element ) => { onChange( insert( value, '\n' ) ); } } else if ( onSplitAtEnd && start === end && end === text.length ) { + // This is no longer used anywhere. Deprecate? event.preventDefault(); onSplitAtEnd(); } else if ( onReplace && onSplit ) { diff --git a/packages/block-library/src/post-title/edit.js b/packages/block-library/src/post-title/edit.js index fdfb8e7c2c6cd..a7137be35d442 100644 --- a/packages/block-library/src/post-title/edit.js +++ b/packages/block-library/src/post-title/edit.js @@ -17,7 +17,6 @@ import { } from '@wordpress/block-editor'; import { ToggleControl, TextControl, PanelBody } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; import { useEntityProp, store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; @@ -25,7 +24,6 @@ export default function PostTitleEdit( { attributes: { level, levelOptions, textAlign, isLink, rel, linkTarget }, setAttributes, context: { postType, postId, queryId }, - insertBlocksAfter, } ) { const TagName = level === 0 ? 'p' : `h${ level }`; const isDescendentOfQueryLoop = Number.isFinite( queryId ); @@ -57,9 +55,6 @@ export default function PostTitleEdit( { postId ); const [ link ] = useEntityProp( 'postType', postType, 'link', postId ); - const onSplitAtEnd = () => { - insertBlocksAfter( createBlock( getDefaultBlockName() ) ); - }; const blockProps = useBlockProps( { className: clsx( { [ `has-text-align-${ textAlign }` ]: textAlign, @@ -77,7 +72,7 @@ export default function PostTitleEdit( { value={ rawTitle } onChange={ setTitle } __experimentalVersion={ 2 } - __unstableOnSplitAtEnd={ onSplitAtEnd } + disableLineBreaks { ...blockProps } /> ) : ( @@ -100,7 +95,7 @@ export default function PostTitleEdit( { value={ rawTitle } onChange={ setTitle } __experimentalVersion={ 2 } - __unstableOnSplitAtEnd={ onSplitAtEnd } + disableLineBreaks /> ) : (