Skip to main content

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

NameTypeDescription
isOpenbooleanIndicates whether the editor modal is open or closed
onClose() => voidCallback function triggered when the modal is closed
onSubmit({ values, form }) => voidCallback function executed when the form is submitted
templateTemplate \| TeamTemplate \| undefinedThe template object to preload in the editor (optional)
titlestringThe title of the editor modal
header({ values, form }) => React.ReactNodeCustom header component (optional)
footer({ handleClose, form, submitting, pristine, values }) => React.ReactNodeCustom footer component