-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement web links and custom link matcher registration #538
Conversation
Part of 455
This enables consumers to have full control.
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 and works great for me.
Seems to be resolving #27 also.
@parisk I'm having second thoughts on how deregister/register works. While currently it's very simple to use, it could be made far more powerful if the link matchers were assigned to actual rows. Consider the following which would be a really cool experience:
Currently the above will do not linkify anything as the link matcher is immediately deregistered. Before merging this I'm going to look at tighter integration between the linkifier and the rows, so instead of just discarding the link matcher completely on deregister, the rows where it was active would keep a reference to it (which would now live outside Linkifier) and eventually be discarded when all references to it are gone (when all rows that had that link matcher go off the end of the buffer and outside references are dropped). |
I think I get it and indeed sounds powerful. Just a clarification question: How will you register link matchers to lines (e.g. using line number, DOM element, something else)? Also, will the linkifying happen automatically or the host application has to invoke it manually at will. |
There would need to be another step where when a row is written to it assigns references to the current link handlers on |
Do you plan to implement this in this PR or as an enhancement in a next one? |
In a new one would probably be better provided we don't advertise the API yet as it could change. |
@Tyriar I'd suggest to take a look at https://github.com/markdown-it/linkify-it for link pattern search algorythms. |
@puzrin thanks for the link! |
Fixes #455
🆕 Web links
This PR adds web links to the terminal which can be clicked to open the URL, a custom handler can be attached which will change the links to use an
onclick
handler instead.🆕 Custom link matchers
The ability for consumers to register custom link matchers has also been added, these are basically the same as web links but can match literally anything the consumer wants.
Implementation details
strictUrlRegex
, meaning only http(s) protocol prefixed links will activate