add AllExtensions interface

This commit is contained in:
Philipp Kühn
2020-10-22 22:40:40 +02:00
parent 79172753ef
commit 6746163dda
23 changed files with 231 additions and 180 deletions

View File

@@ -7,15 +7,7 @@ export interface HeadingOptions {
levels: Level[],
}
// export type HeadingCommand = (options: { level: Level }) => Command
// declare module '@tiptap/core/src/Editor' {
// interface Commands {
// heading: HeadingCommand,
// }
// }
export default createNode({
const Heading = createNode({
name: 'heading',
defaultOptions: <HeadingOptions>{
@@ -51,8 +43,11 @@ export default createNode({
addCommands() {
return {
heading: attrs => ({ commands }) => {
return commands.toggleBlockType('heading', 'paragraph', attrs)
/**
* heading command
*/
heading: (options: { level: Level }): Command => ({ commands }) => {
return commands.toggleBlockType('heading', 'paragraph', options)
},
}
},
@@ -72,3 +67,11 @@ export default createNode({
})
},
})
export default Heading
declare module '@tiptap/core/src/Editor' {
interface AllExtensions {
Heading: typeof Heading,
}
}