-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use new Image API from egui #11
Conversation
/// A cache used for storing content such as images. | ||
pub struct CommonMarkCache { | ||
// Everything stored here must take into account that the cache is for multiple | ||
// CommonMarkviewers with different source_ids. |
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.
The comment is for the entire struct and not for the image field. It's just badly placed by me.
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.
I added it back in
pub fn reload_images(&mut self) { | ||
self.images.lock().clear(); | ||
pub fn reload_images(&mut self, ui: &Ui) { | ||
ui.ctx().forget_all_images(); |
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.
This has a different meaning now. Before it removed only egui_commonmark's images, now it removes all images. The extra tracking of images required just for this function does not seem worth it to me, so I'm tempted to have the entire method removed. I added this method originally just because I could...
Thanks! |
let url = if url.starts_with("http://") || url.starts_with("https://") { | ||
url.to_string() | ||
} else { | ||
format!("file://{url}") |
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.
I think this was a mistake. I think we should pass the uri unchanged to egui.
For instance, the user might specify their uri using something like bytes://
to indicate it should come from the BytesLoader
. Or they specify it using file://
and now egui_commonmark
adds another file://
prefix to it
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.
I would expect ![](image.png)
to just point to the file at {cwd}/image.png
. Maybe we could detect if the URI begins with a protocol of any kind, and if it doesn't, only then append file://
?
Sorry for the noise! Continued from #9.