email-builder-online 4.1.6 → 4.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dist/index.cjs +270 -270
- package/dist/index.mjs +44099 -44097
- package/dist/standalone.js +327 -327
- package/dist/standalone.mjs +53375 -53373
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -777,15 +777,49 @@ interface AIFeatureRequest {
|
|
|
777
777
|
|
|
778
778
|
## Block Schemas & Validation (`@eb/document-core`)
|
|
779
779
|
|
|
780
|
-
All block schemas, the document-level schema, and the validation logic are exported from the `@eb/document-core` package.
|
|
780
|
+
All block schemas, the document-level schema, and the validation logic are exported from the `@eb/document-core` package. The package ships a **node-safe entry** with **zero browser dependencies** (only `zod` is required) — designed for MCP servers, backend scripts, and CLI tools that validate documents in a plain Node.js process.
|
|
781
|
+
|
|
782
|
+
### Two entry points
|
|
783
|
+
|
|
784
|
+
| Entry | Import specifier | Contents | Deps |
|
|
785
|
+
|---|---|---|---|
|
|
786
|
+
| Default (editor) | `@eb/document-core` | Everything, incl. React-coupled builders (`buildBlockComponent`) | React + Zod |
|
|
787
|
+
| **Node-safe** | `@eb/document-core/node` | Schemas, validation, theme schemas, resolvers — **no React** | Zod only |
|
|
788
|
+
|
|
789
|
+
> Server-side consumers (MCP, backend, CLI) must import from **`@eb/document-core/node`** so they never pull in React.
|
|
781
790
|
|
|
782
791
|
### Installation
|
|
783
792
|
|
|
793
|
+
**Inside this monorepo** (e.g. `@eb/backend`) — workspace protocol:
|
|
794
|
+
|
|
784
795
|
```bash
|
|
785
|
-
# Within the monorepo (workspace protocol)
|
|
786
796
|
pnpm add @eb/document-core
|
|
787
797
|
```
|
|
788
798
|
|
|
799
|
+
**From an external project** (e.g. the standalone MCP repo) — the package is not
|
|
800
|
+
published, so consume a **vendored** build. Generate it from the monorepo:
|
|
801
|
+
|
|
802
|
+
```bash
|
|
803
|
+
cd packages/document-core
|
|
804
|
+
pnpm vendor # bundles the node-safe entry → vendor/document-core + a .tgz tarball
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
Copy `vendor/document-core` (or the `eb-document-core-<version>.tgz` tarball) into
|
|
808
|
+
the consumer repo and reference it via `file:`:
|
|
809
|
+
|
|
810
|
+
```jsonc
|
|
811
|
+
// consumer package.json
|
|
812
|
+
{
|
|
813
|
+
"dependencies": {
|
|
814
|
+
"@eb/document-core": "file:./vendor/document-core",
|
|
815
|
+
"zod": "^3.22.4" // peer dep — provided by the consumer
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
The vendored bundle ships ESM + CJS + `.d.ts` and type-checks **without
|
|
821
|
+
`@types/react`**.
|
|
822
|
+
|
|
789
823
|
### Schemas
|
|
790
824
|
|
|
791
825
|
```ts
|
|
@@ -823,7 +857,7 @@ import {
|
|
|
823
857
|
### Validation
|
|
824
858
|
|
|
825
859
|
```ts
|
|
826
|
-
import { validateDocument, type ValidationResult } from '@eb/document-core';
|
|
860
|
+
import { validateDocument, type ValidationResult } from '@eb/document-core/node';
|
|
827
861
|
|
|
828
862
|
const result: ValidationResult = validateDocument(jsonDocument);
|
|
829
863
|
|
|
@@ -891,6 +925,98 @@ The document is a flat `Record<blockId, TEditorBlock>`:
|
|
|
891
925
|
| `Spacer` | Vertical spacing |
|
|
892
926
|
| `SocialMedia` | Social media icon links |
|
|
893
927
|
|
|
928
|
+
## Server-side HTML Rendering (`@eb/email-builder`)
|
|
929
|
+
|
|
930
|
+
In the browser, `EmailBuilderRef.getHtml()` renders the current document to
|
|
931
|
+
HTML. To do the same **outside the editor** — in an MCP server, a backend job,
|
|
932
|
+
or any automated flow — use the **node-safe HTML renderer** shipped by the
|
|
933
|
+
`@eb/email-builder` package. It turns a document (JSON) into a self-contained
|
|
934
|
+
HTML string in a plain Node.js process, with **no browser DOM, no Zustand
|
|
935
|
+
store, and no editor UI**. It renders through `react-dom/server`, so React is
|
|
936
|
+
required (unlike `@eb/document-core/node`, which is React-free).
|
|
937
|
+
|
|
938
|
+
This is the natural companion to `@eb/document-core/node`: validate/build the
|
|
939
|
+
document with one, render it to HTML with the other.
|
|
940
|
+
|
|
941
|
+
### Two entry points
|
|
942
|
+
|
|
943
|
+
| Entry | Import specifier | Contents | Deps |
|
|
944
|
+
|---|---|---|---|
|
|
945
|
+
| Default (editor/browser) | `@eb/email-builder` | `Reader`, render contexts, block primitives, `renderEmailHtml`, `cleanDocument` | React + Zod |
|
|
946
|
+
| **Node-safe** | `@eb/email-builder/node` | `renderEmailHtml`, `cleanDocument`, `Reader`, types — no DOM, no store | React + Zod |
|
|
947
|
+
|
|
948
|
+
> Server-side consumers (MCP, backend, CLI) must import from
|
|
949
|
+
> **`@eb/email-builder/node`** so they never pull in the editor app.
|
|
950
|
+
|
|
951
|
+
### Render a document to HTML
|
|
952
|
+
|
|
953
|
+
```ts
|
|
954
|
+
import { renderEmailHtml } from '@eb/email-builder/node';
|
|
955
|
+
|
|
956
|
+
const html = renderEmailHtml(documentJson, { rootBlockId: 'root' });
|
|
957
|
+
// → self-contained HTML string (DOCTYPE + <head> CSS + desktop body),
|
|
958
|
+
// ready to hand off to Nodemailer, SES, SendGrid, etc.
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
Validate first with `@eb/document-core/node` for a safe pipeline:
|
|
962
|
+
|
|
963
|
+
```ts
|
|
964
|
+
import { validateDocument } from '@eb/document-core/node';
|
|
965
|
+
import { renderEmailHtml } from '@eb/email-builder/node';
|
|
966
|
+
|
|
967
|
+
const result = validateDocument(jsonDocument);
|
|
968
|
+
if (!result.ok) throw new Error(result.issues.join('\n'));
|
|
969
|
+
|
|
970
|
+
const html = renderEmailHtml(result.data, { rootBlockId: 'root' });
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
The export always renders the **desktop** shell; the emitted
|
|
974
|
+
`@media (max-width: 640px)` rules handle mobile, so clients that strip
|
|
975
|
+
`<style>` blocks (Outlook desktop) still render correctly.
|
|
976
|
+
|
|
977
|
+
### Installation
|
|
978
|
+
|
|
979
|
+
**Inside this monorepo** — workspace protocol:
|
|
980
|
+
|
|
981
|
+
```bash
|
|
982
|
+
pnpm add @eb/email-builder
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
**From an external project** (e.g. the standalone MCP repo) — the package is
|
|
986
|
+
not published, so consume a **vendored** build. Generate it from the monorepo:
|
|
987
|
+
|
|
988
|
+
```bash
|
|
989
|
+
cd packages/email-builder
|
|
990
|
+
pnpm vendor # bundles the node-safe renderer → vendor/email-builder + a .tgz tarball
|
|
991
|
+
pnpm smoke # optional: renders a sample document via the built bundle in plain Node
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
Copy `vendor/email-builder` (or the `eb-email-builder-<version>.tgz` tarball)
|
|
995
|
+
into the consumer repo and reference it via `file:`. The bundle ships
|
|
996
|
+
ESM + CJS + `.d.ts`; the workspace `@eb/*` packages and `csso` are bundled in,
|
|
997
|
+
while `react`, `react-dom`, and `zod` stay external (provided by the consumer):
|
|
998
|
+
|
|
999
|
+
```jsonc
|
|
1000
|
+
// consumer package.json
|
|
1001
|
+
{
|
|
1002
|
+
"dependencies": {
|
|
1003
|
+
"@eb/email-builder": "file:./vendor/email-builder",
|
|
1004
|
+
"react": "^19", // peer deps — provided by the consumer
|
|
1005
|
+
"react-dom": "^19",
|
|
1006
|
+
"zod": "^3.22.4"
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
```ts
|
|
1012
|
+
import { renderEmailHtml } from '@eb/email-builder';
|
|
1013
|
+
|
|
1014
|
+
const html = renderEmailHtml(documentJson, { rootBlockId: 'root' });
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
> The vendored copy is a snapshot. When the renderer or blocks change in the
|
|
1018
|
+
> monorepo, re-run `pnpm vendor` and re-copy into the consumer repo.
|
|
1019
|
+
|
|
894
1020
|
## License
|
|
895
1021
|
|
|
896
1022
|
Free to use. © Laravel42. All rights reserved.
|