View as Markdown

API reference: @salmonui/editors/markdown-editor

MarkdownEditorApiinterface

import type { MarkdownEditorApi } from '@salmonui/editors/markdown-editor';
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.

MarkdownEditorApi members (8)
NameSignatureDescription
elementreadonly element: HTMLTextAreaElement | null;

The textarea.

runCommandrunCommand(id: string): void;

Runs a toolbar item by id (built-in or custom).

insertTextinsertText(text: string): void;

Replaces the selection with text (undoable).

wrapSelectionwrapSelection(before: string, after: string): void;

Toggles before / after around the selection.

focusfocus(): void;
blurblur(): void;
getSelectiongetSelection(): { readonly start: number; readonly end: number; readonly text: string; };
setSelectionsetSelection(start: number, end: number): void;