Self-hosted email delivery platform that enables applications to send emails via HTTP APIs while handling SMTP delivery, templates, storage, security, and analytics. Fully self-hostable alternative to services like SendGrid or Mailgun.
Go email-relayemail-routinghttp-to-smtpmail-deliverymailchimp-alternativemailgun-alternativemailsendermailservermailtemplatemailtestpostmark-alternativesend-emailsendgrid-alternativesendmailtransactional-emailtransactional-outbox
feat: support for live preview in template editor (#88)
Jonas Kaninda2152196d3d3f
diff --git a/web/src/api/templates.ts b/web/src/api/templates.tsindex 837c2bc..5096e45 100644--- a/web/src/api/templates.ts+++ b/web/src/api/templates.ts@@ -61,6 +61,17 @@ export const templatesApi = {previewLocalization(templateId: number, versionId: number, data: { language: string; template_data: Record<string, any> }) {return api.post<ApiResponse<TemplatePreview>>(`/users/me/templates/${templateId}/versions/${versionId}/preview`, data)},+ // Renders raw, unsaved template content so the editor can show a live preview+ // without persisting first.+ previewTemplate(data: {+ subject_template: string+ html_template?: string+ text_template?: string+ stylesheet_id?: number | null+ template_data?: Record<string, any>+ }) {+ return api.post<ApiResponse<TemplatePreview>>('/users/me/templates/preview', data)+ },sendTest(templateId: number, data: SendTestInput) {return api.post<ApiResponse<SendTestResponse>>(`/users/me/templates/${templateId}/send-test`, data)diff --git a/web/src/views/templates/TemplateEditor.vue b/web/src/views/templates/TemplateEditor.vueindex f07bb0e..1844623 100644--- a/web/src/views/templates/TemplateEditor.vue+++ b/web/src/views/templates/TemplateEditor.vue@@ -108,7 +108,7 @@ let debounceTimer: ReturnType<typeof setTimeout> | null = nullfunction schedulePreview() {if (debounceTimer) clearTimeout(debounceTimer)- debounceTimer = setTimeout(() => renderPreview(), 600)+ debounceTimer = setTimeout(() => renderPreview(), 300)}async function renderPreview() {@@ -126,8 +126,11 @@ async function renderPreview() {}try {- const res = await templatesApi.previewLocalization(templateId, versionId, {- language: localization.value?.language || template.value.default_language,+ const res = await templatesApi.previewTemplate({+ subject_template: subjectValue.value || ' ',+ html_template: htmlValue.value,+ text_template: textValue.value,+ stylesheet_id: version.value?.stylesheet_id ?? null,template_data: data,})preview.value = res.data.data