mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-28 12:16:53 -06:00
Refuse PDF page ranges in the Place PDF dialog instead of using page 1
Fixes #1337 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
15a2f3c8c8
commit
d271298362
@@ -3268,6 +3268,14 @@ pub fn confirm(app: &mut DesignApp) -> Result<Value, String> {
|
||||
}
|
||||
"pdfImport" => {
|
||||
let crop = d.s("crop");
|
||||
if !d.s("page").trim().is_empty() && d.n("page").is_none() {
|
||||
// A range or list ("4-5", "2,5") is not a page number: refuse it rather than place page 1.
|
||||
let e = "Enter a single page number; one page is placed at a time".to_string();
|
||||
let mut d = d;
|
||||
d.fields.insert("status".into(), json!(e));
|
||||
app.ui.dialog = Some(d);
|
||||
return Err(e);
|
||||
}
|
||||
if d.b("async") {
|
||||
return app.confirm_pdf_import(d.n("page").unwrap_or(1.0).max(1.0) as u64, if crop.is_empty() { "crop".into() } else { crop });
|
||||
}
|
||||
|
||||
@@ -2951,6 +2951,19 @@ mod browser_import_tests {
|
||||
assert_eq!(pixels.data().iter().filter(|p| p.r > 240 && p.g < 10 && p.b < 10).count(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_options_refuse_a_page_range_instead_of_placing_page_one() {
|
||||
for spec in ["4-5", "2,5", "2-3"] {
|
||||
let mut app = app();
|
||||
let request = app.import_request("place");
|
||||
deliver(&mut app, request, "three.pdf", pdf());
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert("page".into(), json!(spec));
|
||||
assert!(dialogs::confirm(&mut app).is_err(), "{spec}");
|
||||
assert!(app.session.doc().unwrap().doc.assets.is_empty(), "{spec}");
|
||||
assert_eq!(app.ui.dialog.as_ref().unwrap().id, "pdfImport", "{spec}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn place_loads_the_cursor_unless_a_frame_can_take_the_graphic() {
|
||||
let mut app = app();
|
||||
|
||||
Reference in New Issue
Block a user