Skip to content

Commit

Permalink
Verse: Disable line breaks (#52783)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Jul 21, 2023
1 parent f2a685f commit 50722cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/block-library/src/verse/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import {
AlignmentToolbar,
useBlockProps,
} from '@wordpress/block-editor';
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';

export default function VerseEdit( {
attributes,
setAttributes,
mergeBlocks,
onRemove,
style,
insertBlocksAfter,
} ) {
const { textAlign, content } = attributes;
const blockProps = useBlockProps( {
Expand Down Expand Up @@ -56,6 +58,9 @@ export default function VerseEdit( {
textAlign={ textAlign }
{ ...blockProps }
__unstablePastePlainText
__unstableOnSplitAtEnd={ () =>
insertBlocksAfter( createBlock( getDefaultBlockName() ) )
}
/>
</>
);
Expand Down
6 changes: 4 additions & 2 deletions packages/block-library/src/verse/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ describe( 'Verse block', () => {
const verseTextInput = await screen.findByPlaceholderText(
'Write verse…'
);
typeInRichText( verseTextInput, 'A great statement.' );
typeInRichText( verseTextInput, 'A great statement.Again', {
finalSelectionStart: 18,
finalSelectionEnd: 18,
} );
fireEvent( verseTextInput, 'onKeyDown', {
nativeEvent: {},
preventDefault() {},
keyCode: ENTER,
} );
typeInRichText( verseTextInput, 'Again' );

// Assert
expect( getEditorHtml() ).toMatchInlineSnapshot( `
Expand Down

0 comments on commit 50722cc

Please sign in to comment.