commit aa14fb092d84f234e60a9882986115cec9831ed0
parent a429ff689c9f639fc323c856bb9b1e7750265055
Author: William Casarin <jb55@jb55.com>
Date: Wed, 11 Dec 2024 16:12:25 -0800
note: add copy note json
very handy
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git 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