Skip to content

Commit e5a4b4c

Browse files
committed
feat: line break on Shift-Enter
1 parent 85575e1 commit e5a4b4c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/defaultPlugins.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NodeType, Schema } from 'prosemirror-model';
22
import { Plugin } from 'prosemirror-state';
33
import { keymap } from 'prosemirror-keymap';
4-
import { toggleMark, baseKeymap } from 'prosemirror-commands';
4+
import { toggleMark, baseKeymap, chainCommands, exitCode } from 'prosemirror-commands';
55
import { splitListItem, liftListItem, sinkListItem } from 'prosemirror-schema-list';
66
import { history, undo, redo } from 'prosemirror-history';
77
import {
@@ -103,6 +103,12 @@ const getKeyboardShortcuts = (schema: Schema, options: ShortcutOptions) => {
103103
}),
104104
keymap({
105105
Enter: splitListItem(schema.nodes.list_item),
106+
'Shift-Enter': chainCommands(exitCode, (state, dispatch) => {
107+
const tr = state.tr;
108+
const br = schema.nodes.hard_break;
109+
dispatch(tr.replaceSelectionWith(br.create()).scrollIntoView());
110+
return true;
111+
}),
106112
'Mod-[': liftListItem(schema.nodes.list_item),
107113
'Mod-]': sinkListItem(schema.nodes.list_item),
108114
Tab: sinkListItem(schema.nodes.list_item)

0 commit comments

Comments
 (0)