improve type handling for commands

This commit is contained in:
Philipp Kühn
2020-04-21 23:22:27 +02:00
parent 3deae61a15
commit 91d4aa7e39
13 changed files with 45 additions and 35 deletions

View File

@@ -1,19 +1,19 @@
import { Editor } from '../Editor'
import { TextSelection } from 'prosemirror-state'
type SetContent = (
content: string,
emitUpdate?: Boolean,
parseOptions?: any,
) => any
declare module '../Editor' {
interface Editor {
setContent(content: string, emitUpdate?: Boolean, parseOptions?: any): Editor,
setContent: SetContent,
}
}
export default function setContent(
next: Function,
editor: Editor,
content = null,
emitUpdate = false,
parseOptions = {},
): void {
export default (next: Function, editor: Editor): SetContent => (content, emitUpdate, parseOptions) => {
if (content === null) {
next()
return