# MarkdownEditorApi (@salmonui/editors/markdown-editor)

> The MarkdownEditorApi interface of @salmonui/editors/markdown-editor: Ref handle.

Canonical: https://salmonui.dev/docs/reference/editors/markdown-editor/MarkdownEditorApi

```ts
import type { MarkdownEditorApi } from '@salmonui/editors/markdown-editor';
```

Entry index: https://salmonui.dev/docs/reference/editors/markdown-editor (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/editors/markdown-editor.md).

## Reference

Kind: interface

```ts
interface MarkdownEditorApi {
    readonly element: HTMLTextAreaElement | null;
    runCommand(id: string): void;
    insertText(text: string): void;
    wrapSelection(before: string, after: string): void;
    focus(): void;
    blur(): void;
    getSelection(): {
        readonly start: number;
        readonly end: number;
        readonly text: string;
    };
    setSelection(start: number, end: number): void;
}
```

Ref handle.

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `element` | `readonly element: HTMLTextAreaElement \| null;` |  | The textarea. |
| `runCommand` | `runCommand(id: string): void;` |  | Runs a toolbar item by id (built-in or custom). |
| `insertText` | `insertText(text: string): void;` |  | Replaces the selection with `text` (undoable). |
| `wrapSelection` | `wrapSelection(before: string, after: string): void;` |  | Toggles `before` / `after` around the selection. |
| `focus` | `focus(): void;` |  |  |
| `blur` | `blur(): void;` |  |  |
| `getSelection` | `getSelection(): {     readonly start: number;     readonly end: number;     readonly text: string; };` |  |  |
| `setSelection` | `setSelection(start: number, end: number): void;` |  |  |
