@@ -260,9 +260,9 @@ export function exitCode(state, dispatch) {
260
260
// If a block node is selected, create an empty paragraph before (if
261
261
// it is its parent's first child) or after it.
262
262
export function createParagraphNear ( state , dispatch ) {
263
- let { $from, $to} = state . selection
264
- if ( $from . parent . inlineContent || $to . parent . inlineContent ) return false
265
- let type = defaultBlockAt ( $from . parent . contentMatchAt ( $to . indexAfter ( ) ) )
263
+ let sel = state . selection , { $from, $to} = sel
264
+ if ( ! ( sel instanceof NodeSelection ) || $from . parent . inlineContent ) return false
265
+ let type = defaultBlockAt ( $to . parent . contentMatchAt ( $to . indexAfter ( ) ) )
266
266
if ( ! type || ! type . isTextblock ) return false
267
267
if ( dispatch ) {
268
268
let side = ( ! $from . parentOffset && $to . index ( ) < $to . parent . childCount ? $from : $to ) . pos
@@ -308,7 +308,7 @@ export function splitBlock(state, dispatch) {
308
308
if ( dispatch ) {
309
309
let atEnd = $to . parentOffset == $to . parent . content . size
310
310
let tr = state . tr
311
- if ( state . selection instanceof TextSelection ) tr . deleteSelection ( )
311
+ if ( state . selection instanceof TextSelection || state . selection instanceof AllSelection ) tr . deleteSelection ( )
312
312
let deflt = $from . depth == 0 ? null : defaultBlockAt ( $from . node ( - 1 ) . contentMatchAt ( $from . indexAfter ( - 1 ) ) )
313
313
let types = atEnd && deflt ? [ { type : deflt } ] : null
314
314
let can = canSplit ( tr . doc , tr . mapping . map ( $from . pos ) , 1 , types )
0 commit comments