-
Couldn't load subscription status.
- Fork 42
feat: add aliasable hyperlinks #73
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
base: main
Are you sure you want to change the base?
Conversation
|
This should probably not be added to the main branch. This completely removes the serde feature from ratatui which is probably not supported. I would like to know the best way to go about this. This is my first larger open source contribution. |
d3d1f03 to
9f740e6
Compare
|
This currently works now, I have an example on my site as of Apr 7 2025 Some pros and cons of my implementation: Pros:
Cons:
<span style="a"></span>
<a href="...">
<span style="b"></span>
<span style="b"></span>
</a>
<span style="c"></span>Mine: <span style="a"></span>
<span style="b">
<a href="..."></a>
</span>
<span style="b">
<a href="..."></a>
</span>
<span style="c"></span>
|
9f740e6 to
e7f36ec
Compare
9b6b378 to
52a13ba
Compare
| ratatui = { git = "https://github.com/jetpham/ratatui.git", branch = "hyperlink", version = "0.29", default-features = false, features = ["all-widgets"] } | ||
| console_error_panic_hook = "0.1.7" | ||
| thiserror = "2.0.12" | ||
| log = "0.4.27" |
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.
You can use console::log_1 for logging in the browser btw :) no need for log
|
Thanks for looking into this! I'm guessing this is similar to what has described in #6, right? The problem with the current approach is also described there... it works in a very hacky way. In a nutshell, we don't have any communication between the rendered widget and the I was thinking of storing a static global state for the things that need to be passed to the But I'm still thinking about this... your approach definitely works but I'd rather we touch WDYT? |
|
I definitely agree with touching |
I suggest taking a look at rendering under the hood for the details. But in a nutshell, Ratatui does not store any data about widgets, it simply passes their final visual representation to the backend as "cells" and let the backend does its magic. Whereas in our case we need to store some additional data.
That would be great! Let me know if you find a better way etc. - feedback is always appreciated! |
|
Hey, any updates on this? @jetpham Maybe want to take a look at this together sometime? |
|
Hey! I will be back on this. But no updates on progress. But I do really like the idea of having a second mask layer that contains hyperlink information. I think there's a way to also make it not break getting the raw buffer. I'll have time to play with this soon, but I'm in midterm season. I'll let you know if you have any updates, please do at me if you have any ideas. |
Add the ability to add aliases to hyperlinks like markdown. Changes the Hyperlink::new() function to accept a
contentfield and aurlfield. This ability comes from an ability I added to ratatui 0.29.0 to add a hyperlink field to Cell. This is accessed through the style, where you can get, and set the hyperlink.A Cell's hyperlink is an
Option<'static str>. I tried making it not static but ran into endless lifetime issues (could possibly be fixed in the future).Also prerender function in the dom is made simpler because now, We can just move the adding of a nested into each span if cell.hyperlink.is_some()
This is still a draft because I have yet to get this all to work. Actively debugging this has led me to find that actually setting the hyperlink field is not working, but reading it and rendering the nested tags is totally fine. example:
