-
Notifications
You must be signed in to change notification settings - Fork 32
/
highlight.ts
29 lines (25 loc) · 1.01 KB
/
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
import type { GeneralOptions } from '@/type'
import type { HighlightOptions as TiptapHighlightOptions } from '@tiptap/extension-highlight'
import { Highlight as TiptapHighlight } from '@tiptap/extension-highlight'
import HighlightActionButton from './components/HighlightActionButton.vue'
export interface HighlightOptions extends TiptapHighlightOptions, GeneralOptions<HighlightOptions> {}
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.chain().focus().setHighlight({ color }).run()
},
isActive: () => editor.isActive('highlight') || false,
disabled: !editor.can().setHighlight(),
icon: 'highlight',
tooltip: t('editor.highlight.tooltip')
}
})
}
}
})