1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-15 05:19:58 +00:00
elk/composables/tiptap/shiki.ts

26 lines
649 B
TypeScript
Raw Normal View History

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'
import { shikiParser } from './shiki-parser'
export const TiptapPluginCodeBlockShiki = CodeBlock.extend({
addOptions() {
return {
...this.parent?.(),
defaultLanguage: null,
}
},
addProseMirrorPlugins() {
return [
createHighlightPlugin({ parser: shikiParser, nodeTypes: ['codeBlock'] }),
]
},
addNodeView() {
return VueNodeViewRenderer(TiptapCodeBlock)
},
})