File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
packages/core/src/extensions/KeyboardShortcuts Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -434,7 +434,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
434434 ] ) ;
435435
436436 const handleEnter = ( withShift = false ) => {
437- return this . editor . commands . first ( ( { commands } ) => [
437+ return this . editor . commands . first ( ( { commands, tr } ) => [
438438 // Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
439439 // of the block.
440440 ( ) =>
@@ -486,9 +486,21 @@ export const KeyboardShortcutsExtension = Extension.create<{
486486 // both enter and shift+enter.
487487 blockHardBreakShortcut === "enter"
488488 ) {
489- return commands . insertContent ( {
490- type : "hardBreak" ,
491- } ) ;
489+ const marks =
490+ tr . storedMarks ||
491+ tr . selection . $head
492+ . marks ( )
493+ . filter ( ( m ) =>
494+ this . editor . extensionManager . splittableMarks . includes (
495+ m . type . name ,
496+ ) ,
497+ ) ;
498+
499+ tr . insert (
500+ tr . selection . head ,
501+ tr . doc . type . schema . nodes . hardBreak . create ( ) ,
502+ ) . ensureMarks ( marks ) ;
503+ return true ;
492504 }
493505
494506 return false ;
You can’t perform that action at this time.
0 commit comments