mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-27 20:07:19 -06:00
* #147: wire Picture Format UI for inserted pictures * #147: fix Picture Format state bugs from review (alt/crop buffers, undo coalescing, pending target, tab fallback) * #147: review round 2 (cancel pending change on next action, alt media check, drag-only undo join) --------- Co-authored-by: Tony <gittonyp@gmail.com>
This commit is contained in:
co-authored by
Tony
parent
59d96995bd
commit
bcfe9111ca
@@ -570,7 +570,6 @@ mod tests {
|
||||
image::DynamicImage::ImageRgba8(img).write_to(&mut std::io::Cursor::new(&mut b), image::ImageFormat::Png).unwrap();
|
||||
b
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn picture_pipeline() {
|
||||
let mut s = Session::new(wordcraft_doc::Document::new());
|
||||
@@ -596,4 +595,17 @@ mod tests {
|
||||
s.run("text.insert", &json!({"text": "x"})).unwrap();
|
||||
assert!(s.run("picture.crop", &json!({"left": 0.1})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn picture_alt_and_crop_round_trip() {
|
||||
let mut s = Session::new(wordcraft_doc::Document::new());
|
||||
let data = super::super::insert::base64_encode(&png(20, 10));
|
||||
s.run("insert.picture", &json!({"data": data})).unwrap();
|
||||
s.run("picture.altText", &json!({"text": "A red box"})).unwrap();
|
||||
s.run("picture.crop", &json!({"left": 0.1, "top": 0.2, "right": 0.05, "bottom": 0.0})).unwrap();
|
||||
let (_, o) = selected(&s).unwrap();
|
||||
let InlineObject::Image { alt, crop, .. } = o else { panic!("expected image") };
|
||||
assert_eq!(alt, "A red box");
|
||||
assert_eq!(crop, [0.1, 0.2, 0.05, 0.0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user