DocumentationSDK on GitHub

Documentation Guides

Hosted drafts and autosave

Keep drafts in Weavour, resume editing and save before leaving the page.

On this page

Enable hosted saving

Autosave is enabled by default. Check the editor’s dashboard setting and omit enableAutosave: false from your mount options. Store the draftId returned by onDraftChange on your application’s email record.

typescript
import { mount } from '@weavour/editor';

const editor = mount('#email-editor', {
  editorKey: 'YOUR_PUBLIC_EDITOR_KEY',
  userId: 'user-123',
  organizationId: 'organization-456',
  onDraftChange({ draftId, revision }) {
    console.log('Associate this draft with your host record:', draftId, revision);
  },
  onSaveStatusChange({ status }) {
    console.log('Hosted save status:', status);
  },
  onError: console.error,
});

// Run in your navigation handler, with error handling in your host UI.
async function closeEditor() {
  await editor.ready;
  await editor.flushAutosave();
  editor.destroy();
}

Resume a draft

Pass draftId with the same editor key, userId and organizationId used to save it. Omit initial content and metadata. The editor loads the latest saved version.

typescript
import { mount } from '@weavour/editor';

function resumeDraft(draftId: string) {
  return mount('#email-editor', {
    editorKey: 'YOUR_PUBLIC_EDITOR_KEY',
    userId: 'user-123',
    organizationId: 'organization-456',
    draftId,
    onError: console.error,
  });
}
  • Await flushAutosave() in your navigation handler, then call destroy().
  • If saving fails, keep the editor open and let the user retry. A timeout may occur after a server write succeeds.
  • A content callback, export or component unmount does not confirm a save. Saving on browser close is best effort.

History and recovery

Draft history keeps 30 days of versions. Restoring creates a new version and retains later work in history. For conflicts, use the editor’s recovery flow rather than overwriting another revision.

Need help? Contact us