Skip to content

Commit

Permalink
move shift
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Dec 18, 2024
1 parent a3b2fdb commit df3423b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ export default ( props ) => ( element ) => {
value,
onSplitAtDoubleLineEnd,
registry,
onSplitAtEnd,
} = props.current;
const { text, start, end } = value;

if (
if ( event.shiftKey ) {
if ( ! disableLineBreaks ) {
event.preventDefault();
onChange( insert( value, '\n' ) );
}
} else if ( onSplitAtEnd && start === end && end === text.length ) {
event.preventDefault();
onSplitAtEnd();
} else if ( onReplace && onSplit ) {
event.__deprecatedOnSplit = true;
} else if (
! supportsSplitting &&
! disableLineBreaks &&
! event.defaultPrevented
Expand All @@ -47,10 +58,6 @@ export default ( props ) => ( element ) => {
onChange( insert( value, '\n' ) );
}
}

if ( onReplace && onSplit ) {
event.__deprecatedOnSplit = true;
}
}

function onDefaultKeyDown( event ) {
Expand All @@ -68,20 +75,9 @@ export default ( props ) => ( element ) => {
return;
}

const { value, onChange, disableLineBreaks, onSplitAtEnd } =
props.current;

// On ENTER, we ALWAYS want to prevent the default browser behaviour
// at this last interception point.
event.preventDefault();

const { text, start, end } = value;

if ( event.shiftKey ) {
if ( ! disableLineBreaks ) {
onChange( insert( value, '\n' ) );
}
} else if ( onSplitAtEnd && start === end && end === text.length ) {
onSplitAtEnd();
}
}

const { defaultView } = element.ownerDocument;
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/plugins/post-type-locking.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test.describe( 'Post-type locking', () => {
.click();

await page.keyboard.type( 'First line' );
await page.keyboard.press( 'Enter' );
await pageUtils.pressKeys( 'shift+Enter' );
await page.keyboard.type( 'Second line' );
await pageUtils.pressKeys( 'shift+Enter' );
await page.keyboard.type( 'Third line' );
Expand Down

0 comments on commit df3423b

Please sign in to comment.