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