Skip to content
Open in

NPM Packages: Upgrading to v1 ​

Version 1 of the @topol.io/editor packages embeds Email Editor v4 and adds the Landing Page Editor. Moving to v4 changes how you initialize the editor, how callbacks receive data, and several option names. This guide lists every change from 0.3 and how to fix it.

This is the upgrade path for integrations that install the editor from npm. If your page loads the editor with a <script> tag instead, follow Script Tag: Upgrading from v3 to v4. For what's new in v4, see Migrating to Email Editor v4.

Install v1 with:

bash
npm install @topol.io/editor@^1
bash
npm install @topol.io/editor-react@^1
bash
npm install @topol.io/editor-vue@^1
bash
npm install @topol.io/editor-svelte@^1

Option and callback reference

The options and callbacks in the rest of the Email Editor guide are the v4 ones and apply to the packages unchanged. Framework components take the config object as their options prop. Package-specific details are on this page and in each package's npm README.

Let an AI agent do the upgrade

TOPOL-io/skills has two skills for coding agents, written as plain markdown. topol-editors-integration sets up either editor in a new project and topol-editors-upgrade-v1 moves an existing integration to v1. They install as a Claude Code plugin (/plugin marketplace add TOPOL-io/skills) or into any agent with npx skills@latest add TOPOL-io/skills.

Who needs to change what ​

IntegrationAfter upgradingSections to apply
Email Editor via core EmailEditor / TopolPlugininit() throws on the old shape; module-level methods are goneAll sections
Email Editor via React, Vue or Svelte componentThe TopolEditor import no longer resolves; once renamed, callbacks receive different arguments and some stop firingCallbacks, Options, Framework packages, Types, Checklist
Landing Page EditorNew in v1, nothing to migrateLanding Page Editor
Email Editor via @topol.io/editor-angularThe Angular package is deprecated and has no v1Replace it with the core @topol.io/editor package, then apply all sections

Package names are the same. The default exports and the TopolPlugin / TopolEditor names are gone, so every import becomes the named EmailEditor. @topol.io/editor-svelte now requires Svelte 5, and @topol.io/editor-react declares React 18 or 19 as a peer dependency; Vue still needs 3.2.25 or later. Renamed types fail the type-check. Renamed options and callbacks do not: they are ignored at runtime without a warning.

Upgrading from a 1.0.0 alpha

The 1.0.0-alpha.1 to 1.0.0-alpha.9 builds (React up to 1.0.0-alpha.10) embedded Email Editor v3 with the 0.3 API, so follow this guide as if you were on 0.3.

Later alphas already embed v4, but they still accepted names that 1.0.0 removes. Go through Methods, Configuration options, Framework packages and Types: the TopolPlugin and TopolEditor exports, the pre-rename type names, authorize.userId, the control panel names, and the Svelte on: events and callbacks prop are all gone.

If you used the Landing Page Editor on an alpha:

  • Up to 1.0.0-alpha.8, callbacks took positional arguments. They now receive a single object: onSave({ json, html }) instead of onSave(json, html), with errors and closing reported through onEditorError and onEditorClose.
  • The React types LandingPageEditorRef and LandingPageEditorProps are now ILandingPageEditorRef and ILandingPageEditorProps, and the TopolSection type is no longer exported.
  • The React component is no longer absolutely positioned and has no fixed id.

Landing Page Editor ​

v1 adds the Landing Page Editor to the same packages, as a named LandingPageEditor export in core, React and Vue. The Svelte package does not include a Landing Page Editor component yet.

Initialization and lifecycle ​

init() now takes { config, ...callbacks } and resolves to an editor instance. It no longer mounts anything: call render() on the instance. Every method lives on the instance and returns a promise.

ts
import TopolPlugin from "@topol.io/editor";

await TopolPlugin.init({
  id: "#editor",
  authorize: { apiKey: "YOUR_API_KEY", entityId: "user-123" },
  savedBlocks: blocks,
  callbacks: {
    onSave(json, html) {
      persist(json, html);
    },
    onError(type, message) {
      report(type, message);
    },
  },
});

TopolPlugin.save("en");
TopolPlugin.destroy();
ts
import { EmailEditor } from "@topol.io/editor";

const editor = await EmailEditor.init({
  config: {
    authorize: { apiKey: "YOUR_API_KEY", entityId: "user-123" },
    savedSections: blocks,
  },
  async onSave({ json, html }) {
    await persist(json, html);
  },
  onEditorError({ source, message }) {
    report(source, message);
  },
});

await editor.render("#editor");
await editor.save({ langCode: "en" });
await editor.destroy();
AreaBeforeAfterHow to fix
Init callinit({ id, authorize, ...options, callbacks })init({ config: { authorize, ...options }, ...callbacks }, { stage, loaderUrl })Move options under config, spread callbacks at the top level, drop id
Mountinginit() mounted into idawait editor.render(container) with a selector or an elementCall render() after init() resolves; the container needs a height
MethodsTopolPlugin.save(), EmailEditor.destroy(), …editor.save(), editor.destroy(), …Call them on the instance. The old module-level methods are undefined
Return valuesMethods returned nothingEvery method returns a promiseawait where order matters, e.g. await editor.save()
InstancesOne editor per page, on windowEach init() creates an independent instanceKeep a reference per editor
entityIdAny string or numberNon-negative integer, or a string matching [A-Za-z0-9_-]+; anything else makes init() throwMap emails and other IDs to a URL-safe value
Authentication errorsReported through onErrorReported through onEditorError; the instance has no working methods afterwardsDestroy and re-init after fixing credentials
onInitEditor loadedEditor loaded and authenticatedWait for onInit before calling methods

Recommended: nonce authentication

authorize.apiKey keeps working on its own in v4, but the setup we recommend is nonce authentication. Pass a getNonce callback: the editor then runs on short-lived nonces that your backend signs for each signed-in user with the Secret key. You can add it now or after the upgrade. See Nonce Authentication.

Methods ​

BeforeAfter
save(lang?)save({ langCode? }), resolves after your onSave settles
setSavedBlocks(blocks)setSavedSections(sections)
refreshSyncedRows()refreshSyncedSections()
getMutations() returned nothing, result came through onGetMutationsgetMutations() resolves to { code, primary }[] and still fires onGetMutations
updateOptions(options)updateOptions(options), without authorize
createLanguage, deleteLanguage, selectLanguage, setPrimaryLanguage(lang)Same names; the argument is the language code
toggleBlocksAndStructuresVisibility()toggleHiddenElementsVisibility()
toggleControlPanel()toggleSelectionPanel()

Every other method keeps its name: load, togglePreview, togglePreviewSize, toggleDarkMode, chooseFile, undo, redo, setPreviewHTML, createNotification, setActiveMembers, changeEmailToMobile, changeEmailToDesktop, updateCustomBlockContent, refreshComments, openPremadeTemplatesSelection, updateApiAuthorizationHeader, setTemplateName, setMergeTags, toggleChatAI, toggleAutosaves, toggleComments, updateTemplate. A method called under its old name throws "not a function". New: translateLanguage(code, sourceCode?) and translateAllLanguages().

Callbacks ​

Every callback now receives either no arguments or a single object. Seven callbacks are renamed.

BeforeAfterHow to fix
onSave(json, html, mutations, syncedSections)onSave({ json, html, mutations, syncedSections }); may return a promise the editor waits forDestructure; return the promise when you persist asynchronously
onSaveAndClose(json, html, …)onSaveAndClose({ json, html, mutations, syncedSections })Destructure
onTestSend(email, json, html)onTestSend({ email, json, html }); email is string | string[]Destructure; handle an array of addresses
onBannerClick(json, html)onBannerClick({ json, html })Destructure
onUndoChange(count), onRedoChange(count)({ count })Destructure
onPreview(html)onPreview({ html })Destructure
onAlert(notification)onAlert({ notification })Destructure
onEdittedWithoutSaveChanged(hasUnsavedChanges)onUnsavedChangesChange({ hasUnsavedChanges })Rename and destructure
onOpenCustomBlockDialog(block)onOpenCustomBlockDialog({ block })Destructure
onTemplateRename(title)onTemplateRename({ name })Read name
updateTestingEmailAddresses(emails)onTestingEmailsChange({ emails })Rename and destructure
onLanguageCreated, onLanguageDeleted, onPrimaryLanguageChanged(lang, mutations)({ code, mutations })Read code
onLanguageSelected(lang)onLanguageSelected({ code })Read code
onGetMutations(mutations)onGetMutations({ mutations })Destructure
onError(type, message, responseBody)onEditorError({ source, message, detail })Rename; type → source, responseBody → detail
onClose()onEditorClose()Rename
onBlockSave(block)onSavedSectionSave({ section })Rename and destructure
onBlockRemove(id)onSavedSectionRemove({ id })Rename; id can be a number or a string
onBlockEdit(id)onSavedSectionEdit({ id })Rename; id can be a number or a string
onInit(), onLoaded(), onOpenFileManager()Unchanged—

Language mutations use { code, primary } everywhere: save payloads, language callbacks, onGetMutations and getMutations().

onClose and onError are dropped before they reach the editor. A handler left under either name never runs, and nothing warns you.

New callbacks: onPreviewClose(), onImageDelete({ items }), onHiddenElementsVisibilityChange({ visible }), onTemplateUpdated(), and the optional getNonce() for nonce authentication.

Configuration options ​

Saved and premade blocks are now called sections. A renamed option left under its old name is ignored without an error.

BeforeAfterHow to fix
idRemovedPass the container to render(); the framework components own it
callbacks: { … }RemovedPut callbacks next to config
authorize.userIdauthorize.entityIdRename
savedBlockssavedSectionsRename; items keep the { id, name, definition, img? } shape
premadeBlocks, premadeBlocksNoOverwritepremadeSections: false, your groups, or { blocks, override }Rename; drop premadeBlocksNoOverwrite and use override: false to keep Topol's default groups next to yours
syncedRowsEnablesyncedSectionsEnabledRename
topBarOptions (controls to show)hideTopbarControls (controls to hide)Invert the list
hideControlPanelhideSelectionPanelRename
showControlPanelExpandhideSelectionPanelExpandRename and invert the value: showControlPanelExpand: false becomes hideSelectionPanelExpand: true
productMergetagTagsproductMergeTagsRename
dynamicMergetags on an API blockdynamicMergeTagsRename
defaultTemplateSettings.langs[].keydefaultTemplateSettings.langs[].codeRename the key
defaultTemplateSettings: blockBackgroundColor, "structure-margin", "line-height", "stack-columns"sectionBackgroundColor, sectionPadding, lineHeight, stackColumnsRename the top-level keys; "line-height" inside the block-level defaults (text, button, …) stays
api.SAVED_BLOCKSapi.SAVED_SECTIONSRename
api.PREMADE_TEMPLATES_KEYWORDSapi.PREMADE_TEMPLATE_KEYWORDSRename
api.SAVE, api.LOAD, api.PREVIEWRemovedPersist through onSave; load with editor.load()
api.AUTOSAVE, api.GET_AUTOSAVE, api.SYNCED_ROWSRemovedServe autosaves from api.AUTOSAVES
api.IMAGE_EDITOR_UPLOADRemovedImages saved from the Image Editor upload through api.IMAGE_UPLOAD; see Self-hosted Storage
googleApiKeyRemovedDrop it; the Image Editor takes its fonts from customFonts
textOverride keys for blocks and rows, and misspelled keysSection names and corrected spellingRename the keys you override; see the script tag guide for both lists

All other options keep their names. v4 also adds optional ones such as permissions, enableSubjectLine, and loop and rating blocks.

Framework packages ​

In all three packages the component is now the named export EmailEditor; the TopolEditor name and the default exports are gone. The options and stage props stay. The components follow the callback changes above, plus these:

ChangeBeforeAfterHow to fix
ContainerFixed id (#editor, #topol-editor-id or #topol-email-editor-id) and position: absoluteNo fixed id, no position: absolute; still width: 100%; height: 100vhStop targeting the ids; size and position the parent yourself
Editor accessGlobal TopolPlugin methodsThe component's instance: React ref.current.getEditor() or onReady, Vue template ref getEditor() or @ready, Svelte bind:this + getEditor() or onReadyCall methods on that instance
Init failuresonError (React, Vue) or nothing (Svelte)onEditorError with source: "integration"Listen to onEditorError
ReconfiguringOptions read once on mountOptions and which handlers exist are captured on mountRemount (React key, Vue key, Svelte {#key}) to change them
New props—loaderUrl; React className, style, onReady; Vue callbacks and the ready event; Svelte class, style, onReadyOptional

React. @topol.io/editor-react has no default export: import { EmailEditor } from "@topol.io/editor-react" instead of TopolEditor. Callback props follow the core table, so positional handlers now receive one object, and a promise returned from onSave is awaited. In Next.js, load the component with SSR disabled; see Next.js integration.

Vue. Event listeners are notifications and their return value is not awaited. Pass handlers the editor must wait for, such as an async onSave, through the callbacks prop. Vue events already sent objects for onSave, onSaveAndClose, onTestSend, onBannerClick and onGetMutations; those keep their shape. The other events change as in the callbacks table, and language events carry { code, … } instead of { lang, … }.

Svelte. v1 requires Svelte 5; a Svelte 4 project stays on @topol.io/editor-svelte@0.3 until it upgrades Svelte. Every callback is now a prop that receives the payload object directly, so the on: events and event.detail are gone, and on:ready becomes onReady. A callback prop may return a promise, and the editor waits for onSave, onSaveAndClose, onEditorClose and getNonce. Type the options prop as ISvelteEmailOptions.

svelte
<!-- Before (0.3) -->
<TopolEditor {options} on:onSave={(event) => persist(event.detail)} />

<!-- After (v1) -->
<EmailEditor {options} onSave={({ json, html }) => persist(json, html)} />

Loader and environments ​

  • The packages load the v4 loader, https://v4.email-assets.topol.io/loader/build.js. Your API key must work with Email Editor v4.
  • Let init() load the script. A loader <script> tag you add to the page yourself makes init() reject.
  • Use one loader URL per page. Switching stages needs a page reload.
  • The dev and staging stages resolve to the production v4 loader. Use the loaderUrl option for preview or local builds.
  • If you rebuild the packages yourself, the build-time overrides are VITE_TOPOL_V4_URL, VITE_TOPOL_V4_DEV_URL and VITE_TOPOL_V4_STAGING_URL. The old VITE_TOPOL_* variables are ignored.

Backend and security policy ​

If you host api.* endpoints, they need the v4 CORS origin and the merged autosave endpoint. If your page sets a Content Security Policy, it needs the v4 loader domain. Both changes are the same for script-tag integrations, so they're described once in Backend and security policy.

Types ​

The exported types follow one naming scheme in v1. The old names are removed, not aliased, so TypeScript reports each one.

BeforeAfterNotes
ITopolOptionsIEmailConfigThe options object. IEmailOptions is the whole init() argument: { config, ...callbacks }
ITopolPluginIEmailEditorInstanceThe instance init() resolves to
ISavedBlockISavedSectionSame shape
ISaveDataIEmailSavePayloadmutations are { code, primary }[]
IErrorDataIEmailErrorPayload{ source, message, detail? } instead of type and responseBody
ISendTestDataIEmailTestSendPayloademail is string | string[]
React IReactTopolOptions, TopolEditorPropsIReactEmailOptions, IEmailEditorPropsIEmailEditorRef types the component ref
Vue IVueOptionsIVueEmailOptions—
Svelte ISvelteOptionsISvelteEmailOptionsIEmailEditorProps types all props

IEmailCallbacks holds the callback signatures. The framework packages re-export the core types, so one import source is enough.

Upgrade checklist ​

These changes raise no error in plain JavaScript. Check each one before you ship the upgrade.

  • [ ] onError is renamed to onEditorError, so editor and init errors still reach you.
  • [ ] onClose is renamed to onEditorClose, so closing the editor still works.
  • [ ] Save handlers read json and html from one object. A two-argument handler would store the payload object as JSON and undefined as HTML.
  • [ ] savedBlocks, setSavedBlocks and the onBlock* callbacks are renamed, so saved sections still appear and persist.
  • [ ] premadeBlocks, syncedRowsEnable and api.SAVED_BLOCKS are renamed.
  • [ ] hideControlPanel and showControlPanelExpand are renamed, the latter with its value inverted, and toggleControlPanel() calls are now toggleSelectionPanel().
  • [ ] productMergetagTags, dynamicMergetags, api.PREMADE_TEMPLATES_KEYWORDS and the four defaultTemplateSettings keys are renamed.
  • [ ] textOverride keys you set use the section names and the corrected spelling.
  • [ ] topBarOptions is converted to hideTopbarControls with the list inverted.
  • [ ] Multilingual code reads code instead of key or lang.
  • [ ] Unsaved-changes guards read { hasUnsavedChanges }, undo/redo buttons read { count }.
  • [ ] The page layout works without the component's fixed id and position: absolute.
  • [ ] authorize.userId is renamed to authorize.entityId.
  • [ ] Svelte handlers are callback props, not on: listeners reading event.detail.
  • [ ] Every entityId passes the new format check.
  • [ ] Existing templates open and save in Email Editor v4 with your API key.

INFO

Running into trouble while upgrading? Contact our support team here and we'll help you get it working.