# @uidu/email-renderer

> Email renderer

Latest version **2.0.1** (published 2024-11-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @uidu/email-renderer
pnpm add @uidu/email-renderer
yarn add @uidu/email-renderer
bun add @uidu/email-renderer
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2024-11-26 |
| First published | 2022-10-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 241 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Atlassian Pty Ltd |
| Maintainers | apuntovanini, flavio-scimeca, bacco40 |

## Links

- npm: https://www.npmjs.com/package/@uidu/email-renderer
- Repository: https://github.com/uidu-org/guidu.git#main
- Homepage: https://github.com/uidu-org/guidu/tree/main#readme
- Issues: https://github.com/uidu-org/guidu/issues
- npm.io page: https://npm.io/package/@uidu/email-renderer

## Dependencies (7)

- [juice](https://npm.io/package/juice.md) ^8.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [date-fns](https://npm.io/package/date-fns.md) ^2.30.0
- [get-video-id](https://npm.io/package/get-video-id.md) ^3.7.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.26.0
- [@uidu/adf-schema](https://npm.io/package/@uidu/adf-schema.md) ^3.0.1
- [prosemirror-model](https://npm.io/package/prosemirror-model.md) ^1.23.0

## Recent versions

- 2.0.1 (latest) — 2024-11-26
- 2.0.0 — 2024-11-26
- 1.12.5 — 2024-09-03
- 1.12.4 — 2024-04-29
- 1.12.3 — 2024-04-29
- 1.12.2 — 2024-04-20
- 1.12.1 — 2024-03-26
- 1.12.0 — 2024-03-21
- 1.11.2 — 2024-02-22
- 1.11.1 — 2024-01-22
- 1.11.0 — 2024-01-04
- 1.10.0 — 2024-01-04
- 1.9.0 — 2023-12-14
- 1.8.0 — 2023-10-26
- 1.7.0 — 2023-10-10
- … 30 more at https://npm.io/package/@uidu/email-renderer/versions

## README

# Email renderer

This package provides renderer that is capable of rendering email-friendly HTML from ADF documents.

## Usage

Use as follows:

```javascript
import { defaultSchema } from '@uidu/adf-schema';
import { EmailSerializer } from '@uidu/email-renderer';

const document = ... // Your ADF JSON document

const serializer = EmailSerializer.fromSchema(defaultSchema);
const node = defaultSchema.nodeFromJSON(document);
const result = serializer.serializeFragment(node.content);
```

## Development

Project consists of different `serializers` in order to render ADF into html

ADF `nodes` serializers are stored in `src/nodes`
ADF `marks` serializers are stored in `src/marks`

HTML rendering occurs via traversal of the ADF and calling the serializer corresponding to each visited ADF Node, as well as applying any `marks` that exist on a node.

### Adding new embedded images / icons

This will generate static image modules that can be used to easily embed inside of email as part of a ADF node serializer, etc.

Currently uses a custom build process, which like this: `SVG -> PNG -> Base64 -> TypeScript Module`

- Add the source image to `src/static/svg` folder and to generator config `src/static/image-sources.ts`
- run `yarn run build:images`

---
_Source: https://npm.io/package/@uidu/email-renderer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
