@bobfrankston/mailx 1.0.355 → 1.0.360
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
|
@@ -1178,6 +1178,30 @@ window.addEventListener("message", (e) => {
|
|
|
1178
1178
|
})();
|
|
1179
1179
|
return;
|
|
1180
1180
|
}
|
|
1181
|
+
// Generic IPC relay: the iframe's api-client routes every IPC call through
|
|
1182
|
+
// postMessage when it's running in a child frame. Same reason as the
|
|
1183
|
+
// compose-send relay — sendMessage wasn't the only method the iframe's
|
|
1184
|
+
// bridge dropped; saveDraft hit the same wall ("Draft save failed: mailxapi
|
|
1185
|
+
// timeout"). This handler invokes the named method on THIS window's
|
|
1186
|
+
// mailxapi and posts the result back to the iframe.
|
|
1187
|
+
if (e.data?.type === "mailx-ipc" && e.data.id && e.data.method) {
|
|
1188
|
+
const src = e.source;
|
|
1189
|
+
const { id, method, args } = e.data;
|
|
1190
|
+
const bridge = window.mailxapi;
|
|
1191
|
+
const fn = bridge?.[method];
|
|
1192
|
+
if (typeof fn !== "function") {
|
|
1193
|
+
src?.postMessage({ type: "mailx-ipc-result", id, ok: false, error: `parent bridge has no method "${method}"` }, "*");
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
try {
|
|
1197
|
+
const result = fn.apply(bridge, args || []);
|
|
1198
|
+
Promise.resolve(result).then((value) => src?.postMessage({ type: "mailx-ipc-result", id, ok: true, result: value }, "*"), (err) => src?.postMessage({ type: "mailx-ipc-result", id, ok: false, error: err?.message || String(err) }, "*"));
|
|
1199
|
+
}
|
|
1200
|
+
catch (err) {
|
|
1201
|
+
src?.postMessage({ type: "mailx-ipc-result", id, ok: false, error: err?.message || String(err) }, "*");
|
|
1202
|
+
}
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1181
1205
|
if (e.data?.type === "openLink" && e.data.url) {
|
|
1182
1206
|
window.open(e.data.url, "_blank", "noopener,noreferrer");
|
|
1183
1207
|
}
|
package/client/compose/editor.js
CHANGED
|
@@ -220,10 +220,24 @@ function createQuillEditor(container) {
|
|
|
220
220
|
document.querySelectorAll(".ql-toolbar button, .ql-toolbar select, .ql-toolbar .ql-picker-label").forEach(el => el.setAttribute("tabindex", "-1"));
|
|
221
221
|
// Native spell-check: WebView2 / Chromium underlines misspellings and the
|
|
222
222
|
// right-click menu offers "Add to dictionary". Quill clears spellcheck on
|
|
223
|
-
// its root by default
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
// its root by default AND may re-clear it asynchronously as part of its
|
|
224
|
+
// setup (user-reported "spell-check broken again" with the one-shot set).
|
|
225
|
+
// Set once now, again after the frame flushes so post-init clears can't
|
|
226
|
+
// win, and install a MutationObserver to re-assert if anything later
|
|
227
|
+
// strips the attribute. Cheap — fires at most on each clear.
|
|
228
|
+
const applySpellcheck = () => {
|
|
229
|
+
if (q.root.getAttribute("spellcheck") !== "true")
|
|
230
|
+
q.root.setAttribute("spellcheck", "true");
|
|
231
|
+
if (q.root.getAttribute("autocorrect") !== "on")
|
|
232
|
+
q.root.setAttribute("autocorrect", "on");
|
|
233
|
+
if (q.root.getAttribute("autocapitalize") !== "on")
|
|
234
|
+
q.root.setAttribute("autocapitalize", "on");
|
|
235
|
+
};
|
|
236
|
+
applySpellcheck();
|
|
237
|
+
requestAnimationFrame(applySpellcheck);
|
|
238
|
+
setTimeout(applySpellcheck, 100);
|
|
239
|
+
const spellObs = new MutationObserver(() => applySpellcheck());
|
|
240
|
+
spellObs.observe(q.root, { attributes: true, attributeFilter: ["spellcheck", "autocorrect", "autocapitalize"] });
|
|
227
241
|
// Toolbar link button: open our modal instead of Quill's built-in URL prompt.
|
|
228
242
|
const toolbar = q.getModule("toolbar");
|
|
229
243
|
toolbar?.addHandler("link", function () {
|
|
@@ -288,17 +302,30 @@ function createQuillEditor(container) {
|
|
|
288
302
|
}
|
|
289
303
|
catch { /* fall through to native menu */ }
|
|
290
304
|
});
|
|
305
|
+
// IMPORTANT: register on the capture phase AND use stopImmediatePropagation
|
|
306
|
+
// when we handle the paste ourselves. Quill 2.x's clipboard module attaches
|
|
307
|
+
// its own listener on the same root element; preventDefault only stops the
|
|
308
|
+
// browser's default contenteditable insertion, NOT Quill's parallel listener.
|
|
309
|
+
// Without stopImmediatePropagation the two handlers fire independently and
|
|
310
|
+
// both insert — user sees the URL twice. Capture phase guarantees we run
|
|
311
|
+
// before Quill so stopImmediatePropagation actually blocks it.
|
|
291
312
|
q.root.addEventListener("paste", (e) => {
|
|
292
313
|
const cb = e.clipboardData;
|
|
293
314
|
if (!cb)
|
|
294
315
|
return;
|
|
316
|
+
// Helper: call when we've handled the paste ourselves. Stops Quill's
|
|
317
|
+
// own listener from also processing the same event.
|
|
318
|
+
const consume = () => {
|
|
319
|
+
e.preventDefault();
|
|
320
|
+
e.stopImmediatePropagation();
|
|
321
|
+
};
|
|
295
322
|
// Q3: image-on-clipboard → inline as data: URL.
|
|
296
323
|
for (const item of Array.from(cb.items)) {
|
|
297
324
|
if (item.kind === "file" && item.type.startsWith("image/")) {
|
|
298
325
|
const file = item.getAsFile();
|
|
299
326
|
if (!file)
|
|
300
327
|
continue;
|
|
301
|
-
|
|
328
|
+
consume();
|
|
302
329
|
const reader = new FileReader();
|
|
303
330
|
reader.onload = () => {
|
|
304
331
|
const dataUrl = String(reader.result || "");
|
|
@@ -337,7 +364,7 @@ function createQuillEditor(container) {
|
|
|
337
364
|
const href = a.getAttribute("href") || "";
|
|
338
365
|
const text = (a.textContent || "").trim();
|
|
339
366
|
if (href && text) {
|
|
340
|
-
|
|
367
|
+
consume();
|
|
341
368
|
const range = q.getSelection(true);
|
|
342
369
|
if (!range)
|
|
343
370
|
return;
|
|
@@ -350,12 +377,35 @@ function createQuillEditor(container) {
|
|
|
350
377
|
return;
|
|
351
378
|
}
|
|
352
379
|
}
|
|
380
|
+
// Single text-node wrapping the URL — common when copying from
|
|
381
|
+
// browser address bar (Chrome ships text/html as
|
|
382
|
+
// `<meta><span>URL</span>` alongside text/plain). Fall through
|
|
383
|
+
// to the plain-URL path below instead of letting Quill insert
|
|
384
|
+
// the bare URL text AND our handler insert it linked — which
|
|
385
|
+
// is exactly the double-paste the user reported.
|
|
386
|
+
const textOnly = (root.textContent || "").trim();
|
|
387
|
+
if (textOnly && looksLikeUrl(textOnly) && !root.querySelector("a")) {
|
|
388
|
+
consume();
|
|
389
|
+
const range = q.getSelection(true);
|
|
390
|
+
if (!range)
|
|
391
|
+
return;
|
|
392
|
+
const url = normalizeUrl(textOnly);
|
|
393
|
+
if (range.length > 0) {
|
|
394
|
+
q.formatText(range.index, range.length, "link", url);
|
|
395
|
+
q.setSelection(range.index + range.length, 0);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
q.insertText(range.index, textOnly, { link: url });
|
|
399
|
+
q.setSelection(range.index + textOnly.length, 0);
|
|
400
|
+
}
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
353
403
|
}
|
|
354
404
|
catch { /* fall through to Quill default */ }
|
|
355
|
-
return; // Quill handles richer HTML clipboard
|
|
405
|
+
return; // Quill handles richer HTML clipboard (no consume → Quill runs)
|
|
356
406
|
}
|
|
357
407
|
if (plain && looksLikeUrl(plain)) {
|
|
358
|
-
|
|
408
|
+
consume();
|
|
359
409
|
const range = q.getSelection(true);
|
|
360
410
|
if (!range)
|
|
361
411
|
return;
|
|
@@ -370,7 +420,7 @@ function createQuillEditor(container) {
|
|
|
370
420
|
q.setSelection(range.index + plain.trim().length, 0);
|
|
371
421
|
}
|
|
372
422
|
}
|
|
373
|
-
});
|
|
423
|
+
}, true); // capture=true — run before Quill's own paste listener
|
|
374
424
|
// Hover preview: show the target URL in a floating tooltip when the
|
|
375
425
|
// pointer is over a link. Built on top of native mouseover/mouseout
|
|
376
426
|
// rather than Quill's ql-tooltip (which is keyboard-triggered).
|
package/client/lib/api-client.js
CHANGED
|
@@ -12,7 +12,76 @@ function getIpc() {
|
|
|
12
12
|
return window.parent.mailxapi;
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
+
/** Build a proxy bridge that forwards every method call to the parent window
|
|
16
|
+
* via postMessage. Used when the compose iframe's own attempt to reach
|
|
17
|
+
* msger's IPC silently drops messages — empirically, `sendMessage` and
|
|
18
|
+
* `saveDraft` both hit this (user-visible: "Sending…" spinner forever;
|
|
19
|
+
* "Draft save failed: mailxapi timeout"). The main window's bridge is
|
|
20
|
+
* provably fine, so the iframe routes through it. */
|
|
21
|
+
function buildRelayBridge() {
|
|
22
|
+
const pending = new Map();
|
|
23
|
+
window.addEventListener("message", (ev) => {
|
|
24
|
+
if (!ev.data || ev.data.type !== "mailx-ipc-result" || !ev.data.id)
|
|
25
|
+
return;
|
|
26
|
+
const entry = pending.get(ev.data.id);
|
|
27
|
+
if (!entry)
|
|
28
|
+
return;
|
|
29
|
+
pending.delete(ev.data.id);
|
|
30
|
+
clearTimeout(entry.timer);
|
|
31
|
+
if (ev.data.ok)
|
|
32
|
+
entry.resolve(ev.data.result);
|
|
33
|
+
else
|
|
34
|
+
entry.reject(new Error(ev.data.error || "parent-relay ipc error"));
|
|
35
|
+
});
|
|
36
|
+
const call = (method, args) => {
|
|
37
|
+
const id = `ipc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const timer = setTimeout(() => {
|
|
40
|
+
pending.delete(id);
|
|
41
|
+
reject(new Error(`parent-relay timeout: ${method}`));
|
|
42
|
+
}, 120000);
|
|
43
|
+
pending.set(id, { resolve, reject, timer });
|
|
44
|
+
try {
|
|
45
|
+
window.parent.postMessage({ type: "mailx-ipc", id, method, args }, "*");
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
pending.delete(id);
|
|
50
|
+
reject(e);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
// Proxy: any property access returns a function that forwards to parent.
|
|
55
|
+
// `isApp` / `platform` / other non-function reads return sensible defaults
|
|
56
|
+
// so existing getIpc-style checks still work.
|
|
57
|
+
return new Proxy({}, {
|
|
58
|
+
get(_t, prop) {
|
|
59
|
+
if (prop === "isApp")
|
|
60
|
+
return true;
|
|
61
|
+
if (prop === "platform")
|
|
62
|
+
return window.parent?.mailxapi?.platform || "webview2";
|
|
63
|
+
if (prop === "onEvent") {
|
|
64
|
+
// Event subscription can't be relayed simply — iframes that need
|
|
65
|
+
// events are rare. Fall back to direct parent bridge for onEvent
|
|
66
|
+
// since the subscription path doesn't hit the broken send path.
|
|
67
|
+
return (handler) => window.parent?.mailxapi?.onEvent?.(handler);
|
|
68
|
+
}
|
|
69
|
+
return (...args) => call(prop, args);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
let cachedRelayBridge = null;
|
|
15
74
|
function ipc() {
|
|
75
|
+
// Direct bridge is fine for the top window (main mailx app). The iframe
|
|
76
|
+
// (compose) can't trust its own bridge resolution because msger-routed
|
|
77
|
+
// sendMessage / saveDraft IPCs disappear without trace. So when we're in
|
|
78
|
+
// a child frame with a parent bridge, go through the parent.
|
|
79
|
+
const inIframe = window.parent && window.parent !== window;
|
|
80
|
+
if (inIframe && window.parent?.mailxapi?.isApp) {
|
|
81
|
+
if (!cachedRelayBridge)
|
|
82
|
+
cachedRelayBridge = buildRelayBridge();
|
|
83
|
+
return cachedRelayBridge;
|
|
84
|
+
}
|
|
16
85
|
const bridge = getIpc();
|
|
17
86
|
if (!bridge)
|
|
18
87
|
throw new Error("IPC bridge not available");
|
package/package.json
CHANGED
|
@@ -102,7 +102,7 @@ export class MailxService {
|
|
|
102
102
|
for (const cfg of cfgs) {
|
|
103
103
|
const a = dbAccounts.find(d => d.id === cfg.id);
|
|
104
104
|
if (a)
|
|
105
|
-
ordered.push({ ...a, label: cfg.label, defaultSend: cfg.defaultSend || false, identityDomains: cfg.identityDomains || []
|
|
105
|
+
ordered.push({ ...a, label: cfg.label, defaultSend: cfg.defaultSend || false, identityDomains: cfg.identityDomains || [] });
|
|
106
106
|
}
|
|
107
107
|
// Append any DB accounts not in settings
|
|
108
108
|
for (const a of dbAccounts) {
|
|
@@ -307,43 +307,36 @@ const PROVIDERS = {
|
|
|
307
307
|
label: "Gmail",
|
|
308
308
|
imap: { host: "imap.gmail.com", port: 993, tls: true, auth: "oauth2" },
|
|
309
309
|
smtp: { host: "smtp.gmail.com", port: 587, tls: true, auth: "oauth2" },
|
|
310
|
-
spam: "SPAM", // Gmail labels, mailx tree shows as "SPAM"
|
|
311
310
|
},
|
|
312
311
|
"googlemail.com": {
|
|
313
312
|
label: "Gmail",
|
|
314
313
|
imap: { host: "imap.gmail.com", port: 993, tls: true, auth: "oauth2" },
|
|
315
314
|
smtp: { host: "smtp.gmail.com", port: 587, tls: true, auth: "oauth2" },
|
|
316
|
-
spam: "SPAM",
|
|
317
315
|
},
|
|
318
316
|
"outlook.com": {
|
|
319
317
|
label: "Outlook",
|
|
320
318
|
imap: { host: "outlook.office365.com", port: 993, tls: true, auth: "oauth2" },
|
|
321
319
|
smtp: { host: "smtp.office365.com", port: 587, tls: true, auth: "oauth2" },
|
|
322
|
-
spam: "Junk Email",
|
|
323
320
|
},
|
|
324
321
|
"hotmail.com": {
|
|
325
322
|
label: "Hotmail",
|
|
326
323
|
imap: { host: "outlook.office365.com", port: 993, tls: true, auth: "oauth2" },
|
|
327
324
|
smtp: { host: "smtp.office365.com", port: 587, tls: true, auth: "oauth2" },
|
|
328
|
-
spam: "Junk Email",
|
|
329
325
|
},
|
|
330
326
|
"yahoo.com": {
|
|
331
327
|
label: "Yahoo",
|
|
332
328
|
imap: { host: "imap.mail.yahoo.com", port: 993, tls: true, auth: "password" },
|
|
333
329
|
smtp: { host: "smtp.mail.yahoo.com", port: 587, tls: true, auth: "password" },
|
|
334
|
-
spam: "Bulk Mail",
|
|
335
330
|
},
|
|
336
331
|
"aol.com": {
|
|
337
332
|
label: "AOL",
|
|
338
333
|
imap: { host: "imap.aol.com", port: 993, tls: true, auth: "password" },
|
|
339
334
|
smtp: { host: "smtp.aol.com", port: 587, tls: true, auth: "password" },
|
|
340
|
-
spam: "Bulk Mail",
|
|
341
335
|
},
|
|
342
336
|
"icloud.com": {
|
|
343
337
|
label: "iCloud",
|
|
344
338
|
imap: { host: "imap.mail.me.com", port: 993, tls: true, auth: "password" },
|
|
345
339
|
smtp: { host: "smtp.mail.me.com", port: 587, tls: true, auth: "password" },
|
|
346
|
-
spam: "Junk",
|
|
347
340
|
},
|
|
348
341
|
};
|
|
349
342
|
/** Fill in provider defaults for an account based on email domain */
|
|
@@ -388,13 +381,10 @@ function normalizeAccount(acct, globalName) {
|
|
|
388
381
|
relayDomains: acct.relayDomains,
|
|
389
382
|
deliveredToPrefix: acct.deliveredToPrefix,
|
|
390
383
|
identityDomains: acct.identityDomains,
|
|
391
|
-
//
|
|
392
|
-
// the
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
// that had it configured. `acct.spam` first so a user-set value on
|
|
396
|
-
// a recognized provider still overrides the default.
|
|
397
|
-
spam: acct.spam !== undefined ? acct.spam : provider?.spam,
|
|
384
|
+
// `spam` passthrough retired 2026-04-22 — markAsSpamMessages now finds
|
|
385
|
+
// the junk folder via `specialUse === "junk"` on the DB folder record
|
|
386
|
+
// (populated by mailx-imap from iflow's getSpecialFolders()). Authoritative
|
|
387
|
+
// per-server info beats per-domain guesses.
|
|
398
388
|
// `signature` is on AccountConfig in mailx-types but the workspace
|
|
399
389
|
// build order sometimes leaves a stale .d.ts for type-check; using
|
|
400
390
|
// `as any` is the minimum-blast-radius way to add the field without
|