D-ID Client SDK - v3.0.0-0
    Preparing search index...

    Type Alias MessagePart

    MessagePart:
        | { text: string; type: "text" }
        | { alt: string; mimeType?: string; src: string; type: "image" }
        | { alt: string; src: string; thumbnail?: string; type: "video" }
        | { href: string; label: string; type: "link" }

    One renderable piece of a message: a run of text, an image, a video or a link.

    parseMessageParts splits a message's content into these, and the SDK keeps the result on Message.parts. Switch on type when rendering. Anything the parser did not recognize is preserved verbatim as a text part, in its original order, and nothing is dropped or reordered; a recognized image, video or link replaces the markup it was written as, so the parts are not a concatenation of the original string.

    Type Declaration

    • { text: string; type: "text" }
      • text: string

        The text itself, exactly as it appeared in Message.content.

      • type: "text"

        Discriminant: plain text that the parser found no markup in.

    • { alt: string; mimeType?: string; src: string; type: "image" }
      • alt: string

        The alt text from the markdown, or an empty string when it had none.

      • OptionalmimeType?: string

        image/gif when the URL itself ends in .gif, ignoring case; absent otherwise.

        The check looks at the whole URL, so a query string or fragment suppresses it — cat.gif?v=2 carries no mimeType. Video detection differs: it strips both before looking at the extension.

      • src: string

        URL of the image.

      • type: "image"

        Discriminant: an image, from markdown image syntax such as ![alt](url).

    • { alt: string; src: string; thumbnail?: string; type: "video" }
      • alt: string

        The alt text from the markdown, or an empty string when it had none.

      • src: string

        URL of the video file.

      • Optionalthumbnail?: string

        URL of the poster image, when the thumbnail syntax supplied one.

      • type: "video"

        Discriminant: a video, either from thumbnail syntax ([![alt](thumb)](video)) or from an image whose URL ends in .mp4, .webm, .mkv, .mov, .m4v or .ogv once any query string and fragment have been stripped.

    • { href: string; label: string; type: "link" }
      • href: string

        Target of the link.

      • label: string

        The text shown for the link.

      • type: "link"

        Discriminant: a link, from markdown [label](url) or from an HTML <a href>.