File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
packages/block-editor/src/components Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -70,11 +70,7 @@ export function useEnter( props ) {
70
70
71
71
const { text, start, end } = _value ;
72
72
73
- if ( event . shiftKey ) {
74
- if ( ! disableLineBreaks ) {
75
- onChange ( insert ( _value , '\n' ) ) ;
76
- }
77
- } else if ( canSplit ) {
73
+ if ( canSplit ) {
78
74
splitValue ( {
79
75
value : _value ,
80
76
onReplace,
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ export default function useInput() {
26
26
__unstableIsSelectionMergeable,
27
27
hasMultiSelection,
28
28
getBlockName,
29
+ canInsertBlockType,
30
+ getBlockRootClientId,
29
31
} = useSelect ( blockEditorStore ) ;
30
32
const {
31
33
replaceBlocks,
@@ -57,18 +59,28 @@ export default function useInput() {
57
59
}
58
60
59
61
const clientId = getSelectedBlockClientId ( ) ;
62
+ const blockName = getBlockName ( clientId ) ;
63
+
60
64
if (
61
65
! hasBlockSupport (
62
- getBlockName ( clientId ) ,
66
+ blockName ,
63
67
'__experimentalOnEnter' ,
64
68
false
65
69
)
66
70
) {
67
71
return ;
68
72
}
69
73
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
+ }
72
84
}
73
85
return ;
74
86
}
You can’t perform that action at this time.
0 commit comments