Skip to content

feat(ui-plugins): add Email Template Builder (email-template-builder) - #242

Open
ppppp2005-p wants to merge 11 commits into
zai-org:mainfrom
ppppp2005-p:feat/email-template-builder
Open

ppppp2005-p wants to merge 11 commits into
zai-org:mainfrom
ppppp2005-p:feat/email-template-builder

Conversation

@ppppp2005-p

Copy link
Copy Markdown

Plugin type (required) / 插件类型(必填)

  • UI Plugin / 是 UI 插件 — provides MCP Apps interactive pages / 提供 MCP Apps 交互页面
  • Standard plugin / 普通插件(非 UI)
  • Not applicable / 不适用

Affected plugin name(s) / 涉及的插件名称:email-template-builder (UI Plugin, new)

What / 改动内容

New community UI plugin Email Template Builder / 截图转邮件模板: email screenshot or design → MJML written by the agent → email-client-safe HTML, checked, previewed next to the design (desktop / mobile / dark), exported as HTML + plain text. Nothing is sent.

Defaults (stated in the READMEs):

  • Template language: MJML (mjml 5.4).
  • Variables: {{var}} placeholders are kept in the export for the user's email service; data.json sample values are used only for the preview.
  • Preview: offline. Remote images become placeholders, and the template's dark-mode CSS is applied (or forced inversion is simulated).
  • Sending: none.

Tools:

  • email_new: starter MJML with preheader, dark-mode styles and unsubscribe link, plus sample data and links to design images.
  • email_write: MJML and/or sample data; compiles and checks.
  • email_check.
  • email_export: .html with variables, .txt and a filled .preview.html; refused while there are errors unless forced.
  • App-only: email_state, email_text, email_design, workspace_images.

Checks:

  • MJML errors with line numbers.
  • Body width over 600 px and images wider than the body.
  • Missing mj-preview; missing prefers-color-scheme: dark styles. The color-scheme meta is injected when dark styles exist.
  • Missing alt text, local image paths (error) and http: images.
  • Empty or # links.
  • WCAG contrast below 4.5:1 for colour pairs found in the HTML.
  • No unsubscribe link (info).
  • Size: warning over 80 KB; error over 102 KB, where Gmail clips.
  • Variables without sample values.

Plain text: html-to-text after removing the preheader and styles. Links go in brackets; wordwrap is 78.

Bundle: htmlnano, typescript and undici (pulled in by mjml's optional minify / cosmiconfig / cheerio fetch paths) are stubbed, which brings the server from 15 MB to about 4 MB. Compiling works without them; minify is not used.

Panel:

  • Design and preview side by side in a sandboxed srcdoc iframe without scripts.
  • Inbox line showing subject + preheader.
  • Desktop or mobile 375 px, and a dark-mode toggle.
  • Size meter out of 102 KB and an issue list with Chinese check names.
  • Editable variable table that saves to data.json.
  • Plain-text and MJML tabs, and an export button.

Network / API / side effects: none. No API keys, no email service and nothing sent. Writes emails/<slug>/ and .email-builder/project.json. No hooks.

Third-party: mjml (MIT), html-to-text (MIT), MCP SDK / ext-apps (MIT), zod (MIT).

Tests:

  • vitest:
    • The fictional Hearth & Bean "order shipped" template compiles with 0 issues: table layout, color-scheme meta, inline fonts, about 15 KB, 11 variables.
    • The planted first draft is flagged for:
      • MJML: unknown mj-colum at line 9.
      • Width: a 680 px body and an oversize image.
      • No preheader and no dark-mode styles.
      • Image: missing alt text, a local image path and an http: image.
      • Contrast 2.0:1, and a # link.
      • No unsubscribe link.
    • A Gmail clipping error over 102 KB.
    • Variable filling with escaping; plain text with bracketed links and no hidden preheader; the contrast maths.
    • The starter template passes all checks.
    • Tool flow: new → bad draft (export refused) → final template + data → export files (variables kept in the HTML, filled in the preview, plain-text unsubscribe link) → duplicate name and unknown template errors.
  • Chrome e2e (bundled server; official AppBridge host):
    1. The user creates the template from the design.
    2. The agent writes the first draft, and the panel shows 2 errors and 9 warnings.
    3. The agent writes the final template and data; the preview matches the design and the inbox line shows the preheader.
    4. The user edits a variable, and the preview updates.
    5. Mobile (375 px) and dark mode are applied.
    6. The plain-text tab and export work.
    7. There are no console errors.
  • validate.py, build_dist.py, git diff --check and tsc pass.

A ZCode Desktop demo recording is attached in the comments. / ZCode 桌面版演示录屏见评论。

Self-check / 自查清单

  • Plugin name is unique kebab-case; new external plugin directory is external_plugins/<name>/
  • Usage category is set (productivity)
  • Plugin type and affected names are declared above
  • version 0.1.0 in both plugin.json and marketplace.json
  • README.md (EN) and README_CN.md (中文) both provided and equivalent
  • description_i18n has both en and zh-CN
  • No secrets, machine-specific paths, or private dependencies
  • Model/API/network dependencies documented
  • python3 scripts/validate.py and python3 scripts/build_dist.py pass locally
  • Exercised in ZCode Desktop (ZCode 4.0.0, macOS arm64: installed from a local marketplace, installed from a local marketplace, email_new from a design image → panel → email_write MJML + data.json (16 variables) → email_check: no errors, 19 KB → email_export HTML, preview with sample data, plain text; demo video in the comments; demo video in the comments)

@ppppp2005-p

Copy link
Copy Markdown
Author

ZCode desktop demo (ZCode 4.0.0, macOS arm64)

email-template-builder-demo.mp4

Flow shown:

  1. Installed email-template-builder from a local marketplace built from this PR's branch.
  2. Asked ZCode to build an "order shipped" email template order-shipped from the design image email/order-shipped-design.png: write the MJML and sample data, export HTML, and report the files and compatibility notes.
  3. The agent called email_new, which opened the side panel (size meter against Gmail's 102 KB clipping limit, error badge, export button, preview / plain text / MJML tabs, desktop / phone / dark mode, "compare with design"). It wrote emails/order-shipped/order-shipped.mjml and data.json (16 variables such as {{first_name}}, {{order_number}}, item rows) with email_write, email_check reported no errors (19.0 KB), and email_export wrote export/order-shipped.html, order-shipped.preview.html (sample data filled in) and order-shipped.txt.
  4. The agent's compatibility notes: dark mode follows the client in Apple Mail but Gmail/Outlook may recolour; Outlook desktop on Windows squares the card corners and doesn't show the page background outside 600 px; web-safe fonts only (Georgia, Helvetica/Arial). The last card shows the design next to the exported preview (product images are placeholder URLs, shown as broken images in an offline thumbnail).

演示流程:本地 marketplace 安装 → email_new 打开面板 → email_write 写 MJML + 示例数据(16 个变量)→ email_check 无错误(19 KB)→ email_export 导出 HTML、带示例数据的预览和纯文本,并给出兼容性提示。

@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants