mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
This will help some people not to loose data after accidently clicking on the user @-mentioning.
30 lines
674 B
JavaScript
30 lines
674 B
JavaScript
import { Node } from 'tiptap'
|
|
import { replaceText } from 'tiptap-commands'
|
|
import { Mention as TipTapMention } from 'tiptap-extensions'
|
|
|
|
export default class Mention extends TipTapMention {
|
|
get schema() {
|
|
const patchedSchema = super.schema
|
|
|
|
patchedSchema.attrs = {
|
|
url: {},
|
|
label: {}
|
|
}
|
|
patchedSchema.toDOM = node => {
|
|
return [
|
|
'a',
|
|
{
|
|
class: this.options.mentionClass,
|
|
href: node.attrs.url,
|
|
target: '_blank'
|
|
},
|
|
`${this.options.matcher.char}${node.attrs.label}`
|
|
]
|
|
}
|
|
patchedSchema.parseDOM = [
|
|
// this is not implemented
|
|
]
|
|
return patchedSchema
|
|
}
|
|
}
|