copy_and_paste: Add documentation for keyboard shortcuts for pasting.

Fixes: #29209.
This commit is contained in:
N-Shar-ma 2024-03-28 03:17:02 +05:30 committed by Tim Abbott
parent 7895b05284
commit 46147cd13c
4 changed files with 31 additions and 0 deletions

View File

@ -25,6 +25,10 @@ in the Zulip app to add more to your repertoire as needed.
* **New direct message**: <kbd>X</kbd> * **New direct message**: <kbd>X</kbd>
* **Paste formatted text**: <kbd>Ctrl</kbd> + <kbd>V</kbd>
* **Paste as plain text**: <kbd data-mac-following-key="⌥">Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>V</kbd>
* **Cancel compose and save draft**: <kbd>Esc</kbd> or <kbd>Ctrl</kbd> + * **Cancel compose and save draft**: <kbd>Esc</kbd> or <kbd>Ctrl</kbd> +
<kbd>[</kbd> — Close the compose box and save the unsent message as a <kbd>[</kbd> — Close the compose box and save the unsent message as a
draft. draft.

View File

@ -80,6 +80,16 @@ export function adjust_mac_kbd_tags(kbd_elem_class: string): void {
} }
$(this).text(key_text); $(this).text(key_text);
// In case of shortcuts, the Mac equivalent of which involves extra keys,
// we use data-mac-following-key attribute to append the extra key to the
// previous key. Currently, this is used to append Opt to Cmd for the Paste
// as plain text shortcut.
const following_key = $(this).attr("data-mac-following-key");
if (following_key !== undefined) {
const $kbd_elem = $("<kbd>").text(following_key);
$(this).after(" + ", $kbd_elem);
}
}); });
} }

View File

@ -20,6 +20,14 @@
<td class="definition">{{t 'New direct message' }}</td> <td class="definition">{{t 'New direct message' }}</td>
<td><span class="hotkey"><kbd>X</kbd></span></td> <td><span class="hotkey"><kbd>X</kbd></span></td>
</tr> </tr>
<tr>
<td class="definition">{{t 'Paste formatted text' }}</td>
<td><span class="hotkey"><kbd>Ctrl</kbd> + <kbd>V</kbd></span></td>
</tr>
<tr>
<td class="definition">{{t 'Paste as plain text' }}</td>
<td><span class="hotkey"><kbd data-mac-following-key="⌥">Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>V</kbd></span></td>
</tr>
<tr> <tr>
<td class="definition">{{t 'Cancel compose and save draft' }}</td> <td class="definition">{{t 'Cancel compose and save draft' }}</td>
<td><span class="hotkey"><kbd>Esc</kbd> or <kbd>Ctrl</kbd> + <kbd>[</kbd></span></td> <td><span class="hotkey"><kbd>Esc</kbd> or <kbd>Ctrl</kbd> + <kbd>[</kbd></span></td>

View File

@ -94,6 +94,7 @@ run_test("adjust_mac_kbd_tags mac", ({override}) => {
["Ctrl+K", "Ctrl+K"], ["Ctrl+K", "Ctrl+K"],
["[", "["], ["[", "["],
["X", "X"], ["X", "X"],
["data-mac-following-key", "data-mac-following-key"],
]); ]);
const fn_shortcuts = new Set(["Home", "End", "PgUp", "PgDn"]); const fn_shortcuts = new Set(["Home", "End", "PgUp", "PgDn"]);
@ -114,6 +115,14 @@ run_test("adjust_mac_kbd_tags mac", ({override}) => {
assert.equal($elem, inserted_fn_key); assert.equal($elem, inserted_fn_key);
}; };
} }
if (old_key === "data-mac-following-key") {
$stub.attr("data-mac-following-key", "⌥");
$stub.after = (plus, $elem) => {
assert.equal(plus, " + ");
assert.equal($elem.selector, "<kbd>");
assert.equal($elem.text(), $stub.attr("data-mac-following-key"));
};
}
test_item.$stub = $stub; test_item.$stub = $stub;
test_item.mac_key = mac_key; test_item.mac_key = mac_key;
test_item.adds_arrow_key = fn_shortcuts.has(old_key); test_item.adds_arrow_key = fn_shortcuts.has(old_key);