debloq-email-editor-vue
Vue Email Editor
The Debloq drag-and-drop email editor as a Vue 3 component. Authors build responsive emails that render in Gmail, Outlook, Apple Mail and mobile clients; you get the HTML, plain text and a JSON design to save.
Installation
npm install debloq-email-editor-vue
Requires Vue 3.4 or later. You need a licence key from your
Debloq dashboard, with your site's domain added to its
project (localhost always works for development).
Usage
<script setup>
import { ref } from 'vue'
import { EmailEditor } from 'debloq-email-editor-vue'
const editor = ref(null)
const design = ref(null) // a design you saved earlier, or null for a blank email
function onReady(api) {
console.log('editor ready')
}
async function save() {
const { design, html, text } = await editor.value.exportHtml()
// store `design` to reopen the email later, send `html` and `text`
}
</script>
<template>
<button @click="save">Save</button>
<div style="height: 700px">
<EmailEditor
ref="editor"
v-model="design"
license-key="YOUR_LICENSE_KEY"
@ready="onReady"
/>
</div>
</template>
The editor fills its parent, so give the parent a height. It starts when the
component mounts and is removed when it unmounts. In Nuxt, wrap it in
<ClientOnly>.
Methods
Call these on the component ref. Each returns a Promise.
| Method | Description |
|---|---|
loadDesign(design) |
Opens a design (object or JSON string). |
getDesign() |
Returns the current design. |
exportHtml() |
Returns { html, text, design }. |
exportAmp() |
Returns { html, text, design, amp } for AMP for Email. |
openTemplates(), openPreflight(), openExport() |
Opens the template gallery, preflight checks or export dialog. |
setDevice(id) |
Shows the 'desktop', 'tablet' or 'mobile' view. |
undo(), redo(), togglePreview() |
Editing controls for your own toolbar. |
The ref also has api (the full editor API once ready), devices and
controls. See the full method list.
Properties
licenseKeyStringyour licence key (required)modelValueObject | Stringthe design to open; usev-modelto keep it in syncversionStringeditor version:'latest'(default),'stable'or an exact release such as'2.0.4'themeString | Objecteditor colours:'light','dark','auto'or{ mode, accent, fontFamily, radius, tokens }brandLogoString | Object | falseyour name or logo in the toolbarbrandObjectbrand colours and fonts offered in every pickerfontsArrayextra fonts for the font pickerchromeBooleanshow the editor's top toolbar (defaulttrue)canvasToolbarBooleanshow the small toolbar above the canvasmergeTagsArraypersonalization tags, e.g.[{ label: 'First name', value: '{{ first_name }}' }]specialLinksArrayready-made links such as UnsubscribeutmObjectUTM parameters added to every linktemplatesArrayyour own template gallerycustomComponentsArrayyour own blocks (see below)imageUploadFunctionasync (file) => urlto store uploads on your serverimageLibrary,stockSearch,onStockSelectFunctionyour media library and stock photossavedBlocksStore,brandSwatchStore,assetStoreObject{ load, save }to keep author libraries on your serveronSendTestFunctionadds a Send test actionautosaveKeyStringrecovers unsaved work after the tab closes
See the Integration & Customization Guide for every option with examples.
Events
| Event | Payload | When |
|---|---|---|
ready |
api |
The editor is ready. |
change |
{ design, html, text } |
Shortly after the author stops editing. |
update:modelValue |
design |
On every edit. |
locked |
reason |
The editor can't open, e.g. DomainMismatch. |
error |
Error |
Something went wrong. |
Customization
<EmailEditor
license-key="YOUR_LICENSE_KEY"
:theme="{ mode: 'auto', accent: '#0f766e' }"
brand-logo="Acme Mail"
:merge-tags="[{ label: 'First name', value: '{{ first_name }}' }]"
:image-upload="uploadImage"
/>
async function uploadImage(file) {
const body = new FormData()
body.append('file', file)
const res = await fetch('/api/uploads', { method: 'POST', body })
return (await res.json()).url
}
Custom Components
Add your own blocks to the palette, such as a product card. Define them as data with an HTML template; authors edit the fields you list.
const customComponents = [{
type: 'product-card',
label: 'Product',
defaults: { title: 'Running shoe', url: 'https://acme.com/shoe' },
fields: [
{ key: 'title', label: 'Title', type: 'text' },
{ key: 'url', label: 'Link', type: 'linkurl' }
],
template: '<h3>{{ props.title }}</h3><a >Buy now</a>'
}]
<EmailEditor license-key="YOUR_LICENSE_KEY" :custom-components="customComponents" />
Troubleshooting
The editor area is blank. Give the parent element a height. If your site
sends a Content Security Policy, allow frame-src https://editor.debloq.io.
locked fires instead of ready. The author sees a message and the event
gives the reason:
| Reason | Fix |
|---|---|
MissingKey |
Pass license-key. |
UnknownKey |
Check the key in your dashboard. |
Revoked |
Create a new key in your dashboard. |
Inactive |
Your subscription isn't active; check billing. |
DomainMismatch |
Add this site's domain to the key's project. |
ServiceUnavailable, PremiumUnavailable |
Temporary; the author can press Retry. |
A method rejects with "Editor is not ready". Wait for the ready event
before calling methods.
An option has no effect. Some options belong to specific plans; the editor ignores options your plan doesn't include.
Also available
- React:
debloq-email-editor-react - Angular:
debloq-email-editor-angular
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 2.0.5 | ^3.4.0 | ||
| 2.0.4 | ^3.4.0 |
Pre-releases (1)
| Version | Released | License |
|---|---|---|
| 0.0.0-stage |