Personal no-bs blogging platform.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061import { schema } from "prosemirror-markdown";import { keymap } from "prosemirror-keymap";import { undo, redo } from "prosemirror-history";import { baseKeymap, toggleMark, setBlockType, wrapIn, exitCode } from "prosemirror-commands";import { splitListItem, sinkListItem, liftListItem, } from "prosemirror-schema-list";import { chainCommands, newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock } from "prosemirror-commands"
const { strong, em } = schema.marks;const { heading, blockquote } = schema.nodes;
export const tabKeymap = keymap({ Tab: (state, dispatch, view) => { dispatch!( state.tr.insertText("\t") ) return true }});
export default keymap({ ...baseKeymap,
Enter: chainCommands( splitListItem(schema.nodes.list_item!), newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock ), "Shift-Enter": chainCommands( exitCode, (state, dispatch) => { const { from, to } = state.selection;
if (dispatch) dispatch( state.tr.replaceRangeWith( from, to, schema.nodes.hard_break.create() ).scrollIntoView() ) return true; } ),
Tab: sinkListItem(schema.nodes.list_item!), "Shift-Tab": liftListItem(schema.nodes.list_item!),
"Mod-z": undo, "Mod-y": redo, "Mod-Shift-z": redo,
"Mod-b": toggleMark(strong),
"Mod-i": toggleMark(em),
"Shift-Ctrl-1": setBlockType(heading, { level: 1 }), "Shift-Ctrl-2": setBlockType(heading, { level: 2 }),
"Ctrl->": wrapIn(blockquote),});