@bobfrankston/rmfmail 1.2.193 → 1.2.195
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/compose/compose.bundle.js +38 -5
- package/client/compose/compose.bundle.js.map +2 -2
- package/client/compose/compose.js +13 -3
- package/client/compose/compose.js.map +1 -1
- package/client/compose/compose.ts +12 -3
- package/client/compose/editor.js +14 -1
- package/client/compose/editor.js.map +1 -1
- package/client/compose/editor.ts +14 -1
- package/client/compose/paste-markdown.js +0 -0
- package/client/compose/paste-markdown.js.map +1 -1
- package/client/compose/paste-markdown.ts +0 -0
- package/client/package.json +1 -1
- package/package.json +1 -1
- /package/packages/mailx-imap/{node_modules.npmglobalize-stash-46388 → node_modules.npmglobalize-stash-72196}/.package-lock.json +0 -0
|
@@ -3568,6 +3568,23 @@ function markdownToEmailHtml(md) {
|
|
|
3568
3568
|
}
|
|
3569
3569
|
return out.join("\n");
|
|
3570
3570
|
}
|
|
3571
|
+
function looksLikeHtml(text) {
|
|
3572
|
+
if (!text || text.length > 5e5)
|
|
3573
|
+
return false;
|
|
3574
|
+
const t = text.trim();
|
|
3575
|
+
if (!t.startsWith("<"))
|
|
3576
|
+
return false;
|
|
3577
|
+
if (!/^<(!doctype|html|head|body|div|p|table|ul|ol|li|h[1-6]|blockquote|section|article|header|footer|span|b|i|strong|em|a|img|br|hr|pre|code|font|center)\b/i.test(t))
|
|
3578
|
+
return false;
|
|
3579
|
+
return /<\/[a-z][a-z0-9]*\s*>/i.test(t) || /^<(img|br|hr|!doctype)\b/i.test(t);
|
|
3580
|
+
}
|
|
3581
|
+
function sanitizeHtmlSource(html) {
|
|
3582
|
+
let t = html;
|
|
3583
|
+
const bm = t.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
|
|
3584
|
+
if (bm)
|
|
3585
|
+
t = bm[1];
|
|
3586
|
+
return t.replace(/<script\b[\s\S]*?<\/script\s*>/gi, "").replace(/<style\b[\s\S]*?<\/style\s*>/gi, "").replace(/\son[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s(href|src)\s*=\s*(["']?)\s*javascript:[^"'\s>]*\2/gi, "");
|
|
3587
|
+
}
|
|
3571
3588
|
function wireMarkdownPaste(target, insertHtml) {
|
|
3572
3589
|
target.addEventListener("paste", (e) => {
|
|
3573
3590
|
try {
|
|
@@ -3579,11 +3596,18 @@ function wireMarkdownPaste(target, insertHtml) {
|
|
|
3579
3596
|
if (Array.from(cb.items).some((it) => it.kind === "file"))
|
|
3580
3597
|
return;
|
|
3581
3598
|
const plain = cb.getData("text/plain");
|
|
3582
|
-
if (!plain
|
|
3599
|
+
if (!plain)
|
|
3600
|
+
return;
|
|
3601
|
+
let converted = null;
|
|
3602
|
+
if (looksLikeHtml(plain))
|
|
3603
|
+
converted = sanitizeHtmlSource(plain);
|
|
3604
|
+
else if (looksLikeMarkdown(plain))
|
|
3605
|
+
converted = markdownToEmailHtml(plain);
|
|
3606
|
+
if (converted === null)
|
|
3583
3607
|
return;
|
|
3584
3608
|
e.preventDefault();
|
|
3585
3609
|
e.stopImmediatePropagation();
|
|
3586
|
-
insertHtml(
|
|
3610
|
+
insertHtml(converted);
|
|
3587
3611
|
} catch {
|
|
3588
3612
|
}
|
|
3589
3613
|
}, true);
|
|
@@ -4035,6 +4059,14 @@ function createQuillEditor(container2) {
|
|
|
4035
4059
|
}
|
|
4036
4060
|
return;
|
|
4037
4061
|
}
|
|
4062
|
+
if (plain && looksLikeHtml(plain)) {
|
|
4063
|
+
consume();
|
|
4064
|
+
const range = q.getSelection(true) || { index: q.getLength(), length: 0 };
|
|
4065
|
+
if (range.length > 0)
|
|
4066
|
+
q.deleteText(range.index, range.length);
|
|
4067
|
+
q.clipboard.dangerouslyPasteHTML(range.index, sanitizeHtmlSource(plain));
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4038
4070
|
if (plain && looksLikeMarkdown(plain)) {
|
|
4039
4071
|
consume();
|
|
4040
4072
|
const range = q.getSelection(true) || { index: q.getLength(), length: 0 };
|
|
@@ -6150,8 +6182,9 @@ document.getElementById("btn-edit-in-word")?.addEventListener("click", async ()
|
|
|
6150
6182
|
return;
|
|
6151
6183
|
}
|
|
6152
6184
|
const label = result.opener === "word" ? "Word" : result.opener === "libreoffice" ? "LibreOffice" : "your default editor";
|
|
6153
|
-
|
|
6154
|
-
|
|
6185
|
+
const isDocx = /\.docx$/i.test(result.path || "");
|
|
6186
|
+
showDraftStatus(`Editing in ${label} \u2014 Ctrl+S there and the message updates here automatically.`, false);
|
|
6187
|
+
if (!isDocx) showExternalEditHint(label);
|
|
6155
6188
|
} catch (e) {
|
|
6156
6189
|
showDraftStatus(`Edit-in-Word failed: ${e?.message || e}`, true);
|
|
6157
6190
|
}
|
|
@@ -6257,7 +6290,7 @@ function showExternalEditHint(editorLabel) {
|
|
|
6257
6290
|
<div style="font-weight:600;font-size:16px;margin-bottom:10px;">Editing in ${escapeHtml(editorLabel)}</div>
|
|
6258
6291
|
<ol style="margin:0 0 12px 18px;padding:0;">
|
|
6259
6292
|
<li>Edit your message in <b>${escapeHtml(editorLabel)}</b>.</li>
|
|
6260
|
-
<li>Save (<b>Ctrl+S</b>).
|
|
6293
|
+
<li>Save (<b>Ctrl+S</b>). Choose <b>"Web Page, Filtered (.htm)"</b> if asked for a format \u2014 keep the same filename.</li>
|
|
6261
6294
|
<li>Switch back to this window (<b>Alt+Tab</b>). The body will reload here.</li>
|
|
6262
6295
|
<li>Click <b>Send</b> in this window when ready.</li>
|
|
6263
6296
|
</ol>
|