API Reference
EditorOptions Core editor options, auto-save, metadata, uploads, AI, version history, and lifecycle callbacks.
SVeditor.create() accepts an EditorOptions object. The only required field is el; most product behavior lives under extensionsOptions.
SVeditor. create ({
el: "#editor" ,
content: "<p>Hello</p>" ,
editable: true ,
extensionsOptions: {
autoSave: {
onFetch : () => fetchContent (docId),
onSaveContent : ( json ) => saveContent (docId, json),
},
},
});
Option Type Default Description elstring | HTMLElementRequired Mount target contentstring | object""Initial HTML or ProseMirror JSON editablebooleantrueWhether the document can be edited classNamesClassNames- Optional host classes extensionsOptionsExtensionsOptions{}Feature configuration
extensionsOptions?.autoSave ?: AutoSaveOptions
Option Type Default Description enabledbooleantrueEnable auto-save onFetch() => Promise<{ content: string }>- Load content before editor render onSaveContent(json: string) => Promise<void>- Persist body JSON debounceMsnumber1000Save debounce onStatusChange(status) => void- Receives idle, saving, saved, or error
See Auto-save for the full flow.
extensionsOptions?.codeBlockShiki ?: CodeBlockShikiOptions
Option Type Default Description defaultThemestringSDK default Default Shiki theme cdnfalse | CodeBlockShikiCdnOptionsenabled Remote Shiki language/theme loading
See Code blocks .
extensionsOptions?.ai ?: AiExtensionOptions
Option Type Default Description enabledbooleanfalseEnable AI extension aiConfig.onStreamRequest(opts: AiTextResolverOptions) => Promise<ReadableStream>- Stream request handler aiConfig.onCompletionRequest(opts: AiTextResolverOptions) => Promise<string | null>- Completion request handler onLoading(context) => void- AI loading callback onSuccess(context) => void- AI success callback onError(error, context) => void- AI error callback
extensionsOptions?.image ?: ImageExtensionOptions
Option Type Default Description enabledbooleantrueEnable image extension onUpload(file: File) => Promise<string>- Image upload handler; returns URL
extensionsOptions?.attachment ?: AttachmentExtensionOptions
Option Type Default Description enabledbooleantrueEnable attachment extension onUpload(file: File) => Promise<{ url: string; name: string }>- Attachment upload handler
extensionsOptions?.wechatCopy ?: WechatCopyExtensionOptions
Option Type Default Description enabledbooleanfalseEnable WeChat copy onCopy(payload) => void- Copy event callback
extensionsOptions?.meta ?: MetaOptions
Title bar, emoji, and cover use FetchMetaObject.
Option Type Default Description onFetchMeta() => Promise<FetchMetaObject>- Load metadata before the editor renders onSaveMeta(meta: FetchMetaObject) => Promise<void>- Persist metadata from the built-in meta UI onMetaChange(meta: FetchMetaObject) => void- Sync host state when metadata changes
If onSaveMeta or onMetaChange is provided, the built-in meta section is shown. At runtime, editor.getMeta() and editor.setMeta(partial) read and merge metadata on the EditorInstance .
extensionsOptions?.versionHistory ?: VersionHistoryOptions
See Version History for full documentation.
Option Type Default Description enabledbooleanfalseEnable version history storageKeystring- localStorage key maxEntriesnumber50Max local snapshots debounceMsnumber2000Auto-snapshot debounce
Option Type Description onCreate(instance: EditorInstance) => voidCalled after editor is ready onUpdate(instance: EditorInstance) => voidCalled on every content change onDestroy() => voidCalled when editor is destroyed
interface ClassNames {
root ?: string ;
toolbar ?: string ;
content ?: string ;
}
SVeditor. create ({
el: "#editor" ,
content: "<p>Hello world</p>" ,
editable: true ,
extensionsOptions: {
autoSave: {
onFetch : async () => fetchDoc (docId),
onSaveContent : async ( json ) => saveDoc (docId, json),
debounceMs: 1000 ,
onStatusChange: setSaveStatus,
},
meta: {
onFetchMeta : async () => fetchMeta (docId),
onSaveMeta : async ( meta ) => saveMeta (docId, meta),
onMetaChange : ( meta ) => setHostMetaSnapshot (meta),
},
ai: {
enabled: true ,
aiConfig: {
onStreamRequest: handleAiStream,
},
},
image: {
enabled: true ,
onUpload : async ( file ) => uploadImage (file),
},
versionHistory: {
enabled: true ,
storageKey: `doc:${ docId }:snapshots` ,
maxEntries: 50 ,
},
},
onCreate : ( instance ) => {
console. log ( "Editor ready" , instance);
},
onDestroy : () => {
console. log ( "Editor destroyed" );
},
});