Skip to content

Commit

Permalink
feat: line break on Shift-Enter
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Mar 17, 2021
1 parent 85575e1 commit e5a4b4c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/defaultPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NodeType, Schema } from 'prosemirror-model';
import { Plugin } from 'prosemirror-state';
import { keymap } from 'prosemirror-keymap';
import { toggleMark, baseKeymap } from 'prosemirror-commands';
import { toggleMark, baseKeymap, chainCommands, exitCode } from 'prosemirror-commands';
import { splitListItem, liftListItem, sinkListItem } from 'prosemirror-schema-list';
import { history, undo, redo } from 'prosemirror-history';
import {
Expand Down Expand Up @@ -103,6 +103,12 @@ const getKeyboardShortcuts = (schema: Schema, options: ShortcutOptions) => {
}),
keymap({
Enter: splitListItem(schema.nodes.list_item),
'Shift-Enter': chainCommands(exitCode, (state, dispatch) => {
const tr = state.tr;
const br = schema.nodes.hard_break;
dispatch(tr.replaceSelectionWith(br.create()).scrollIntoView());
return true;
}),
'Mod-[': liftListItem(schema.nodes.list_item),
'Mod-]': sinkListItem(schema.nodes.list_item),
Tab: sinkListItem(schema.nodes.list_item)
Expand Down

0 comments on commit e5a4b4c

Please sign in to comment.