Sanity Library Reference Docs
    Preparing search index...

    Interface PortableTextInputProps

    Component props for the PortableTextInput React component.

    Extends ArrayOfObjectsInputProps.

    interface PortableTextInputProps {
        __unstable_computeDiff: ComputeDiff<ProvenanceDiffAnnotation>;
        arrayFunctions?: ComponentType<
            ArrayInputFunctionsProps<
                PortableTextBlock,
                ArraySchemaType<PortableTextBlock>,
            >,
        >;
        changed: boolean;
        compareValue?: PortableTextBlock[];
        displayInlineChanges: boolean;
        editorRef?: MutableRefObject<PortableTextEditor>;
        elementProps: ComplexElementProps;
        focused?: boolean;
        focusPath: Path;
        hasUpstreamVersion: boolean;
        hideToolbar?: boolean;
        hotkeys?: HotkeyOptions;
        id: string;
        initialActive?: boolean;
        initialFullscreen?: boolean;
        level: number;
        markers?: PortableTextMarker[];
        members: ArrayOfObjectsMember[];
        onChange: (patch: PatchEvent | FormPatch | FormPatch[]) => void;
        onCopy?: OnCopyFn;
        onEditorChange?: (change: EditorChange, editor: PortableTextEditor) => void;
        onFullScreenChange?: (isFullScreen: boolean) => void;
        onInsert: (event: ArrayInputInsertEvent<PortableTextBlock>) => void;
        onItemAppend: (item: PortableTextBlock) => void;
        onItemClose: () => void;
        onItemCollapse: (itemKey: string) => void;
        onItemExpand: (itemKey: string) => void;
        onItemMove: (event: ArrayInputMoveItemEvent) => void;
        onItemOpen: (path: Path) => void;
        onItemPrepend: (item: PortableTextBlock) => void;
        onItemRemove: (itemKey: string) => void;
        onPaste?: OnPasteFn;
        onPathFocus: (path: Path, payload?: OnPathFocusPayload) => void;
        onSelectFile?: (props: InputOnSelectFileFunctionProps) => void;
        onUpload?: (event: UploadEvent) => void;
        path: Path;
        presence: FormNodePresence[];
        rangeDecorations?: RangeDecoration[];
        readOnly?: boolean;
        renderAnnotation?: RenderAnnotationCallback;
        renderBlock?: RenderBlockCallback;
        renderBlockActions?: RenderBlockActionsCallback;
        renderCustomMarkers?: RenderCustomMarkers;
        renderDefault: (props: InputProps) => Element;
        renderField: RenderFieldCallback;
        renderInlineBlock?: RenderBlockCallback;
        renderInput: RenderInputCallback;
        renderItem: RenderArrayOfObjectsItemCallback;
        renderPreview: RenderPreviewCallback;
        resolveInitialValue: (
            type: SchemaType,
            params: Record<string, unknown>,
        ) => Promise<PortableTextBlock>;
        resolveUploader: UploaderResolver<ObjectSchemaType>;
        schemaType: ArraySchemaType;
        validation: FormNodeValidation[];
        value: PortableTextBlock[];
    }

    Hierarchy (View Summary)

    Index

    Properties

    __unstable_computeDiff: ComputeDiff<ProvenanceDiffAnnotation>

    A function that takes any value and produces a diff between that value and the value the node is being compared to.

    This can be used to compute a diff optimistically.

    This is marked as unstable because the API may need to evolve as we iterate on the advanced version control functionality. It will be stabilised when that project has matured.

    arrayFunctions?: ComponentType<
        ArrayInputFunctionsProps<
            PortableTextBlock,
            ArraySchemaType<PortableTextBlock>,
        >,
    >
    changed: boolean

    Whether the current value is different to the value the node is being compared to.

    compareValue?: PortableTextBlock[]

    The value the node is currently being compared to. This is taken from the upstream version, if the document has an upstream version. Otherwise, it's taken from the document's current value.

    You can use the hasUpstreamVersion prop to determine whether the document has an upstream version.

    displayInlineChanges: boolean

    Whether the input should display inline changes. Inline changes express how a field's value differs from its upstream version. Unlike custom diff components, inline changes is a mode that allows the input component itself to display the change in situ.

    editorRef?: MutableRefObject<PortableTextEditor>

    A React Ref that can reference the underlying editor instance

    elementProps: ComplexElementProps
    focused?: boolean

    Whether the node is focused.

    focusPath: Path

    The focus path of the form node.

    hasUpstreamVersion: boolean

    Whether the document has an upstream version.

    hideToolbar?: boolean

    Option to hide the default toolbar

    hotkeys?: HotkeyOptions

    Assign hotkeys that can be attached to custom editing functions

    id: string

    The unique identifier of the node.

    initialActive?: boolean

    Whether the input is activated and should receive events on mount. By default, this value is set to true

    initialFullscreen?: boolean

    Whether the input is initially open in fullscreen mode

    level: number

    The level of the node in the form hierarchy.

    markers?: PortableTextMarker[]

    Array of PortableTextMarker with meta data connected to the content.

    will be removed in the next major version of Sanity Studio. Use the renderBlock interface instead.

    onChange: (patch: PatchEvent | FormPatch | FormPatch[]) => void
    onCopy?: OnCopyFn

    Custom copy function

    onEditorChange?: (change: EditorChange, editor: PortableTextEditor) => void

    Returns changes from the underlying editor

    onFullScreenChange?: (isFullScreen: boolean) => void

    Optional callback for when the editor goes into or out of full screen mode

    onInsert: (event: ArrayInputInsertEvent<PortableTextBlock>) => void
    onItemAppend: (item: PortableTextBlock) => void
    onItemClose: () => void
    onItemCollapse: (itemKey: string) => void

    for array inputs using expand/collapse semantics for items

    onItemExpand: (itemKey: string) => void
    onItemMove: (event: ArrayInputMoveItemEvent) => void
    onItemOpen: (path: Path) => void

    for array inputs using modal open/close semantics for items

    onItemPrepend: (item: PortableTextBlock) => void
    onItemRemove: (itemKey: string) => void
    onPaste?: OnPasteFn

    Custom paste function

    onPathFocus: (path: Path, payload?: OnPathFocusPayload) => void
    onSelectFile?: (props: InputOnSelectFileFunctionProps) => void
    onUpload?: (event: UploadEvent) => void
    path: Path

    The path of the node in the form hierarchy.

    presence: FormNodePresence[]
    rangeDecorations?: RangeDecoration[]

    Array of RangeDecoration that can be used to decorate the content.

    readOnly?: boolean

    Whether the node is read-only.

    renderAnnotation?: RenderAnnotationCallback
    renderBlock?: RenderBlockCallback
    renderBlockActions?: RenderBlockActionsCallback

    Function to render custom block actions

    will be removed in the next major version of Sanity Studio. Use the renderBlock interface instead.

    renderCustomMarkers?: RenderCustomMarkers

    Function to render custom markers

    will be removed in the next major version of Sanity Studio. Use the renderBlock interface instead.

    renderDefault: (props: InputProps) => Element
    renderField: RenderFieldCallback
    renderInlineBlock?: RenderBlockCallback
    renderInput: RenderInputCallback
    renderPreview: RenderPreviewCallback
    resolveInitialValue: (
        type: SchemaType,
        params: Record<string, unknown>,
    ) => Promise<PortableTextBlock>
    schemaType: ArraySchemaType

    The schema type of the node.

    validation: FormNodeValidation[]

    The validation markers of the node.

    The value of the node.