mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 02:04:59 -06:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5beadf780 | ||
|
|
ba45da9143 | ||
|
|
0d190bc0af | ||
|
|
864820eda9 | ||
|
|
93caf4d222 |
@@ -335,8 +335,9 @@ fn paste(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
return paste_plain(s, t);
|
||||
}
|
||||
let editing = s.doc()?.selection.text.is_some();
|
||||
if editing {
|
||||
let (editing, notes) = s.doc()?.selection.text.as_ref().map_or((false, false), |t| (true, t.notes));
|
||||
// Copied shapes are pasted as shapes even while a text box is being edited (the caret leaves it), but never into the notes.
|
||||
if editing && (notes || s.clipboard.text.is_some() || s.clipboard.shapes.is_empty()) {
|
||||
if let Some(body) = s.clipboard.text.clone() {
|
||||
return super::text::paste_body(s, &body);
|
||||
}
|
||||
|
||||
@@ -668,6 +668,32 @@ fn sample_placeholders_paste_with_their_look() {
|
||||
assert!(checked >= 3, "the sample has text placeholders ({checked})");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copied_shapes_paste_as_shapes_while_a_text_box_is_being_edited() {
|
||||
let mut s = session();
|
||||
s.execute("shape.insert", &json!({"preset": "ellipse", "rect": [10, 10, 50, 50]})).unwrap();
|
||||
s.execute("edit.copy", &json!({})).unwrap();
|
||||
let r = s.execute("insert.textBox", &json!({"text": "Hello"})).unwrap();
|
||||
let id = r["id"].as_u64().unwrap();
|
||||
s.execute("text.edit", &json!({"id": id})).unwrap();
|
||||
let before = s.doc().unwrap().current_slide().unwrap().shapes.len();
|
||||
s.execute("edit.paste", &json!({})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().current_slide().unwrap().shapes.len(), before + 1);
|
||||
assert!(s.doc().unwrap().selection.text.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copied_shapes_are_not_pasted_while_the_notes_are_being_edited() {
|
||||
let mut s = session();
|
||||
s.execute("shape.insert", &json!({"preset": "ellipse", "rect": [10, 10, 50, 50]})).unwrap();
|
||||
s.execute("edit.copy", &json!({})).unwrap();
|
||||
s.execute("text.edit", &json!({"notes": true})).unwrap();
|
||||
let before = s.doc().unwrap().current_slide().unwrap().shapes.len();
|
||||
s.execute("edit.paste", &json!({})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().current_slide().unwrap().shapes.len(), before);
|
||||
assert!(s.doc().unwrap().selection.text.as_ref().is_some_and(|t| t.notes));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pasted_shapes_get_the_next_automatic_name() {
|
||||
let mut s = session();
|
||||
|
||||
Reference in New Issue
Block a user