SVeditor Docs
API Reference

EditorInstance

Methods and properties available on the SVeditor instance returned by SVeditor.create().

EditorInstance

SVeditor.create() returns an EditorInstance object. It is also passed as the argument to the onCreate and onUpdate callbacks.

Content Methods

interface EditorInstance {
  /** Get document as HTML string */
  getHTML(): string;

  /** Set document from HTML string */
  setHTML(html: string): void;

  /** Get document as plain text */
  getText(): string;

  /** Get document as Tiptap JSON object */
  getJSON(): object;
}

Examples

const editor = SVeditor.create({ el: '#editor', content: '<p>Hello</p>' });

// Read content
const html = editor.getHTML();      // '<p>Hello</p>'
const text = editor.getText();      // 'Hello'
const json = editor.getJSON();      // { type: 'doc', content: [...] }

// Set content
editor.setHTML('<p>New content</p>');

Document metadata

Title, emoji, cover, and other document fields live in FetchMetaObject. Configure persistence with extensionsOptions.meta (onFetchMeta, onSaveMeta, onMetaChange). From host code you can also read and merge-updates via the instance:

interface EditorInstance {
  /** Current document metadata (title, emoji, cover, etc.) */
  getMeta(): FetchMetaObject;

  /**
   * Shallow-merge metadata into editor state.
   * Triggers the same UI update as editing in the meta bar and fires `onMetaChange` when configured.
   */
  setMeta(meta: Partial<FetchMetaObject>): void;
}

Examples

const editor = SVeditor.create({
  el: '#editor',
  content: '<p>Hello</p>',
  extensionsOptions: {
    meta: {
      onMetaChange: (meta) => {
        console.log('meta updated', meta.name, meta.emojiInfo);
      },
    },
  },
});

editor.setMeta({
  name: 'From host',
  emojiInfo: JSON.stringify({ emoji: '😍', label: 'Smiling face with heart-eyes' }),
});

const meta = editor.getMeta();

See EditorOptions (extensionsOptions.meta) and Types (FetchMetaObject).

Version history

Listing, restoring, and creating snapshots are handled in the editor UI (right sidebar → Version history) and extensionsOptions.versionHistory. No snapshot CRUD methods are exposed on EditorInstance. For app-level persistence, use getJSON() / setJSON() with your own storage.

See Version history.

Lifecycle

interface EditorInstance {
  /** Destroy the editor and release all resources */
  destroy(): void;
}

Always call destroy() when navigating away or unmounting the component to prevent memory leaks.

On this page

MuseCanto

Creator ops workspace from inspiration to publishing and review.

Explore MuseCanto