Skip to content

feat(editor-integration): preview the real beehiiv email in the post editor - #195

Draft
phpbits wants to merge 9 commits into
mainfrom
feature/19813218-email-preview
Draft

phpbits wants to merge 9 commits into
mainfrom
feature/19813218-email-preview

Conversation

@phpbits

@phpbits phpbits commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an in-editor preview of the real beehiiv email for a saved post (Teamwork 19813218, Brief 862095db).

  • Preview email button in the beehiiv sidebar (only while "Send to newsletter" is on). It opens a WordPress modal with beehiiv's rendered email in a sandboxed, inert frame, with Desktop / Mobile views (448px / 1280px max), a browser-window overlay on desktop, and From / Subject / Preview Text.
  • Each click syncs a linked beehiiv draft from the saved post (created on first preview, updated in place, recreated when the publication or template changes), then fetches the rendered email. The newsletter title and subtitle override the subject and preview text.
  • The editor polls with a fetch-only call while beehiiv prepares a new email, so no PHP request is held open.
  • Drafts survive status changes, are removed when "Send to newsletter" is turned off or the post is deleted, and are replaced by a real send when the post is published or scheduled. A per-post lock stops two simultaneous previews from creating two drafts.
  • New route POST beehiiv/v1/email-preview (edit + publish rights, enforced server-side).

Not included / known gaps

  • The linked-status notice copy ("edits no longer sync") is not built (one E2E test is test.fixme for it).
  • Confirming the previewed draft in place on Publish is not built; publishing replaces the draft with a normal send (new beehiiv post ID).
  • Not verified against a live beehiiv account: whether beehiiv renders a draft's email, plan gating, and read access for the stored authorization (data.content.free.email shape is taken from the docs).
  • From shows the publication name only; beehiiv does not expose the sending address.

Test plan

  • vendor/bin/phpcs, npm run lint:js, npm run lint:css, npm run build clean
  • PHPUnit: 111 tests pass in wp-env
  • Playwright email-preview.spec.js passes (AC-004 untestable without a live account; one AC-010 notice test fixme)
  • Manual check in the editor against a Max/Enterprise publication (preview renders, Desktop/Mobile, title/subtitle overrides, publish replaces the draft)

…ost in the editor

Adds a Preview email button and modal (desktop and mobile views, from, subject and
preview text, sandboxed inert frame), a REST route that syncs a linked beehiiv draft
from the saved post and fetches the rendered email, and the draft lifecycle it needs:
created on first preview, updated in place, recreated when the publication or template
changes, kept across status changes, removed when Send to newsletter is turned off or
the post is deleted.
…t read, and fix the preview E2E expectations
…rge stale locks, memoize the inert email, and cover the new paths
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.

1 participant