• Takes a Portable Text block and returns a nested tree of nodes optimized for rendering in HTML-like environments where you want marks/annotations to be nested inside of eachother. For instance, a naive span-by-span rendering might yield:

    <strong>This block contains </strong>
    <strong><a href="https://some.url/">a link</a></strong>
    <strong> and some bolded and </strong>
    <em><strong>italicized text</strong></em>

    ...whereas an optimal order would be:

    <strong>
    This block contains <a href="https://some.url/">a link</a>
    and some bolded and <em>italicized text</em>
    </strong>

    Note that since "native" Portable Text spans cannot be nested, this function returns an array of "toolkit specific" types: @text and @span .

    The toolkit-specific type can hold both types, as well as any arbitrary inline objects, creating an actual tree.

    Type Parameters

    • M extends PortableTextMarkDefinition = PortableTextMarkDefinition

    Parameters

    • block: PortableTextBlock<M, PortableTextSpan | ArbitraryTypedObject, string, string>

      The Portable Text block to create a tree of nodes from

    Returns (ToolkitNestedPortableTextSpan<M> | ToolkitTextNode | ArbitraryTypedObject)[]

    Array of (potentially) nested spans, text nodes and/or arbitrary inline objects