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,14 @@ export interface ItalicOptions {
},
}
declare module '@tiptap/core' {
interface Commands {
setItalic: () => Command,
toggleItalic: () => Command,
unsetItalic: () => Command,
}
}
export const starInputRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/gm
export const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/gm
export const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/gm
@@ -48,19 +56,19 @@ export const Italic = Mark.create({
/**
* Set an italic mark
*/
setItalic: (): Command => ({ commands }) => {
setItalic: () => ({ commands }) => {
return commands.setMark('italic')
},
/**
* Toggle an italic mark
*/
toggleItalic: (): Command => ({ commands }) => {
toggleItalic: () => ({ commands }) => {
return commands.toggleMark('italic')
},
/**
* Unset an italic mark
*/
unsetItalic: (): Command => ({ commands }) => {
unsetItalic: () => ({ commands }) => {
return commands.unsetMark('italic')
},
}
@@ -86,9 +94,3 @@ export const Italic = Mark.create({
]
},
})
declare module '@tiptap/core' {
interface AllExtensions {
Italic: typeof Italic,
}
}