@contember/react-richtext-renderer 2.1.0-alpha.37 → 2.1.0-alpha.39

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.
Files changed (198) hide show
  1. package/dist/development/index.cjs +17 -0
  2. package/dist/development/index.cjs.map +1 -0
  3. package/dist/development/index.js +17 -0
  4. package/dist/development/index.js.map +1 -0
  5. package/dist/development/src/RichTextRendererError.cjs +6 -0
  6. package/dist/development/src/RichTextRendererError.cjs.map +1 -0
  7. package/dist/development/src/RichTextRendererError.js +6 -0
  8. package/dist/development/src/RichTextRendererError.js.map +1 -0
  9. package/dist/development/src/components/RichText.cjs +40 -0
  10. package/dist/development/src/components/RichText.cjs.map +1 -0
  11. package/dist/development/src/components/RichText.js +40 -0
  12. package/dist/development/src/components/RichText.js.map +1 -0
  13. package/dist/development/src/components/RichTextBlocksRenderer.cjs +42 -0
  14. package/dist/development/src/components/RichTextBlocksRenderer.cjs.map +1 -0
  15. package/dist/development/src/components/RichTextBlocksRenderer.js +42 -0
  16. package/dist/development/src/components/RichTextBlocksRenderer.js.map +1 -0
  17. package/dist/development/src/components/RichTextFieldRenderer.cjs +36 -0
  18. package/dist/development/src/components/RichTextFieldRenderer.cjs.map +1 -0
  19. package/dist/development/src/components/RichTextFieldRenderer.js +36 -0
  20. package/dist/development/src/components/RichTextFieldRenderer.js.map +1 -0
  21. package/dist/development/src/components/RichTextRenderer.cjs +22 -0
  22. package/dist/development/src/components/RichTextRenderer.cjs.map +1 -0
  23. package/dist/development/src/components/RichTextRenderer.js +22 -0
  24. package/dist/development/src/components/RichTextRenderer.js.map +1 -0
  25. package/dist/development/src/hooks/useRichTextBlocksSource.cjs +64 -0
  26. package/dist/development/src/hooks/useRichTextBlocksSource.cjs.map +1 -0
  27. package/dist/development/src/hooks/useRichTextBlocksSource.js +64 -0
  28. package/dist/development/src/hooks/useRichTextBlocksSource.js.map +1 -0
  29. package/dist/development/src/hooks/useRichTextFieldSource.cjs +26 -0
  30. package/dist/development/src/hooks/useRichTextFieldSource.cjs.map +1 -0
  31. package/dist/development/src/hooks/useRichTextFieldSource.js +26 -0
  32. package/dist/development/src/hooks/useRichTextFieldSource.js.map +1 -0
  33. package/dist/development/src/internal/components/ElementRenderer.cjs +40 -0
  34. package/dist/development/src/internal/components/ElementRenderer.cjs.map +1 -0
  35. package/dist/development/src/internal/components/ElementRenderer.js +40 -0
  36. package/dist/development/src/internal/components/ElementRenderer.js.map +1 -0
  37. package/dist/development/src/internal/components/LeafRenderer.cjs +27 -0
  38. package/dist/development/src/internal/components/LeafRenderer.cjs.map +1 -0
  39. package/dist/development/src/internal/components/LeafRenderer.js +27 -0
  40. package/dist/development/src/internal/components/LeafRenderer.js.map +1 -0
  41. package/dist/development/src/internal/components/RenderElementFallback.cjs +164 -0
  42. package/dist/development/src/internal/components/RenderElementFallback.cjs.map +1 -0
  43. package/dist/development/src/internal/components/RenderElementFallback.js +164 -0
  44. package/dist/development/src/internal/components/RenderElementFallback.js.map +1 -0
  45. package/dist/development/src/internal/components/RenderLeafFallback.cjs +74 -0
  46. package/dist/development/src/internal/components/RenderLeafFallback.cjs.map +1 -0
  47. package/dist/development/src/internal/components/RenderLeafFallback.js +74 -0
  48. package/dist/development/src/internal/components/RenderLeafFallback.js.map +1 -0
  49. package/dist/development/src/internal/defaultDeserialize.cjs +14 -0
  50. package/dist/development/src/internal/defaultDeserialize.cjs.map +1 -0
  51. package/dist/development/src/internal/defaultDeserialize.js +14 -0
  52. package/dist/development/src/internal/defaultDeserialize.js.map +1 -0
  53. package/dist/development/src/internal/renderChildren.cjs +30 -0
  54. package/dist/development/src/internal/renderChildren.cjs.map +1 -0
  55. package/dist/development/src/internal/renderChildren.js +30 -0
  56. package/dist/development/src/internal/renderChildren.js.map +1 -0
  57. package/dist/development/src/internal/useReferenceMetadata.cjs +42 -0
  58. package/dist/development/src/internal/useReferenceMetadata.cjs.map +1 -0
  59. package/dist/development/src/internal/useReferenceMetadata.js +42 -0
  60. package/dist/development/src/internal/useReferenceMetadata.js.map +1 -0
  61. package/dist/production/index.cjs +17 -0
  62. package/dist/production/index.cjs.map +1 -0
  63. package/dist/production/index.js +17 -0
  64. package/dist/production/index.js.map +1 -0
  65. package/dist/production/src/RichTextRendererError.cjs +6 -0
  66. package/dist/production/src/RichTextRendererError.cjs.map +1 -0
  67. package/dist/production/src/RichTextRendererError.js +6 -0
  68. package/dist/production/src/RichTextRendererError.js.map +1 -0
  69. package/dist/production/src/components/RichText.cjs +32 -0
  70. package/dist/production/src/components/RichText.cjs.map +1 -0
  71. package/dist/production/src/components/RichText.js +32 -0
  72. package/dist/production/src/components/RichText.js.map +1 -0
  73. package/dist/production/src/components/RichTextBlocksRenderer.cjs +30 -0
  74. package/dist/production/src/components/RichTextBlocksRenderer.cjs.map +1 -0
  75. package/dist/production/src/components/RichTextBlocksRenderer.js +30 -0
  76. package/dist/production/src/components/RichTextBlocksRenderer.js.map +1 -0
  77. package/dist/production/src/components/RichTextFieldRenderer.cjs +28 -0
  78. package/dist/production/src/components/RichTextFieldRenderer.cjs.map +1 -0
  79. package/dist/production/src/components/RichTextFieldRenderer.js +28 -0
  80. package/dist/production/src/components/RichTextFieldRenderer.js.map +1 -0
  81. package/dist/production/src/components/RichTextRenderer.cjs +14 -0
  82. package/dist/production/src/components/RichTextRenderer.cjs.map +1 -0
  83. package/dist/production/src/components/RichTextRenderer.js +14 -0
  84. package/dist/production/src/components/RichTextRenderer.js.map +1 -0
  85. package/dist/production/src/hooks/useRichTextBlocksSource.cjs +64 -0
  86. package/dist/production/src/hooks/useRichTextBlocksSource.cjs.map +1 -0
  87. package/dist/production/src/hooks/useRichTextBlocksSource.js +64 -0
  88. package/dist/production/src/hooks/useRichTextBlocksSource.js.map +1 -0
  89. package/dist/production/src/hooks/useRichTextFieldSource.cjs +26 -0
  90. package/dist/production/src/hooks/useRichTextFieldSource.cjs.map +1 -0
  91. package/dist/production/src/hooks/useRichTextFieldSource.js +26 -0
  92. package/dist/production/src/hooks/useRichTextFieldSource.js.map +1 -0
  93. package/dist/production/src/internal/components/ElementRenderer.cjs +32 -0
  94. package/dist/production/src/internal/components/ElementRenderer.cjs.map +1 -0
  95. package/dist/production/src/internal/components/ElementRenderer.js +32 -0
  96. package/dist/production/src/internal/components/ElementRenderer.js.map +1 -0
  97. package/dist/production/src/internal/components/LeafRenderer.cjs +23 -0
  98. package/dist/production/src/internal/components/LeafRenderer.cjs.map +1 -0
  99. package/dist/production/src/internal/components/LeafRenderer.js +23 -0
  100. package/dist/production/src/internal/components/LeafRenderer.js.map +1 -0
  101. package/dist/production/src/internal/components/RenderElementFallback.cjs +85 -0
  102. package/dist/production/src/internal/components/RenderElementFallback.cjs.map +1 -0
  103. package/dist/production/src/internal/components/RenderElementFallback.js +85 -0
  104. package/dist/production/src/internal/components/RenderElementFallback.js.map +1 -0
  105. package/dist/production/src/internal/components/RenderLeafFallback.cjs +38 -0
  106. package/dist/production/src/internal/components/RenderLeafFallback.cjs.map +1 -0
  107. package/dist/production/src/internal/components/RenderLeafFallback.js +38 -0
  108. package/dist/production/src/internal/components/RenderLeafFallback.js.map +1 -0
  109. package/dist/production/src/internal/defaultDeserialize.cjs +14 -0
  110. package/dist/production/src/internal/defaultDeserialize.cjs.map +1 -0
  111. package/dist/production/src/internal/defaultDeserialize.js +14 -0
  112. package/dist/production/src/internal/defaultDeserialize.js.map +1 -0
  113. package/dist/production/src/internal/renderChildren.cjs +18 -0
  114. package/dist/production/src/internal/renderChildren.cjs.map +1 -0
  115. package/dist/production/src/internal/renderChildren.js +18 -0
  116. package/dist/production/src/internal/renderChildren.js.map +1 -0
  117. package/dist/production/src/internal/useReferenceMetadata.cjs +37 -0
  118. package/dist/production/src/internal/useReferenceMetadata.cjs.map +1 -0
  119. package/dist/production/src/internal/useReferenceMetadata.js +37 -0
  120. package/dist/production/src/internal/useReferenceMetadata.js.map +1 -0
  121. package/dist/types/RichTextRendererError.d.ts +3 -0
  122. package/dist/types/RichTextRendererError.d.ts.map +1 -0
  123. package/dist/types/components/RichText.d.ts +13 -0
  124. package/dist/types/components/RichText.d.ts.map +1 -0
  125. package/dist/types/components/RichTextBlocksRenderer.d.ts +10 -0
  126. package/dist/types/components/RichTextBlocksRenderer.d.ts.map +1 -0
  127. package/dist/types/components/RichTextFieldRenderer.d.ts +10 -0
  128. package/dist/types/components/RichTextFieldRenderer.d.ts.map +1 -0
  129. package/dist/types/components/RichTextRenderer.d.ts +12 -0
  130. package/dist/types/components/RichTextRenderer.d.ts.map +1 -0
  131. package/dist/types/components/index.d.ts +5 -0
  132. package/dist/types/components/index.d.ts.map +1 -0
  133. package/dist/types/hooks/index.d.ts +3 -0
  134. package/dist/types/hooks/index.d.ts.map +1 -0
  135. package/dist/types/hooks/useRichTextBlocksSource.d.ts +3 -0
  136. package/dist/types/hooks/useRichTextBlocksSource.d.ts.map +1 -0
  137. package/dist/types/hooks/useRichTextFieldSource.d.ts +3 -0
  138. package/dist/types/hooks/useRichTextFieldSource.d.ts.map +1 -0
  139. package/dist/types/index.d.ts +5 -0
  140. package/dist/types/index.d.ts.map +1 -0
  141. package/dist/types/internal/components/ElementRenderer.d.ts +14 -0
  142. package/dist/types/internal/components/ElementRenderer.d.ts.map +1 -0
  143. package/dist/types/internal/components/LeafRenderer.d.ts +12 -0
  144. package/dist/types/internal/components/LeafRenderer.d.ts.map +1 -0
  145. package/dist/types/internal/components/RenderElementFallback.d.ts +14 -0
  146. package/dist/types/internal/components/RenderElementFallback.d.ts.map +1 -0
  147. package/dist/types/internal/components/RenderLeafFallback.d.ts +6 -0
  148. package/dist/types/internal/components/RenderLeafFallback.d.ts.map +1 -0
  149. package/dist/types/internal/defaultDeserialize.d.ts +5 -0
  150. package/dist/types/internal/defaultDeserialize.d.ts.map +1 -0
  151. package/dist/types/internal/renderChildren.d.ts +8 -0
  152. package/dist/types/internal/renderChildren.d.ts.map +1 -0
  153. package/dist/types/internal/useReferenceMetadata.d.ts +9 -0
  154. package/dist/types/internal/useReferenceMetadata.d.ts.map +1 -0
  155. package/dist/types/tsconfig.tsbuildinfo +1 -0
  156. package/dist/types/types/RenderChildren.d.ts +9 -0
  157. package/dist/types/types/RenderChildren.d.ts.map +1 -0
  158. package/dist/types/types/RichTextBlock.d.ts +8 -0
  159. package/dist/types/types/RichTextBlock.d.ts.map +1 -0
  160. package/dist/types/types/RichTextBlockSource.d.ts +9 -0
  161. package/dist/types/types/RichTextBlockSource.d.ts.map +1 -0
  162. package/dist/types/types/RichTextFieldSource.d.ts +6 -0
  163. package/dist/types/types/RichTextFieldSource.d.ts.map +1 -0
  164. package/dist/types/types/RichTextReference.d.ts +5 -0
  165. package/dist/types/types/RichTextReference.d.ts.map +1 -0
  166. package/dist/types/types/RichTextReferenceMetadata.d.ts +15 -0
  167. package/dist/types/types/RichTextReferenceMetadata.d.ts.map +1 -0
  168. package/dist/types/types/RichTextRenderingOptions.d.ts +14 -0
  169. package/dist/types/types/RichTextRenderingOptions.d.ts.map +1 -0
  170. package/dist/types/types/builtin/BuiltinElements.d.ts +48 -0
  171. package/dist/types/types/builtin/BuiltinElements.d.ts.map +1 -0
  172. package/dist/types/types/builtin/BuiltinLeaves.d.ts +21 -0
  173. package/dist/types/types/builtin/BuiltinLeaves.d.ts.map +1 -0
  174. package/dist/types/types/builtin/index.d.ts +3 -0
  175. package/dist/types/types/builtin/index.d.ts.map +1 -0
  176. package/dist/types/types/custom/ReferenceRenderer.d.ts +17 -0
  177. package/dist/types/types/custom/ReferenceRenderer.d.ts.map +1 -0
  178. package/dist/types/types/custom/RenderBlock.d.ts +7 -0
  179. package/dist/types/types/custom/RenderBlock.d.ts.map +1 -0
  180. package/dist/types/types/custom/RenderElement.d.ts +24 -0
  181. package/dist/types/types/custom/RenderElement.d.ts.map +1 -0
  182. package/dist/types/types/custom/RenderLeaf.d.ts +11 -0
  183. package/dist/types/types/custom/RenderLeaf.d.ts.map +1 -0
  184. package/dist/types/types/custom/index.d.ts +5 -0
  185. package/dist/types/types/custom/index.d.ts.map +1 -0
  186. package/dist/types/types/index.d.ts +11 -0
  187. package/dist/types/types/index.d.ts.map +1 -0
  188. package/dist/types/types/structure/RichTextChild.d.ts +5 -0
  189. package/dist/types/types/structure/RichTextChild.d.ts.map +1 -0
  190. package/dist/types/types/structure/RichTextElement.d.ts +8 -0
  191. package/dist/types/types/structure/RichTextElement.d.ts.map +1 -0
  192. package/dist/types/types/structure/RichTextLeaf.d.ts +4 -0
  193. package/dist/types/types/structure/RichTextLeaf.d.ts.map +1 -0
  194. package/dist/types/types/structure/RootEditorNode.d.ts +8 -0
  195. package/dist/types/types/structure/RootEditorNode.d.ts.map +1 -0
  196. package/dist/types/types/structure/index.d.ts +5 -0
  197. package/dist/types/types/structure/index.d.ts.map +1 -0
  198. package/package.json +4 -4
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const RichText = require("./RichText.cjs");
5
+ const useRichTextFieldSource = require("../hooks/useRichTextFieldSource.cjs");
6
+ const RichTextFieldRenderer = ({
7
+ renderLeaf,
8
+ renderBlock,
9
+ renderElement,
10
+ attributeNamePrefix,
11
+ undefinedReferenceHandler,
12
+ ...source
13
+ }) => {
14
+ const blocks = useRichTextFieldSource.useRichTextFieldSource(source);
15
+ return /* @__PURE__ */ jsxRuntime.jsx(
16
+ RichText.RichText,
17
+ {
18
+ blocks,
19
+ renderElement,
20
+ renderLeaf,
21
+ renderBlock,
22
+ attributeNamePrefix,
23
+ undefinedReferenceHandler
24
+ }
25
+ );
26
+ };
27
+ exports.RichTextFieldRenderer = RichTextFieldRenderer;
28
+ //# sourceMappingURL=RichTextFieldRenderer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextFieldRenderer.cjs","sources":["../../../../../packages/react-richtext-renderer/src/components/RichTextFieldRenderer.tsx"],"sourcesContent":["import { RichText } from './RichText'\nimport { RichTextElement, RichTextFieldSource, RichTextLeaf, RichTextRenderingOptions } from '../types'\nimport { useRichTextFieldSource } from '../hooks'\n\nexport type { RichTextFieldSource }\n\nexport type RichTextFieldRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> =\n\t& RichTextFieldSource<CustomElements, CustomLeaves>\n\t& RichTextRenderingOptions<CustomElements, CustomLeaves>\n\n/**\n * Accepts raw RichText field source and renders them using the provided renderers.\n *\n * @group Content rendering\n */\nexport const RichTextFieldRenderer = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\trenderLeaf,\n\trenderBlock,\n\trenderElement,\n\tattributeNamePrefix,\n\tundefinedReferenceHandler,\n\t...source\n}: RichTextFieldRendererProps<CustomElements, CustomLeaves>) => {\n\tconst blocks = useRichTextFieldSource(source)\n\n\treturn (\n\t\t<RichText<CustomElements, CustomLeaves>\n\t\t\tblocks={blocks}\n\t\t\trenderElement={renderElement}\n\t\t\trenderLeaf={renderLeaf}\n\t\t\trenderBlock={renderBlock}\n\t\t\tattributeNamePrefix={attributeNamePrefix}\n\t\t\tundefinedReferenceHandler={undefinedReferenceHandler}\n\t\t/>\n\t)\n}\n"],"names":["useRichTextFieldSource","jsx","RichText"],"mappings":";;;;;AAkBO,MAAM,wBAAwB,CAGnC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAgE;AAC/D,QAAM,SAASA,uBAAAA,uBAAuB,MAAM;AAE5C,SACCC,2BAAAA;AAAAA,IAACC,SAAAA;AAAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAGH;;"}
@@ -0,0 +1,28 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { RichText } from "./RichText.js";
3
+ import { useRichTextFieldSource } from "../hooks/useRichTextFieldSource.js";
4
+ const RichTextFieldRenderer = ({
5
+ renderLeaf,
6
+ renderBlock,
7
+ renderElement,
8
+ attributeNamePrefix,
9
+ undefinedReferenceHandler,
10
+ ...source
11
+ }) => {
12
+ const blocks = useRichTextFieldSource(source);
13
+ return /* @__PURE__ */ jsx(
14
+ RichText,
15
+ {
16
+ blocks,
17
+ renderElement,
18
+ renderLeaf,
19
+ renderBlock,
20
+ attributeNamePrefix,
21
+ undefinedReferenceHandler
22
+ }
23
+ );
24
+ };
25
+ export {
26
+ RichTextFieldRenderer
27
+ };
28
+ //# sourceMappingURL=RichTextFieldRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextFieldRenderer.js","sources":["../../../../../packages/react-richtext-renderer/src/components/RichTextFieldRenderer.tsx"],"sourcesContent":["import { RichText } from './RichText'\nimport { RichTextElement, RichTextFieldSource, RichTextLeaf, RichTextRenderingOptions } from '../types'\nimport { useRichTextFieldSource } from '../hooks'\n\nexport type { RichTextFieldSource }\n\nexport type RichTextFieldRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> =\n\t& RichTextFieldSource<CustomElements, CustomLeaves>\n\t& RichTextRenderingOptions<CustomElements, CustomLeaves>\n\n/**\n * Accepts raw RichText field source and renders them using the provided renderers.\n *\n * @group Content rendering\n */\nexport const RichTextFieldRenderer = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\trenderLeaf,\n\trenderBlock,\n\trenderElement,\n\tattributeNamePrefix,\n\tundefinedReferenceHandler,\n\t...source\n}: RichTextFieldRendererProps<CustomElements, CustomLeaves>) => {\n\tconst blocks = useRichTextFieldSource(source)\n\n\treturn (\n\t\t<RichText<CustomElements, CustomLeaves>\n\t\t\tblocks={blocks}\n\t\t\trenderElement={renderElement}\n\t\t\trenderLeaf={renderLeaf}\n\t\t\trenderBlock={renderBlock}\n\t\t\tattributeNamePrefix={attributeNamePrefix}\n\t\t\tundefinedReferenceHandler={undefinedReferenceHandler}\n\t\t/>\n\t)\n}\n"],"names":[],"mappings":";;;AAkBO,MAAM,wBAAwB,CAGnC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAgE;AAC/D,QAAM,SAAS,uBAAuB,MAAM;AAE5C,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAGH;"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const RichTextFieldRenderer = require("./RichTextFieldRenderer.cjs");
6
+ const RichTextBlocksRenderer = require("./RichTextBlocksRenderer.cjs");
7
+ const RichTextRenderer = React.memo(function RichTextRenderer2(props) {
8
+ if ("source" in props) {
9
+ return /* @__PURE__ */ jsxRuntime.jsx(RichTextFieldRenderer.RichTextFieldRenderer, { ...props });
10
+ }
11
+ return /* @__PURE__ */ jsxRuntime.jsx(RichTextBlocksRenderer.RichTextBlocksRenderer, { ...props });
12
+ });
13
+ exports.RichTextRenderer = RichTextRenderer;
14
+ //# sourceMappingURL=RichTextRenderer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextRenderer.cjs","sources":["../../../../../packages/react-richtext-renderer/src/components/RichTextRenderer.tsx"],"sourcesContent":["import { memo, ReactElement } from 'react'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport { RichTextFieldRenderer, RichTextFieldRendererProps } from './RichTextFieldRenderer'\nimport { RichTextBlocksRenderer, RichTextBlocksRendererProps } from './RichTextBlocksRenderer'\n\nexport type RichTextRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> =\n\t| RichTextFieldRendererProps<CustomElements, CustomLeaves>\n\t| RichTextBlocksRendererProps<CustomElements, CustomLeaves>\n\n/**\n * @deprecated Use `RichTextBlocksRenderer` or `RichTextFieldRenderer` instead, or directly use `RichText`.\n * @group Content rendering\n */\nexport const RichTextRenderer = memo(function RichTextRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>(props: RichTextRendererProps<CustomElements, CustomLeaves>) {\n\tif ('source' in props) {\n\t\treturn <RichTextFieldRenderer<CustomElements, CustomLeaves> {...props} />\n\t}\n\n\treturn <RichTextBlocksRenderer<CustomElements, CustomLeaves> {...props} />\n}) as <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf>(\n\tprops: RichTextRendererProps<CustomElements, CustomLeaves>,\n) => ReactElement\n"],"names":["memo","RichTextRenderer","jsx","RichTextFieldRenderer","RichTextBlocksRenderer"],"mappings":";;;;;;AAiBO,MAAM,mBAAmBA,MAAAA,KAAK,SAASC,kBAG5C,OAA4D;AAC7D,MAAI,YAAY,OAAO;AACtB,WAAOC,+BAACC,sBAAAA,uBAAA,EAAqD,GAAG,MAAA,CAAO;AAAA,EACxE;AAEA,SAAOD,+BAACE,uBAAAA,wBAAA,EAAsD,GAAG,MAAA,CAAO;AACzE,CAAC;;"}
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ import { RichTextFieldRenderer } from "./RichTextFieldRenderer.js";
4
+ import { RichTextBlocksRenderer } from "./RichTextBlocksRenderer.js";
5
+ const RichTextRenderer = memo(function RichTextRenderer2(props) {
6
+ if ("source" in props) {
7
+ return /* @__PURE__ */ jsx(RichTextFieldRenderer, { ...props });
8
+ }
9
+ return /* @__PURE__ */ jsx(RichTextBlocksRenderer, { ...props });
10
+ });
11
+ export {
12
+ RichTextRenderer
13
+ };
14
+ //# sourceMappingURL=RichTextRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextRenderer.js","sources":["../../../../../packages/react-richtext-renderer/src/components/RichTextRenderer.tsx"],"sourcesContent":["import { memo, ReactElement } from 'react'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport { RichTextFieldRenderer, RichTextFieldRendererProps } from './RichTextFieldRenderer'\nimport { RichTextBlocksRenderer, RichTextBlocksRendererProps } from './RichTextBlocksRenderer'\n\nexport type RichTextRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> =\n\t| RichTextFieldRendererProps<CustomElements, CustomLeaves>\n\t| RichTextBlocksRendererProps<CustomElements, CustomLeaves>\n\n/**\n * @deprecated Use `RichTextBlocksRenderer` or `RichTextFieldRenderer` instead, or directly use `RichText`.\n * @group Content rendering\n */\nexport const RichTextRenderer = memo(function RichTextRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>(props: RichTextRendererProps<CustomElements, CustomLeaves>) {\n\tif ('source' in props) {\n\t\treturn <RichTextFieldRenderer<CustomElements, CustomLeaves> {...props} />\n\t}\n\n\treturn <RichTextBlocksRenderer<CustomElements, CustomLeaves> {...props} />\n}) as <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf>(\n\tprops: RichTextRendererProps<CustomElements, CustomLeaves>,\n) => ReactElement\n"],"names":["RichTextRenderer"],"mappings":";;;;AAiBO,MAAM,mBAAmB,KAAK,SAASA,kBAG5C,OAA4D;AAC7D,MAAI,YAAY,OAAO;AACtB,WAAO,oBAAC,uBAAA,EAAqD,GAAG,MAAA,CAAO;AAAA,EACxE;AAEA,SAAO,oBAAC,wBAAA,EAAsD,GAAG,MAAA,CAAO;AACzE,CAAC;"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const defaultDeserialize = require("../internal/defaultDeserialize.cjs");
4
+ const React = require("react");
5
+ const RichTextRendererError = require("../RichTextRendererError.cjs");
6
+ const useRichTextBlocksSource = ({
7
+ deserialize = defaultDeserialize.defaultDeserialize,
8
+ blocks,
9
+ referencesField,
10
+ sourceField,
11
+ referenceDiscriminationField
12
+ }) => {
13
+ return React.useMemo(() => {
14
+ const sourceFieldResolved = sourceField ?? "source";
15
+ const referencesFieldResolved = referencesField ?? "references";
16
+ const referenceDiscriminationFieldResolved = referenceDiscriminationField ?? "type";
17
+ return blocks.map((block) => {
18
+ if (!(sourceFieldResolved in block)) {
19
+ throw new RichTextRendererError.RichTextRendererError(
20
+ `Found a block without a '${sourceFieldResolved}' field. ` + (sourceField === void 0 ? `The 'sourceField' prop has not been supplied, and so '${sourceFieldResolved}' was used as a default.` : `That is what the 'sourceField' prop has been set to, and so either this is a typo, or the data supplied is invalid.`)
21
+ );
22
+ }
23
+ const source = block[sourceFieldResolved];
24
+ if (typeof source !== "string" && (typeof source !== "object" || source === null)) {
25
+ throw new RichTextRendererError.RichTextRendererError(`Found a block whose source is not a string or an object.`);
26
+ }
27
+ if (referencesField !== void 0 && !(referencesFieldResolved in block)) {
28
+ throw new RichTextRendererError.RichTextRendererError(
29
+ `The 'referencesField' prop is set to '${referencesFieldResolved}' but a block without such field has been encountered. Unless this is just a typo, if you do not wish to use references, avoid supplying the 'referencesField' prop.`
30
+ );
31
+ }
32
+ const references = block[referencesFieldResolved];
33
+ let normalizedReferences;
34
+ if (references) {
35
+ if (typeof Object(references)[Symbol.iterator] !== "function") {
36
+ throw new RichTextRendererError.RichTextRendererError(`The set of references must be an iterable!`);
37
+ }
38
+ normalizedReferences = Object.fromEntries(
39
+ Array.from(references).map((reference) => {
40
+ if (!("id" in reference)) {
41
+ throw new RichTextRendererError.RichTextRendererError(`Found a reference without an id field.`);
42
+ }
43
+ if (!(referenceDiscriminationFieldResolved in reference) || typeof reference[referenceDiscriminationFieldResolved] !== "string") {
44
+ throw new RichTextRendererError.RichTextRendererError(
45
+ `Found a reference without a '${referenceDiscriminationFieldResolved}' field. ` + (referenceDiscriminationField === void 0 ? `The 'referenceDiscriminationField' prop has not been supplied, and so '${referenceDiscriminationFieldResolved}' was used as a default.` : `That is what the 'referenceDiscriminationField' prop has been set to, and so either this is a typo, or the data supplied is invalid.`)
46
+ );
47
+ }
48
+ return [reference.id, {
49
+ ...reference,
50
+ type: reference[referenceDiscriminationFieldResolved]
51
+ }];
52
+ })
53
+ );
54
+ }
55
+ return {
56
+ id: typeof block.id === "string" ? block.id : void 0,
57
+ content: typeof source === "string" ? deserialize(source) : source,
58
+ references: normalizedReferences
59
+ };
60
+ });
61
+ }, [blocks, deserialize, referenceDiscriminationField, referencesField, sourceField]);
62
+ };
63
+ exports.useRichTextBlocksSource = useRichTextBlocksSource;
64
+ //# sourceMappingURL=useRichTextBlocksSource.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRichTextBlocksSource.cjs","sources":["../../../../../packages/react-richtext-renderer/src/hooks/useRichTextBlocksSource.ts"],"sourcesContent":["import { RichTextBlock, RichTextBlockSource, RichTextElement, RichTextLeaf, RichTextReference, RootEditorNode } from '../types'\nimport { defaultDeserialize } from '../internal/defaultDeserialize'\nimport { useMemo } from 'react'\nimport { RichTextRendererError } from '../RichTextRendererError'\n\nexport const useRichTextBlocksSource = <CustomElements extends RichTextElement, CustomLeaves extends RichTextLeaf>({\n\tdeserialize = defaultDeserialize,\n\tblocks,\n\treferencesField,\n\tsourceField,\n\treferenceDiscriminationField,\n}: RichTextBlockSource<CustomElements, CustomLeaves>) => {\n\treturn useMemo((): RichTextBlock<CustomElements, CustomLeaves>[] => {\n\t\tconst sourceFieldResolved = sourceField ?? 'source'\n\t\tconst referencesFieldResolved = referencesField ?? 'references'\n\t\tconst referenceDiscriminationFieldResolved = referenceDiscriminationField ?? 'type'\n\n\t\treturn blocks.map(block => {\n\t\t\tif (!(sourceFieldResolved in block)) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`Found a block without a '${sourceFieldResolved}' field. `\n\t\t\t\t\t\t+ (sourceField === undefined\n\t\t\t\t\t\t\t? `The 'sourceField' prop has not been supplied, and so '${sourceFieldResolved}' was used as a default.`\n\t\t\t\t\t\t\t: `That is what the 'sourceField' prop has been set to, and so either this is a typo, `\n\t\t\t\t\t\t\t\t+ `or the data supplied is invalid.`),\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst source = block[sourceFieldResolved]\n\t\t\tif (typeof source !== 'string' && (typeof source !== 'object' || source === null)) {\n\t\t\t\tthrow new RichTextRendererError(`Found a block whose source is not a string or an object.`)\n\t\t\t}\n\n\t\t\tif (referencesField !== undefined && !(referencesFieldResolved in block)) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`The 'referencesField' prop is set to '${referencesFieldResolved}' but a block without such field `\n\t\t\t\t\t\t+ `has been encountered. Unless this is just a typo, `\n\t\t\t\t\t\t+ `if you do not wish to use references, avoid supplying the 'referencesField' prop.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst references = block[referencesFieldResolved]\n\n\t\t\tlet normalizedReferences: Record<string, RichTextReference> | undefined\n\t\t\tif (references) {\n\t\t\t\tif (typeof Object(references)[Symbol.iterator] !== 'function') {\n\t\t\t\t\tthrow new RichTextRendererError(`The set of references must be an iterable!`)\n\t\t\t\t}\n\n\t\t\t\tnormalizedReferences = Object.fromEntries(\n\t\t\t\t\tArray.from(references as Iterable<RichTextReference>).map(reference => {\n\t\t\t\t\t\tif (!('id' in reference)) {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(`Found a reference without an id field.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!(referenceDiscriminationFieldResolved in reference) || typeof reference[referenceDiscriminationFieldResolved] !== 'string') {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t\t\t`Found a reference without a '${referenceDiscriminationFieldResolved}' field. `\n\t\t\t\t\t\t\t\t\t+ (referenceDiscriminationField === undefined\n\t\t\t\t\t\t\t\t\t\t? `The 'referenceDiscriminationField' prop has not been supplied, `\n\t\t\t\t\t\t\t\t\t\t\t+ `and so '${referenceDiscriminationFieldResolved}' was used as a default.`\n\t\t\t\t\t\t\t\t\t\t: `That is what the 'referenceDiscriminationField' prop has been set to, `\n\t\t\t\t\t\t\t\t\t\t\t+ `and so either this is a typo, or the data supplied is invalid.`),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [reference.id, {\n\t\t\t\t\t\t\t...reference,\n\t\t\t\t\t\t\ttype: reference[referenceDiscriminationFieldResolved] as string,\n\t\t\t\t\t\t}]\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: typeof block.id === 'string' ? block.id : undefined,\n\t\t\t\tcontent: typeof source === 'string' ? deserialize(source) : source as RootEditorNode<CustomElements, CustomLeaves>,\n\t\t\t\treferences: normalizedReferences,\n\t\t\t}\n\t\t})\n\t}, [blocks, deserialize, referenceDiscriminationField, referencesField, sourceField])\n}\n"],"names":["defaultDeserialize","useMemo","RichTextRendererError"],"mappings":";;;;;AAKO,MAAM,0BAA0B,CAA4E;AAAA,EAClH,cAAcA,mBAAAA;AAAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAyD;AACxD,SAAOC,MAAAA,QAAQ,MAAqD;AACnE,UAAM,sBAAsB,eAAe;AAC3C,UAAM,0BAA0B,mBAAmB;AACnD,UAAM,uCAAuC,gCAAgC;AAE7E,WAAO,OAAO,IAAI,CAAA,UAAS;AAC1B,UAAI,EAAE,uBAAuB,QAAQ;AACpC,cAAM,IAAIC,sBAAAA;AAAAA,UACT,4BAA4B,mBAAmB,eAC3C,gBAAgB,SAChB,yDAAyD,mBAAmB,6BAC5E;AAAA,QAAA;AAAA,MAGN;AACA,YAAM,SAAS,MAAM,mBAAmB;AACxC,UAAI,OAAO,WAAW,aAAa,OAAO,WAAW,YAAY,WAAW,OAAO;AAClF,cAAM,IAAIA,sBAAAA,sBAAsB,0DAA0D;AAAA,MAC3F;AAEA,UAAI,oBAAoB,UAAa,EAAE,2BAA2B,QAAQ;AACzE,cAAM,IAAIA,sBAAAA;AAAAA,UACT,yCAAyC,uBAAuB;AAAA,QAAA;AAAA,MAIlE;AACA,YAAM,aAAa,MAAM,uBAAuB;AAEhD,UAAI;AACJ,UAAI,YAAY;AACf,YAAI,OAAO,OAAO,UAAU,EAAE,OAAO,QAAQ,MAAM,YAAY;AAC9D,gBAAM,IAAIA,sBAAAA,sBAAsB,4CAA4C;AAAA,QAC7E;AAEA,+BAAuB,OAAO;AAAA,UAC7B,MAAM,KAAK,UAAyC,EAAE,IAAI,CAAA,cAAa;AACtE,gBAAI,EAAE,QAAQ,YAAY;AACzB,oBAAM,IAAIA,sBAAAA,sBAAsB,wCAAwC;AAAA,YACzE;AACA,gBAAI,EAAE,wCAAwC,cAAc,OAAO,UAAU,oCAAoC,MAAM,UAAU;AAChI,oBAAM,IAAIA,sBAAAA;AAAAA,gBACT,gCAAgC,oCAAoC,eAChE,iCAAiC,SACjC,0EACY,oCAAoC,6BAChD;AAAA,cAAA;AAAA,YAGN;AACA,mBAAO,CAAC,UAAU,IAAI;AAAA,cACrB,GAAG;AAAA,cACH,MAAM,UAAU,oCAAoC;AAAA,YAAA,CACpD;AAAA,UACF,CAAC;AAAA,QAAA;AAAA,MAEH;AACA,aAAO;AAAA,QACN,IAAI,OAAO,MAAM,OAAO,WAAW,MAAM,KAAK;AAAA,QAC9C,SAAS,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI;AAAA,QAC5D,YAAY;AAAA,MAAA;AAAA,IAEd,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,aAAa,8BAA8B,iBAAiB,WAAW,CAAC;AACrF;;"}
@@ -0,0 +1,64 @@
1
+ import { defaultDeserialize } from "../internal/defaultDeserialize.js";
2
+ import { useMemo } from "react";
3
+ import { RichTextRendererError } from "../RichTextRendererError.js";
4
+ const useRichTextBlocksSource = ({
5
+ deserialize = defaultDeserialize,
6
+ blocks,
7
+ referencesField,
8
+ sourceField,
9
+ referenceDiscriminationField
10
+ }) => {
11
+ return useMemo(() => {
12
+ const sourceFieldResolved = sourceField ?? "source";
13
+ const referencesFieldResolved = referencesField ?? "references";
14
+ const referenceDiscriminationFieldResolved = referenceDiscriminationField ?? "type";
15
+ return blocks.map((block) => {
16
+ if (!(sourceFieldResolved in block)) {
17
+ throw new RichTextRendererError(
18
+ `Found a block without a '${sourceFieldResolved}' field. ` + (sourceField === void 0 ? `The 'sourceField' prop has not been supplied, and so '${sourceFieldResolved}' was used as a default.` : `That is what the 'sourceField' prop has been set to, and so either this is a typo, or the data supplied is invalid.`)
19
+ );
20
+ }
21
+ const source = block[sourceFieldResolved];
22
+ if (typeof source !== "string" && (typeof source !== "object" || source === null)) {
23
+ throw new RichTextRendererError(`Found a block whose source is not a string or an object.`);
24
+ }
25
+ if (referencesField !== void 0 && !(referencesFieldResolved in block)) {
26
+ throw new RichTextRendererError(
27
+ `The 'referencesField' prop is set to '${referencesFieldResolved}' but a block without such field has been encountered. Unless this is just a typo, if you do not wish to use references, avoid supplying the 'referencesField' prop.`
28
+ );
29
+ }
30
+ const references = block[referencesFieldResolved];
31
+ let normalizedReferences;
32
+ if (references) {
33
+ if (typeof Object(references)[Symbol.iterator] !== "function") {
34
+ throw new RichTextRendererError(`The set of references must be an iterable!`);
35
+ }
36
+ normalizedReferences = Object.fromEntries(
37
+ Array.from(references).map((reference) => {
38
+ if (!("id" in reference)) {
39
+ throw new RichTextRendererError(`Found a reference without an id field.`);
40
+ }
41
+ if (!(referenceDiscriminationFieldResolved in reference) || typeof reference[referenceDiscriminationFieldResolved] !== "string") {
42
+ throw new RichTextRendererError(
43
+ `Found a reference without a '${referenceDiscriminationFieldResolved}' field. ` + (referenceDiscriminationField === void 0 ? `The 'referenceDiscriminationField' prop has not been supplied, and so '${referenceDiscriminationFieldResolved}' was used as a default.` : `That is what the 'referenceDiscriminationField' prop has been set to, and so either this is a typo, or the data supplied is invalid.`)
44
+ );
45
+ }
46
+ return [reference.id, {
47
+ ...reference,
48
+ type: reference[referenceDiscriminationFieldResolved]
49
+ }];
50
+ })
51
+ );
52
+ }
53
+ return {
54
+ id: typeof block.id === "string" ? block.id : void 0,
55
+ content: typeof source === "string" ? deserialize(source) : source,
56
+ references: normalizedReferences
57
+ };
58
+ });
59
+ }, [blocks, deserialize, referenceDiscriminationField, referencesField, sourceField]);
60
+ };
61
+ export {
62
+ useRichTextBlocksSource
63
+ };
64
+ //# sourceMappingURL=useRichTextBlocksSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRichTextBlocksSource.js","sources":["../../../../../packages/react-richtext-renderer/src/hooks/useRichTextBlocksSource.ts"],"sourcesContent":["import { RichTextBlock, RichTextBlockSource, RichTextElement, RichTextLeaf, RichTextReference, RootEditorNode } from '../types'\nimport { defaultDeserialize } from '../internal/defaultDeserialize'\nimport { useMemo } from 'react'\nimport { RichTextRendererError } from '../RichTextRendererError'\n\nexport const useRichTextBlocksSource = <CustomElements extends RichTextElement, CustomLeaves extends RichTextLeaf>({\n\tdeserialize = defaultDeserialize,\n\tblocks,\n\treferencesField,\n\tsourceField,\n\treferenceDiscriminationField,\n}: RichTextBlockSource<CustomElements, CustomLeaves>) => {\n\treturn useMemo((): RichTextBlock<CustomElements, CustomLeaves>[] => {\n\t\tconst sourceFieldResolved = sourceField ?? 'source'\n\t\tconst referencesFieldResolved = referencesField ?? 'references'\n\t\tconst referenceDiscriminationFieldResolved = referenceDiscriminationField ?? 'type'\n\n\t\treturn blocks.map(block => {\n\t\t\tif (!(sourceFieldResolved in block)) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`Found a block without a '${sourceFieldResolved}' field. `\n\t\t\t\t\t\t+ (sourceField === undefined\n\t\t\t\t\t\t\t? `The 'sourceField' prop has not been supplied, and so '${sourceFieldResolved}' was used as a default.`\n\t\t\t\t\t\t\t: `That is what the 'sourceField' prop has been set to, and so either this is a typo, `\n\t\t\t\t\t\t\t\t+ `or the data supplied is invalid.`),\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst source = block[sourceFieldResolved]\n\t\t\tif (typeof source !== 'string' && (typeof source !== 'object' || source === null)) {\n\t\t\t\tthrow new RichTextRendererError(`Found a block whose source is not a string or an object.`)\n\t\t\t}\n\n\t\t\tif (referencesField !== undefined && !(referencesFieldResolved in block)) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`The 'referencesField' prop is set to '${referencesFieldResolved}' but a block without such field `\n\t\t\t\t\t\t+ `has been encountered. Unless this is just a typo, `\n\t\t\t\t\t\t+ `if you do not wish to use references, avoid supplying the 'referencesField' prop.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst references = block[referencesFieldResolved]\n\n\t\t\tlet normalizedReferences: Record<string, RichTextReference> | undefined\n\t\t\tif (references) {\n\t\t\t\tif (typeof Object(references)[Symbol.iterator] !== 'function') {\n\t\t\t\t\tthrow new RichTextRendererError(`The set of references must be an iterable!`)\n\t\t\t\t}\n\n\t\t\t\tnormalizedReferences = Object.fromEntries(\n\t\t\t\t\tArray.from(references as Iterable<RichTextReference>).map(reference => {\n\t\t\t\t\t\tif (!('id' in reference)) {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(`Found a reference without an id field.`)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!(referenceDiscriminationFieldResolved in reference) || typeof reference[referenceDiscriminationFieldResolved] !== 'string') {\n\t\t\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t\t\t`Found a reference without a '${referenceDiscriminationFieldResolved}' field. `\n\t\t\t\t\t\t\t\t\t+ (referenceDiscriminationField === undefined\n\t\t\t\t\t\t\t\t\t\t? `The 'referenceDiscriminationField' prop has not been supplied, `\n\t\t\t\t\t\t\t\t\t\t\t+ `and so '${referenceDiscriminationFieldResolved}' was used as a default.`\n\t\t\t\t\t\t\t\t\t\t: `That is what the 'referenceDiscriminationField' prop has been set to, `\n\t\t\t\t\t\t\t\t\t\t\t+ `and so either this is a typo, or the data supplied is invalid.`),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn [reference.id, {\n\t\t\t\t\t\t\t...reference,\n\t\t\t\t\t\t\ttype: reference[referenceDiscriminationFieldResolved] as string,\n\t\t\t\t\t\t}]\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tid: typeof block.id === 'string' ? block.id : undefined,\n\t\t\t\tcontent: typeof source === 'string' ? deserialize(source) : source as RootEditorNode<CustomElements, CustomLeaves>,\n\t\t\t\treferences: normalizedReferences,\n\t\t\t}\n\t\t})\n\t}, [blocks, deserialize, referenceDiscriminationField, referencesField, sourceField])\n}\n"],"names":[],"mappings":";;;AAKO,MAAM,0BAA0B,CAA4E;AAAA,EAClH,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAyD;AACxD,SAAO,QAAQ,MAAqD;AACnE,UAAM,sBAAsB,eAAe;AAC3C,UAAM,0BAA0B,mBAAmB;AACnD,UAAM,uCAAuC,gCAAgC;AAE7E,WAAO,OAAO,IAAI,CAAA,UAAS;AAC1B,UAAI,EAAE,uBAAuB,QAAQ;AACpC,cAAM,IAAI;AAAA,UACT,4BAA4B,mBAAmB,eAC3C,gBAAgB,SAChB,yDAAyD,mBAAmB,6BAC5E;AAAA,QAAA;AAAA,MAGN;AACA,YAAM,SAAS,MAAM,mBAAmB;AACxC,UAAI,OAAO,WAAW,aAAa,OAAO,WAAW,YAAY,WAAW,OAAO;AAClF,cAAM,IAAI,sBAAsB,0DAA0D;AAAA,MAC3F;AAEA,UAAI,oBAAoB,UAAa,EAAE,2BAA2B,QAAQ;AACzE,cAAM,IAAI;AAAA,UACT,yCAAyC,uBAAuB;AAAA,QAAA;AAAA,MAIlE;AACA,YAAM,aAAa,MAAM,uBAAuB;AAEhD,UAAI;AACJ,UAAI,YAAY;AACf,YAAI,OAAO,OAAO,UAAU,EAAE,OAAO,QAAQ,MAAM,YAAY;AAC9D,gBAAM,IAAI,sBAAsB,4CAA4C;AAAA,QAC7E;AAEA,+BAAuB,OAAO;AAAA,UAC7B,MAAM,KAAK,UAAyC,EAAE,IAAI,CAAA,cAAa;AACtE,gBAAI,EAAE,QAAQ,YAAY;AACzB,oBAAM,IAAI,sBAAsB,wCAAwC;AAAA,YACzE;AACA,gBAAI,EAAE,wCAAwC,cAAc,OAAO,UAAU,oCAAoC,MAAM,UAAU;AAChI,oBAAM,IAAI;AAAA,gBACT,gCAAgC,oCAAoC,eAChE,iCAAiC,SACjC,0EACY,oCAAoC,6BAChD;AAAA,cAAA;AAAA,YAGN;AACA,mBAAO,CAAC,UAAU,IAAI;AAAA,cACrB,GAAG;AAAA,cACH,MAAM,UAAU,oCAAoC;AAAA,YAAA,CACpD;AAAA,UACF,CAAC;AAAA,QAAA;AAAA,MAEH;AACA,aAAO;AAAA,QACN,IAAI,OAAO,MAAM,OAAO,WAAW,MAAM,KAAK;AAAA,QAC9C,SAAS,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI;AAAA,QAC5D,YAAY;AAAA,MAAA;AAAA,IAEd,CAAC;AAAA,EACF,GAAG,CAAC,QAAQ,aAAa,8BAA8B,iBAAiB,WAAW,CAAC;AACrF;"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const defaultDeserialize = require("../internal/defaultDeserialize.cjs");
5
+ const useRichTextFieldSource = ({
6
+ source,
7
+ deserialize = defaultDeserialize.defaultDeserialize
8
+ }) => {
9
+ return React.useMemo(() => {
10
+ return [
11
+ {
12
+ content: source ? typeof source === "string" ? deserialize(source) : source : {
13
+ formatVersion: 0,
14
+ children: []
15
+ },
16
+ id: void 0,
17
+ referencesField: void 0,
18
+ referenceDiscriminationField: void 0,
19
+ referenceRenderers: {},
20
+ references: void 0
21
+ }
22
+ ];
23
+ }, [deserialize, source]);
24
+ };
25
+ exports.useRichTextFieldSource = useRichTextFieldSource;
26
+ //# sourceMappingURL=useRichTextFieldSource.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRichTextFieldSource.cjs","sources":["../../../../../packages/react-richtext-renderer/src/hooks/useRichTextFieldSource.ts"],"sourcesContent":["import { RichTextBlock, RichTextElement, RichTextFieldSource, RichTextLeaf } from '../types'\nimport { useMemo } from 'react'\nimport { defaultDeserialize } from '../internal/defaultDeserialize'\n\nexport const useRichTextFieldSource = <CustomElements extends RichTextElement, CustomLeaves extends RichTextLeaf>({\n\tsource,\n\tdeserialize = defaultDeserialize,\n}: RichTextFieldSource<CustomElements, CustomLeaves>): RichTextBlock<CustomElements, CustomLeaves>[] => {\n\treturn useMemo(() => {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcontent: source\n\t\t\t\t\t? (typeof source === 'string' ? deserialize(source) : source)\n\t\t\t\t\t: {\n\t\t\t\t\t\tformatVersion: 0,\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t},\n\t\t\t\tid: undefined,\n\t\t\t\treferencesField: undefined,\n\t\t\t\treferenceDiscriminationField: undefined,\n\t\t\t\treferenceRenderers: {},\n\t\t\t\treferences: undefined,\n\t\t\t},\n\t\t]\n\t}, [deserialize, source])\n}\n"],"names":["defaultDeserialize","useMemo"],"mappings":";;;;AAIO,MAAM,yBAAyB,CAA4E;AAAA,EACjH;AAAA,EACA,cAAcA,mBAAAA;AACf,MAAwG;AACvG,SAAOC,MAAAA,QAAQ,MAAM;AACpB,WAAO;AAAA,MACN;AAAA,QACC,SAAS,SACL,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI,SACpD;AAAA,UACD,eAAe;AAAA,UACf,UAAU,CAAA;AAAA,QAAC;AAAA,QAEb,IAAI;AAAA,QACJ,iBAAiB;AAAA,QACjB,8BAA8B;AAAA,QAC9B,oBAAoB,CAAA;AAAA,QACpB,YAAY;AAAA,MAAA;AAAA,IACb;AAAA,EAEF,GAAG,CAAC,aAAa,MAAM,CAAC;AACzB;;"}
@@ -0,0 +1,26 @@
1
+ import { useMemo } from "react";
2
+ import { defaultDeserialize } from "../internal/defaultDeserialize.js";
3
+ const useRichTextFieldSource = ({
4
+ source,
5
+ deserialize = defaultDeserialize
6
+ }) => {
7
+ return useMemo(() => {
8
+ return [
9
+ {
10
+ content: source ? typeof source === "string" ? deserialize(source) : source : {
11
+ formatVersion: 0,
12
+ children: []
13
+ },
14
+ id: void 0,
15
+ referencesField: void 0,
16
+ referenceDiscriminationField: void 0,
17
+ referenceRenderers: {},
18
+ references: void 0
19
+ }
20
+ ];
21
+ }, [deserialize, source]);
22
+ };
23
+ export {
24
+ useRichTextFieldSource
25
+ };
26
+ //# sourceMappingURL=useRichTextFieldSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRichTextFieldSource.js","sources":["../../../../../packages/react-richtext-renderer/src/hooks/useRichTextFieldSource.ts"],"sourcesContent":["import { RichTextBlock, RichTextElement, RichTextFieldSource, RichTextLeaf } from '../types'\nimport { useMemo } from 'react'\nimport { defaultDeserialize } from '../internal/defaultDeserialize'\n\nexport const useRichTextFieldSource = <CustomElements extends RichTextElement, CustomLeaves extends RichTextLeaf>({\n\tsource,\n\tdeserialize = defaultDeserialize,\n}: RichTextFieldSource<CustomElements, CustomLeaves>): RichTextBlock<CustomElements, CustomLeaves>[] => {\n\treturn useMemo(() => {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcontent: source\n\t\t\t\t\t? (typeof source === 'string' ? deserialize(source) : source)\n\t\t\t\t\t: {\n\t\t\t\t\t\tformatVersion: 0,\n\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t},\n\t\t\t\tid: undefined,\n\t\t\t\treferencesField: undefined,\n\t\t\t\treferenceDiscriminationField: undefined,\n\t\t\t\treferenceRenderers: {},\n\t\t\t\treferences: undefined,\n\t\t\t},\n\t\t]\n\t}, [deserialize, source])\n}\n"],"names":[],"mappings":";;AAIO,MAAM,yBAAyB,CAA4E;AAAA,EACjH;AAAA,EACA,cAAc;AACf,MAAwG;AACvG,SAAO,QAAQ,MAAM;AACpB,WAAO;AAAA,MACN;AAAA,QACC,SAAS,SACL,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI,SACpD;AAAA,UACD,eAAe;AAAA,UACf,UAAU,CAAA;AAAA,QAAC;AAAA,QAEb,IAAI;AAAA,QACJ,iBAAiB;AAAA,QACjB,8BAA8B;AAAA,QAC9B,oBAAoB,CAAA;AAAA,QACpB,YAAY;AAAA,MAAA;AAAA,IACb;AAAA,EAEF,GAAG,CAAC,aAAa,MAAM,CAAC;AACzB;"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const renderChildren = require("../renderChildren.cjs");
6
+ const RenderElementFallback = require("./RenderElementFallback.cjs");
7
+ const useReferenceMetadata = require("../useReferenceMetadata.cjs");
8
+ function ElementRenderer({ element, children, options, block }) {
9
+ const referenceMetadata = useReferenceMetadata.useReferenceMetadata(element, options, block);
10
+ const fallback = /* @__PURE__ */ jsxRuntime.jsx(
11
+ RenderElementFallback.RenderElementFallback,
12
+ {
13
+ element,
14
+ options,
15
+ block,
16
+ children
17
+ }
18
+ );
19
+ return options.renderElement ? React.createElement(options.renderElement, {
20
+ ...referenceMetadata,
21
+ formatVersion: block.content.formatVersion,
22
+ block,
23
+ options,
24
+ element,
25
+ fallback,
26
+ children,
27
+ renderChildren: (children2, opts = options) => renderChildren.renderChildren(children2, opts, block),
28
+ renderChildrenOptions: options
29
+ }) : fallback;
30
+ }
31
+ exports.ElementRenderer = ElementRenderer;
32
+ //# sourceMappingURL=ElementRenderer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementRenderer.cjs","sources":["../../../../../../packages/react-richtext-renderer/src/internal/components/ElementRenderer.tsx"],"sourcesContent":["import type { ReactElement } from 'react'\nimport { createElement } from 'react'\nimport type { BuiltinElements } from '../../types/builtin/BuiltinElements'\nimport { renderChildren } from '../renderChildren'\nimport { RenderElementFallback } from './RenderElementFallback'\nimport { useReferenceMetadata } from '../useReferenceMetadata'\nimport type { RichTextElement } from '../../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../../types/structure/RichTextLeaf'\nimport { RichTextBlock } from '../../types/RichTextBlock'\nimport { RichTextRenderingOptions } from '../../types/RichTextRenderingOptions'\n\nexport interface ElementRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> {\n\telement: CustomElements | BuiltinElements<CustomElements, CustomLeaves>\n\tchildren: ReactElement\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>\n\tblock: RichTextBlock<CustomElements, CustomLeaves>\n}\n\nexport function ElementRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({ element, children, options, block }: ElementRendererProps<CustomElements, CustomLeaves>) {\n\tconst referenceMetadata = useReferenceMetadata<CustomElements, CustomLeaves>(element, options, block)\n\n\tconst fallback = (\n\t\t<RenderElementFallback<CustomElements, CustomLeaves>\n\t\t\telement={element as BuiltinElements<CustomElements, CustomLeaves>}\n\t\t\toptions={options}\n\t\t\tblock={block}\n\t\t>\n\t\t\t{children}\n\t\t</RenderElementFallback>\n\t)\n\n\treturn options.renderElement\n\t\t? createElement(options.renderElement, {\n\t\t\t...referenceMetadata,\n\t\t\tformatVersion: block.content.formatVersion,\n\t\t\tblock,\n\t\t\toptions,\n\t\t\telement,\n\t\t\tfallback,\n\t\t\tchildren,\n\t\t\trenderChildren: (children, opts = options) => renderChildren(children, opts, block),\n\t\t\trenderChildrenOptions: options,\n\t\t})\n\t\t: fallback\n}\n"],"names":["useReferenceMetadata","jsx","RenderElementFallback","createElement","children","renderChildren"],"mappings":";;;;;;;AAqBO,SAAS,gBAGd,EAAE,SAAS,UAAU,SAAS,SAA6D;AAC5F,QAAM,oBAAoBA,qBAAAA,qBAAmD,SAAS,SAAS,KAAK;AAEpG,QAAM,WACLC,2BAAAA;AAAAA,IAACC,sBAAAA;AAAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAIH,SAAO,QAAQ,gBACZC,oBAAc,QAAQ,eAAe;AAAA,IACtC,GAAG;AAAA,IACH,eAAe,MAAM,QAAQ;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,CAACC,WAAU,OAAO,YAAYC,eAAAA,eAAeD,WAAU,MAAM,KAAK;AAAA,IAClF,uBAAuB;AAAA,EAAA,CACvB,IACC;AACJ;;"}
@@ -0,0 +1,32 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createElement } from "react";
3
+ import { renderChildren } from "../renderChildren.js";
4
+ import { RenderElementFallback } from "./RenderElementFallback.js";
5
+ import { useReferenceMetadata } from "../useReferenceMetadata.js";
6
+ function ElementRenderer({ element, children, options, block }) {
7
+ const referenceMetadata = useReferenceMetadata(element, options, block);
8
+ const fallback = /* @__PURE__ */ jsx(
9
+ RenderElementFallback,
10
+ {
11
+ element,
12
+ options,
13
+ block,
14
+ children
15
+ }
16
+ );
17
+ return options.renderElement ? createElement(options.renderElement, {
18
+ ...referenceMetadata,
19
+ formatVersion: block.content.formatVersion,
20
+ block,
21
+ options,
22
+ element,
23
+ fallback,
24
+ children,
25
+ renderChildren: (children2, opts = options) => renderChildren(children2, opts, block),
26
+ renderChildrenOptions: options
27
+ }) : fallback;
28
+ }
29
+ export {
30
+ ElementRenderer
31
+ };
32
+ //# sourceMappingURL=ElementRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementRenderer.js","sources":["../../../../../../packages/react-richtext-renderer/src/internal/components/ElementRenderer.tsx"],"sourcesContent":["import type { ReactElement } from 'react'\nimport { createElement } from 'react'\nimport type { BuiltinElements } from '../../types/builtin/BuiltinElements'\nimport { renderChildren } from '../renderChildren'\nimport { RenderElementFallback } from './RenderElementFallback'\nimport { useReferenceMetadata } from '../useReferenceMetadata'\nimport type { RichTextElement } from '../../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../../types/structure/RichTextLeaf'\nimport { RichTextBlock } from '../../types/RichTextBlock'\nimport { RichTextRenderingOptions } from '../../types/RichTextRenderingOptions'\n\nexport interface ElementRendererProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> {\n\telement: CustomElements | BuiltinElements<CustomElements, CustomLeaves>\n\tchildren: ReactElement\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>\n\tblock: RichTextBlock<CustomElements, CustomLeaves>\n}\n\nexport function ElementRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({ element, children, options, block }: ElementRendererProps<CustomElements, CustomLeaves>) {\n\tconst referenceMetadata = useReferenceMetadata<CustomElements, CustomLeaves>(element, options, block)\n\n\tconst fallback = (\n\t\t<RenderElementFallback<CustomElements, CustomLeaves>\n\t\t\telement={element as BuiltinElements<CustomElements, CustomLeaves>}\n\t\t\toptions={options}\n\t\t\tblock={block}\n\t\t>\n\t\t\t{children}\n\t\t</RenderElementFallback>\n\t)\n\n\treturn options.renderElement\n\t\t? createElement(options.renderElement, {\n\t\t\t...referenceMetadata,\n\t\t\tformatVersion: block.content.formatVersion,\n\t\t\tblock,\n\t\t\toptions,\n\t\t\telement,\n\t\t\tfallback,\n\t\t\tchildren,\n\t\t\trenderChildren: (children, opts = options) => renderChildren(children, opts, block),\n\t\t\trenderChildrenOptions: options,\n\t\t})\n\t\t: fallback\n}\n"],"names":["children"],"mappings":";;;;;AAqBO,SAAS,gBAGd,EAAE,SAAS,UAAU,SAAS,SAA6D;AAC5F,QAAM,oBAAoB,qBAAmD,SAAS,SAAS,KAAK;AAEpG,QAAM,WACL;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAIH,SAAO,QAAQ,gBACZ,cAAc,QAAQ,eAAe;AAAA,IACtC,GAAG;AAAA,IACH,eAAe,MAAM,QAAQ;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB,CAACA,WAAU,OAAO,YAAY,eAAeA,WAAU,MAAM,KAAK;AAAA,IAClF,uBAAuB;AAAA,EAAA,CACvB,IACC;AACJ;"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const RenderLeafFallback = require("./RenderLeafFallback.cjs");
6
+ function LeafRenderer({
7
+ leaf,
8
+ options: { renderLeaf },
9
+ block: { content: { formatVersion } }
10
+ }) {
11
+ const fallback = /* @__PURE__ */ jsxRuntime.jsx(RenderLeafFallback.RenderLeafFallback, { leaf });
12
+ return renderLeaf ? React.createElement(
13
+ renderLeaf,
14
+ {
15
+ formatVersion,
16
+ leaf,
17
+ fallback,
18
+ children: leaf.text
19
+ }
20
+ ) : fallback;
21
+ }
22
+ exports.LeafRenderer = LeafRenderer;
23
+ //# sourceMappingURL=LeafRenderer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LeafRenderer.cjs","sources":["../../../../../../packages/react-richtext-renderer/src/internal/components/LeafRenderer.tsx"],"sourcesContent":["import { createElement } from 'react'\nimport type { BuiltinLeaves } from '../../types/builtin/BuiltinLeaves'\nimport { RenderLeafFallback } from './RenderLeafFallback'\nimport type { RichTextLeaf } from '../../types/structure/RichTextLeaf'\nimport { RichTextElement } from '../../types/structure/RichTextElement'\nimport { RichTextRenderingOptions } from '../../types/RichTextRenderingOptions'\nimport { RichTextBlock } from '../../types/RichTextBlock'\n\nexport interface LeafRendererProps<CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf> {\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>\n\tblock: RichTextBlock<CustomElements, CustomLeaves>\n\tleaf: CustomLeaves & BuiltinLeaves\n}\n\nexport function LeafRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\tleaf,\n\toptions: { renderLeaf },\n\tblock: { content: { formatVersion } },\n}: LeafRendererProps<CustomElements, CustomLeaves>) {\n\tconst fallback = <RenderLeafFallback leaf={leaf} />\n\n\treturn renderLeaf\n\t\t? createElement(\n\t\t\trenderLeaf,\n\t\t\t{\n\t\t\t\tformatVersion,\n\t\t\t\tleaf,\n\t\t\t\tfallback,\n\t\t\t\tchildren: leaf.text,\n\t\t\t},\n\t\t)\n\t\t: fallback\n}\n"],"names":["jsx","RenderLeafFallback","createElement"],"mappings":";;;;;AAcO,SAAS,aAGd;AAAA,EACD;AAAA,EACA,SAAS,EAAE,WAAA;AAAA,EACX,OAAO,EAAE,SAAS,EAAE,gBAAc;AACnC,GAAoD;AACnD,QAAM,WAAWA,2BAAAA,IAACC,uCAAA,EAAmB,KAAA,CAAY;AAEjD,SAAO,aACJC,MAAAA;AAAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,KAAK;AAAA,IAAA;AAAA,EAChB,IAEC;AACJ;;"}
@@ -0,0 +1,23 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createElement } from "react";
3
+ import { RenderLeafFallback } from "./RenderLeafFallback.js";
4
+ function LeafRenderer({
5
+ leaf,
6
+ options: { renderLeaf },
7
+ block: { content: { formatVersion } }
8
+ }) {
9
+ const fallback = /* @__PURE__ */ jsx(RenderLeafFallback, { leaf });
10
+ return renderLeaf ? createElement(
11
+ renderLeaf,
12
+ {
13
+ formatVersion,
14
+ leaf,
15
+ fallback,
16
+ children: leaf.text
17
+ }
18
+ ) : fallback;
19
+ }
20
+ export {
21
+ LeafRenderer
22
+ };
23
+ //# sourceMappingURL=LeafRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LeafRenderer.js","sources":["../../../../../../packages/react-richtext-renderer/src/internal/components/LeafRenderer.tsx"],"sourcesContent":["import { createElement } from 'react'\nimport type { BuiltinLeaves } from '../../types/builtin/BuiltinLeaves'\nimport { RenderLeafFallback } from './RenderLeafFallback'\nimport type { RichTextLeaf } from '../../types/structure/RichTextLeaf'\nimport { RichTextElement } from '../../types/structure/RichTextElement'\nimport { RichTextRenderingOptions } from '../../types/RichTextRenderingOptions'\nimport { RichTextBlock } from '../../types/RichTextBlock'\n\nexport interface LeafRendererProps<CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf> {\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>\n\tblock: RichTextBlock<CustomElements, CustomLeaves>\n\tleaf: CustomLeaves & BuiltinLeaves\n}\n\nexport function LeafRenderer<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\tleaf,\n\toptions: { renderLeaf },\n\tblock: { content: { formatVersion } },\n}: LeafRendererProps<CustomElements, CustomLeaves>) {\n\tconst fallback = <RenderLeafFallback leaf={leaf} />\n\n\treturn renderLeaf\n\t\t? createElement(\n\t\t\trenderLeaf,\n\t\t\t{\n\t\t\t\tformatVersion,\n\t\t\t\tleaf,\n\t\t\t\tfallback,\n\t\t\t\tchildren: leaf.text,\n\t\t\t},\n\t\t)\n\t\t: fallback\n}\n"],"names":[],"mappings":";;;AAcO,SAAS,aAGd;AAAA,EACD;AAAA,EACA,SAAS,EAAE,WAAA;AAAA,EACX,OAAO,EAAE,SAAS,EAAE,gBAAc;AACnC,GAAoD;AACnD,QAAM,WAAW,oBAAC,oBAAA,EAAmB,KAAA,CAAY;AAEjD,SAAO,aACJ;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,KAAK;AAAA,IAAA;AAAA,EAChB,IAEC;AACJ;"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const renderChildren = require("../renderChildren.cjs");
6
+ const useReferenceMetadata = require("../useReferenceMetadata.cjs");
7
+ const getElementDataAttributes = (element, attributeNamePrefix = "contember-") => {
8
+ const { children, referenceId, ...extendedSpecifics } = element;
9
+ return Object.fromEntries(
10
+ Object.entries(extendedSpecifics).filter(([, value]) => {
11
+ const t = typeof value;
12
+ return t === "string" || t === "number" || t === "boolean";
13
+ }).map(([attribute, value]) => [`data-${attributeNamePrefix}${attribute.toLowerCase()}`, value])
14
+ );
15
+ };
16
+ function RenderElementFallback({ element, children, options, block }) {
17
+ const attributes = getElementDataAttributes(element, options.attributeNamePrefix);
18
+ switch (element.type) {
19
+ case "anchor":
20
+ return /* @__PURE__ */ jsxRuntime.jsx("a", { ...attributes, href: element.href, children });
21
+ case "heading":
22
+ return React.createElement(`h${element.level}`, attributes, children);
23
+ // TODO numbered
24
+ case "horizontalRule":
25
+ return /* @__PURE__ */ jsxRuntime.jsx("hr", { ...attributes });
26
+ case "listItem":
27
+ return /* @__PURE__ */ jsxRuntime.jsx("li", { ...attributes, children });
28
+ case "orderedList":
29
+ return /* @__PURE__ */ jsxRuntime.jsx("ol", { ...attributes, children });
30
+ case "paragraph":
31
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { ...attributes, children });
32
+ case "reference": {
33
+ return /* @__PURE__ */ jsxRuntime.jsx(ReferenceElementFallback, { element, children, options, block });
34
+ }
35
+ case "scrollTarget":
36
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ...attributes, id: element.identifier, children });
37
+ case "table": {
38
+ const firstRow = element.children[0];
39
+ if (!firstRow || firstRow.headerScope !== "table") {
40
+ return /* @__PURE__ */ jsxRuntime.jsx("table", { ...attributes, children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { children }) });
41
+ }
42
+ return /* @__PURE__ */ jsxRuntime.jsxs("table", { ...attributes, children: [
43
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: renderChildren.renderChildren([firstRow], options, block) }),
44
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: renderChildren.renderChildren(element.children.slice(1), options, block) })
45
+ ] });
46
+ }
47
+ case "tableRow":
48
+ return /* @__PURE__ */ jsxRuntime.jsx("tr", { ...attributes, children });
49
+ case "tableCell": {
50
+ if (element.headerScope) {
51
+ return /* @__PURE__ */ jsxRuntime.jsx("th", { ...attributes, scope: element.headerScope, children });
52
+ }
53
+ return /* @__PURE__ */ jsxRuntime.jsx("td", { ...attributes, children });
54
+ }
55
+ case "unorderedList":
56
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { ...attributes, children });
57
+ default: {
58
+ {
59
+ return children;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ function ReferenceElementFallback({ element, children, options, block }) {
65
+ const elementMetadata = useReferenceMetadata.useReferenceMetadata(element, options, block, true);
66
+ if (elementMetadata.referenceRenderer === void 0 || elementMetadata.referenceType === void 0 || elementMetadata.reference === void 0) {
67
+ return children;
68
+ }
69
+ let Renderer = elementMetadata.referenceRenderer;
70
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
71
+ Renderer,
72
+ {
73
+ referenceType: elementMetadata.referenceType,
74
+ referenceRenderer: elementMetadata.referenceRenderer,
75
+ reference: elementMetadata.reference,
76
+ formatVersion: block.content.formatVersion,
77
+ block,
78
+ options,
79
+ element,
80
+ children
81
+ }
82
+ ) });
83
+ }
84
+ exports.RenderElementFallback = RenderElementFallback;
85
+ //# sourceMappingURL=RenderElementFallback.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderElementFallback.cjs","sources":["../../../../../../packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx"],"sourcesContent":["import { createElement, ReactElement } from 'react'\nimport type { BuiltinElements, RichTextReferenceElement, RichTextTableRowElement } from '../../types/builtin/BuiltinElements'\nimport { renderChildren } from '../renderChildren'\nimport { useReferenceMetadata } from '../useReferenceMetadata'\nimport type { RichTextElement } from '../../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../../types/structure/RichTextLeaf'\nimport { RichTextRendererError } from '../../RichTextRendererError'\nimport { RichTextBlock } from '../../types/RichTextBlock'\nimport { RichTextRenderingOptions } from '../../types/RichTextRenderingOptions'\n\nexport interface RenderElementFallbackProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> {\n\telement: BuiltinElements<CustomElements, CustomLeaves>\n\tchildren: ReactElement\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>\n\tblock: RichTextBlock<CustomElements, CustomLeaves>\n}\n\nconst getElementDataAttributes = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>(\n\telement: RichTextElement<CustomElements, CustomLeaves>,\n\tattributeNamePrefix: string = 'contember-',\n): {\n\t[dataAttribute: string]: string | number | boolean\n} => {\n\tconst { children, referenceId, ...extendedSpecifics } = element\n\n\treturn Object.fromEntries(\n\t\tObject.entries(extendedSpecifics)\n\t\t\t.filter(([, value]) => {\n\t\t\t\tconst t = typeof value\n\t\t\t\treturn t === 'string' || t === 'number' || t === 'boolean'\n\t\t\t})\n\t\t\t.map(([attribute, value]) => [`data-${attributeNamePrefix}${attribute.toLowerCase()}`, value]),\n\t)\n}\n\nexport function RenderElementFallback<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({ element, children, options, block }: RenderElementFallbackProps<CustomElements, CustomLeaves>) {\n\tconst attributes = getElementDataAttributes(element, options.attributeNamePrefix)\n\n\tswitch (element.type) {\n\t\tcase 'anchor':\n\t\t\treturn (\n\t\t\t\t<a {...attributes} href={element.href}>\n\t\t\t\t\t{children}\n\t\t\t\t</a>\n\t\t\t)\n\t\tcase 'heading':\n\t\t\treturn createElement(`h${element.level}`, attributes, children) // TODO numbered\n\t\tcase 'horizontalRule':\n\t\t\treturn <hr {...attributes} />\n\t\tcase 'listItem':\n\t\t\treturn <li {...attributes}>{children}</li>\n\t\tcase 'orderedList':\n\t\t\treturn <ol {...attributes}>{children}</ol>\n\t\tcase 'paragraph':\n\t\t\treturn <p {...attributes}>{children}</p>\n\t\tcase 'reference': {\n\t\t\treturn <ReferenceElementFallback element={element} children={children} options={options} block={block} />\n\t\t}\n\t\tcase 'scrollTarget':\n\t\t\treturn (\n\t\t\t\t<span {...attributes} id={element.identifier}>\n\t\t\t\t\t{children}\n\t\t\t\t</span>\n\t\t\t)\n\t\tcase 'table': {\n\t\t\tconst firstRow = element.children[0] as RichTextTableRowElement<CustomElements, CustomLeaves> | undefined\n\t\t\tif (!firstRow || firstRow.headerScope !== 'table') {\n\t\t\t\treturn (\n\t\t\t\t\t<table {...attributes}>\n\t\t\t\t\t\t<tbody>{children}</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t<table {...attributes}>\n\t\t\t\t\t<thead>{renderChildren<CustomElements, CustomLeaves>([firstRow], options, block)}</thead>\n\t\t\t\t\t<tbody>{renderChildren<CustomElements, CustomLeaves>(element.children.slice(1) as any, options, block)}</tbody>\n\t\t\t\t</table>\n\t\t\t)\n\t\t}\n\t\tcase 'tableRow':\n\t\t\treturn <tr {...attributes}>{children}</tr>\n\t\tcase 'tableCell': {\n\t\t\tif (element.headerScope) {\n\t\t\t\treturn (\n\t\t\t\t\t<th {...attributes} scope={element.headerScope}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</th>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn <td {...attributes}>{children}</td>\n\t\t}\n\t\tcase 'unorderedList':\n\t\t\treturn <ul {...attributes}>{children}</ul>\n\t\tdefault: {\n\t\t\tif (import.meta.env.DEV) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: unknown element of type '${(element as { type: string }).type}'.`,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\treturn children // At least render the text contents\n\t\t\t}\n\t\t}\n\t}\n}\n\ntype ReferenceElementFallbackProps<CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf> = {\n\telement: RichTextReferenceElement<CustomElements, CustomLeaves>\n\tchildren: ReactElement\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>\n\tblock: RichTextBlock<CustomElements, CustomLeaves>\n}\n\nfunction ReferenceElementFallback<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({ element, children, options, block }: ReferenceElementFallbackProps<CustomElements, CustomLeaves>) {\n\tconst elementMetadata = useReferenceMetadata<CustomElements, CustomLeaves>(element, options, block, true)\n\n\tif (\n\t\telementMetadata.referenceRenderer === undefined\n\t\t|| elementMetadata.referenceType === undefined\n\t\t|| elementMetadata.reference === undefined\n\t) {\n\t\treturn children // At least render the text contents\n\t}\n\n\tlet Renderer = elementMetadata.referenceRenderer\n\treturn (\n\t\t<>\n\t\t\t<Renderer\n\t\t\t\treferenceType={elementMetadata.referenceType}\n\t\t\t\treferenceRenderer={elementMetadata.referenceRenderer}\n\t\t\t\treference={elementMetadata.reference}\n\t\t\t\tformatVersion={block.content.formatVersion}\n\t\t\t\tblock={block}\n\t\t\t\toptions={options}\n\t\t\t\telement={element}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</Renderer>\n\t\t</>\n\t)\n}\n"],"names":["createElement","jsx","jsxs","renderChildren","useReferenceMetadata","Fragment"],"mappings":";;;;;;AAoBA,MAAM,2BAA2B,CAIhC,SACA,sBAA8B,iBAG1B;AACJ,QAAM,EAAE,UAAU,aAAa,GAAG,sBAAsB;AAExD,SAAO,OAAO;AAAA,IACb,OAAO,QAAQ,iBAAiB,EAC9B,OAAO,CAAC,CAAA,EAAG,KAAK,MAAM;AACtB,YAAM,IAAI,OAAO;AACjB,aAAO,MAAM,YAAY,MAAM,YAAY,MAAM;AAAA,IAClD,CAAC,EACA,IAAI,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,QAAQ,mBAAmB,GAAG,UAAU,aAAa,IAAI,KAAK,CAAC;AAAA,EAAA;AAEhG;AAEO,SAAS,sBAGd,EAAE,SAAS,UAAU,SAAS,SAAmE;AAClG,QAAM,aAAa,yBAAyB,SAAS,QAAQ,mBAAmB;AAEhF,UAAQ,QAAQ,MAAA;AAAA,IACf,KAAK;AACJ,4CACE,KAAA,EAAG,GAAG,YAAY,MAAM,QAAQ,MAC/B,UACF;AAAA,IAEF,KAAK;AACJ,aAAOA,MAAAA,cAAc,IAAI,QAAQ,KAAK,IAAI,YAAY,QAAQ;AAAA;AAAA,IAC/D,KAAK;AACJ,aAAOC,+BAAC,MAAA,EAAI,GAAG,YAAY;AAAA,IAC5B,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,UAAS;AAAA,IACtC,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,UAAS;AAAA,IACtC,KAAK;AACJ,4CAAQ,KAAA,EAAG,GAAG,YAAa,UAAS;AAAA,IACrC,KAAK,aAAa;AACjB,4CAAQ,0BAAA,EAAyB,SAAkB,UAAoB,SAAkB,OAAc;AAAA,IACxG;AAAA,IACA,KAAK;AACJ,4CACE,QAAA,EAAM,GAAG,YAAY,IAAI,QAAQ,YAChC,UACF;AAAA,IAEF,KAAK,SAAS;AACb,YAAM,WAAW,QAAQ,SAAS,CAAC;AACnC,UAAI,CAAC,YAAY,SAAS,gBAAgB,SAAS;AAClD,8CACE,SAAA,EAAO,GAAG,YACV,UAAAA,2BAAAA,IAAC,SAAA,EAAO,SAAA,CAAS,GAClB;AAAA,MAEF;AACA,aACCC,2BAAAA,KAAC,SAAA,EAAO,GAAG,YACV,UAAA;AAAA,QAAAD,+BAAC,WAAO,UAAAE,eAAAA,eAA6C,CAAC,QAAQ,GAAG,SAAS,KAAK,GAAE;AAAA,QACjFF,2BAAAA,IAAC,SAAA,EAAO,UAAAE,eAAAA,eAA6C,QAAQ,SAAS,MAAM,CAAC,GAAU,SAAS,KAAK,GAAE;AAAA,MAAA,GACxG;AAAA,IAEF;AAAA,IACA,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,UAAS;AAAA,IACtC,KAAK,aAAa;AACjB,UAAI,QAAQ,aAAa;AACxB,8CACE,MAAA,EAAI,GAAG,YAAY,OAAO,QAAQ,aACjC,UACF;AAAA,MAEF;AACA,4CAAQ,MAAA,EAAI,GAAG,YAAa,UAAS;AAAA,IACtC;AAAA,IACA,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,UAAS;AAAA,IACtC,SAAS;AAKD;AACN,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EAAA;AAEF;AASA,SAAS,yBAGP,EAAE,SAAS,UAAU,SAAS,SAAsE;AACrG,QAAM,kBAAkBC,qBAAAA,qBAAmD,SAAS,SAAS,OAAO,IAAI;AAExG,MACC,gBAAgB,sBAAsB,UACnC,gBAAgB,kBAAkB,UAClC,gBAAgB,cAAc,QAChC;AACD,WAAO;AAAA,EACR;AAEA,MAAI,WAAW,gBAAgB;AAC/B,SACCH,+BAAAI,WAAAA,UAAA,EACC,UAAAJ,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACA,eAAe,gBAAgB;AAAA,MAC/B,mBAAmB,gBAAgB;AAAA,MACnC,WAAW,gBAAgB;AAAA,MAC3B,eAAe,MAAM,QAAQ;AAAA,MAC7B;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA,GAEH;AAEF;;"}