@bobfrankston/rmfmail 1.1.110 → 1.1.112

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.
@@ -928,7 +928,8 @@ function showPreviewBodyMenu(absX, absY, selectedText, sourceWindow, linkUrl, li
928
928
  break;
929
929
  }
930
930
  }
931
- } });
931
+ } }, { label: "", action: () => {
932
+ }, separator: true }, { label: "Print\u2026 (Ctrl+P)", action: () => printCurrentMessage() });
932
933
  showContextMenu(absX, absY, items);
933
934
  }
934
935
  function toggleFullscreenPreview() {
@@ -2116,6 +2117,44 @@ function popOutCurrentMessage() {
2116
2117
  }
2117
2118
  spawnDesktopPopout(currentMessage, currentAccountId);
2118
2119
  }
2120
+ function printCurrentMessage() {
2121
+ if (!currentMessage)
2122
+ return;
2123
+ const m = currentMessage;
2124
+ const fmt = (a) => a?.name ? `${a.name} <${a.address || ""}>` : a?.address || "";
2125
+ const esc = escapeHtmlLocal;
2126
+ const row = (label, value) => value ? `<div><strong>${label}:</strong> ${esc(value)}</div>` : "";
2127
+ const headerHtml = `<div style="font-family:system-ui,Segoe UI,sans-serif;font-size:11pt;border-bottom:1px solid #999;padding-bottom:8px;margin-bottom:14px;line-height:1.5;">` + row("From", fmt(m.from || {})) + row("To", (m.to || []).map(fmt).join(", ")) + (m.cc?.length ? row("Cc", m.cc.map(fmt).join(", ")) : "") + row("Subject", m.subject || "") + row("Date", m.date ? new Date(m.date).toLocaleString() : "") + `</div>`;
2128
+ const bodyHtml = m.bodyHtml ? m.bodyHtml : `<pre style="white-space:pre-wrap;word-break:break-word;font-family:system-ui,sans-serif;">${esc(m.bodyText || "")}</pre>`;
2129
+ const doc = `<!DOCTYPE html><html><head><meta charset="utf-8"><title>${esc(m.subject || "Message")}</title><style>@media print{body{margin:0;}}body{margin:16px;}img{max-width:100%;}</style></head><body>${headerHtml}${bodyHtml}</body></html>`;
2130
+ const iframe = document.createElement("iframe");
2131
+ iframe.style.cssText = "position:fixed;left:-9999px;width:1px;height:1px;border:0;";
2132
+ iframe.srcdoc = doc;
2133
+ iframe.addEventListener("load", () => {
2134
+ const win = iframe.contentWindow;
2135
+ if (!win) {
2136
+ iframe.remove();
2137
+ return;
2138
+ }
2139
+ let removed = false;
2140
+ const cleanup = () => {
2141
+ if (!removed) {
2142
+ removed = true;
2143
+ iframe.remove();
2144
+ }
2145
+ };
2146
+ win.addEventListener("afterprint", cleanup, { once: true });
2147
+ setTimeout(cleanup, 12e4);
2148
+ try {
2149
+ win.focus();
2150
+ win.print();
2151
+ } catch (e) {
2152
+ console.error("[print] failed:", e);
2153
+ cleanup();
2154
+ }
2155
+ }, { once: true });
2156
+ document.body.appendChild(iframe);
2157
+ }
2119
2158
  function spawnDesktopPopout(msg, accountId) {
2120
2159
  const wrapper = document.createElement("div");
2121
2160
  wrapper.className = "compose-overlay viewer-popout";
@@ -7224,9 +7263,9 @@ function showComposeOverlay(title = "Compose") {
7224
7263
  wrapper.className = "compose-overlay";
7225
7264
  const isSmall = window.innerWidth <= 768 || window.innerHeight <= 600;
7226
7265
  if (isSmall) {
7227
- wrapper.style.cssText = "position:fixed;inset:0;z-index:1000;display:flex;flex-direction:column;background:#fff;";
7266
+ wrapper.style.cssText = "position:fixed;inset:0;z-index:1600;display:flex;flex-direction:column;background:#fff;";
7228
7267
  } else {
7229
- wrapper.style.cssText = "position:fixed;top:48px;left:calc((100vw - min(900px,55vw)) / 2);width:min(900px,55vw);height:min(700px,70vh);z-index:1000;border-radius:8px;box-shadow:0 4px 24px rgba(0,0,0,0.3);display:flex;flex-direction:column;overflow:hidden;";
7268
+ wrapper.style.cssText = "position:fixed;top:48px;left:calc((100vw - min(900px,55vw)) / 2);width:min(900px,55vw);height:min(700px,70vh);z-index:1600;border-radius:8px;box-shadow:0 4px 24px rgba(0,0,0,0.3);display:flex;flex-direction:column;overflow:hidden;";
7230
7269
  }
7231
7270
  const titleBar = document.createElement("div");
7232
7271
  titleBar.style.cssText = "display:flex;align-items:center;justify-content:space-between;padding:4px 8px;background:#e8ecf0;border-radius:8px 8px 0 0;cursor:move;user-select:none;flex-shrink:0;";
@@ -7264,7 +7303,7 @@ function showComposeOverlay(title = "Compose") {
7264
7303
  popoutBtn.addEventListener("click", () => {
7265
7304
  if (!maximized) {
7266
7305
  savedCss = wrapper.style.cssText;
7267
- wrapper.style.cssText = "position:fixed;inset:0;z-index:1000;display:flex;flex-direction:column;background:#fff;overflow:hidden;";
7306
+ wrapper.style.cssText = "position:fixed;inset:0;z-index:1600;display:flex;flex-direction:column;background:#fff;overflow:hidden;";
7268
7307
  popoutBtn.innerHTML = RESTORE_SVG;
7269
7308
  popoutBtn.title = "Restore";
7270
7309
  maximized = true;
@@ -8693,6 +8732,14 @@ document.addEventListener("keydown", (e) => {
8693
8732
  e.preventDefault();
8694
8733
  openCompose("new");
8695
8734
  }
8735
+ if (e.ctrlKey && (e.key === "p" || e.key === "P") && !e.shiftKey && !e.altKey) {
8736
+ const t = e.target;
8737
+ const inText = t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable);
8738
+ if (!inText) {
8739
+ e.preventDefault();
8740
+ printCurrentMessage();
8741
+ }
8742
+ }
8696
8743
  if (e.ctrlKey && (e.key === "t" || e.key === "T") && !e.shiftKey && !e.altKey) {
8697
8744
  e.preventDefault();
8698
8745
  openTab({ kind: "unified" }, "All Inboxes", true);