feat: print email with customizable Ctrl+P shortcut#129
Open
saiththerobo wants to merge 8 commits into
Open
Conversation
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 / ^).
Contributor
Author
|
Additional fix: While testing, I noticed an inconsistency in how the reply: () => handleReply(defaultReplyAll),This meant that if the user set their default reply mode to "Reply All" in settings, pressing The fix changes
The default reply preference now only controls which action the toolbar button performs, not what the keyboard shortcuts do. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:handlePrintbuilds a self-contained HTML page with the message header and body, opens it in a new window, and callswindow.print(). HTML is XSS-escaped before injection.Shortcut system integration
defaultShortcuts.js: addedprintMessageaction (defaultKey: 'ctrl+p'),parseModKeyhelper,buildModKeyMapfor modifier+key dispatch, andmodLabel/modCompactLabelfor platform-aware display (⌘ on Mac, Ctrl / ^ elsewhere).MailApp.jsx: global key handler now checksmodKeyMapfor Ctrl/Cmd combos — only intercepts keys explicitly registered, passes everything else through to the browser unchanged.MessagePane.jsx: rawdocument.addEventListenerfor Ctrl+P replaced byshortcutBus.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.Testing
?help overlay and the Settings → Shortcuts tab.Contributor License Agreement
By submitting this pull request I confirm that: