Skip to content

Vizel API / core/src / VizelEditorOptions

Interface: VizelEditorOptions

Defined in: packages/core/src/types.ts:204

Editor configuration options

Extended by

Properties

autofocus?

ts
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

ts
false

editable?

ts
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

ts
true

features?

ts
optional features?: VizelFeatureOptions;

Defined in: packages/core/src/types.ts:206

Feature configuration


initialContent?

ts
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?

ts
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

typescript
const editor = useVizelEditor({
  initialMarkdown: "# Hello World\n\nThis is **bold** text.",
});

locale?

ts
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?

ts
optional markdown?: object;

Defined in: packages/core/src/types.ts:225

Markdown pipeline configuration.

  • flavor selects the Markdown output flavor. The parser remains tolerant across formats; only serialization follows the selected flavor. Defaults to vizelGfmFlavor when omitted.
  • encoding selects 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?

ts
readonly optional encoding?: VizelMarkdownEncodingOptions;

flavor?

ts
readonly optional flavor?: VizelMarkdownFlavor;

onBlur?

ts
optional onBlur?: (props) => void;

Defined in: packages/core/src/types.ts:289

Callback when editor loses focus

Parameters

ParameterType
props{ editor: Editor; }
props.editorEditor

Returns

void


onCreate?

ts
optional onCreate?: (props) => void;

Defined in: packages/core/src/types.ts:281

Callback when editor is created

Parameters

ParameterType
props{ editor: Editor; }
props.editorEditor

Returns

void


onDestroy?

ts
optional onDestroy?: () => void;

Defined in: packages/core/src/types.ts:283

Callback when editor is destroyed

Returns

void


onError?

ts
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 to onErrorand then rethrows so global handlers (Sentry, window.onunhandledrejection, React error boundaries, test runners) still observe the failure. Supplying onError does not suppress the rethrow — a blank editor must never fail silently.
  • Recoverable runtime errors (UPLOAD_FAILED, EMBED_LOAD_FAILED, the MARKDOWN_LOSSY warning, ...). The core emits these through emitVizelError(error, onError) without rethrow; the editor keeps running. When no onError is set, the fallback writes errors to console.error and 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

ParameterType
errorVizelError

Returns

void

Example

typescript
const editor = useVizelEditor({
  onError: (error) => {
    reportToSentry(error);
    if (error.code === "UPLOAD_FAILED") showToast(error.message);
  },
});

onFocus?

ts
optional onFocus?: (props) => void;

Defined in: packages/core/src/types.ts:287

Callback when editor gets focus

Parameters

ParameterType
props{ editor: Editor; }
props.editorEditor

Returns

void


onSelectionUpdate?

ts
optional onSelectionUpdate?: (props) => void;

Defined in: packages/core/src/types.ts:285

Callback when selection changes

Parameters

ParameterType
props{ editor: Editor; }
props.editorEditor

Returns

void


onUpdate?

ts
optional onUpdate?: (props) => void;

Defined in: packages/core/src/types.ts:279

Callback when content changes

Parameters

ParameterType
props{ editor: Editor; }
props.editorEditor

Returns

void


placeholder?

ts
optional placeholder?: string;

Defined in: packages/core/src/types.ts:259

Placeholder text when editor is empty


transformDiagramsOnImport?

ts
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

ts
true

Released under the MIT License.