diff --git a/crates/notedeck_columns/src/ui/note/context.rs b/crates/notedeck_columns/src/ui/note/context.rs index d675ce2a..5b2283b7 100644 --- a/crates/notedeck_columns/src/ui/note/context.rs +++ b/crates/notedeck_columns/src/ui/note/context.rs @@ -2,6 +2,7 @@ use crate::colors; use egui::{Rect, Vec2}; use enostr::{NoteId, Pubkey}; use nostrdb::{Note, NoteKey}; +use tracing::error; #[derive(Clone)] #[allow(clippy::enum_variant_names)] @@ -9,6 +10,7 @@ pub enum NoteContextSelection { CopyText, CopyPubkey, CopyNoteId, + CopyNoteJSON, } impl NoteContextSelection { @@ -33,6 +35,12 @@ impl NoteContextSelection { } }); } + NoteContextSelection::CopyNoteJSON => { + ui.output_mut(|w| match note.json() { + Ok(json) => w.copied_text = json, + Err(err) => error!("error copying note json: {err}"), + }); + } } } } @@ -162,6 +170,10 @@ impl NoteContextButton { context_selection = Some(NoteContextSelection::CopyNoteId); ui.close_menu(); } + if ui.button("Copy note json").clicked() { + context_selection = Some(NoteContextSelection::CopyNoteJSON); + ui.close_menu(); + } }); context_selection