[lexical-markdown] Bug Fix: Prevent Markdown links with empty string link text from being automatically removed#7919
Conversation
…link text from being removed
|
Hi @adambolcsfoldi! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I don't think that strict compliance is useful here, an empty unmergeable TextNode is going to cause other problems (you can't really interact with it). A zwsp might be better if you really wanted to parse such a construct. There are plenty of other instances where better conformance to the commonmark spec would be useful but I don't think this is one of them. |
I can definitely get behind that. |
|
That's probably slightly better than dropping it altogether, but I don't have a strong preference about that. lexical isn't specifically a markdown editor so lossless transformation isn't really the expectation. It's certainly something that could be built but not very easily with the architecture of the current |
|
Closed in favour of a more useful solution here: #7923 |
Description
Currently any markdown link where the link text is an empty string, e.g.
[](https://lexical.dev), will be automatically removed on transformation. According to the CommonMark Spec, it's a valid link.With this pull request the removal of the link's text node is prevented by using the Unmergeable flag.
Not sure what the desired behaviour is here. Admittedly, a link without a corresponding text isn't terribly useful unless handled by the UI layer in some way.
An option would be to not parse it as a valid link as is currently done when the link destination is empty string (
[some link title]()), even despite being compliant with the CommonMark Spec.Test plan
Before
Before.Link.disappears.mov
After
After.-.Link.persists.mov