arboard
arboard copied to clipboard
`content="text/html"` not possible
Hey,
I try to use this crate to copy gifs into my clipboard looking like "<img src=\"data:image/gif;base64,$base64\" >".
This works fine when done in Java and put into the DataFormat.HTML slot of the ClipboardContent but I cannot get this working in rust :( Is it maybe not possible with this crate, because it uses somewhere internally something like "text/plain" ?
I use it like the following, not providing a gif because unsure about permssions.
use arboard::Clipboard;
extern crate image_base64;
fn main() {
let mut clipboard = Clipboard::new().unwrap();
let image_base64 = image_base64::to_base64("src/pleaseWork.gif");
// Used meta-tag in hope of content negotiation at some higher level
let once_more_html = format!(r#"<meta http-equiv="content-type" content="text/html; charset=utf-8"><img alt="" src="{image_base64}">"#);
clipboard.set_text(once_more_html.to_string()).unwrap()
}
Hey there @deggers. You guessed right that this crate make some assumptions regarding the content type of clipboard contents advertised to different apps on the system. When you use .set_text(), the contents are advertised as a UTF-8 string (in the platform's most matching system-level content type).
If you're interested, I think that we would accept a PR adding support for the text/html format on the Set builder. It seems like its supported on all the relevant platforms.
This is now available in the 3.1.1 release, which was published to crates.io a few minutes ago.