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

@@ -12,6 +12,12 @@ export interface ImageOptions {
},
}
declare module '@tiptap/core' {
interface Commands {
setImage: (options: { src: string, alt?: string, title?: string }) => Command,
}
}
export const inputRegex = /!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/
export const Image = Node.create({
@@ -63,7 +69,7 @@ export const Image = Node.create({
/**
* Add an image
*/
setImage: (options: { src: string, alt?: string, title?: string }): Command => ({ tr, dispatch }) => {
setImage: options => ({ tr, dispatch }) => {
const { selection } = tr
const node = this.type.create(options)
@@ -86,9 +92,3 @@ export const Image = Node.create({
]
},
})
declare module '@tiptap/core' {
interface AllExtensions {
Image: typeof Image,
}
}