drupal-campaign-easy-email
v0.1.0
Published
Self-contained browser bundle of the easy-email editor (easy-email-core/editor/extensions + React 18 + mjml-browser) exposing a stable window.CampaignEasyEmail mount API.
Readme
drupal-campaign-easy-email
A self-contained browser bundle of the
easy-email block-based email editor.
It composes easy-email-core, easy-email-editor and easy-email-extensions
(with React 18, react-final-form, mjml-browser and all required CSS) into a
single IIFE file plus one stylesheet, and exposes a small stable API on
window.CampaignEasyEmail. The host page loads nothing else — no React, no
CDN assets.
This directory is the source of the published package. Built output under
dist/ is never committed; the maintainer builds and publishes it (see
below). Consumers only ever download the published npm tarball — they never
need Node.js or this directory.
API
Load both built files in a plain page:
<link rel="stylesheet" href="campaign-easy-email.min.css">
<script src="campaign-easy-email.min.js"></script>Then:
const instance = window.CampaignEasyEmail.mount(container, {
// Optional: an easy-email document (page block JSON). A default empty
// page document is created when omitted.
document: pageJson,
// Optional: called with the current document object on every document
// mutation made in the editor (and after loadDocument()).
onChange(doc) {},
// Optional: CSS height of the editor chrome. Default '600px'.
height: '600px',
});
instance.getDocument(); // Current document (easy-email page block JSON).
instance.getHtml(); // HTML of the *current* document, rendered via
// easy-email-core JsonToMjml + mjml-browser.
// Returns '' (and logs) on render failure.
instance.loadDocument(doc); // Replace the editor content (null/undefined
// loads a fresh default page document).
instance.unmount(); // Tear the editor down.
window.CampaignEasyEmail.createDefaultDocument(); // A fresh empty page doc.
window.CampaignEasyEmail.version; // Wrapper version string.Calling mount() again on the same container replaces the existing editor
and does not error.
Pinned versions
All dependencies are pinned exact; upgrades are deliberate maintainer acts (bump, rebuild, republish, then update the consuming pin).
| Package | Version | | --- | --- | | easy-email-core | 4.17.1 | | easy-email-editor | 4.17.1 | | easy-email-extensions | 4.17.1 | | react | 18.2.0 | | react-dom | 18.2.0 | | react-final-form | 6.5.9 | | mjml-browser | 4.18.0 | | @arco-themes/react-easy-email-theme | 0.0.3 | | vite (dev) | 7.3.6 | | @vitejs/plugin-react (dev) | 5.2.0 | | playwright-core (dev) | 1.62.1 |
The easy-email OSS packages support React 18 only (React 19 is reserved for the commercial Easy Email Pro); React 18.2 is bundled deliberately and never leaks into the host page.
Build
npm ci
npm run buildemits:
| File | Size (built with the pins above) |
| --- | --- |
| dist/campaign-easy-email.min.js | 3.1 MB (940 kB gzip) |
| dist/campaign-easy-email.min.css | 513 kB (97 kB gzip) |
The size is accepted: the bundle carries React, the full editor and mjml-browser, and is only ever loaded on composition forms.
Verify
npm run checkdrives the built bundle in headless Chrome (playwright-core, chrome
channel — requires a locally installed Chrome) and asserts the API contract:
global defined, default mount produces a valid page document, getHtml()
returns HTML containing <body, loadDocument() round-trips, onChange
fires, a second mount() does not error, and the mounted editor performs no
network requests for its own assets. A manual test page is at
dev/index.html (open it in a browser after building).
Self-containment notes
- All editor chrome assets (icon fonts, arco theme, placeholder images) are
bundled or inlined as
data:URIs. The upstream demo-site image defaults (easy-email-m-ryan.vercel.app) are overridden with an inline placeholder at startup via easy-email-core'sImageManager. grep -E "https?://" dist/*.jsstill matches string constants: XML namespaces, React error-decoder links, mjml's Google-font map and social share URL templates, and upstream default-content URLs. None of them are loaded by the editor at runtime (verified bynpm run check).- Exception: the preview iframe (and rendered email HTML) may contain
@import url(https://fonts.googleapis.com/...)lines — that is mjml's standard web-font handling for its default font stack and belongs to the email content, not to the editor's own assets.
Publish (maintainer only)
npm ci
npm run build
npm run check
npm publishThe package is unscoped, so it is public by default and needs no
--access public. Publishing requires npm rights on the
drupal-campaign-easy-email name. Only dist/ is published (files in
package.json). After publishing, update the version pin recorded in the
consuming campaign_easy_email module's libraries.yml.
License
MIT (see LICENSE) for the wrapper itself. The bundle embeds upstream MIT
packages — easy-email-core/editor/extensions, React, react-dom,
react-final-form, mjml-browser, @arco-design/web-react and their transitive
dependencies — which keep their own licenses.
