add Commands interface
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import { Command } from '../types'
|
||||
import { AnyObject, Command, Commands } from '../types'
|
||||
|
||||
/**
|
||||
* Replace the whole document with new content.
|
||||
*/
|
||||
export const setContent = (content: string, emitUpdate: Boolean = false, parseOptions = {}): Command => ({ tr, editor, dispatch }) => {
|
||||
export const setContent: Commands['setContent'] = (content, emitUpdate = false, parseOptions = {}) => ({ tr, editor, dispatch }) => {
|
||||
const { createDocument } = editor
|
||||
const { doc } = tr
|
||||
const document = createDocument(content, parseOptions)
|
||||
@@ -18,3 +18,9 @@ export const setContent = (content: string, emitUpdate: Boolean = false, parseOp
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
setContent: (content: string, emitUpdate?: Boolean, parseOptions?: AnyObject) => Command,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user