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