Email Template Editor
A shared package that offers a component for creating and editing email templates.
Usage
import { EmailTemplateEditor } from '@shared/email-template-editor'
const MyComponent = () => {
const props = {
isOpen: true,
onClose: () => {},
onSubmit: ({ values, form }) => {},
template: {
title: 'Example Template',
subject: 'Example Subject',
body: '<p>Example body</p>',
open_tracking: true,
click_tracking: true,
attachments: [],
tags: [],
},
title: 'Edit Template',
header: ({ values, form }) => <div>Custom Header</div>,
footer: ({ handleClose, form, submitting, pristine, values }) => (
<div>
<button onClick={handleClose}>Cancel</button>
<button type="submit" disabled={submitting || pristine}>Save</button>
</div>
),
}
return <EmailTemplateEditor {...props} />
}
Components
EmailTemplateEditor
Props
| Name | Type | Description |
|---|---|---|
isOpen | boolean | Indicates whether the editor modal is open or closed |
onClose | () => void | Callback function triggered when the modal is closed |
onSubmit | ({ values, form }) => void | Callback function executed when the form is submitted |
template | Template \| TeamTemplate \| undefined | The template object to preload in the editor (optional) |
title | string | The title of the editor modal |
header | ({ values, form }) => React.ReactNode | Custom header component (optional) |
footer | ({ handleClose, form, submitting, pristine, values }) => React.ReactNode | Custom footer component |