add basic new chaining

This commit is contained in:
Philipp Kühn
2020-09-20 23:19:27 +02:00
parent 26af779d22
commit fbdc156981
7 changed files with 159 additions and 60 deletions

View File

@@ -1,6 +1,6 @@
import { Editor } from '../Editor'
import { Command } from '../Editor'
type InsertTextCommand = (value: string) => Editor
type InsertTextCommand = (value: string) => Command
declare module '../Editor' {
interface Editor {
@@ -8,10 +8,8 @@ declare module '../Editor' {
}
}
export default (next: Function, editor: Editor) => (value: string) => {
const { view, state } = editor
const transaction = state.tr.insertText(value)
export const insertText: InsertTextCommand = value => ({ tr }) => {
tr.insertText(value)
view.dispatch(transaction)
next()
return true
}