Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

hotkey: Add hotkey "copy link to message" for selected message.

Pratik Chanda483032e783c2
diff --git a/starlight_help/src/content/docs/keyboard-shortcuts.mdx b/starlight_help/src/content/docs/keyboard-shortcuts.mdx
index 8a4e782f731..ed5587e9775 100644
--- a/starlight_help/src/content/docs/keyboard-shortcuts.mdx
+++ b/starlight_help/src/content/docs/keyboard-shortcuts.mdx
@@ -169,6 +169,7 @@ reference in the Zulip app to add more to your repertoire as needed.
message views and views that list topics (e.g., [inbox](/help/inbox), [recent
conversations](/help/recent-conversations)). Learn about [muted
topics](/help/mute-a-topic).
+* **Copy link to message**: <kbd>L</kbd>
## Recent conversations
diff --git a/web/src/hotkey.ts b/web/src/hotkey.ts
index 7a67e0c898b..a716637d7ef 100644
--- a/web/src/hotkey.ts
+++ b/web/src/hotkey.ts
@@ -3,7 +3,9 @@ import assert from "minimalistic-assert";
import * as activity from "./activity.ts";
import * as activity_ui from "./activity_ui.ts";
+import * as blueslip from "./blueslip.ts";
import * as browser_history from "./browser_history.ts";
+import * as clipboard_handler from "./clipboard_handler.ts";
import * as color_picker_popover from "./color_picker_popover.ts";
import * as common from "./common.ts";
import * as compose from "./compose.ts";
@@ -15,6 +17,7 @@ import * as compose_send_menu_popover from "./compose_send_menu_popover.ts";
import * as compose_state from "./compose_state.ts";
import * as compose_textarea from "./compose_textarea.ts";
import * as condense from "./condense.ts";
+import {show_copied_confirmation} from "./copied_tooltip.ts";
import * as deprecated_feature_notice from "./deprecated_feature_notice.ts";
import * as drafts_overlay_ui from "./drafts_overlay_ui.ts";
import * as emoji from "./emoji.ts";
@@ -24,6 +27,7 @@ import * as gear_menu from "./gear_menu.ts";
import * as giphy from "./giphy.ts";
import * as hash_util from "./hash_util.ts";
import * as hashchange from "./hashchange.ts";
+import {$t} from "./i18n.ts";
import * as inbox_ui from "./inbox_ui.ts";
import * as lightbox from "./lightbox.ts";
import * as list_util from "./list_util.ts";
@@ -1485,6 +1489,26 @@ function process_hotkey(e: JQuery.KeyDownEvent, hotkey: Hotkey): boolean {
message_view.narrow_to_message_near(msg, "hotkey");
return true;
}
+ case "vim_right": {
+ if (msg.url && !msg.locally_echoed) {
+ const $row = message_lists.current.selected_row();
+ const $message_time = $row.find("a.message-time");
+ void clipboard_handler
+ .copy_link_to_clipboard(msg.url)
+ .then(() => {
+ show_copied_confirmation(util.the($message_time), {
+ custom_content: $t({defaultMessage: "Message link copied!"}),
+ });
+ })
+ .catch((error: unknown) => {
+ blueslip.error("Failed to copy link to clipboard: ", {
+ error: String(error),
+ });
+ });
+ return true;
+ }
+ return false;
+ }
}
return false;
diff --git a/web/templates/keyboard_shortcuts.hbs b/web/templates/keyboard_shortcuts.hbs
index 080a6520d7e..48587990771 100644
--- a/web/templates/keyboard_shortcuts.hbs
+++ b/web/templates/keyboard_shortcuts.hbs
@@ -465,6 +465,10 @@
<td class="definition">{{t 'Toggle topic mute' }}</td>
<td><span class="hotkey"><kbd>Shift</kbd> + <kbd>M</kbd></span></td>
</tr>
+ <tr>
+ <td class="definition">{{t 'Copy link to message' }}</td>
+ <td><span class="hotkey"><kbd>L</kbd></span></td>
+ </tr>
</table>
</div>
<div>
diff --git a/web/templates/popovers/message_actions_popover.hbs b/web/templates/popovers/message_actions_popover.hbs
index 6d64176222c..63715a7c3cb 100644
--- a/web/templates/popovers/message_actions_popover.hbs
+++ b/web/templates/popovers/message_actions_popover.hbs
@@ -129,6 +129,7 @@
<a role="menuitem" class="copy_link navigate-link-on-enter popover-menu-link" data-message-id="{{message_id}}" data-clipboard-text="{{ conversation_time_url }}" tabindex="0">
<i class="popover-menu-icon zulip-icon zulip-icon-link-alt" aria-hidden="true"></i>
<span class="popover-menu-label">{{t "Copy link to message" }}</span>
+ {{popover_hotkey_hints "L"}}
</a>
</li>
</ul>