tiptap/packages/core/src/commands/insertText.ts

16 lines
345 B
TypeScript
Raw Normal View History

2019-12-08 07:16:44 +08:00
import { Editor } from '../Editor'
2019-12-15 06:54:20 +08:00
declare module '../Editor' {
2019-12-08 07:16:44 +08:00
interface Editor {
2019-12-15 06:54:20 +08:00
insertText(value: string): Editor,
2019-12-08 07:16:44 +08:00
}
}
2020-03-05 04:27:22 +08:00
export default function insertText(next: Function, editor: Editor, value: string): void {
const { view, state } = editor
2019-12-15 06:54:20 +08:00
const transaction = state.tr.insertText(value)
view.dispatch(transaction)
2019-12-08 07:16:44 +08:00
next()
}