View as Markdown

API reference: @salmonui/rich-text

BlockEditorPropsinterface

import type { BlockEditorProps } from '@salmonui/rich-text';
interface BlockEditorProps {
    readonly value?: readonly Block[];
    readonly defaultValue?: readonly Block[];
    readonly onChange?: (blocks: Block[]) => void;
    readonly onBlockChange?: (event: BlockEditorBlockChangeEvent) => void;
    readonly onSelectionChange?: (selection: BlockEditorSelection | null) => void;
    readonly onFocus?: () => void;
    readonly onBlur?: () => void;
    readonly readOnly?: boolean;
    readonly placeholder?: string;
    readonly slashMenu?: false | readonly BlockEditorSlashItem[];
    readonly inlineToolbar?: false | readonly BlockEditorInlineToolbarItem[];
    readonly transforms?: readonly BlockEditorTransformId[];
    readonly blockActions?: readonly BlockEditorBlockAction[];
    readonly contextMenu?: false | readonly BlockEditorContextMenuItem[];
    readonly draggable?: boolean;
    readonly onBeforeBlockMove?: (event: BlockEditorBeforeBlockMoveEvent) => void;
    readonly onBlockMove?: (event: BlockEditorBlockMoveEvent) => void;
    readonly onUpload?: (file: File) => Promise<{
        readonly src: string;
        readonly alt?: string;
    }>;
    readonly codeLanguages?: readonly {
        readonly value: string;
        readonly label: string;
    }[];
    readonly highlight?: HighlightFn;
    readonly pasteCleanup?: Omit<PasteCleanupOptions, 'embedHosts' | 'sanitize'>;
    readonly onBeforePaste?: (event: BlockEditorBeforePasteEvent) => void;
    readonly onPaste?: (event: BlockEditorPasteEvent) => void;
    readonly undoLimit?: number;
    readonly keyBindings?: Readonly<Partial<Record<BlockEditorCommandId, string | false>>>;
    readonly mentions?: BlockEditorMentions;
    readonly labels?: BlockEditorLabels;
    readonly extensions?: readonly RichTextExtension[];
    readonly embedHosts?: readonly string[];
    readonly sanitize?: SanitizeHook;
    readonly localeText?: Partial<BlockEditorLocaleText>;
    readonly 'aria-label'?: string;
    readonly 'aria-labelledby'?: string;
    readonly id?: string;
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly actionsRef?: Ref<BlockEditorActions | null>;
}
BlockEditorProps members (37)
NameSignatureDescription
valueoptionalreadonly value?: readonly Block[];

Controlled document. Pass back what onChange gave to keep the editor in sync.

defaultValueoptionalreadonly defaultValue?: readonly Block[];
onChangeoptionalreadonly onChange?: (blocks: Block[]) => void;
onBlockChangeoptionalreadonly onBlockChange?: (event: BlockEditorBlockChangeEvent) => void;
onSelectionChangeoptionalreadonly onSelectionChange?: (selection: BlockEditorSelection | null) => void;
onFocusoptionalreadonly onFocus?: () => void;
onBluroptionalreadonly onBlur?: () => void;
readOnlyoptionalreadonly readOnly?: boolean;
placeholderoptionalreadonly placeholder?: string;

Shown in an empty document.

slashMenuoptionalreadonly slashMenu?: false | readonly BlockEditorSlashItem[];

Slash menu entries (default: every built-in); false turns the menu off.

inlineToolbaroptionalreadonly inlineToolbar?: false | readonly BlockEditorInlineToolbarItem[];

Selection toolbar entries (default bold, italic, underline, strike, code, link, turnInto); false hides it.

transformsoptionalreadonly transforms?: readonly BlockEditorTransformId[];

Types offered by 'turnInto' (default: all).

blockActionsoptionalreadonly blockActions?: readonly BlockEditorBlockAction[];

Block action menu entries (default duplicate, delete, moveUp, moveDown, turnInto).

contextMenuoptionalreadonly contextMenu?: false | readonly BlockEditorContextMenuItem[];

Context menu entries (default: all built-in); false keeps the browser menu.

draggableoptionalreadonly draggable?: boolean;

Drag handles reorder and nest blocks (default true).

onBeforeBlockMoveoptionalreadonly onBeforeBlockMove?: (event: BlockEditorBeforeBlockMoveEvent) => void;
onBlockMoveoptionalreadonly onBlockMove?: (event: BlockEditorBlockMoveEvent) => void;
onUploadoptionalreadonly onUpload?: (file: File) => Promise<{ readonly src: string; readonly alt?: string; }>;

Uploads an image, audio or video file; the block is pending until it settles. Default: a blob URL.

codeLanguagesoptionalreadonly codeLanguages?: readonly { readonly value: string; readonly label: string; }[];

Code block languages.

highlightoptionalreadonly highlight?: HighlightFn;

Code highlighting hook.

pasteCleanupoptionalreadonly pasteCleanup?: Omit<PasteCleanupOptions, 'embedHosts' | 'sanitize'>;

Paste cleanup. Default mode 'clean'.

onBeforePasteoptionalreadonly onBeforePaste?: (event: BlockEditorBeforePasteEvent) => void;
onPasteoptionalreadonly onPaste?: (event: BlockEditorPasteEvent) => void;
undoLimitoptionalreadonly undoLimit?: number;

Undo steps kept (default 30).

keyBindingsoptionalreadonly keyBindings?: Readonly<Partial<Record<BlockEditorCommandId, string | false>>>;

Command id -> key chord (ProseMirror key names, Mod- = Ctrl/Cmd); false removes the default.

mentionsoptionalreadonly mentions?: BlockEditorMentions;
labelsoptionalreadonly labels?: BlockEditorLabels;
extensionsoptionalreadonly extensions?: readonly RichTextExtension[];

Engine extensions, for example createCollaboration() from /collab. Keep the array stable.

embedHostsoptionalreadonly embedHosts?: readonly string[];

Hosts whose iframe embeds are kept by the sanitizer.

sanitizeoptionalreadonly sanitize?: SanitizeHook;

Further sanitizer restriction. Keep it stable.

localeTextoptionalreadonly localeText?: Partial<BlockEditorLocaleText>;
aria-labeloptionalreadonly 'aria-label'?: string;
aria-labelledbyoptionalreadonly 'aria-labelledby'?: string;
idoptionalreadonly id?: string;
classNameoptionalreadonly className?: string;
styleoptionalreadonly style?: CSSProperties;
actionsRefoptionalreadonly actionsRef?: Ref<BlockEditorActions | null>;