-
-
Notifications
You must be signed in to change notification settings - Fork 725
fix(ui): Link rendering in comment editor #1371
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
base: main
Are you sure you want to change the base?
fix(ui): Link rendering in comment editor #1371
Conversation
Uses new npm dependency @tiptap/extension-link to fix link rendering Previously links would be stripped from the editor in rich text mode This extension allows users to: - Insert links using markdown syntax in markdown mode - Paste links directly in rich text mode - Preserve links when toggling between modes
Hey @widal001 Thanks very much, I'm not sure how I missed support for links actually, this is a good start! You're right, there aren't any decent tests for the CommentEditor, and really there should be. It was a bit nasty trying to work out the best way to test this stuff, since it's so embedded in the UI. I couldn't work out if adding some web (playwright) tests was the best way to go, or if there was a nicer way to isolate it.. If you have any ideas? Just played with this and it's working really well.. I was wondering if we should also add a button to the editor to make it easy to create a link on the rich text side... that might be a bit tricky though since you're going to need to prompt for a URL to create the link for... so perhaps we shouldn't bother adding that now. I also spotted when I added a post with a link, that the link was added to the title of the post in markdown format, which obs didn't look great, so we'll need to do something about that too: ![]() I was under the impression that all markdown was being stripped for the title, I guess not! |
Thanks for this additional context and feedback @mattwoberts Based on your notes, here's a proposal for next steps:
I'll prioritize 1) today and try to get to 2) as well and comment back on this ticket in the next day or two with an update. Does that sound good to you? |
Thanks @widal001 that sounds like a perfect plan! |
Auto-generated titles would preserve markdown syntax and html characters This strips markdown and html from the post body when updating the title
- Creates LinkInsertModal component - Adds insert link button to MenuBar component - Increases max width of ShareFeedback component to avoid wrapping
@mattwoberts See the last three commits for updates! Here's a quick summary below as well:
Next steps: I might suggest tackling some of those link modal limitations as part of a PR that adds more robust testing. That PR might also benefit from some refactoring of the |
Just something I remembered... Someone recently added support for crypto-style links, since they were being removed as part of the parsing... We'll possibly need to make sure all that continues to work? |
@mattwoberts It's been a busy end to the week. I'll try to incorporate these remaining updates this weekend:
|
Refactors the LinkInsertModal component to use the Input component and adds translations for input fields to client.json
Updates LinkInsertModal and CommentEditor to support custom link schemes defined by the Fider admin, such as mailto:, bitcoin:, monero:, etc.
Explains why we need to call plainText() to strip markdown syntax from editor.getText() in markdown mode
@mattwoberts This commit should add support for crypto links and any other schemes added to the "Accepted schemes" configuration section by the Fider admin (e.g. |
Thanks @widal001, I'll get onto this asap, I'm not very well at the moment so not running on full speed.... |
Oh no! Hope you're feeling better soon! |
Summary
Issue: Fixes: #1370
@tiptap/extension-link
to fix link rendering. Previously links would be stripped from the editor in rich text mode. This extension allows users to:LinkInsertModal
component and an insert link button to theMenuBar
of theCommentEditor
ShareFeedback
component to avoid wrappingMenuBar
items on desktop&
and'
) from auto-generated titleValidation
Here's a loom explaining the current bug and highlighting the new fix. I updated the loom link to include the full demo of all features.
Notes
CommentEditor
component, but I might have missed it. I tried creating a new test file but was having a little trouble hooking it into the existing test harness. If you want an accompanying unit test, I can spend bit more time getting it to work!