diff --git a/packages/tiptap-commands/src/commands/insertText.js b/packages/tiptap-commands/src/commands/insertText.js new file mode 100644 index 00000000..ee7d4ae7 --- /dev/null +++ b/packages/tiptap-commands/src/commands/insertText.js @@ -0,0 +1,10 @@ +export default function (text = '') { + return (state, dispatch) => { + const { $from } = state.selection + const { pos } = $from.pos + + dispatch(state.tr.insertText(text, pos)) + + return true + } +} diff --git a/packages/tiptap-commands/src/index.js b/packages/tiptap-commands/src/index.js index e2d9a318..0b83c23f 100644 --- a/packages/tiptap-commands/src/index.js +++ b/packages/tiptap-commands/src/index.js @@ -38,6 +38,7 @@ import { textblockTypeInputRule, } from 'prosemirror-inputrules' +import insertText from './commands/insertText' import markInputRule from './commands/markInputRule' import removeMark from './commands/removeMark' import replaceText from './commands/replaceText' @@ -86,6 +87,7 @@ export { textblockTypeInputRule, // custom + insertText, markInputRule, removeMark, replaceText,