chat: add copy text entry to message menu (#8271)
As we don't have selection inside the chat right now (which might be complicated to implement, e.g. cross element selection and markdown blocks), I think its viable to support copying the whole text of a message using the message menu:  Release Notes: - Added option to copy the text of a message within the chat
This commit is contained in:
parent
0f584cb353
commit
c90065e6ea
1 changed files with 17 additions and 3 deletions
|
@ -7,9 +7,9 @@ use collections::HashMap;
|
||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, list, prelude::*, px, Action, AppContext, AsyncWindowContext, CursorStyle,
|
actions, div, list, prelude::*, px, Action, AppContext, AsyncWindowContext, ClipboardItem,
|
||||||
DismissEvent, ElementId, EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight,
|
CursorStyle, DismissEvent, ElementId, EventEmitter, FocusHandle, FocusableView, FontStyle,
|
||||||
HighlightStyle, ListOffset, ListScrollEvent, ListState, Model, Render, StyledText,
|
FontWeight, HighlightStyle, ListOffset, ListScrollEvent, ListState, Model, Render, StyledText,
|
||||||
Subscription, Task, View, ViewContext, VisualContext, WeakView,
|
Subscription, Task, View, ViewContext, VisualContext, WeakView,
|
||||||
};
|
};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
|
@ -629,6 +629,20 @@ impl ChatPanel {
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
.entry(
|
||||||
|
"Copy message text",
|
||||||
|
None,
|
||||||
|
cx.handler_for(&this, move |this, cx| {
|
||||||
|
this.active_chat().map(|active_chat| {
|
||||||
|
if let Some(message) =
|
||||||
|
active_chat.read(cx).find_loaded_message(message_id)
|
||||||
|
{
|
||||||
|
let text = message.body.clone();
|
||||||
|
cx.write_to_clipboard(ClipboardItem::new(text))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
)
|
||||||
.when(can_delete_message, move |menu| {
|
.when(can_delete_message, move |menu| {
|
||||||
menu.entry(
|
menu.entry(
|
||||||
"Delete message",
|
"Delete message",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue