{"version":3,"file":"richText.cjs","sources":["../../../src/value/richText.ts"],"sourcesContent":["import type { EmbedField } from \"./embed\";\nimport type { FieldState } from \"./types\";\nimport type { FilledContentRelationshipField } from \"./contentRelationship\";\nimport type { FilledLinkToMediaField } from \"./linkToMedia\";\nimport type { FilledLinkToWebField } from \"./link\";\n\n/**\n * Types for RichTextNodes\n *\n * @see More details: {@link https://prismic.io/docs/core-concepts/rich-text-title}\n */\nexport const RichTextNodeType = {\n\theading1: \"heading1\",\n\theading2: \"heading2\",\n\theading3: \"heading3\",\n\theading4: \"heading4\",\n\theading5: \"heading5\",\n\theading6: \"heading6\",\n\tparagraph: \"paragraph\",\n\tpreformatted: \"preformatted\",\n\tstrong: \"strong\",\n\tem: \"em\",\n\tlistItem: \"list-item\",\n\toListItem: \"o-list-item\",\n\tlist: \"group-list-item\",\n\toList: \"group-o-list-item\",\n\timage: \"image\",\n\tembed: \"embed\",\n\thyperlink: \"hyperlink\",\n\tlabel: \"label\",\n\tspan: \"span\",\n} as const;\n\n// Text nodes\n\n/**\n * Base to be extended by other RT Nodes.\n */\nexport interface RTTextNodeBase {\n\ttext: string;\n\tspans: RTInlineNode[];\n}\n\n/**\n * Rich Text `heading1` node\n */\nexport interface RTHeading1Node extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.heading1;\n}\n\n/**\n * Rich Text `heading2` node\n */\nexport interface RTHeading2Node extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.heading2;\n}\n\n/**\n * Rich Text `heading3` node\n */\nexport interface RTHeading3Node extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.heading3;\n}\n\n/**\n * Rich Text `heading4` node\n */\nexport interface RTHeading4Node extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.heading4;\n}\n\n/**\n * Rich Text `heading5` node\n */\nexport interface RTHeading5Node extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.heading5;\n}\n\n/**\n * Rich Text `heading6` node\n */\nexport interface RTHeading6Node extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.heading6;\n}\n\n/**\n * Rich Text `paragraph` node\n */\nexport interface RTParagraphNode extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.paragraph;\n}\n\n/**\n * Rich Text `preformatted` node\n */\nexport interface RTPreformattedNode extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.preformatted;\n}\n\n/**\n * Rich Text `list-item` node\n */\nexport interface RTListItemNode extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.listItem;\n}\n\n/**\n * Rich Text `o-list-item` node for ordered lists\n */\nexport interface RTOListItemNode extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.oListItem;\n}\n\n// Span nodes\n\n/**\n * @internal Span Node base to be extended for other Span nodes\n */\nexport interface RTSpanNodeBase {\n\tstart: number;\n\tend: number;\n}\n/**\n * Rich Text `strong` node\n */\nexport interface RTStrongNode extends RTSpanNodeBase {\n\ttype: typeof RichTextNodeType.strong;\n}\n\n/**\n * Rich Text `embed` node\n */\nexport interface RTEmNode extends RTSpanNodeBase {\n\ttype: typeof RichTextNodeType.em;\n}\n\n/**\n * Rich Text `label` node\n */\nexport interface RTLabelNode extends RTSpanNodeBase {\n\ttype: typeof RichTextNodeType.label;\n\tdata: {\n\t\tlabel: string;\n\t};\n}\n\n// Media nodes\n\n/**\n * Rich Text `image` nodes. They could link to other documents, external web\n * links and media fields\n */\nexport type RTImageNode = {\n\ttype: typeof RichTextNodeType.image;\n\tid: string;\n\turl: string;\n\talt: string | null;\n\tcopyright: string | null;\n\tdimensions: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tedit: {\n\t\tx: number;\n\t\ty: number;\n\t\tzoom: number;\n\t\tbackground: string;\n\t};\n\tlinkTo?:\n\t\t| FilledContentRelationshipField\n\t\t| FilledLinkToWebField\n\t\t| FilledLinkToMediaField;\n};\n\n/**\n * Rich Text `embed` node\n */\nexport type RTEmbedNode = {\n\ttype: typeof RichTextNodeType.embed;\n\toembed: EmbedField;\n};\n\n// Link nodes\n\n/**\n * Rich Text `a` node\n *\n * @see More details: {@link https://prismic.io/docs/core-concepts/edit-rich-text#add-links}\n */\nexport interface RTLinkNode extends RTSpanNodeBase {\n\ttype: typeof RichTextNodeType.hyperlink;\n\tdata:\n\t\t| FilledContentRelationshipField\n\t\t| FilledLinkToWebField\n\t\t| FilledLinkToMediaField;\n}\n\n// Serialization related nodes\n\n/**\n * Rich Text `list` node\n */\nexport interface RTListNode {\n\ttype: typeof RichTextNodeType.list;\n\titems: RTListItemNode[];\n}\n\n/**\n * Rich Text o-lost node\n */\nexport interface RTOListNode {\n\ttype: typeof RichTextNodeType.oList;\n\titems: RTOListItemNode[];\n}\n\n// This one is confusing but it's actually the inner content of a block\n/**\n * Rich Text `span` node\n */\nexport interface RTSpanNode extends RTTextNodeBase {\n\ttype: typeof RichTextNodeType.span;\n}\n\n// Helpers\n\n/**\n * Nodes from a Rich Text Field\n */\nexport type RTNode =\n\t| RTHeading1Node\n\t| RTHeading2Node\n\t| RTHeading3Node\n\t| RTHeading4Node\n\t| RTHeading5Node\n\t| RTHeading6Node\n\t| RTParagraphNode\n\t| RTPreformattedNode\n\t| RTListItemNode\n\t| RTOListItemNode\n\t| RTImageNode\n\t| RTEmbedNode;\n\n/**\n * Rich text nodes with text\n */\nexport type RTTextNode =\n\t| RTHeading1Node\n\t| RTHeading2Node\n\t| RTHeading3Node\n\t| RTHeading4Node\n\t| RTHeading5Node\n\t| RTHeading6Node\n\t| RTParagraphNode\n\t| RTPreformattedNode\n\t| RTListItemNode\n\t| RTOListItemNode;\n\n/**\n * Rich Text block nodes\n */\nexport type RTBlockNode =\n\t| RTHeading1Node\n\t| RTHeading2Node\n\t| RTHeading3Node\n\t| RTHeading4Node\n\t| RTHeading5Node\n\t| RTHeading6Node\n\t| RTParagraphNode\n\t| RTPreformattedNode\n\t| RTListItemNode\n\t| RTOListItemNode\n\t| RTListNode\n\t| RTOListNode\n\t| RTImageNode\n\t| RTEmbedNode;\n\n/**\n * Inline Rich Text Nodes\n */\nexport type RTInlineNode = RTStrongNode | RTEmNode | RTLabelNode | RTLinkNode;\n\n/**\n * All Rich Text nodes\n */\nexport type RTAnyNode = RTBlockNode | RTInlineNode | RTSpanNode;\n\n/**\n * Rich Text Field\n *\n * @see Rich Text field documentation: {@link https://prismic.io/docs/core-concepts/rich-text-title}\n */\nexport type RichTextField<State extends FieldState = FieldState> =\n\tState extends \"empty\" ? [] : [RTNode, ...RTNode[]];\n"],"names":[],"mappings":";;AAWO,MAAM,mBAAmB;AAAA,EAC/B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,WAAW;AAAA,EACX,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;;;"}