emailPreviewDocument (lib/email-preview.ts)

appwrite · apps/console/src/lib/email-preview.ts · typescript · BSD-3-Clause
email

* Document for the email body preview frame. HTML bodies render exactly as sent. Plain-text bodies are escaped and wrapped so the frame shows them verbatim, the way a mail client renders a text/plain part. /

// Source: https://github.com/appwrite/appwrite | License: BSD-3-Clause | Copyright 2019 Appwrite (https://appwrite.io) and individual contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Document for the email body preview frame.
 *
 * HTML bodies render exactly as sent. Plain-text bodies are escaped and wrapped
 * so the frame shows them verbatim, the way a mail client renders a text/plain
 * part.
 */
export function emailPreviewDocument(content: string, html: boolean): string {
  if (html) return content
  const text = content
    .replace(/&/g, '&')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
  return `<!doctype html><html><head><meta charset="utf-8"><style>body{margin:16px;color:#111;background:#fff;font:14px/1.5 -apple-system,BlinkMacSys

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key