-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the mention extension to have custom renderHTML #4082
Conversation
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Seems like the original PR author isn’t responding. Any chance this could still be merged? @bdbch |
Hey guys, is there anything else preventing the merging of this pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, cc @svenadlung
Hey guys, it seems like this PR is ready to be integrated into a new release, isn't it? |
Is any way to make a link on mention block while this PR hasn't merged? |
@Skryabind Yes, you can extend the stock Mention extension and add whatever methods you want to your extended version. You can modify the text or HTML being rendered, or render a node view. See here. Not sure why this PR isn’t yet merged, though. It’s a fairly small change. Maybe the core team is busy. |
@andrictham thank you! I did it by using extend and changing the "name" parameter in config. |
Just wanted to give a heads up to anyone that comes across this. The change to remove |
Just a heads up, this completely broke rendering data attributes. We fixed it by extending the mention extension with: renderHTML({ node, HTMLAttributes }) {
return [
'span',
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
`${this.options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
]
} Even the TipTap mentions demo does not render data attributes anymore |
can you provide a minimal example with the problem? |
Data attributes work fine in the demo, can you provide a reproducible example? |
@moham96 you can inspect mention elements in the demo and you will see that no attributes are being attached with the span. This is not just the case for |
Please describe your changes
Currently the mention extension's
renderLabel
doesn't allow returning HTML and expect returning string, there is a workaround by tricking the typesystem but this breaks when generating text fromJSONContent
(i.e usinggenerateText
from@tiptap/core
, this should allow the user to customize the text and html rendering.This can be very useful when one wants to render and
a
tag instead of just aspan
tag so that it can link to the profile of the mention personHow did you accomplish your changes
Basically introduced two new functions
renderText
andrenderHTML
How have you tested your changes
Yes, tested it on my current project (Laravel with Inertiajs)
How can we verify your changes
It can be tested using the mention demo
Remarks
N/A
Checklist
Related issues
#3325