@bobfrankston/rmfmail 1.0.674 → 1.0.676

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/app.js CHANGED
@@ -40,6 +40,73 @@ function propagateAppName() {
40
40
  }
41
41
  propagateAppName();
42
42
  window.__btick && window.__btick("app.ts module body executing");
43
+ // ── App-vs-browser policy: this is a desktop app, not a web page. ──
44
+ // Block browser-default accelerators (Reload, Save Page, Print, View
45
+ // Source, history navigation, …) and the right-click context menu so
46
+ // mailx's keymap is the only way to do anything. F12 is preserved as
47
+ // the developer-tools escape hatch (Bob 2026-05-11 explicitly).
48
+ //
49
+ // Capture-phase listener so we intercept BEFORE any inner widget can
50
+ // observe the event — mailx's own keymap re-emits via specific element
51
+ // handlers (Ctrl+N compose, Ctrl+R reply, etc.) which were never the
52
+ // browser's accelerators in the first place.
53
+ (function blockBrowserKeysAndMenu() {
54
+ const isBlockedKey = (e) => {
55
+ // Always-allow: F12 for DevTools, and any single non-modifier key
56
+ // (typing, arrow nav, Tab/Esc/Enter) which is the user typing.
57
+ if (e.key === "F12")
58
+ return false;
59
+ // Block reload paths: F5, Ctrl+R, Ctrl+Shift+R, Ctrl+F5.
60
+ if (e.key === "F5" || e.key === "F3")
61
+ return true;
62
+ if ((e.ctrlKey || e.metaKey) && (e.key === "r" || e.key === "R"))
63
+ return true;
64
+ // Browser accelerators bound to Ctrl-letter combos that mailx
65
+ // doesn't want to forward: P (print), S (save page), U (view
66
+ // source), J (downloads), L (focus address bar — n/a in WebView
67
+ // but harmless), G (find next). Note: O is "open file" in
68
+ // browsers — mailx uses Ctrl+O nowhere meaningful, so block.
69
+ if (e.ctrlKey || e.metaKey) {
70
+ const k = e.key.toLowerCase();
71
+ if (["p", "s", "u", "j", "l", "g", "o"].includes(k))
72
+ return true;
73
+ }
74
+ // Alt+Left / Alt+Right = browser back / forward. No use in mailx.
75
+ if (e.altKey && (e.key === "ArrowLeft" || e.key === "ArrowRight"))
76
+ return true;
77
+ // Backspace as nav-back when no input is focused — fires on some
78
+ // WebView builds. Only block when target isn't text-editable.
79
+ if (e.key === "Backspace") {
80
+ const t = e.target;
81
+ const editable = t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA"
82
+ || t.isContentEditable);
83
+ if (!editable)
84
+ return true;
85
+ }
86
+ return false;
87
+ };
88
+ document.addEventListener("keydown", (e) => {
89
+ if (isBlockedKey(e)) {
90
+ e.preventDefault();
91
+ e.stopPropagation();
92
+ }
93
+ }, true);
94
+ // Right-click context menu — mailx has its own (showContextMenu) for
95
+ // specific surfaces. Default WebView menu is "Reload / Save As /
96
+ // View Source / Inspect" which doesn't belong in a desktop app.
97
+ // Individual handlers that DO want a context menu must
98
+ // `e.preventDefault()` themselves AFTER showing — this only
99
+ // suppresses the default browser one when nothing else handles.
100
+ document.addEventListener("contextmenu", (e) => {
101
+ // Allow contextmenu to bubble normally so mailx-internal handlers
102
+ // (folder-tree right-click, address-pill right-click, link
103
+ // right-click in preview) can react. We only kill it if it would
104
+ // otherwise show the browser default — i.e., no other handler
105
+ // called preventDefault.
106
+ if (!e.defaultPrevented)
107
+ e.preventDefault();
108
+ });
109
+ })();
43
110
  let baseTitle = APP_NAME;
44
111
  let lastSeenCount = 0;
45
112
  let badgeCount = 0;