Vizel API / core/src / VizelEditorOptions
Interface: VizelEditorOptions
Defined in: packages/core/src/types.ts:204
Editor configuration options
Extended by
Properties
autofocus?
optional autofocus?: number | boolean | "all" | "start" | "end";Defined in: packages/core/src/types.ts:277
Auto focus on mount.
false(default) — do not focus.true— focus and place the cursor at the end of the document."start"/"end"/"all"— focus with the corresponding selection.number— focus and place the cursor at that document position (clamped to[0, docSize]).
Default
falseeditable?
optional editable?: boolean;Defined in: packages/core/src/types.ts:267
Whether the editor accepts user input. Toggle at runtime to switch between read-write and read-only modes; the framework hooks/composables/runes propagate the change through editor.setEditable() automatically.
Default
truefeatures?
optional features?: VizelFeatureOptions;Defined in: packages/core/src/types.ts:206
Feature configuration
initialContent?
optional initialContent?: JSONContent;Defined in: packages/core/src/types.ts:236
Initial content in JSON format.
Mutually exclusive with VizelEditorOptions.initialMarkdown. If both are provided, initialMarkdown wins and a warning is emitted at editor creation time.
initialMarkdown?
optional initialMarkdown?: string;Defined in: packages/core/src/types.ts:251
Initial content in Markdown format.
Mutually exclusive with VizelEditorOptions.initialContent. If both are provided, initialMarkdown wins and a warning is emitted at editor creation time.
Example
const editor = useVizelEditor({
initialMarkdown: "# Hello World\n\nThis is **bold** text.",
});locale?
optional locale?: VizelLocale;Defined in: packages/core/src/types.ts:212
Locale for UI strings. Defaults to English (vizelEnLocale). Use createVizelLocale() to merge partial translations with the default.
markdown?
optional markdown?: object;Defined in: packages/core/src/types.ts:225
Markdown pipeline configuration.
flavorselects the Markdown output flavor. The parser remains tolerant across formats; only serialization follows the selected flavor. Defaults to vizelGfmFlavor when omitted.encodingselects the per-node encoding mode for nodes that have no canonical Markdown representation (embed,mention,wikiLink)."default"chooses the lossy-but-portable encoding;"metadata-comment"chooses the lossless-but-noisy encoding that preserves identifiers via a trailing HTML comment.
encoding?
readonly optional encoding?: VizelMarkdownEncodingOptions;flavor?
readonly optional flavor?: VizelMarkdownFlavor;onBlur?
optional onBlur?: (props) => void;Defined in: packages/core/src/types.ts:289
Callback when editor loses focus
Parameters
| Parameter | Type |
|---|---|
props | { editor: Editor; } |
props.editor | Editor |
Returns
void
onCreate?
optional onCreate?: (props) => void;Defined in: packages/core/src/types.ts:281
Callback when editor is created
Parameters
| Parameter | Type |
|---|---|
props | { editor: Editor; } |
props.editor | Editor |
Returns
void
onDestroy?
optional onDestroy?: () => void;Defined in: packages/core/src/types.ts:283
Callback when editor is destroyed
Returns
void
onError?
optional onError?: (error) => void;Defined in: packages/core/src/types.ts:323
Editor-level error sink. Receives a typed VizelError carrying a stable code so the consumer can log, branch, or render user feedback.
Two delivery paths reach this callback, matching the error model in .claude/rules/packages/core.md:
- Configuration / initialization errors (
INVALID_CONFIG,SSR_NOT_SUPPORTED, ...). The adapter emits the error toonErrorand then rethrows so global handlers (Sentry,window.onunhandledrejection, React error boundaries, test runners) still observe the failure. SupplyingonErrordoes not suppress the rethrow — a blank editor must never fail silently. - Recoverable runtime errors (
UPLOAD_FAILED,EMBED_LOAD_FAILED, theMARKDOWN_LOSSYwarning, ...). The core emits these throughemitVizelError(error, onError)without rethrow; the editor keeps running. When noonErroris set, the fallback writes errors toconsole.errorand stays silent for warnings.
Image-upload failures route here in addition to the feature-level features.content.image.onUploadError, so observability sinks see the failure even when only the feature callback drives UI.
Parameters
| Parameter | Type |
|---|---|
error | VizelError |
Returns
void
Example
const editor = useVizelEditor({
onError: (error) => {
reportToSentry(error);
if (error.code === "UPLOAD_FAILED") showToast(error.message);
},
});onFocus?
optional onFocus?: (props) => void;Defined in: packages/core/src/types.ts:287
Callback when editor gets focus
Parameters
| Parameter | Type |
|---|---|
props | { editor: Editor; } |
props.editor | Editor |
Returns
void
onSelectionUpdate?
optional onSelectionUpdate?: (props) => void;Defined in: packages/core/src/types.ts:285
Callback when selection changes
Parameters
| Parameter | Type |
|---|---|
props | { editor: Editor; } |
props.editor | Editor |
Returns
void
onUpdate?
optional onUpdate?: (props) => void;Defined in: packages/core/src/types.ts:279
Callback when content changes
Parameters
| Parameter | Type |
|---|---|
props | { editor: Editor; } |
props.editor | Editor |
Returns
void
placeholder?
optional placeholder?: string;Defined in: packages/core/src/types.ts:259
Placeholder text when editor is empty
transformDiagramsOnImport?
optional transformDiagramsOnImport?: boolean;Defined in: packages/core/src/types.ts:257
Automatically transform diagram code blocks (mermaid, graphviz) to diagram nodes when importing markdown content. Only applies when initialMarkdown is provided.
Default
true