Skip to content

Commit 193ba19

Browse files
committed
Fix for locked template
1 parent 59a0581 commit 193ba19

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/block-editor/src/components/rich-text/use-enter.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ export function useEnter( props ) {
7070

7171
const { text, start, end } = _value;
7272

73-
if ( event.shiftKey ) {
74-
if ( ! disableLineBreaks ) {
75-
onChange( insert( _value, '\n' ) );
76-
}
77-
} else if ( canSplit ) {
73+
if ( canSplit ) {
7874
splitValue( {
7975
value: _value,
8076
onReplace,

packages/block-editor/src/components/writing-flow/use-input.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export default function useInput() {
2626
__unstableIsSelectionMergeable,
2727
hasMultiSelection,
2828
getBlockName,
29+
canInsertBlockType,
30+
getBlockRootClientId,
2931
} = useSelect( blockEditorStore );
3032
const {
3133
replaceBlocks,
@@ -57,18 +59,28 @@ export default function useInput() {
5759
}
5860

5961
const clientId = getSelectedBlockClientId();
62+
const blockName = getBlockName( clientId );
63+
6064
if (
6165
! hasBlockSupport(
62-
getBlockName( clientId ),
66+
blockName,
6367
'__experimentalOnEnter',
6468
false
6569
)
6670
) {
6771
return;
6872
}
6973

70-
event.preventDefault();
71-
__unstableSplitSelection();
74+
// Ensure template is not locked.
75+
if (
76+
canInsertBlockType(
77+
blockName,
78+
getBlockRootClientId( clientId )
79+
)
80+
) {
81+
__unstableSplitSelection();
82+
event.preventDefault();
83+
}
7284
}
7385
return;
7486
}

0 commit comments

Comments
 (0)