add Commands interface

This commit is contained in:
Philipp Kühn
2021-02-10 09:59:35 +01:00
parent 0ed368e9f4
commit 290ff76e37
100 changed files with 695 additions and 487 deletions

View File

@@ -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,
}
}