-
Notifications
You must be signed in to change notification settings - Fork 27
/
code.ts
26 lines (22 loc) · 813 Bytes
/
code.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 { CodeOptions as TiptapCodeOptions } from '@tiptap/extension-code'
import { Code as TiptapCode } from '@tiptap/extension-code'
import ActionButton from './components/ActionButton.vue'
import type { GeneralOptions } from '@/type'
export interface CodeOptions extends TiptapCodeOptions, GeneralOptions<CodeOptions> {}
export const Code = /* @__PURE__*/ TiptapCode.extend<CodeOptions>({
addOptions() {
return {
...this.parent?.(),
button: ({ editor, t }) => ({
component: ActionButton,
componentProps: {
action: () => editor.commands.toggleCode(),
isActive: () => editor.isActive('code') || false,
disabled: !editor.can().toggleCode(),
icon: 'code',
tooltip: t('editor.code.tooltip')
}
})
}
}
})