Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
copy_and_paste: Add documentation for keyboard shortcuts for pasting.
N-Shar-ma46147cd13c8d
diff --git a/help/keyboard-shortcuts.md b/help/keyboard-shortcuts.mdindex 456b13e3317..fa4c7c509cb 100644--- a/help/keyboard-shortcuts.md+++ b/help/keyboard-shortcuts.md@@ -25,6 +25,10 @@ in the Zulip app to add more to your repertoire as needed.* **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> +<kbd>[</kbd> — Close the compose box and save the unsent message as adraft.diff --git a/web/src/common.ts b/web/src/common.tsindex d1544674470..ac9ac166f67 100644--- a/web/src/common.ts+++ b/web/src/common.ts@@ -80,6 +80,16 @@ export function adjust_mac_kbd_tags(kbd_elem_class: string): void {}$(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);+ }});}diff --git a/web/templates/keyboard_shortcuts.hbs b/web/templates/keyboard_shortcuts.hbsindex 1a82965e81d..d6a22c72ca4 100644--- a/web/templates/keyboard_shortcuts.hbs+++ b/web/templates/keyboard_shortcuts.hbs@@ -20,6 +20,14 @@<td class="definition">{{t 'New direct message' }}</td><td><span class="hotkey"><kbd>X</kbd></span></td></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><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>diff --git a/web/tests/common.test.js b/web/tests/common.test.jsindex 79ea625b915..537391e02ca 100644--- a/web/tests/common.test.js+++ b/web/tests/common.test.js@@ -94,6 +94,7 @@ run_test("adjust_mac_kbd_tags mac", ({override}) => {["Ctrl+K", "Ctrl+K"],["[", "["],["X", "X"],+ ["data-mac-following-key", "data-mac-following-key"],]);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);};}+ 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.mac_key = mac_key;test_item.adds_arrow_key = fn_shortcuts.has(old_key);