mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-22 01:15:25 +03:00
25 lines
657 B
TypeScript
25 lines
657 B
TypeScript
import CodeBlock from '@tiptap/extension-code-block'
|
|
import { VueNodeViewRenderer } from '@tiptap/vue-3'
|
|
|
|
import { createHighlightPlugin } from 'prosemirror-highlight'
|
|
import { shikijiParser } from './shikiji-parser'
|
|
import TiptapCodeBlock from '~/components/tiptap/TiptapCodeBlock.vue'
|
|
|
|
export const TiptapPluginCodeBlockShikiji = CodeBlock.extend({
|
|
addOptions() {
|
|
return {
|
|
...this.parent?.(),
|
|
defaultLanguage: null,
|
|
}
|
|
},
|
|
|
|
addProseMirrorPlugins() {
|
|
return [
|
|
createHighlightPlugin({ parser: shikijiParser, nodeTypes: ['codeBlock'] }),
|
|
]
|
|
},
|
|
|
|
addNodeView() {
|
|
return VueNodeViewRenderer(TiptapCodeBlock)
|
|
},
|
|
})
|