Sanity Library Reference Docs
    Preparing search index...

    Interface BlockProps

    Props for rendering a Portable Text block

    interface BlockProps {
        __unstable_floatingBoundary: HTMLElement;
        __unstable_referenceBoundary: HTMLElement;
        __unstable_referenceElement: HTMLElement;
        children: ReactNode;
        focused: boolean;
        markers: PortableTextMarker[];
        onClose: () => void;
        onOpen: () => void;
        onPathFocus: (path: Path) => void;
        onRemove: () => void;
        open: boolean;
        parentSchemaType: ObjectSchemaType | ArraySchemaType<unknown>;
        path: Path;
        presence: FormNodePresence[];
        readOnly: boolean;
        renderAnnotation?: RenderAnnotationCallback;
        renderBlock?: RenderBlockCallback;
        renderDefault: (props: BlockProps) => Element;
        renderField: RenderFieldCallback;
        renderInlineBlock?: RenderBlockCallback;
        renderInput: RenderInputCallback;
        renderItem: RenderArrayOfObjectsItemCallback;
        renderPreview: RenderPreviewCallback;
        schemaType: ObjectSchemaType;
        selected: boolean;
        validation: FormNodeValidation[];
        value: PortableTextBlock;
    }
    Index

    Properties

    __unstable_floatingBoundary: HTMLElement

    Boundary element of the floating toolbar element.

    __unstable_referenceBoundary: HTMLElement

    Boundary element for the block.

    __unstable_referenceElement: HTMLElement

    DOM element for the block.

    children: ReactNode

    The default rendering of the block (the text).

    focused: boolean

    If the block currently is focused by the user.

    markers: PortableTextMarker[]

    Markers (meta data) connected to this annotation.

    • use renderBlock and renderInlineBlock interfaces instead
    onClose: () => void

    Closes the editing form connected to this block. For regular text blocks this is not relevant.

    onOpen: () => void

    Opens the editing form connected to this block. For regular text blocks this is not relevant.

    onPathFocus: (path: Path) => void

    Focus a form node in this block.

    Type declaration

      • (path: Path): void
      • Parameters

        • path: Path

          the relative path to the form node to put focus on.

        Returns void

    onRemove: () => void

    Removes the block.

    open: boolean

    If the block is currently opened for editing.

    parentSchemaType: ObjectSchemaType | ArraySchemaType<unknown>

    The parent schema type (array type).

    path: Path

    The full form path to this block from document root.

    presence: FormNodePresence[]

    Form presence for this block.

    readOnly: boolean

    Is the block object read only?

    renderAnnotation?: RenderAnnotationCallback

    Plugin chain render callback.

    renderBlock?: RenderBlockCallback

    Plugin chain render callback.

    renderDefault: (props: BlockProps) => Element

    Plugin chain render callback (default rendering function of the block).

    renderField: RenderFieldCallback

    Plugin chain render callback.

    renderInlineBlock?: RenderBlockCallback

    Plugin chain render callback.

    renderInput: RenderInputCallback

    Plugin chain render callback.

    renderItem: RenderArrayOfObjectsItemCallback

    Plugin chain render callback.

    renderPreview: RenderPreviewCallback

    Plugin chain render callback.

    schemaType: ObjectSchemaType

    The schema type for the block.

    selected: boolean

    If the block is in the user's selection.

    validation: FormNodeValidation[]

    Form validation for the block object.

    Value of the block.