Implement the Edit > Paste menu entry (#683)

Closes #682
This commit is contained in:
Keavon Chambers
2022-06-19 00:53:33 -07:00
parent 5d6d2b22bc
commit fe4a76a395
6 changed files with 105 additions and 23 deletions

View File

@@ -1204,7 +1204,7 @@ impl MessageHandler<DocumentMessage, (&InputPreprocessorMessageHandler, &FontCac
.into(),
);
let mouse = mouse.map_or(ipp.mouse.position, |pos| pos.into());
let mouse = mouse.map_or(ipp.viewport_bounds.center(), |pos| pos.into());
let transform = DAffine2::from_translation(mouse - ipp.viewport_bounds.top_left).to_cols_array();
responses.push_back(DocumentOperation::SetLayerTransformInViewport { path, transform }.into());
}

View File

@@ -176,8 +176,13 @@ impl PropertyHolder for MenuBarMessageHandler {
action: MenuEntry::create_action(|_| PortfolioMessage::Copy { clipboard: Clipboard::Device }.into()),
..MenuEntry::default()
},
// TODO: Fix this
// { label: "Paste", icon: "Paste", shortcut: ["KeyControl", "KeyV"], action: async (): Promise<void> => editor.instance.paste() },
MenuEntry {
label: "Paste".into(),
icon: Some("Paste".into()),
shortcut: Some(vec![Key::KeyControl, Key::KeyV]),
action: MenuEntry::create_action(|_| FrontendMessage::TriggerPaste.into()),
..MenuEntry::default()
},
],
],
},

View File

@@ -28,6 +28,7 @@ pub enum FrontendMessage {
TriggerFontLoad { font: Font, is_default: bool },
TriggerIndexedDbRemoveDocument { document_id: u64 },
TriggerIndexedDbWriteDocument { document: String, details: FrontendDocumentDetails, version: String },
TriggerPaste,
TriggerRasterDownload { document: String, name: String, mime: String, size: (f64, f64) },
TriggerTextCommit,
TriggerTextCopy { copy_text: String },