-
Notifications
You must be signed in to change notification settings - Fork 32
/
italic.ts
26 lines (22 loc) · 860 Bytes
/
italic.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
import type { GeneralOptions } from '@/type'
import type { ItalicOptions as TiptapItalicOptions } from '@tiptap/extension-italic'
import { Italic as TiptapItalic } from '@tiptap/extension-italic'
import ActionButton from './components/ActionButton.vue'
export interface ItalicOptions extends TiptapItalicOptions, GeneralOptions<ItalicOptions> {}
export const Italic = /* @__PURE__*/ TiptapItalic.extend<ItalicOptions>({
addOptions() {
return {
...this.parent?.(),
button: ({ editor, t }) => ({
component: ActionButton,
componentProps: {
action: () => editor.chain().focus().toggleItalic().run(),
isActive: () => editor.isActive('italic') || false,
disabled: !editor.can().toggleItalic(),
icon: 'italic',
tooltip: t('editor.italic.tooltip')
}
})
}
}
})