Fix link classes duplicating on paste (#788)

This commit is contained in:
Sinclair Chen 2022-08-22 17:45:23 -07:00 committed by GitHub
parent 552f9add70
commit 20fd286756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import {
JSONContent, JSONContent,
Content, Content,
Editor, Editor,
mergeAttributes,
} from '@tiptap/react' } from '@tiptap/react'
import StarterKit from '@tiptap/starter-kit' import StarterKit from '@tiptap/starter-kit'
import { Image } from '@tiptap/extension-image' import { Image } from '@tiptap/extension-image'
@ -38,7 +39,16 @@ const DisplayImage = Image.configure({
}, },
}) })
const DisplayLink = Link.configure({ const DisplayLink = Link.extend({
renderHTML({ HTMLAttributes }) {
delete HTMLAttributes.class // only use our classes (don't duplicate on paste)
return [
'a',
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
0,
]
},
}).configure({
HTMLAttributes: { HTMLAttributes: {
class: clsx('no-underline !text-indigo-700', linkClass), class: clsx('no-underline !text-indigo-700', linkClass),
}, },