mirror of
https://github.com/keven1024/015.git
synced 2026-06-03 10:59:35 +00:00
feat(front): integrate markdown-it for rendering markdown content in MarkdownRender component
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
import { Extension } from '@tiptap/core'
|
||||
import { Plugin, PluginKey } from 'prosemirror-state'
|
||||
import { marked } from 'marked'
|
||||
|
||||
export const MarkdownPaste = Extension.create({
|
||||
name: 'markdownPaste',
|
||||
addProseMirrorPlugins() {
|
||||
return [
|
||||
new Plugin({
|
||||
key: new PluginKey('markdownPaste'),
|
||||
props: {
|
||||
handlePaste: (view, event) => {
|
||||
const clipboardText = event.clipboardData?.getData('text/plain')
|
||||
if (clipboardText) {
|
||||
const html = marked(clipboardText)
|
||||
this.editor.commands.insertContent(html)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
},
|
||||
}),
|
||||
]
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user