import { ToolkitListNestMode, ToolkitListNestMode as ListNestMode, ToolkitPortableTextList, ToolkitPortableTextListItem, toPlainText } from "@portabletext/toolkit"; import { ComponentType, JSX, ReactNode } from "react"; import { ArbitraryTypedObject, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextBlockStyle, PortableTextListItemBlock, PortableTextListItemType, TypedObject } from "@portabletext/types"; /** * Properties for the Portable Text react component * * @template B Types that can appear in the array of blocks */ interface PortableTextProps { /** * One or more blocks to render */ value: B | B[] | null | undefined; /** * React components to use for rendering */ components?: PortableTextComponents; /** * Function to call when encountering unknown unknown types, eg blocks, marks, * block style, list styles without an associated React component. * * Will print a warning message to the console by default. * Pass `false` to disable. */ onMissingComponent?: MissingComponentHandler | false; /** * Determines whether or not lists are nested inside of list items (`html`) * or as a direct child of another list (`direct` - for React Native) * * You rarely (if ever) need/want to customize this */ listNestingMode?: ToolkitListNestMode; } /** * Generic type for portable text rendering components that takes blocks/inline blocks * * @template N Node types we expect to be rendering (`PortableTextBlock` should usually be part of this) */ type PortableTextComponent = ComponentType>; /** * React component type for rendering portable text blocks (paragraphs, headings, blockquotes etc) */ type PortableTextBlockComponent = PortableTextComponent; /** * React component type for rendering (virtual, not part of the spec) portable text lists */ type PortableTextListComponent = PortableTextComponent; /** * React component type for rendering portable text list items */ type PortableTextListItemComponent = PortableTextComponent; /** * React component type for rendering portable text marks and/or decorators * * @template M The mark type we expect */ type PortableTextMarkComponent = ComponentType>; type PortableTextTypeComponent = ComponentType>; type LooseRecord = Record & { [P in K]?: V }; type TypeName = T extends { _type: infer Name; } ? (Name extends string ? Name : never) : never; type BuiltInPortableTextString = T extends string ? (string extends T ? never : T) : never; type CustomPortableTextType = Exclude; type CustomPortableTextTypeName = TypeName>; type PortableTextBlockType = Extract; type DefaultPortableTextBlockStyle = BuiltInPortableTextString; type PortableTextBlockStyleName = PortableTextBlockType extends { style?: infer Style; } ? NonNullable