Vanilla JS
FrameworksVanilla JS
No framework? Add one script tag, or install vanilla-email-craft, and use the mailkaro global: mailkaro.init(...) for one editor, mailkaro.createEditor(...) for several.
<script src="https://unpkg.com/vanilla-email-craft/dist/embed.js"></script>Or install it and import the same global:
npm install vanilla-email-craft<div id="editor-container" style="height: 700px;"></div>
<script type="module">
import { mailkaro } from "vanilla-email-craft";
mailkaro.init({
id: "editor-container", displayMode: "email", // email | web | document | popup
token: "pk_live_…", // scopes plan + features
});
mailkaro.exportHtml((data) => console.log(data.html));
</script>createEditor takes id (or container), token, displayMode, locale, mergeTags and fonts; keys MailKaro has no use for are accepted and ignored.Methods#
Every method mirrors the editor ref: loadDesign, saveDesign, exportHtml, exportPlainText, exportZip, addEventListener, registerCallback, unregisterCallback, setMergeTags, setDisplayMode, destroy, plus the rest of the editor methods (undo/redo, exportImage, exportPdf, setLocale, setAppearance, setStyleGuide, registerTool, registerTab, createPanel, loadTemplate and more). Calls made before the editor is ready are queued. Use mailkaro.createEditor(...) for multiple editors on one page.
Upgrading from version 1#
Version 2 has only the mailkaro global. If your page calls the older global name, rename those calls to mailkaro. (mailkaro.init, mailkaro.createEditor, mailkaro.exportHtml and so on), and import { mailkaro } from the package. Nothing else changes. Moving from another editor? See the migration guide.
Next: Methods & ref.