mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
compose: Allow ctrl + enter to send in preview mode as well.
When the user chose to send the composebox message on pressing ctrl + enter instead of just enter, it only worked in writing mode but not in the preview mode. This change makes ctrl + enter send the message even in preview mode, when that setting is chosen. Fixes: #21670.
This commit is contained in:
@@ -268,9 +268,12 @@ export function send_message(request = create_message_object()) {
|
||||
}
|
||||
}
|
||||
|
||||
export function enter_with_preview_open() {
|
||||
if (user_settings.enter_sends) {
|
||||
// If enter_sends is enabled, we attempt to send the message
|
||||
export function enter_with_preview_open(ctrl_pressed = false) {
|
||||
if (
|
||||
(user_settings.enter_sends && !ctrl_pressed) ||
|
||||
(!user_settings.enter_sends && ctrl_pressed)
|
||||
) {
|
||||
// If this enter should send, we attempt to send the message.
|
||||
finish();
|
||||
} else {
|
||||
// Otherwise, we return to the normal compose state.
|
||||
|
||||
@@ -89,6 +89,7 @@ const keydown_unshift_mappings = {
|
||||
|
||||
const keydown_ctrl_mappings = {
|
||||
219: {name: "escape", message_view_only: false}, // '['
|
||||
13: {name: "ctrl_enter", message_view_only: true}, // enter
|
||||
};
|
||||
|
||||
const keydown_cmd_or_ctrl_mappings = {
|
||||
@@ -471,6 +472,16 @@ export function process_enter_key(e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function process_ctrl_enter_key() {
|
||||
if ($("#preview_message_area").is(":visible")) {
|
||||
const ctrl_pressed = true;
|
||||
compose.enter_with_preview_open(ctrl_pressed);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function process_tab_key() {
|
||||
// Returns true if we handled it, false if the browser should.
|
||||
// TODO: See if browsers like Safari can now handle tabbing correctly
|
||||
@@ -566,6 +577,8 @@ export function process_hotkey(e, hotkey) {
|
||||
return process_escape_key(e);
|
||||
case "enter":
|
||||
return process_enter_key(e);
|
||||
case "ctrl_enter":
|
||||
return process_ctrl_enter_key(e);
|
||||
case "tab":
|
||||
return process_tab_key();
|
||||
case "shift_tab":
|
||||
|
||||
Reference in New Issue
Block a user