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