forked from yikoyu/vuetify-pro-tiptap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhighlight.ts
30 lines (26 loc) · 990 Bytes
/
highlight.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { HighlightOptions as TiptapHighlightOptions } from '@tiptap/extension-highlight'
import { Highlight as TiptapHighlight } from '@tiptap/extension-highlight'
import HighlightActionButton from './components/HighlightActionButton.vue'
import type { ButtonView, GeneralOptions } from '@/type'
export interface HighlightOptions extends TiptapHighlightOptions, GeneralOptions {
button: ButtonView
}
export const Highlight = /* @__PURE__*/ TiptapHighlight.extend<HighlightOptions>({
addOptions() {
return {
...this.parent?.(),
multicolor: true,
button: ({ editor, t }) => ({
component: HighlightActionButton,
componentProps: {
action: (color?: unknown) => {
if (typeof color === 'string') editor.commands.setHighlight({ color })
},
isActive: () => editor.isActive('highlight') || false,
icon: 'highlight',
tooltip: t('editor.highlight.tooltip')
}
})
}
}
})