> ## Documentation Index
> Fetch the complete documentation index at: https://help.emaillove.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Editor options and session API

> The options @email-love/editor takes, and the session it gives your app to save, read and close an email.

The editor has no server and sends nothing anywhere. You pass it options that say where emails and pictures go. When it's ready, it gives your app a session.

The same options work for the React component and for `mountEmailLoveEditor`.

## Emails and pictures

| Option | What it does |
| - | - |
| `email.open()` | Returns the saved document, or nothing. |
| `email.save(document)` | Keeps the document. Throw an error to have it tried again 1, 3 and 8 seconds later. Throw an error with `retry: false` to stop it trying again. |
| `email.startFrom` | The document for an email with nothing saved yet. It isn't saved until someone changes it. |
| `images.upload(file)` | Returns `{ url, alt }` or just the address. The address must be https. |
| `images.types`, `images.maxBytes` | Limit which files can be uploaded. |
| `autosaveAfter` | Milliseconds after a change before the editor saves. The default is 2000. Set it to `null` to save only when asked. |

## Design systems

| Option | What it does |
| - | - |
| `designSystem` | `{ tokens, components }`. Leave it out to use the Ultimate Email Design System, which is only loaded then. |
| `components` | Your own components, added to the design system's. |
| `modules` | The component keys people can add. |
| `assetBase` | Where you serve the starter's pictures and the carousel, accordion and social icons. The default is `https://app.emaillove.com`. |

See [Design systems and your own components](https://help.emaillove.com/builder/sdk/design-systems.md) for the format.

## Other options

| Option | What it does |
| - | - |
| `name` | The email's name, shown over the canvas and in the Style panel. |
| `onNameChange(name)` | Called when the name is changed in the editor. |
| `readOnly` | Opens the email without editing. |
| `onOpen(session)` | Called with the session when the editor is ready. |
| `onChange(document)` | Called with the document after every change. |
| `onError(error)` | Called when something goes wrong. |

## The session

`onOpen(session)` gives you the session. With `mountEmailLoveEditor`, `await editor.ready` gives you the same session.

| Method | What it does |
| - | - |
| `save()` | Saves now what isn't saved yet. |
| `close()` | Ends the session. It saves what isn't saved first. |
| `getJSON()` | The document. |
| `upload(file)` | Uploads a picture through `images.upload`. |
| `getHTML()` | A promise of the email's HTML. |
| `getMJML()` | A promise of the email's MJML. |
| `getText()` | A promise of the email's plain text. |
| `subscribe(listener)` | Reports the save status. |

### Save status

`session.subscribe(({ status, error }) => …)` reports one of these:

| Status | Meaning |
| - | - |
| `loading` | The email is opening. |
| `load-failed` | The email couldn't be opened. |
| `saved` | Every change is saved. |
| `unsaved` | There are changes that aren't saved yet. |
| `saving` | A save is in progress. |
| `save-failed` | The save didn't work. |

## Adding your own features

Test emails, live co-editing, AI and accounts are not part of the editor. You can add them in your own app. The session gives you the HTML, MJML and plain text to send, and `onChange` gives you every change.

They're also in the hosted [Email Love Builder](https://help.emaillove.com/builder/getting-started/overview.md). See [Email Love SDK](https://www.emaillove.com/sdk) for hosted plans.

## Styles

`style.css` applies only inside the editor, and its dialogs open inside it too. The editor uses the Inter font if your page has it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.