Implement web links and custom link matcher registration#538
Implement web links and custom link matcher registration#538Tyriar merged 22 commits intoxtermjs:masterfrom
Conversation
Part of 455
This enables consumers to have full control.
|
@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
onclickhandler 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