diff --git a/web/src/components/app/campaigns/sequences/EmailContentEditor.tsx b/web/src/components/app/campaigns/sequences/EmailContentEditor.tsx index 1cd18bcf..a8e30232 100644 --- a/web/src/components/app/campaigns/sequences/EmailContentEditor.tsx +++ b/web/src/components/app/campaigns/sequences/EmailContentEditor.tsx @@ -120,6 +120,10 @@ export default function EmailContentEditor({ // notes below the editor come from it, and an author writing markup // is exactly who needs them while they write. if (tab !== "preview" && !code) return; + // Switching to Preview is a deliberate act and should feel immediate. + // Writing markup is not: the request carries the whole body, which for + // a designed email is tens of kilobytes, so it waits for a real pause. + const settle = tab === "preview" ? 250 : 800; // Responses can land out of order; only the newest request may paint. let active = true; const t = setTimeout(() => { @@ -140,7 +144,7 @@ export default function EmailContentEditor({ .catch(() => { if (active) setServerPreview(null); }); - }, 250); + }, settle); return () => { active = false; clearTimeout(t); diff --git a/web/src/components/app/unibox/EmailBody.tsx b/web/src/components/app/unibox/EmailBody.tsx index 4f1dfdf0..508d3a8b 100644 --- a/web/src/components/app/unibox/EmailBody.tsx +++ b/web/src/components/app/unibox/EmailBody.tsx @@ -50,7 +50,7 @@ const DOCUMENT_CSS = ` // designed newsletter) must not be nested inside another one: the doctype and // the
would land in the body, and the frame would preview something the // recipient will never see. Its own gets our shell instead. -const DOCUMENT_ROOT = /^\s*(?:])/i; +const DOCUMENT_ROOT = /^\s*(?:\s*)*(?:])/i; const HEAD_OPEN = /]*>/i; const HTML_OPEN = /]*>/i; diff --git a/web/src/lib/email/pastedEmail.test.ts b/web/src/lib/email/pastedEmail.test.ts index 5d4c7621..b382bb54 100644 --- a/web/src/lib/email/pastedEmail.test.ts +++ b/web/src/lib/email/pastedEmail.test.ts @@ -34,6 +34,12 @@ describe("detectPastedEmail", () => { expect(detectPastedEmail(clipboard({ "text/plain": "| Hi |