Skip to content

feat: print email with customizable Ctrl+P shortcut#129

Open
saiththerobo wants to merge 8 commits into
maathimself:mainfrom
saiththerobo:feat/print-shortcut-customizable
Open

feat: print email with customizable Ctrl+P shortcut#129
saiththerobo wants to merge 8 commits into
maathimself:mainfrom
saiththerobo:feat/print-shortcut-customizable

Conversation

@saiththerobo
Copy link
Copy Markdown
Contributor

Summary

Adds a print action that opens a formatted print view of the current message, wired into the existing customizable shortcut system as a first-class action (default Ctrl+P / Cmd+P on Mac).

Changes

Print feature

  • MessagePane: handlePrint builds a self-contained HTML page with the message header and body, opens it in a new window, and calls window.print(). HTML is XSS-escaped before injection.
  • Toolbar print button added alongside Reply / Forward / Archive.
  • i18n strings added for all supported locales.

Shortcut system integration

  • defaultShortcuts.js: added printMessage action (defaultKey: 'ctrl+p'), parseModKey helper, buildModKeyMap for modifier+key dispatch, and modLabel / modCompactLabel for platform-aware display (⌘ on Mac, Ctrl / ^ elsewhere).
  • MailApp.jsx: global key handler now checks modKeyMap for Ctrl/Cmd combos — only intercepts keys explicitly registered, passes everything else through to the browser unchanged.
  • MessagePane.jsx: raw document.addEventListener for Ctrl+P replaced by shortcutBus.on('printMessage', ...), consistent with all other pane shortcuts.
  • AdminPanel.jsx: shortcuts settings tab renders and records modifier combos (e.g. Ctrl + P); users can rebind print to any key or modifier combo.
  • Toolbar badges (Reply, Forward, Archive, Print) are now dynamic — they update live when the user rebinds a shortcut, and disappear if the shortcut is cleared.

Testing

  • Print opens a correctly formatted view (subject, from, to, cc, date, body) and triggers the browser print dialog.
  • Ctrl+P / Cmd+P intercepted; browser print dialog suppressed.
  • Shortcut appears in the ? help overlay and the Settings → Shortcuts tab.
  • Rebinding print to another key (e.g. Ctrl+I) updates the toolbar badge and dispatches correctly.
  • Clearing the print shortcut hides the toolbar badge.
  • All pre-existing shortcuts (r, f, e, j, k, gi, etc.) continue to work.
  • Unregistered Ctrl/Cmd combos (Ctrl+C, Ctrl+V, Ctrl+Z, Cmd+Tab, etc.) pass through to the browser unaffected.

Contributor License Agreement

By submitting this pull request I confirm that:

  • I have read and agree to the Contributor License Agreement.
  • My contribution is my own original work (or I have identified any third-party material and confirmed it is compatible with the CLA).
  • I have the right to submit this contribution under the terms of the CLA.

Adds a print button to the message pane toolbar and a Ctrl+P / Cmd+P
keyboard shortcut. Opens a formatted print view (header + body) in a
new window and triggers the browser print dialog via win.print().
- Escape all user-controlled strings (name, email, subject, body text)
  through a shared esc() helper; fixes & not being escaped previously
- Guard window.open() return value — returns null if browser blocks popup
- Add text label and ^P kbd hint to print button on desktop, consistent
  with Reply/Forward/Archive
Add printMessage (Ctrl+P default) to ACTION_DEFS so it appears in the
shortcuts help overlay and settings tab alongside all other actions.
Users can rebind or clear it like any other shortcut.

- defaultShortcuts: add printMessage action, parseModKey helper,
  buildModKeyMap for modifier+key dispatch
- MailApp: global handler now checks modKeyMap for Ctrl/Cmd combos
  instead of skipping them entirely; keyBadge renders Ctrl+P style
- MessagePane: replace raw onCtrlP document listener with
  shortcutBus.on('printMessage'); make reply/forward/archive/print
  toolbar badges dynamic via shortcutLabel() helper
- AdminPanel: renderKey and recording handler both support ctrl+ notation
Adds modLabel() and modCompactLabel() to defaultShortcuts so the help
overlay, settings tab, and toolbar badges all show the correct symbol
on Mac (⌘) vs Windows/Linux (Ctrl / ^).
@saiththerobo saiththerobo mentioned this pull request Jun 1, 2026
3 tasks
@saiththerobo
Copy link
Copy Markdown
Contributor Author

Additional fix: R shortcut now always triggers plain reply

While testing, I noticed an inconsistency in how the reply action was wired. The paneActionsRef had:

reply: () => handleReply(defaultReplyAll),

This meant that if the user set their default reply mode to "Reply All" in settings, pressing R would open a Reply All compose window — even though R is defined and labelled as the Reply shortcut. Both R and A would silently do the same thing, which is confusing.

The fix changes reply to always call handleReply(false):

  • R → always plain reply
  • A → always reply all
  • Toolbar button → follows the default setting (unchanged)

The default reply preference now only controls which action the toolbar button performs, not what the keyboard shortcuts do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant