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

@@ -27,9 +27,3 @@ export const ColorHighlighter = Extension.create({
]
},
})
declare module '@tiptap/core' {
interface AllExtensions {
ColorHighlighter: typeof ColorHighlighter,
}
}

View File

@@ -13,6 +13,13 @@ export interface AnnotationOptions {
onUpdate: (items: [any?]) => {},
}
declare module '@tiptap/core' {
interface Commands {
addAnnotation: (content: any) => Command,
deleteAnnotation: (id: number) => Command,
}
}
export const Annotation = Extension.create({
name: 'annotation',
@@ -25,7 +32,7 @@ export const Annotation = Extension.create({
addCommands() {
return {
addAnnotation: (content: any): Command => ({ dispatch, state }) => {
addAnnotation: (content: any) => ({ dispatch, state }) => {
const { selection } = state
if (selection.empty) {
@@ -46,7 +53,7 @@ export const Annotation = Extension.create({
return true
},
deleteAnnotation: (id: number): Command => ({ dispatch, state }) => {
deleteAnnotation: (id: number) => ({ dispatch, state }) => {
if (dispatch) {
dispatch(state.tr.setMeta(AnnotationPluginKey, { type: 'deleteAnnotation', id }))
}
@@ -62,9 +69,3 @@ export const Annotation = Extension.create({
]
},
})
declare module '@tiptap/core' {
interface AllExtensions {
Annotation: typeof Annotation,
}
}

View File

@@ -60,9 +60,3 @@ export const Color = Extension.create({
]
},
})
declare module '@tiptap/core' {
interface AllExtensions {
Color: typeof Color,
}
}

View File

@@ -7,6 +7,12 @@ export interface IframeOptions {
},
}
declare module '@tiptap/core' {
interface Commands {
setIframe: (options: { src: string }) => Command,
}
}
export default Node.create({
name: 'iframe',
@@ -55,7 +61,7 @@ export default Node.create({
/**
* Add an iframe
*/
setIframe: (options: { src: string }): Command => ({ tr, dispatch }) => {
setIframe: (options: { src: string }) => ({ tr, dispatch }) => {
const { selection } = tr
const node = this.type.create(options)

View File

@@ -90,9 +90,3 @@ export const Linter = Extension.create({
]
},
})
declare module '@tiptap/core' {
interface AllExtensions {
Linter: typeof Linter,
}
}