tiptap/packages/core/src/commands/insertText.ts
2020-04-21 23:22:27 +02:00

18 lines
372 B
TypeScript

import { Editor } from '../Editor'
type InsertText = (value: string) => any
declare module '../Editor' {
interface Editor {
insertText: InsertText,
}
}
export default (next: Function, editor: Editor, value: string): InsertText => () => {
const { view, state } = editor
const transaction = state.tr.insertText(value)
view.dispatch(transaction)
next()
}