API Reference
Types
TypeScript type definitions exported by SVeditor.
Types
All types are exported from the main package entry:
import type {
EditorOptions,
EditorInstance,
AutoSaveOptions,
MetaOptions,
FetchMetaObject,
SaveStatus,
FetchStatus,
CollaborationExtensionOptions,
CollabStatus,
AiTextResolverOptions,
VersionHistoryOptions,
VersionSnapshot,
} from '@wztlink1013/sveditor';Core Types
EditorOptions
See EditorOptions for full documentation.
interface EditorOptions {
el: string | HTMLElement;
content?: string;
editable?: boolean;
classNames?: ClassNames;
autoSave?: AutoSaveOptions;
extensionsOptions?: ExtensionOptions;
versionHistory?: VersionHistoryOptions;
onCreate?: (instance: EditorInstance) => void;
onUpdate?: (instance: EditorInstance) => void;
onDestroy?: () => void;
}EditorInstance
See EditorInstance for full documentation.
interface EditorInstance {
getHTML(): string;
setHTML(html: string): void;
getText(): string;
getJSON(): object;
setJSON(json: object | string): void;
getMeta(): FetchMetaObject;
setMeta(meta: Partial<FetchMetaObject>): void;
destroy(): void;
}Configure metadata persistence and change notifications with MetaOptions (extensionsOptions.meta). See EditorInstance and EditorOptions.
Auto Save Types
SaveStatus
type SaveStatus = 'idle' | 'saving' | 'saved' | 'error';FetchStatus
type FetchStatus = 'idle' | 'fetching' | 'success' | 'error';FetchMetaObject
interface FetchMetaObject {
name?: string;
description?: string;
contentStr?: string;
emojiInfo?: string;
coverImage?: string;
coverBlock?: string;
coverPos?: string;
}emojiInfo is typically a JSON string produced by the built-in emoji control (parse if you need structured fields).
MetaOptions
interface MetaOptions {
onFetchMeta?: () => Promise<FetchMetaObject>;
onSaveMeta?: (meta: FetchMetaObject) => Promise<void>;
onMetaChange?: (meta: FetchMetaObject) => void;
}Collaboration Types
CollabStatus
type CollabStatus = 'disconnected' | 'connecting' | 'connected' | 'error';AI Types
AiTextResolverOptions
interface AiTextResolverOptions {
editor: Editor;
action: string;
text: string;
textOptions: {
format?: 'plain-text' | 'rich-text';
};
extensionOptions: AiOptions;
aborter?: AbortController;
}Version History Types
VersionSnapshot
interface VersionSnapshot {
id: string;
label?: string;
createdAt: number;
content: string;
}