kopia lustrzana https://github.com/elk-zone/elk
26 wiersze
649 B
TypeScript
26 wiersze
649 B
TypeScript
import CodeBlock from '@tiptap/extension-code-block'
|
|
import { VueNodeViewRenderer } from '@tiptap/vue-3'
|
|
|
|
import { createHighlightPlugin } from 'prosemirror-highlight'
|
|
import { shikiParser } from './shiki-parser'
|
|
import TiptapCodeBlock from '~/components/tiptap/TiptapCodeBlock.vue'
|
|
|
|
export const TiptapPluginCodeBlockShiki = CodeBlock.extend({
|
|
addOptions() {
|
|
return {
|
|
...this.parent?.(),
|
|
defaultLanguage: null,
|
|
}
|
|
},
|
|
|
|
addProseMirrorPlugins() {
|
|
return [
|
|
createHighlightPlugin({ parser: shikiParser, nodeTypes: ['codeBlock'] }),
|
|
]
|
|
},
|
|
|
|
addNodeView() {
|
|
return VueNodeViewRenderer(TiptapCodeBlock)
|
|
},
|
|
})
|