feat: Extend support for link target and rel to lexical-react’s AutoLinkPlugin#3209
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
157cac7 to
6c2a41b
Compare
db6c360 to
26a62cc
Compare
9c11421 to
08c2683
Compare
acywatson
left a comment
There was a problem hiding this comment.
I was originally not sure about making this part of matcher result, but it makes sense because you might want different values here for different matcher types.
Maybe it makes more sense to add one property to the LinkMatcherResult that's a bag of attributes that can be added to the link:
LinkMatcherResult = {
...
attributes: {
rel?: ?string
target?: ?string
}
}
|
@acywatson that would match the API of
in my case, i am using a lexical editor for user generated content, so for this instance of the editor, i’m planning to set |
|
|
08c2683 to
92b5e6e
Compare
$createAutoLinkNode and toggleLink were missing latest changes to link attributes (rel & target) support
92b5e6e to
d62f0ec
Compare
|
@fantactuka i added an exported |
d62f0ec to
7262438
Compare
acywatson
left a comment
There was a problem hiding this comment.
this looks right to me.
|
i’m happy to rebase this against latest i didn’t come across any other references to optional attributes like that in lexical-react’s plugins doc, so i just went for the single-line comment, but if there is a different way you all would prefer, please let me know. or if i should just remove that line from the docs and allow it to be something people discover via typescript types or browsing through source code, that’s also fine with me. |
…inkPlugin (#3209) * fix: Remove redundant conditional check * Fix out-of-date LexicalLink flow types $createAutoLinkNode and toggleLink were missing latest changes to link attributes (rel & target) support * Add and use LinkAttributes type in lexical-link * feat: Support link target + rel in AutoLinkPlugin * docs: Cleanup trailing commas in react/plugins.md * docs: Add default protocol in AutoLinkPlugin example * docs: Add example usage of LinkMatcher rel/target
this is a follow-up to #2687 (which resolved issue #2671) that extends support for setting link target and rel to the
AutoLinkPlugincomponent via itsmatchersprop. it adds optionalrelandtargetfields to theLinkMatcherResulttype and forwards those along to$createAutoLinkNode, or useslinkNode.setRel/linkNode.setTargetinhandleLinkEditif they have changed.i also updated the lexical-react docs plugins page’s
AutoLinkPluginsection to adopt the default protocol behavior introduced in #2654 and added commented-out example usage of the new LinkMatcherrelandtargetfields (preview). i wasn’t sure how to properly document it, so if there is a better way (e.g. just a single comment at the beginning or ending of the LinkMatcher object mentioning the optional fields or something else entirely), please let me know.i didn’t find an open issue for this, though there is a question about it in the original PR thread: #2687 (comment). i’d be happy to open one if that would be helpful.