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

@@ -13,6 +13,14 @@ export interface HighlightOptions {
},
}
declare module '@tiptap/core' {
interface Commands {
setHighlight: (attributes?: { color: string }) => Command,
toggleHighlight: (attributes?: { color: string }) => Command,
unsetHighlight: () => Command,
}
}
export const inputRegex = /(?:^|\s)((?:==)((?:[^~]+))(?:==))$/gm
export const pasteRegex = /(?:^|\s)((?:==)((?:[^~]+))(?:==))/gm
@@ -68,19 +76,19 @@ export const Highlight = Mark.create({
/**
* Set a highlight mark
*/
setHighlight: (attributes?: { color: string }): Command => ({ commands }) => {
setHighlight: attributes => ({ commands }) => {
return commands.setMark('highlight', attributes)
},
/**
* Toggle a highlight mark
*/
toggleHighlight: (attributes?: { color: string }): Command => ({ commands }) => {
toggleHighlight: attributes => ({ commands }) => {
return commands.toggleMark('highlight', attributes)
},
/**
* Unset a highlight mark
*/
unsetHighlight: (): Command => ({ commands }) => {
unsetHighlight: () => ({ commands }) => {
return commands.unsetMark('highlight')
},
}
@@ -104,9 +112,3 @@ export const Highlight = Mark.create({
]
},
})
declare module '@tiptap/core' {
interface AllExtensions {
Highlight: typeof Highlight,
}
}