Closed MetaflameDragon closed 1 year ago
Link handling in composer is handled differently between web and mobile versions.
It's very finicky on the web because of the plugin it's currently using to get that underlining effect. https://tiptap.dev/api/marks/link
Most importantly whether or not the underlining happens doesn't actually reflect what will be sent on the post, because the client does an additional parsing of its own, independent of what the WYSIWYG editor does, and that's what actually makes it into the post.
Commenting this to give more context as to what's happening within the post composer.
Yep yall are sniffing out the root of the problem. There's a mismatch between the link plugin's behavior and our intended behavior.
Luckily I've got something from my larger sideproject to replace the editor that we can use here. It's a custom plugin that just decorates text based on regex matches. I'll pull in that piece to fix this for now.
Describe the bug This seems like a really far-reaching bug with a lot of extra cases, but I'll try my best. Each time I returned to test further, I found more weird behavior.
In the post compositor, returning the cursor to a link not at the end of the text, and either editing it or appending text, causes all the extra text to get underlined, including whitespace and URL-incompatible characters. Newline at the end of the link is an exception, but not when inserted into the middle. Pasting from Bluesky, other browser tabs, or external sources all produces different results (elaborated below)
I couldn't repro this on mobile - the text field seems to re-parse pasted links correctly and extra text added onto a link doesn't get underlined.
This appears to be an entirely client-side visual discrepancy, and only before a post is sent.
To Reproduce
Additionally, this also occurs when, after writing a link at the end of a post:
Expected behavior
Screenshots
Details
Additional context
I discovered this while reporting #1292, and testing it yielded a lot of weird edge cases. Feel free to refer to a thread where I tried out various things: https://bsky.app/profile/metaflame.bsky.social/post/3k5wu6gboov2o The server side of things seems to handle everything properly, though I raised concerns there about a potential typo-squatting exploit with links and non-matching cards; that's for another Issue though.