@prismicio/svelte 2.0.0-alpha.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,11 @@
1
1
  <script lang="ts">
2
- import type { RTAnyNode } from "@prismicio/client";
3
- import type { Snippet } from "svelte";
2
+ import type { RichTextComponentProps } from "../types";
4
3
 
5
4
  import PrismicEmbed from "../PrismicEmbed.svelte";
6
5
  import PrismicImage from "../PrismicImage.svelte";
7
6
  import PrismicLink from "../PrismicLink.svelte";
8
7
 
9
- type Props = {
10
- node: RTAnyNode;
11
- children?: Snippet;
12
- };
8
+ type Props = RichTextComponentProps;
13
9
 
14
10
  const { node, children }: Props = $props();
15
11
 
@@ -19,33 +15,33 @@
19
15
  </script>
20
16
 
21
17
  {#if node.type === "heading1"}
22
- <h1 {...dirProp}>{@render children?.()}</h1>
18
+ <h1 {...dirProp}>{@render children()}</h1>
23
19
  {:else if node.type === "heading2"}
24
- <h2 {...dirProp}>{@render children?.()}</h2>
20
+ <h2 {...dirProp}>{@render children()}</h2>
25
21
  {:else if node.type === "heading3"}
26
- <h3 {...dirProp}>{@render children?.()}</h3>
22
+ <h3 {...dirProp}>{@render children()}</h3>
27
23
  {:else if node.type === "heading4"}
28
- <h4 {...dirProp}>{@render children?.()}</h4>
24
+ <h4 {...dirProp}>{@render children()}</h4>
29
25
  {:else if node.type === "heading5"}
30
- <h5 {...dirProp}>{@render children?.()}</h5>
26
+ <h5 {...dirProp}>{@render children()}</h5>
31
27
  {:else if node.type === "heading6"}
32
- <h6 {...dirProp}>{@render children?.()}</h6>
28
+ <h6 {...dirProp}>{@render children()}</h6>
33
29
  {:else if node.type === "paragraph"}
34
- <p {...dirProp}>{@render children?.()}</p>
30
+ <p {...dirProp}>{@render children()}</p>
35
31
  {:else if node.type === "preformatted"}
36
- <pre>{@render children?.()}</pre>
32
+ <pre>{@render children()}</pre>
37
33
  {:else if node.type === "strong"}
38
- <strong>{@render children?.()}</strong>
34
+ <strong>{@render children()}</strong>
39
35
  {:else if node.type === "em"}
40
- <em>{@render children?.()}</em>
36
+ <em>{@render children()}</em>
41
37
  {:else if node.type === "list-item"}
42
- <li {...dirProp}>{@render children?.()}</li>
38
+ <li {...dirProp}>{@render children()}</li>
43
39
  {:else if node.type === "o-list-item"}
44
- <li {...dirProp}>{@render children?.()}</li>
40
+ <li {...dirProp}>{@render children()}</li>
45
41
  {:else if node.type === "group-list-item"}
46
- <ul>{@render children?.()}</ul>
42
+ <ul>{@render children()}</ul>
47
43
  {:else if node.type === "group-o-list-item"}
48
- <ol>{@render children?.()}</ol>
44
+ <ol>{@render children()}</ol>
49
45
  {:else if node.type === "image"}
50
46
  <p class="block-img">
51
47
  <PrismicImage field={node} />
@@ -53,9 +49,9 @@
53
49
  {:else if node.type === "embed"}
54
50
  <PrismicEmbed field={node.oembed} />
55
51
  {:else if node.type === "hyperlink"}
56
- <PrismicLink field={node.data}>{@render children?.()}</PrismicLink>
52
+ <PrismicLink field={node.data}>{@render children()}</PrismicLink>
57
53
  {:else if node.type === "label"}
58
- <span class={node.data.label}>{@render children?.()}</span>
54
+ <span class={node.data.label}>{@render children()}</span>
59
55
  {:else}
60
56
  {#each node.text.split("\n") as line, index (index)}
61
57
  {#if index > 0}<br />{/if}{line}
@@ -1,9 +1,5 @@
1
- import type { RTAnyNode } from "@prismicio/client";
2
- import type { Snippet } from "svelte";
3
- type Props = {
4
- node: RTAnyNode;
5
- children?: Snippet;
6
- };
1
+ import type { RichTextComponentProps } from "../types";
2
+ type Props = RichTextComponentProps;
7
3
  declare const DefaultComponent: import("svelte").Component<Props, {}, "">;
8
4
  type DefaultComponent = ReturnType<typeof DefaultComponent>;
9
5
  export default DefaultComponent;
@@ -2,7 +2,7 @@
2
2
  import type { RichTextField } from "@prismicio/client";
3
3
  import { asTree } from "@prismicio/client/richtext";
4
4
 
5
- import type { SvelteRichTextSerializer } from "../types";
5
+ import type { RichTextComponents } from "../types";
6
6
 
7
7
  import Serialize from "./Serialize.svelte";
8
8
 
@@ -15,7 +15,7 @@
15
15
  /**
16
16
  * An object that maps a rich text block type to a Svelte component.
17
17
  */
18
- components?: SvelteRichTextSerializer;
18
+ components?: RichTextComponents;
19
19
  };
20
20
 
21
21
  const { field, components = {} }: Props = $props();
@@ -1,5 +1,5 @@
1
1
  import type { RichTextField } from "@prismicio/client";
2
- import type { SvelteRichTextSerializer } from "../types";
2
+ import type { RichTextComponents } from "../types";
3
3
  type Props = {
4
4
  /**
5
5
  * The Prismic rich text field to render.
@@ -8,7 +8,7 @@ type Props = {
8
8
  /**
9
9
  * An object that maps a rich text block type to a Svelte component.
10
10
  */
11
- components?: SvelteRichTextSerializer;
11
+ components?: RichTextComponents;
12
12
  };
13
13
  /**
14
14
  * Component to render a Prismic rich text field.
@@ -1,13 +1,13 @@
1
1
  <script lang="ts">
2
2
  import type { asTree } from "@prismicio/client/richtext";
3
3
 
4
- import type { SvelteRichTextSerializer } from "../types";
4
+ import type { RichTextComponent, RichTextComponents } from "../types";
5
5
 
6
6
  import DefaultComponent from "./DefaultComponent.svelte";
7
7
  import Serialize from "./Serialize.svelte";
8
8
 
9
9
  type Props = {
10
- components: SvelteRichTextSerializer;
10
+ components: RichTextComponents;
11
11
  children: ReturnType<typeof asTree>["children"];
12
12
  };
13
13
 
@@ -22,10 +22,10 @@
22
22
 
23
23
  function getComponent(child: ReturnType<typeof asTree>["children"][number]) {
24
24
  return (
25
- components[
25
+ (components[
26
26
  CHILD_TYPE_RENAMES[child.type as keyof typeof CHILD_TYPE_RENAMES] ||
27
27
  (child.type as keyof typeof components)
28
- ] || DefaultComponent
28
+ ] as RichTextComponent) || DefaultComponent
29
29
  );
30
30
  }
31
31
  </script>
@@ -1,8 +1,8 @@
1
1
  import type { asTree } from "@prismicio/client/richtext";
2
- import type { SvelteRichTextSerializer } from "../types";
2
+ import type { RichTextComponents } from "../types";
3
3
  import Serialize from "./Serialize.svelte";
4
4
  type Props = {
5
- components: SvelteRichTextSerializer;
5
+ components: RichTextComponents;
6
6
  children: ReturnType<typeof asTree>["children"];
7
7
  };
8
8
  declare const Serialize: import("svelte").Component<Props, {}, "">;
@@ -5,10 +5,10 @@
5
5
 
6
6
  type Props = {
7
7
  type: keyof TableComponents;
8
- children?: Snippet;
8
+ children: Snippet;
9
9
  };
10
10
 
11
11
  const { type, children }: Props = $props();
12
12
  </script>
13
13
 
14
- <svelte:element this={type}>{@render children?.()}</svelte:element>
14
+ <svelte:element this={type}>{@render children()}</svelte:element>
@@ -2,7 +2,7 @@ import type { Snippet } from "svelte";
2
2
  import type { TableComponents } from "../types";
3
3
  type Props = {
4
4
  type: keyof TableComponents;
5
- children?: Snippet;
5
+ children: Snippet;
6
6
  };
7
7
  declare const DefaultComponent: import("svelte").Component<Props, {}, "">;
8
8
  type DefaultComponent = ReturnType<typeof DefaultComponent>;
@@ -2,7 +2,7 @@
2
2
  import { type TableField, isFilled } from "@prismicio/client";
3
3
  import { type Component } from "svelte";
4
4
 
5
- import type { SvelteRichTextSerializer, TableComponents } from "../types";
5
+ import type { RichTextComponents, TableComponents } from "../types";
6
6
 
7
7
  import PrismicRichText from "../PrismicRichText/PrismicRichText.svelte";
8
8
 
@@ -17,7 +17,7 @@
17
17
  /**
18
18
  * An object that maps a rich text block type to a Svelte component.
19
19
  */
20
- components?: TableComponents & SvelteRichTextSerializer;
20
+ components?: TableComponents & RichTextComponents;
21
21
 
22
22
  /**
23
23
  * The component rendered when the field is empty. If a fallback is not
@@ -1,6 +1,6 @@
1
1
  import { type TableField } from "@prismicio/client";
2
2
  import { type Component } from "svelte";
3
- import type { SvelteRichTextSerializer, TableComponents } from "../types";
3
+ import type { RichTextComponents, TableComponents } from "../types";
4
4
  type Props = {
5
5
  /**
6
6
  * The Prismic table field to render.
@@ -9,7 +9,7 @@ type Props = {
9
9
  /**
10
10
  * An object that maps a rich text block type to a Svelte component.
11
11
  */
12
- components?: TableComponents & SvelteRichTextSerializer;
12
+ components?: TableComponents & RichTextComponents;
13
13
  /**
14
14
  * The component rendered when the field is empty. If a fallback is not
15
15
  * given, `null` will be rendered.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { RichTextComponents } from "./types";
1
2
  export { default as PrismicEmbed } from "./PrismicEmbed.svelte";
2
3
  export { default as PrismicImage } from "./PrismicImage.svelte";
3
4
  export { default as PrismicLink } from "./PrismicLink.svelte";
@@ -5,4 +6,9 @@ export { default as PrismicRichText } from "./PrismicRichText/PrismicRichText.sv
5
6
  export { default as PrismicTable } from "./PrismicTable/PrismicTable.svelte";
6
7
  export { default as PrismicText } from "./PrismicText.svelte";
7
8
  export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
8
- export type { SvelteRichTextSerializer, SliceComponentProps } from "./types";
9
+ /**
10
+ * @deprecated Replaced with `RichTextComponents`
11
+ */
12
+ export type SvelteRichTextSerializer = RichTextComponents;
13
+ export type { RichTextComponents };
14
+ export type { RichTextComponentProps, SliceComponentProps } from "./types";
package/dist/types.d.ts CHANGED
@@ -1,26 +1,55 @@
1
- import type { RTAnyNode, RichTextNodeType, Slice, TableField, TableFieldBody, TableFieldBodyRow, TableFieldDataCell, TableFieldHead, TableFieldHeadRow, TableFieldHeaderCell } from "@prismicio/client";
2
- import type { Component } from "svelte";
3
- export type SvelteRichTextSerializer = Partial<Record<keyof typeof RichTextNodeType, Component<{
4
- node?: RTAnyNode;
5
- }>>>;
1
+ import type { RTAnyNode, RTEmNode, RTEmbedNode, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTImageNode, RTLabelNode, RTLinkNode, RTListItemNode, RTListNode, RTOListItemNode, RTOListNode, RTParagraphNode, RTPreformattedNode, RTSpanNode, RTStrongNode, Slice, TableField, TableFieldBody, TableFieldBodyRow, TableFieldDataCell, TableFieldHead, TableFieldHeadRow, TableFieldHeaderCell } from "@prismicio/client";
2
+ import type { Component, Snippet } from "svelte";
3
+ export type RichTextComponents = {
4
+ heading1?: RichTextComponent<RTHeading1Node>;
5
+ heading2?: RichTextComponent<RTHeading2Node>;
6
+ heading3?: RichTextComponent<RTHeading3Node>;
7
+ heading4?: RichTextComponent<RTHeading4Node>;
8
+ heading5?: RichTextComponent<RTHeading5Node>;
9
+ heading6?: RichTextComponent<RTHeading6Node>;
10
+ paragraph?: RichTextComponent<RTParagraphNode>;
11
+ preformatted?: RichTextComponent<RTPreformattedNode>;
12
+ strong?: RichTextComponent<RTStrongNode>;
13
+ em?: RichTextComponent<RTEmNode>;
14
+ listItem?: RichTextComponent<RTListItemNode>;
15
+ oListItem?: RichTextComponent<RTOListItemNode>;
16
+ list?: RichTextComponent<RTListNode>;
17
+ oList?: RichTextComponent<RTOListNode>;
18
+ image?: RichTextComponent<RTImageNode>;
19
+ embed?: RichTextComponent<RTEmbedNode>;
20
+ hyperlink?: RichTextComponent<RTLinkNode>;
21
+ label?: RichTextComponent<RTLabelNode>;
22
+ span?: RichTextComponent<RTSpanNode>;
23
+ };
24
+ export type RichTextComponent<TNode extends RTAnyNode = RTAnyNode> = Component<RichTextComponentProps<TNode>>;
25
+ export type RichTextComponentProps<TNode extends RTAnyNode = RTAnyNode> = {
26
+ node: TNode;
27
+ children: Snippet;
28
+ };
6
29
  export type TableComponents = {
7
30
  table?: Component<{
8
31
  table: TableField<"filled">;
32
+ children: Snippet;
9
33
  }>;
10
34
  thead?: Component<{
11
35
  head: TableFieldHead;
36
+ children: Snippet;
12
37
  }>;
13
38
  tbody?: Component<{
14
39
  body: TableFieldBody;
40
+ children: Snippet;
15
41
  }>;
16
42
  tr?: Component<{
17
43
  row: TableFieldHeadRow | TableFieldBodyRow;
44
+ children: Snippet;
18
45
  }>;
19
46
  th?: Component<{
20
47
  cell: TableFieldHeaderCell;
48
+ children: Snippet;
21
49
  }>;
22
50
  td?: Component<{
23
51
  cell: TableFieldDataCell;
52
+ children: Snippet;
24
53
  }>;
25
54
  };
26
55
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/svelte",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "Svelte components to present Prismic content.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -1,15 +1,11 @@
1
1
  <script lang="ts">
2
- import type { RTAnyNode } from "@prismicio/client";
3
- import type { Snippet } from "svelte";
2
+ import type { RichTextComponentProps } from "../types";
4
3
 
5
4
  import PrismicEmbed from "../PrismicEmbed.svelte";
6
5
  import PrismicImage from "../PrismicImage.svelte";
7
6
  import PrismicLink from "../PrismicLink.svelte";
8
7
 
9
- type Props = {
10
- node: RTAnyNode;
11
- children?: Snippet;
12
- };
8
+ type Props = RichTextComponentProps;
13
9
 
14
10
  const { node, children }: Props = $props();
15
11
 
@@ -19,33 +15,33 @@
19
15
  </script>
20
16
 
21
17
  {#if node.type === "heading1"}
22
- <h1 {...dirProp}>{@render children?.()}</h1>
18
+ <h1 {...dirProp}>{@render children()}</h1>
23
19
  {:else if node.type === "heading2"}
24
- <h2 {...dirProp}>{@render children?.()}</h2>
20
+ <h2 {...dirProp}>{@render children()}</h2>
25
21
  {:else if node.type === "heading3"}
26
- <h3 {...dirProp}>{@render children?.()}</h3>
22
+ <h3 {...dirProp}>{@render children()}</h3>
27
23
  {:else if node.type === "heading4"}
28
- <h4 {...dirProp}>{@render children?.()}</h4>
24
+ <h4 {...dirProp}>{@render children()}</h4>
29
25
  {:else if node.type === "heading5"}
30
- <h5 {...dirProp}>{@render children?.()}</h5>
26
+ <h5 {...dirProp}>{@render children()}</h5>
31
27
  {:else if node.type === "heading6"}
32
- <h6 {...dirProp}>{@render children?.()}</h6>
28
+ <h6 {...dirProp}>{@render children()}</h6>
33
29
  {:else if node.type === "paragraph"}
34
- <p {...dirProp}>{@render children?.()}</p>
30
+ <p {...dirProp}>{@render children()}</p>
35
31
  {:else if node.type === "preformatted"}
36
- <pre>{@render children?.()}</pre>
32
+ <pre>{@render children()}</pre>
37
33
  {:else if node.type === "strong"}
38
- <strong>{@render children?.()}</strong>
34
+ <strong>{@render children()}</strong>
39
35
  {:else if node.type === "em"}
40
- <em>{@render children?.()}</em>
36
+ <em>{@render children()}</em>
41
37
  {:else if node.type === "list-item"}
42
- <li {...dirProp}>{@render children?.()}</li>
38
+ <li {...dirProp}>{@render children()}</li>
43
39
  {:else if node.type === "o-list-item"}
44
- <li {...dirProp}>{@render children?.()}</li>
40
+ <li {...dirProp}>{@render children()}</li>
45
41
  {:else if node.type === "group-list-item"}
46
- <ul>{@render children?.()}</ul>
42
+ <ul>{@render children()}</ul>
47
43
  {:else if node.type === "group-o-list-item"}
48
- <ol>{@render children?.()}</ol>
44
+ <ol>{@render children()}</ol>
49
45
  {:else if node.type === "image"}
50
46
  <p class="block-img">
51
47
  <PrismicImage field={node} />
@@ -53,9 +49,9 @@
53
49
  {:else if node.type === "embed"}
54
50
  <PrismicEmbed field={node.oembed} />
55
51
  {:else if node.type === "hyperlink"}
56
- <PrismicLink field={node.data}>{@render children?.()}</PrismicLink>
52
+ <PrismicLink field={node.data}>{@render children()}</PrismicLink>
57
53
  {:else if node.type === "label"}
58
- <span class={node.data.label}>{@render children?.()}</span>
54
+ <span class={node.data.label}>{@render children()}</span>
59
55
  {:else}
60
56
  {#each node.text.split("\n") as line, index (index)}
61
57
  {#if index > 0}<br />{/if}{line}
@@ -2,7 +2,7 @@
2
2
  import type { RichTextField } from "@prismicio/client";
3
3
  import { asTree } from "@prismicio/client/richtext";
4
4
 
5
- import type { SvelteRichTextSerializer } from "../types";
5
+ import type { RichTextComponents } from "../types";
6
6
 
7
7
  import Serialize from "./Serialize.svelte";
8
8
 
@@ -15,7 +15,7 @@
15
15
  /**
16
16
  * An object that maps a rich text block type to a Svelte component.
17
17
  */
18
- components?: SvelteRichTextSerializer;
18
+ components?: RichTextComponents;
19
19
  };
20
20
 
21
21
  const { field, components = {} }: Props = $props();
@@ -1,13 +1,13 @@
1
1
  <script lang="ts">
2
2
  import type { asTree } from "@prismicio/client/richtext";
3
3
 
4
- import type { SvelteRichTextSerializer } from "../types";
4
+ import type { RichTextComponent, RichTextComponents } from "../types";
5
5
 
6
6
  import DefaultComponent from "./DefaultComponent.svelte";
7
7
  import Serialize from "./Serialize.svelte";
8
8
 
9
9
  type Props = {
10
- components: SvelteRichTextSerializer;
10
+ components: RichTextComponents;
11
11
  children: ReturnType<typeof asTree>["children"];
12
12
  };
13
13
 
@@ -22,10 +22,10 @@
22
22
 
23
23
  function getComponent(child: ReturnType<typeof asTree>["children"][number]) {
24
24
  return (
25
- components[
25
+ (components[
26
26
  CHILD_TYPE_RENAMES[child.type as keyof typeof CHILD_TYPE_RENAMES] ||
27
27
  (child.type as keyof typeof components)
28
- ] || DefaultComponent
28
+ ] as RichTextComponent) || DefaultComponent
29
29
  );
30
30
  }
31
31
  </script>
@@ -5,10 +5,10 @@
5
5
 
6
6
  type Props = {
7
7
  type: keyof TableComponents;
8
- children?: Snippet;
8
+ children: Snippet;
9
9
  };
10
10
 
11
11
  const { type, children }: Props = $props();
12
12
  </script>
13
13
 
14
- <svelte:element this={type}>{@render children?.()}</svelte:element>
14
+ <svelte:element this={type}>{@render children()}</svelte:element>
@@ -2,7 +2,7 @@
2
2
  import { type TableField, isFilled } from "@prismicio/client";
3
3
  import { type Component } from "svelte";
4
4
 
5
- import type { SvelteRichTextSerializer, TableComponents } from "../types";
5
+ import type { RichTextComponents, TableComponents } from "../types";
6
6
 
7
7
  import PrismicRichText from "../PrismicRichText/PrismicRichText.svelte";
8
8
 
@@ -17,7 +17,7 @@
17
17
  /**
18
18
  * An object that maps a rich text block type to a Svelte component.
19
19
  */
20
- components?: TableComponents & SvelteRichTextSerializer;
20
+ components?: TableComponents & RichTextComponents;
21
21
 
22
22
  /**
23
23
  * The component rendered when the field is empty. If a fallback is not
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { RichTextComponents } from "./types";
2
+
1
3
  export { default as PrismicEmbed } from "./PrismicEmbed.svelte";
2
4
  export { default as PrismicImage } from "./PrismicImage.svelte";
3
5
  export { default as PrismicLink } from "./PrismicLink.svelte";
@@ -6,4 +8,11 @@ export { default as PrismicTable } from "./PrismicTable/PrismicTable.svelte";
6
8
  export { default as PrismicText } from "./PrismicText.svelte";
7
9
  export { default as SliceZone } from "./SliceZone/SliceZone.svelte";
8
10
 
9
- export type { SvelteRichTextSerializer, SliceComponentProps } from "./types";
11
+ /**
12
+ * @deprecated Replaced with `RichTextComponents`
13
+ */
14
+ // TODO: Remove in v3.
15
+ export type SvelteRichTextSerializer = RichTextComponents;
16
+ export type { RichTextComponents };
17
+
18
+ export type { RichTextComponentProps, SliceComponentProps } from "./types";
package/src/types.ts CHANGED
@@ -1,6 +1,24 @@
1
1
  import type {
2
2
  RTAnyNode,
3
- RichTextNodeType,
3
+ RTEmNode,
4
+ RTEmbedNode,
5
+ RTHeading1Node,
6
+ RTHeading2Node,
7
+ RTHeading3Node,
8
+ RTHeading4Node,
9
+ RTHeading5Node,
10
+ RTHeading6Node,
11
+ RTImageNode,
12
+ RTLabelNode,
13
+ RTLinkNode,
14
+ RTListItemNode,
15
+ RTListNode,
16
+ RTOListItemNode,
17
+ RTOListNode,
18
+ RTParagraphNode,
19
+ RTPreformattedNode,
20
+ RTSpanNode,
21
+ RTStrongNode,
4
22
  Slice,
5
23
  TableField,
6
24
  TableFieldBody,
@@ -10,20 +28,65 @@ import type {
10
28
  TableFieldHeadRow,
11
29
  TableFieldHeaderCell,
12
30
  } from "@prismicio/client";
13
- import type { Component } from "svelte";
31
+ import type { Component, Snippet } from "svelte";
14
32
 
15
- export type SvelteRichTextSerializer = Partial<
16
- Record<keyof typeof RichTextNodeType, Component<{ node?: RTAnyNode }>>
33
+ export type RichTextComponents = {
34
+ heading1?: RichTextComponent<RTHeading1Node>;
35
+ heading2?: RichTextComponent<RTHeading2Node>;
36
+ heading3?: RichTextComponent<RTHeading3Node>;
37
+ heading4?: RichTextComponent<RTHeading4Node>;
38
+ heading5?: RichTextComponent<RTHeading5Node>;
39
+ heading6?: RichTextComponent<RTHeading6Node>;
40
+ paragraph?: RichTextComponent<RTParagraphNode>;
41
+ preformatted?: RichTextComponent<RTPreformattedNode>;
42
+ strong?: RichTextComponent<RTStrongNode>;
43
+ em?: RichTextComponent<RTEmNode>;
44
+ listItem?: RichTextComponent<RTListItemNode>;
45
+ oListItem?: RichTextComponent<RTOListItemNode>;
46
+ list?: RichTextComponent<RTListNode>;
47
+ oList?: RichTextComponent<RTOListNode>;
48
+ image?: RichTextComponent<RTImageNode>;
49
+ embed?: RichTextComponent<RTEmbedNode>;
50
+ hyperlink?: RichTextComponent<RTLinkNode>;
51
+ label?: RichTextComponent<RTLabelNode>;
52
+ span?: RichTextComponent<RTSpanNode>;
53
+ };
54
+
55
+ export type RichTextComponent<TNode extends RTAnyNode = RTAnyNode> = Component<
56
+ RichTextComponentProps<TNode>
17
57
  >;
18
58
 
59
+ export type RichTextComponentProps<TNode extends RTAnyNode = RTAnyNode> = {
60
+ node: TNode;
61
+ children: Snippet;
62
+ };
63
+
19
64
  // Define the type for the components prop
20
65
  export type TableComponents = {
21
- table?: Component<{ table: TableField<"filled"> }>;
22
- thead?: Component<{ head: TableFieldHead }>;
23
- tbody?: Component<{ body: TableFieldBody }>;
24
- tr?: Component<{ row: TableFieldHeadRow | TableFieldBodyRow }>;
25
- th?: Component<{ cell: TableFieldHeaderCell }>;
26
- td?: Component<{ cell: TableFieldDataCell }>;
66
+ table?: Component<{
67
+ table: TableField<"filled">;
68
+ children: Snippet;
69
+ }>;
70
+ thead?: Component<{
71
+ head: TableFieldHead;
72
+ children: Snippet;
73
+ }>;
74
+ tbody?: Component<{
75
+ body: TableFieldBody;
76
+ children: Snippet;
77
+ }>;
78
+ tr?: Component<{
79
+ row: TableFieldHeadRow | TableFieldBodyRow;
80
+ children: Snippet;
81
+ }>;
82
+ th?: Component<{
83
+ cell: TableFieldHeaderCell;
84
+ children: Snippet;
85
+ }>;
86
+ td?: Component<{
87
+ cell: TableFieldDataCell;
88
+ children: Snippet;
89
+ }>;
27
90
  };
28
91
 
29
92
  /**