add basic new chaining
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user