/** * Contentful Rich Text <-> the pivot document. * * Contentful is the recursive one: a `document` node containing block nodes * containing inline nodes containing text, every node carrying a `data` object * and a `nodeType` from a closed vocabulary. Two consequences shape this file. * * A link is a *node*, not a mark. `hyperlink` wraps the text it decorates, so a * run of pivot text nodes sharing one link mark has to be gathered back into a * single wrapper on the way out, and unwrapped into per-text marks on the way * in — otherwise a two-word link comes back as two adjacent links. * * Nothing in a Contentful document is addressable. There are no keys, no * per-node identity, and the API takes the whole field value on every write — * so unlike Portable Text there is nothing to merge against and no `previous` * parameter here. Content the vocabulary does not cover (embedded entries and * assets, tables) still rides through as `avocadoUnknownBlock` so that editing * the prose around an embedded entry does not delete it. */ import { type RichTextDoc } from "./doc.ts"; export type ContentfulMark = { type: string; }; export type ContentfulNode = { nodeType: string; data?: Record; content?: ContentfulNode[]; value?: string; marks?: ContentfulMark[]; }; export type ContentfulDocument = { nodeType: "document"; data: Record; content: ContentfulNode[]; }; /** Convert a Contentful Rich Text document into the pivot document. */ export declare function fromContentful(document: unknown): RichTextDoc; /** Convert the pivot document back to a Contentful Rich Text document. */ export declare function toContentful(doc: RichTextDoc): ContentfulDocument;