Skip to content

Vizel API / core/src / CreateVizelEditorInstanceOptions

Interface: CreateVizelEditorInstanceOptions

Defined in: packages/core/src/utils/editorFactory.ts:80

Options for creating a Vizel editor instance. Extends VizelEditorOptions with additional framework-specific parameters.

Extends

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

Inherited from

VizelEditorOptions.autofocus


createSlashMenuRenderer

ts
createSlashMenuRenderer: () => Partial<SuggestionOptions<VizelCommand>>;

Defined in: packages/core/src/utils/editorFactory.ts:84

Factory function to create the slash menu renderer

Returns

Partial&lt;SuggestionOptions&lt;VizelCommand&gt;&gt;


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

Inherited from

VizelEditorOptions.editable


extensions?

ts
optional extensions?: Extensions;

Defined in: packages/core/src/utils/editorFactory.ts:82

Additional extensions to include


features?

ts
optional features?: VizelFeatureOptions;

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

Feature configuration

Inherited from

VizelEditorOptions.features


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.

Inherited from

VizelEditorOptions.initialContent


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.",
});

Inherited from

VizelEditorOptions.initialMarkdown


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.

Inherited from

VizelEditorOptions.locale


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;

Inherited from

VizelEditorOptions.markdown


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

Inherited from

VizelEditorOptions.onBlur


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

Inherited from

VizelEditorOptions.onCreate


onDestroy?

ts
optional onDestroy?: () => void;

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

Callback when editor is destroyed

Returns

void

Inherited from

VizelEditorOptions.onDestroy


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);
  },
});

Inherited from

VizelEditorOptions.onError


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

Inherited from

VizelEditorOptions.onFocus


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

Inherited from

VizelEditorOptions.onSelectionUpdate


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

Inherited from

VizelEditorOptions.onUpdate


placeholder?

ts
optional placeholder?: string;

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

Placeholder text when editor is empty

Inherited from

VizelEditorOptions.placeholder


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

Inherited from

VizelEditorOptions.transformDiagramsOnImport

Released under the MIT License.