File handler
Receive dropped paths and pasted clipboard images in your GPUI app.
Try it
Section titled “Try it”Copy an image, click the paragraph, and paste. The example reports how many images the clipboard supplied.
Install
Section titled “Install”cargo add gpdoc-plugin-file-handlerExample
Section titled “Example”use gpdoc_plugin_file_handler::{FileInput, file_handler};
let files = file_handler(|_, input, _, _| match input { FileInput::Drop { paths, at } => { eprintln!("Dropped {paths:?} at {at:?}"); true } FileInput::Paste(images) => { eprintln!("Pasted {} images", images.len()); true }});let config = gpdoc::EditorConfig::builder() .plugin(gpdoc_plugin_paragraph::paragraph()) .plugin(files) .build() .expect("configure editor");Drop a file or paste an image to log the event. Replace the logging with your app’s import logic. For a drop, at is the destination document position. A paste supplies the clipboard images and the callback can read the current selection from the editor.
Return true when your app consumes the event. Return false to let other handlers try it.