Paste copied shapes while a text box is being edited (#1550)

This commit is contained in:
MarekSpodBiedry
2026-10-30 16:38:51 +01:00
parent 3a4e30e10e
commit 93caf4d222
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -278,7 +278,8 @@ fn paste(s: &mut Session, p: &Value) -> Result<Value> {
return paste_plain(s, t);
}
let editing = s.doc()?.selection.text.is_some();
if editing {
// Copied shapes are pasted as shapes even while a text box is being edited (the caret leaves it).
if editing && (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);
}
+14
View File
@@ -214,6 +214,20 @@ fn clipboard_copy_paste_shapes_and_slides() {
assert!(s.doc().unwrap().doc.validate().is_empty());
}
#[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 pasted_shapes_get_the_next_automatic_name() {
let mut s = session();