mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-28 15:49:23 +08:00
fix some types
This commit is contained in:
parent
f7b62be436
commit
adb2d1a12c
@ -13,6 +13,7 @@ import injectCSS from './utils/injectCSS'
|
|||||||
import ExtensionManager from './ExtensionManager'
|
import ExtensionManager from './ExtensionManager'
|
||||||
|
|
||||||
type EditorContent = string | JSON
|
type EditorContent = string | JSON
|
||||||
|
type Command = (next: Function, editor: Editor, ...args: any) => any
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
element?: Node
|
element?: Node
|
||||||
@ -155,13 +156,10 @@ export class Editor extends EventEmitter {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerCommand(name: string, method: Function): Editor {
|
public registerCommand(name: string, callback: Command): Editor {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this[name] = this.chainCommand((...args: any) => {
|
this[name] = this.chainCommand((...args: any) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => callback(resolve, this, ...args))
|
||||||
// return method(resolve, this, ...args)
|
|
||||||
return method(resolve as Function, this as Editor, ...args as any)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
declare module '@tiptap/core/src/Editor' {
|
declare module '@tiptap/core/src/Editor' {
|
||||||
interface Editor {
|
interface Editor {
|
||||||
undo(): Editor,
|
undo(): Editor,
|
||||||
|
undo(): Editor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,11 +19,15 @@ export default class History extends Extension {
|
|||||||
name = 'history'
|
name = 'history'
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
// @ts-ignore
|
|
||||||
this.editor.registerCommand('undo', (next, { view }) => {
|
this.editor.registerCommand('undo', (next, { view }) => {
|
||||||
undo(view.state, view.dispatch)
|
undo(view.state, view.dispatch)
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.editor.registerCommand('redo', (next, { view }) => {
|
||||||
|
redo(view.state, view.dispatch)
|
||||||
|
next()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get plugins() {
|
get plugins() {
|
||||||
|
Loading…
Reference in New Issue
Block a user