From 7f8771ea6cbd5856da49e87342c5ba36b32a800b Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Tue, 28 May 2024 13:13:55 +0200 Subject: [PATCH] Pass context to in use-input --- .../block-editor/src/components/writing-flow/use-input.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/writing-flow/use-input.js b/packages/block-editor/src/components/writing-flow/use-input.js index 0f10cc9c2d1c75..234cf125778700 100644 --- a/packages/block-editor/src/components/writing-flow/use-input.js +++ b/packages/block-editor/src/components/writing-flow/use-input.js @@ -3,6 +3,7 @@ */ import { useSelect, useDispatch } from '@wordpress/data'; import { useRefEffect } from '@wordpress/compose'; +import { useContext } from '@wordpress/element'; import { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes'; import { createBlock, @@ -16,6 +17,7 @@ import { * Internal dependencies */ import { store as blockEditorStore } from '../../store'; +import BlockContext from '../block-context'; /** * Handles input for selections across blocks. @@ -42,6 +44,7 @@ export default function useInput() { __unstableExpandSelection, __unstableMarkAutomaticChange, } = useDispatch( blockEditorStore ); + const blockContext = useContext( BlockContext ); return useRefEffect( ( node ) => { function onBeforeInput( event ) { @@ -115,7 +118,7 @@ export default function useInput() { getBlockRootClientId( clientId ) ) ) { - __unstableSplitSelection(); + __unstableSplitSelection( [], blockContext ); event.preventDefault(); } } @@ -131,7 +134,7 @@ export default function useInput() { createBlock( getDefaultBlockName() ) ); } else { - __unstableSplitSelection(); + __unstableSplitSelection( [], blockContext ); } } else if ( event.keyCode === BACKSPACE ||