UNPKG

@prismicio/client

Version:

The official JavaScript + TypeScript client library for Prismic

48 lines (47 loc) 1.91 kB
import type { RichTextField } from "../types/value/richText"; /** * Configuration that determines the output of `asText()`. */ type AsTextConfig = { /** * Separator used to join each element. * * @defaultValue ` ` (a space) */ separator?: string; }; /** * @deprecated Use object-style configuration instead. */ type AsTextDeprecatedTupleConfig = [separator?: string]; /** * The return type of `asText()`. */ type AsTextReturnType<Field extends RichTextField | null | undefined> = Field extends RichTextField ? string : null; export declare const asText: { /** * Serializes a rich text or title field to a plain text string. * * @param richTextField - A rich text or title field from Prismic * @param config - Configuration that determines the output of `asText()` * * @returns Plain text equivalent of the provided rich text or title field * * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} */ <Field extends RichTextField | null | undefined>(richTextField: Field, config?: AsTextConfig): AsTextReturnType<Field>; /** * Serializes a rich text or title field to a plain text string. * * @deprecated Use object-style configuration instead. * * @param richTextField - A rich text or title field from Prismic * @param separator - Separator used to join each element, defaults to a space * * @returns Plain text equivalent of the provided rich text or title field * * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title} */ <Field extends RichTextField | null | undefined>(richTextField: Field, ...config: AsTextDeprecatedTupleConfig): AsTextReturnType<Field>; }; export {};