Skip to content
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

Add hover callback for LinkProviders #3056

Closed
Coding-Kiwi opened this issue Aug 25, 2020 · 3 comments · Fixed by #3233
Closed

Add hover callback for LinkProviders #3056

Coding-Kiwi opened this issue Aug 25, 2020 · 3 comments · Fixed by #3233
Labels
area/addon/web-links help wanted type/enhancement Features or improvements to existing features
Milestone

Comments

@Coding-Kiwi
Copy link
Contributor

The LinkMatchers are eventually removed, right?
If you pass _useLinkProvider to the xterm-web-links-addon, there is currently no way to get a hover callback to show a tooltip.
I would like to switch to the LinkProvider but I also want to show a tooltip when hovering a link

@Tyriar Tyriar added area/addon/web-links help wanted type/enhancement Features or improvements to existing features labels Aug 25, 2020
@Tyriar
Copy link
Member

Tyriar commented Aug 25, 2020

👍 PR welcome to add the hover callback to the web link provider, it needs to get added to the result ILinks:

xterm.js/typings/xterm.d.ts

Lines 1146 to 1153 in 566fad4

/**
* Called when the mouse hovers the link. To use this to create a DOM-based hover tooltip,
* create the hover element within `Terminal.element` and add the `xterm-hover` class to it,
* that will cause mouse events to not fall through and activate other links.
* @param event The mouse event triggering the callback.
* @param text The text of the link.
*/
hover?(event: MouseEvent, text: string): void;

@Coding-Kiwi
Copy link
Contributor Author

@Tyriar this would be a quick and dirty way of passing the callbacks through, what do you think

https://github.com/Coding-Kiwi/xterm.js/commit/8d7958c3df3b6a00a3623cf591ae67e186507711

@Tyriar
Copy link
Member

Tyriar commented Aug 29, 2020

@Coding-Kiwi something like that is what I was thinking, decorating the result of computeLinks in a separate function would be preferable though:

const links = LinkComputer.computeLink(y, this._regex, this._terminal, this._handler);
callback(addCallbacks(links, this._options.tooltipCallback, this._options.leaveCallback);

Want to iterate on it in a PR?

marvinthepa pushed a commit to marvinthepa/xterm.js that referenced this issue Jan 25, 2021
marvinthepa pushed a commit to marvinthepa/xterm.js that referenced this issue Feb 2, 2021
marvinthepa pushed a commit to marvinthepa/xterm.js that referenced this issue Feb 3, 2021
@Tyriar Tyriar added this to the 4.11.0 milestone Feb 3, 2021
marvinthepa pushed a commit to marvinthepa/xterm.js that referenced this issue Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/addon/web-links help wanted type/enhancement Features or improvements to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants