2023-12-21 03:54:40 +09:00
|
|
|
import CodeBlock from '@tiptap/extension-code-block'
|
|
|
|
import { VueNodeViewRenderer } from '@tiptap/vue-3'
|
|
|
|
|
|
|
|
import { createHighlightPlugin } from 'prosemirror-highlight'
|
2024-02-15 16:43:09 +09:00
|
|
|
import { shikiParser } from './shiki-parser'
|
2023-12-21 03:54:40 +09:00
|
|
|
import TiptapCodeBlock from '~/components/tiptap/TiptapCodeBlock.vue'
|
|
|
|
|
2024-02-15 16:43:09 +09:00
|
|
|
export const TiptapPluginCodeBlockShiki = CodeBlock.extend({
|
2023-12-21 03:54:40 +09:00
|
|
|
addOptions() {
|
|
|
|
return {
|
|
|
|
...this.parent?.(),
|
|
|
|
defaultLanguage: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
addProseMirrorPlugins() {
|
|
|
|
return [
|
2024-02-15 16:43:09 +09:00
|
|
|
createHighlightPlugin({ parser: shikiParser, nodeTypes: ['codeBlock'] }),
|
2023-12-21 03:54:40 +09:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
addNodeView() {
|
|
|
|
return VueNodeViewRenderer(TiptapCodeBlock)
|
|
|
|
},
|
|
|
|
})
|