@contember/react-richtext-renderer 2.0.0-alpha.2 → 2.0.0-alpha.20
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.
- package/api-extractor.json +3 -0
- package/dist/development/index.cjs +7 -7
- package/dist/development/index.js +7 -7
- package/dist/development/src/RichTextRendererError.cjs.map +1 -0
- package/dist/development/src/RichTextRendererError.js.map +1 -0
- package/dist/development/{components → src/components}/RichText.cjs +4 -4
- package/dist/development/src/components/RichText.cjs.map +1 -0
- package/dist/development/{components → src/components}/RichText.js +2 -2
- package/dist/development/src/components/RichText.js.map +1 -0
- package/dist/development/{components → src/components}/RichTextBlocksRenderer.cjs +2 -2
- package/dist/development/src/components/RichTextBlocksRenderer.cjs.map +1 -0
- package/dist/development/{components → src/components}/RichTextBlocksRenderer.js +2 -2
- package/dist/development/src/components/RichTextBlocksRenderer.js.map +1 -0
- package/dist/development/{components → src/components}/RichTextFieldRenderer.cjs +1 -1
- package/dist/development/src/components/RichTextFieldRenderer.cjs.map +1 -0
- package/dist/development/{components → src/components}/RichTextFieldRenderer.js +1 -1
- package/dist/development/src/components/RichTextFieldRenderer.js.map +1 -0
- package/dist/development/{components → src/components}/RichTextRenderer.cjs +4 -4
- package/dist/development/src/components/RichTextRenderer.cjs.map +1 -0
- package/dist/development/{components → src/components}/RichTextRenderer.js +2 -2
- package/dist/development/src/components/RichTextRenderer.js.map +1 -0
- package/dist/development/{hooks → src/hooks}/useRichTextBlocksSource.cjs +2 -2
- package/dist/development/src/hooks/useRichTextBlocksSource.cjs.map +1 -0
- package/dist/development/src/hooks/useRichTextBlocksSource.js.map +1 -0
- package/dist/{production → development/src}/hooks/useRichTextFieldSource.cjs +2 -2
- package/dist/development/src/hooks/useRichTextFieldSource.cjs.map +1 -0
- package/dist/development/src/hooks/useRichTextFieldSource.js.map +1 -0
- package/dist/development/{internal → src/internal}/components/ElementRenderer.cjs +3 -3
- package/dist/development/src/internal/components/ElementRenderer.cjs.map +1 -0
- package/dist/development/{internal → src/internal}/components/ElementRenderer.js +1 -1
- package/dist/development/src/internal/components/ElementRenderer.js.map +1 -0
- package/dist/development/{internal → src/internal}/components/LeafRenderer.cjs +3 -3
- package/dist/development/src/internal/components/LeafRenderer.cjs.map +1 -0
- package/dist/development/{internal → src/internal}/components/LeafRenderer.js +1 -1
- package/dist/development/src/internal/components/LeafRenderer.js.map +1 -0
- package/dist/development/{internal → src/internal}/components/RenderElementFallback.cjs +20 -20
- package/dist/development/src/internal/components/RenderElementFallback.cjs.map +1 -0
- package/dist/development/{internal → src/internal}/components/RenderElementFallback.js +18 -18
- package/dist/development/src/internal/components/RenderElementFallback.js.map +1 -0
- package/dist/development/{internal → src/internal}/components/RenderLeafFallback.cjs +11 -11
- package/dist/development/src/internal/components/RenderLeafFallback.cjs.map +1 -0
- package/dist/development/{internal → src/internal}/components/RenderLeafFallback.js +9 -9
- package/dist/development/src/internal/components/RenderLeafFallback.js.map +1 -0
- package/dist/development/src/internal/defaultDeserialize.cjs.map +1 -0
- package/dist/development/src/internal/defaultDeserialize.js.map +1 -0
- package/dist/development/{internal → src/internal}/renderChildren.cjs +3 -3
- package/dist/development/src/internal/renderChildren.cjs.map +1 -0
- package/dist/development/{internal → src/internal}/renderChildren.js +3 -3
- package/dist/development/src/internal/renderChildren.js.map +1 -0
- package/dist/development/{internal → src/internal}/useReferenceMetadata.cjs +2 -2
- package/dist/development/src/internal/useReferenceMetadata.cjs.map +1 -0
- package/dist/development/src/internal/useReferenceMetadata.js.map +1 -0
- package/dist/production/index.cjs +7 -7
- package/dist/production/index.js +7 -7
- package/dist/production/src/RichTextRendererError.cjs.map +1 -0
- package/dist/production/src/RichTextRendererError.js.map +1 -0
- package/dist/production/{components → src/components}/RichText.cjs +2 -2
- package/dist/production/src/components/RichText.cjs.map +1 -0
- package/dist/production/src/components/RichText.js.map +1 -0
- package/dist/production/src/components/RichTextBlocksRenderer.cjs.map +1 -0
- package/dist/production/src/components/RichTextBlocksRenderer.js.map +1 -0
- package/dist/production/src/components/RichTextFieldRenderer.cjs.map +1 -0
- package/dist/production/src/components/RichTextFieldRenderer.js.map +1 -0
- package/dist/production/{components → src/components}/RichTextRenderer.cjs +2 -2
- package/dist/production/src/components/RichTextRenderer.cjs.map +1 -0
- package/dist/production/src/components/RichTextRenderer.js.map +1 -0
- package/dist/production/{hooks → src/hooks}/useRichTextBlocksSource.cjs +2 -2
- package/dist/production/src/hooks/useRichTextBlocksSource.cjs.map +1 -0
- package/dist/production/src/hooks/useRichTextBlocksSource.js.map +1 -0
- package/dist/{development → production/src}/hooks/useRichTextFieldSource.cjs +2 -2
- package/dist/production/src/hooks/useRichTextFieldSource.cjs.map +1 -0
- package/dist/production/src/hooks/useRichTextFieldSource.js.map +1 -0
- package/dist/production/{internal → src/internal}/components/ElementRenderer.cjs +2 -2
- package/dist/production/src/internal/components/ElementRenderer.cjs.map +1 -0
- package/dist/production/src/internal/components/ElementRenderer.js.map +1 -0
- package/dist/production/{internal → src/internal}/components/LeafRenderer.cjs +2 -2
- package/dist/production/src/internal/components/LeafRenderer.cjs.map +1 -0
- package/dist/production/src/internal/components/LeafRenderer.js.map +1 -0
- package/dist/production/{internal → src/internal}/components/RenderElementFallback.cjs +2 -2
- package/dist/production/src/internal/components/RenderElementFallback.cjs.map +1 -0
- package/dist/production/src/internal/components/RenderElementFallback.js.map +1 -0
- package/dist/production/{internal → src/internal}/components/RenderLeafFallback.cjs +2 -2
- package/dist/production/src/internal/components/RenderLeafFallback.cjs.map +1 -0
- package/dist/production/src/internal/components/RenderLeafFallback.js.map +1 -0
- package/dist/production/src/internal/defaultDeserialize.cjs.map +1 -0
- package/dist/production/src/internal/defaultDeserialize.js.map +1 -0
- package/dist/production/src/internal/renderChildren.cjs.map +1 -0
- package/dist/production/src/internal/renderChildren.js.map +1 -0
- package/dist/production/{internal → src/internal}/useReferenceMetadata.cjs +2 -2
- package/dist/production/src/internal/useReferenceMetadata.cjs.map +1 -0
- package/dist/production/src/internal/useReferenceMetadata.js.map +1 -0
- package/dist/types/components/RichText.d.ts +1 -1
- package/dist/types/components/RichText.d.ts.map +1 -1
- package/dist/types/components/RichTextBlocksRenderer.d.ts +1 -1
- package/dist/types/components/RichTextBlocksRenderer.d.ts.map +1 -1
- package/dist/types/components/RichTextFieldRenderer.d.ts +1 -1
- package/dist/types/components/RichTextFieldRenderer.d.ts.map +1 -1
- package/dist/types/components/RichTextRenderer.d.ts +1 -1
- package/dist/types/components/RichTextRenderer.d.ts.map +1 -1
- package/dist/types/hooks/useRichTextBlocksSource.d.ts +1 -1
- package/dist/types/hooks/useRichTextBlocksSource.d.ts.map +1 -1
- package/dist/types/hooks/useRichTextFieldSource.d.ts +1 -1
- package/dist/types/hooks/useRichTextFieldSource.d.ts.map +1 -1
- package/dist/types/internal/defaultDeserialize.d.ts +1 -1
- package/dist/types/internal/defaultDeserialize.d.ts.map +1 -1
- package/dist/types/internal/renderChildren.d.ts +1 -1
- package/dist/types/internal/renderChildren.d.ts.map +1 -1
- package/dist/types/internal/useReferenceMetadata.d.ts +1 -1
- package/dist/types/internal/useReferenceMetadata.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/custom/RenderBlock.d.ts.map +1 -1
- package/dist/types/types/custom/RenderElement.d.ts.map +1 -1
- package/package.json +6 -13
- package/src/internal/components/LeafRenderer.tsx +7 -7
- package/src/internal/components/RenderElementFallback.tsx +1 -1
- package/src/tsconfig.json +4 -1
- package/src/types/custom/RenderBlock.ts +1 -1
- package/src/types/custom/RenderElement.ts +1 -1
- package/tests/decodeBlockSource.test.tsx +63 -0
- package/tests/renderElement.test.tsx +207 -0
- package/tests/renderLeaf.test.tsx +112 -0
- package/tests/renderReferences.test.tsx +112 -0
- package/tests/tsconfig.json +10 -0
- package/tsconfig.json +8 -0
- package/tsdoc.json +6 -0
- package/dist/development/RichTextRendererError.cjs.map +0 -1
- package/dist/development/RichTextRendererError.js.map +0 -1
- package/dist/development/components/RichText.cjs.map +0 -1
- package/dist/development/components/RichText.js.map +0 -1
- package/dist/development/components/RichTextBlocksRenderer.cjs.map +0 -1
- package/dist/development/components/RichTextBlocksRenderer.js.map +0 -1
- package/dist/development/components/RichTextFieldRenderer.cjs.map +0 -1
- package/dist/development/components/RichTextFieldRenderer.js.map +0 -1
- package/dist/development/components/RichTextRenderer.cjs.map +0 -1
- package/dist/development/components/RichTextRenderer.js.map +0 -1
- package/dist/development/hooks/useRichTextBlocksSource.cjs.map +0 -1
- package/dist/development/hooks/useRichTextBlocksSource.js.map +0 -1
- package/dist/development/hooks/useRichTextFieldSource.cjs.map +0 -1
- package/dist/development/hooks/useRichTextFieldSource.js.map +0 -1
- package/dist/development/internal/components/ElementRenderer.cjs.map +0 -1
- package/dist/development/internal/components/ElementRenderer.js.map +0 -1
- package/dist/development/internal/components/LeafRenderer.cjs.map +0 -1
- package/dist/development/internal/components/LeafRenderer.js.map +0 -1
- package/dist/development/internal/components/RenderElementFallback.cjs.map +0 -1
- package/dist/development/internal/components/RenderElementFallback.js.map +0 -1
- package/dist/development/internal/components/RenderLeafFallback.cjs.map +0 -1
- package/dist/development/internal/components/RenderLeafFallback.js.map +0 -1
- package/dist/development/internal/defaultDeserialize.cjs.map +0 -1
- package/dist/development/internal/defaultDeserialize.js.map +0 -1
- package/dist/development/internal/renderChildren.cjs.map +0 -1
- package/dist/development/internal/renderChildren.js.map +0 -1
- package/dist/development/internal/useReferenceMetadata.cjs.map +0 -1
- package/dist/development/internal/useReferenceMetadata.js.map +0 -1
- package/dist/production/RichTextRendererError.cjs.map +0 -1
- package/dist/production/RichTextRendererError.js.map +0 -1
- package/dist/production/components/RichText.cjs.map +0 -1
- package/dist/production/components/RichText.js.map +0 -1
- package/dist/production/components/RichTextBlocksRenderer.cjs.map +0 -1
- package/dist/production/components/RichTextBlocksRenderer.js.map +0 -1
- package/dist/production/components/RichTextFieldRenderer.cjs.map +0 -1
- package/dist/production/components/RichTextFieldRenderer.js.map +0 -1
- package/dist/production/components/RichTextRenderer.cjs.map +0 -1
- package/dist/production/components/RichTextRenderer.js.map +0 -1
- package/dist/production/hooks/useRichTextBlocksSource.cjs.map +0 -1
- package/dist/production/hooks/useRichTextBlocksSource.js.map +0 -1
- package/dist/production/hooks/useRichTextFieldSource.cjs.map +0 -1
- package/dist/production/hooks/useRichTextFieldSource.js.map +0 -1
- package/dist/production/internal/components/ElementRenderer.cjs.map +0 -1
- package/dist/production/internal/components/ElementRenderer.js.map +0 -1
- package/dist/production/internal/components/LeafRenderer.cjs.map +0 -1
- package/dist/production/internal/components/LeafRenderer.js.map +0 -1
- package/dist/production/internal/components/RenderElementFallback.cjs.map +0 -1
- package/dist/production/internal/components/RenderElementFallback.js.map +0 -1
- package/dist/production/internal/components/RenderLeafFallback.cjs.map +0 -1
- package/dist/production/internal/components/RenderLeafFallback.js.map +0 -1
- package/dist/production/internal/defaultDeserialize.cjs.map +0 -1
- package/dist/production/internal/defaultDeserialize.js.map +0 -1
- package/dist/production/internal/renderChildren.cjs.map +0 -1
- package/dist/production/internal/renderChildren.js.map +0 -1
- package/dist/production/internal/useReferenceMetadata.cjs.map +0 -1
- package/dist/production/internal/useReferenceMetadata.js.map +0 -1
- /package/dist/development/{RichTextRendererError.cjs → src/RichTextRendererError.cjs} +0 -0
- /package/dist/development/{RichTextRendererError.js → src/RichTextRendererError.js} +0 -0
- /package/dist/development/{hooks → src/hooks}/useRichTextBlocksSource.js +0 -0
- /package/dist/development/{hooks → src/hooks}/useRichTextFieldSource.js +0 -0
- /package/dist/development/{internal → src/internal}/defaultDeserialize.cjs +0 -0
- /package/dist/development/{internal → src/internal}/defaultDeserialize.js +0 -0
- /package/dist/development/{internal → src/internal}/useReferenceMetadata.js +0 -0
- /package/dist/production/{RichTextRendererError.cjs → src/RichTextRendererError.cjs} +0 -0
- /package/dist/production/{RichTextRendererError.js → src/RichTextRendererError.js} +0 -0
- /package/dist/production/{components → src/components}/RichText.js +0 -0
- /package/dist/production/{components → src/components}/RichTextBlocksRenderer.cjs +0 -0
- /package/dist/production/{components → src/components}/RichTextBlocksRenderer.js +0 -0
- /package/dist/production/{components → src/components}/RichTextFieldRenderer.cjs +0 -0
- /package/dist/production/{components → src/components}/RichTextFieldRenderer.js +0 -0
- /package/dist/production/{components → src/components}/RichTextRenderer.js +0 -0
- /package/dist/production/{hooks → src/hooks}/useRichTextBlocksSource.js +0 -0
- /package/dist/production/{hooks → src/hooks}/useRichTextFieldSource.js +0 -0
- /package/dist/production/{internal → src/internal}/components/ElementRenderer.js +0 -0
- /package/dist/production/{internal → src/internal}/components/LeafRenderer.js +0 -0
- /package/dist/production/{internal → src/internal}/components/RenderElementFallback.js +0 -0
- /package/dist/production/{internal → src/internal}/components/RenderLeafFallback.js +0 -0
- /package/dist/production/{internal → src/internal}/defaultDeserialize.cjs +0 -0
- /package/dist/production/{internal → src/internal}/defaultDeserialize.js +0 -0
- /package/dist/production/{internal → src/internal}/renderChildren.cjs +0 -0
- /package/dist/production/{internal → src/internal}/renderChildren.js +0 -0
- /package/dist/production/{internal → src/internal}/useReferenceMetadata.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const RichTextRendererError = require("../RichTextRendererError.cjs");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const emptyReference = {
|
|
6
6
|
reference: void 0,
|
|
7
7
|
referenceType: void 0,
|
|
@@ -10,7 +10,7 @@ const emptyReference = {
|
|
|
10
10
|
const useReferenceMetadata = (element, options, block, expectReference = false) => {
|
|
11
11
|
const undefinedReferenceHandler = options.undefinedReferenceHandler;
|
|
12
12
|
const referenceRenderers = options.referenceRenderers;
|
|
13
|
-
return
|
|
13
|
+
return React.useMemo(() => {
|
|
14
14
|
const id = element["referenceId"];
|
|
15
15
|
if (typeof id !== "string") {
|
|
16
16
|
if (expectReference) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferenceMetadata.cjs","sources":["../../../../../packages/react-richtext-renderer/src/internal/useReferenceMetadata.ts"],"sourcesContent":["import type { BuiltinElements } from '../types/builtin/BuiltinElements'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextReferenceMetadata } from '../types/RichTextReferenceMetadata'\nimport { RichTextReferenceEmptyMetadata } from '../types/RichTextReferenceMetadata'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport type { RichTextReference } from '../types/RichTextReference'\nimport { RichTextRendererError } from '../RichTextRendererError'\nimport { RichTextBlock } from '../types/RichTextBlock'\nimport { RichTextRenderingOptions } from '../types/RichTextRenderingOptions'\nimport { useMemo } from 'react'\n\nconst emptyReference: RichTextReferenceEmptyMetadata = {\n\treference: undefined,\n\treferenceType: undefined,\n\treferenceRenderer: undefined,\n}\nexport const useReferenceMetadata = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n\tReference extends RichTextReference = RichTextReference,\n>(\n\telement: CustomElements | BuiltinElements<CustomElements, CustomLeaves>,\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves, Reference>,\n\tblock: RichTextBlock<CustomElements, CustomLeaves>,\n\texpectReference: boolean = false,\n): RichTextReferenceMetadata<CustomElements, CustomLeaves, Reference> => {\n\tconst undefinedReferenceHandler = options.undefinedReferenceHandler\n\tconst referenceRenderers = options.referenceRenderers\n\n\treturn useMemo(() => {\n\t\tconst id = element['referenceId']\n\n\t\tif (typeof id !== 'string') {\n\t\t\tif (import.meta.env.DEV && expectReference) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Expected element to have a referenceId.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn emptyReference\n\t\t}\n\n\t\tconst reference: Reference | undefined = block.references?.[id] as Reference | undefined\n\n\t\tif (reference === undefined) {\n\t\t\tif (undefinedReferenceHandler) {\n\t\t\t\treturn undefinedReferenceHandler(id) ?? emptyReference\n\t\t\t} else {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Cannot find reference id '${id}'`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tconst referenceRenderer = referenceRenderers?.[reference.type]\n\n\t\treturn {\n\t\t\treference,\n\t\t\treferenceType: reference.type,\n\t\t\treferenceRenderer,\n\t\t}\n\t}, [block.references, element, expectReference, referenceRenderers, undefinedReferenceHandler])\n}\n"],"names":["useMemo","RichTextRendererError"],"mappings":";;;;AAWA,MAAM,iBAAiD;AAAA,EACtD,WAAW;AAAA,EACX,eAAe;AAAA,EACf,mBAAmB;AACpB;AACO,MAAM,uBAAuB,CAKnC,SACA,SACA,OACA,kBAA2B,UAC6C;AACxE,QAAM,4BAA4B,QAAQ;AAC1C,QAAM,qBAAqB,QAAQ;AAEnC,SAAOA,cAAQ,MAAM;AACd,UAAA,KAAK,QAAQ,aAAa;AAE5B,QAAA,OAAO,OAAO,UAAU;AACvB,UAAuB,iBAAiB;AAC3C,cAAM,IAAIC,sBAAA;AAAA,UACT;AAAA,QAAA;AAAA,MAEF;AACO,aAAA;AAAA,IACR;AAEM,UAAA,YAAmC,MAAM,aAAa,EAAE;AAE9D,QAAI,cAAc,QAAW;AAC5B,UAAI,2BAA2B;AACvB,eAAA,0BAA0B,EAAE,KAAK;AAAA,MAAA,OAClC;AACN,cAAM,IAAIA,sBAAA;AAAA,UACT,+CAA+C,EAAE;AAAA,QAAA;AAAA,MAEnD;AAAA,IACD;AAEM,UAAA,oBAAoB,qBAAqB,UAAU,IAAI;AAEtD,WAAA;AAAA,MACN;AAAA,MACA,eAAe,UAAU;AAAA,MACzB;AAAA,IAAA;AAAA,EACD,GACE,CAAC,MAAM,YAAY,SAAS,iBAAiB,oBAAoB,yBAAyB,CAAC;AAC/F;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferenceMetadata.js","sources":["../../../../../packages/react-richtext-renderer/src/internal/useReferenceMetadata.ts"],"sourcesContent":["import type { BuiltinElements } from '../types/builtin/BuiltinElements'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextReferenceMetadata } from '../types/RichTextReferenceMetadata'\nimport { RichTextReferenceEmptyMetadata } from '../types/RichTextReferenceMetadata'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport type { RichTextReference } from '../types/RichTextReference'\nimport { RichTextRendererError } from '../RichTextRendererError'\nimport { RichTextBlock } from '../types/RichTextBlock'\nimport { RichTextRenderingOptions } from '../types/RichTextRenderingOptions'\nimport { useMemo } from 'react'\n\nconst emptyReference: RichTextReferenceEmptyMetadata = {\n\treference: undefined,\n\treferenceType: undefined,\n\treferenceRenderer: undefined,\n}\nexport const useReferenceMetadata = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n\tReference extends RichTextReference = RichTextReference,\n>(\n\telement: CustomElements | BuiltinElements<CustomElements, CustomLeaves>,\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves, Reference>,\n\tblock: RichTextBlock<CustomElements, CustomLeaves>,\n\texpectReference: boolean = false,\n): RichTextReferenceMetadata<CustomElements, CustomLeaves, Reference> => {\n\tconst undefinedReferenceHandler = options.undefinedReferenceHandler\n\tconst referenceRenderers = options.referenceRenderers\n\n\treturn useMemo(() => {\n\t\tconst id = element['referenceId']\n\n\t\tif (typeof id !== 'string') {\n\t\t\tif (import.meta.env.DEV && expectReference) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Expected element to have a referenceId.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn emptyReference\n\t\t}\n\n\t\tconst reference: Reference | undefined = block.references?.[id] as Reference | undefined\n\n\t\tif (reference === undefined) {\n\t\t\tif (undefinedReferenceHandler) {\n\t\t\t\treturn undefinedReferenceHandler(id) ?? emptyReference\n\t\t\t} else {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Cannot find reference id '${id}'`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tconst referenceRenderer = referenceRenderers?.[reference.type]\n\n\t\treturn {\n\t\t\treference,\n\t\t\treferenceType: reference.type,\n\t\t\treferenceRenderer,\n\t\t}\n\t}, [block.references, element, expectReference, referenceRenderers, undefinedReferenceHandler])\n}\n"],"names":[],"mappings":";;AAWA,MAAM,iBAAiD;AAAA,EACtD,WAAW;AAAA,EACX,eAAe;AAAA,EACf,mBAAmB;AACpB;AACO,MAAM,uBAAuB,CAKnC,SACA,SACA,OACA,kBAA2B,UAC6C;AACxE,QAAM,4BAA4B,QAAQ;AAC1C,QAAM,qBAAqB,QAAQ;AAEnC,SAAO,QAAQ,MAAM;AACd,UAAA,KAAK,QAAQ,aAAa;AAE5B,QAAA,OAAO,OAAO,UAAU;AACvB,UAAuB,iBAAiB;AAC3C,cAAM,IAAI;AAAA,UACT;AAAA,QAAA;AAAA,MAEF;AACO,aAAA;AAAA,IACR;AAEM,UAAA,YAAmC,MAAM,aAAa,EAAE;AAE9D,QAAI,cAAc,QAAW;AAC5B,UAAI,2BAA2B;AACvB,eAAA,0BAA0B,EAAE,KAAK;AAAA,MAAA,OAClC;AACN,cAAM,IAAI;AAAA,UACT,+CAA+C,EAAE;AAAA,QAAA;AAAA,MAEnD;AAAA,IACD;AAEM,UAAA,oBAAoB,qBAAqB,UAAU,IAAI;AAEtD,WAAA;AAAA,MACN;AAAA,MACA,eAAe,UAAU;AAAA,MACzB;AAAA,IAAA;AAAA,EACD,GACE,CAAC,MAAM,YAAY,SAAS,iBAAiB,oBAAoB,yBAAyB,CAAC;AAC/F;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const RichTextRendererError = require("./RichTextRendererError.cjs");
|
|
4
|
-
const RichText = require("./components/RichText.cjs");
|
|
5
|
-
const RichTextFieldRenderer = require("./components/RichTextFieldRenderer.cjs");
|
|
6
|
-
const RichTextBlocksRenderer = require("./components/RichTextBlocksRenderer.cjs");
|
|
7
|
-
const RichTextRenderer = require("./components/RichTextRenderer.cjs");
|
|
8
|
-
const useRichTextFieldSource = require("./hooks/useRichTextFieldSource.cjs");
|
|
9
|
-
const useRichTextBlocksSource = require("./hooks/useRichTextBlocksSource.cjs");
|
|
3
|
+
const RichTextRendererError = require("./src/RichTextRendererError.cjs");
|
|
4
|
+
const RichText = require("./src/components/RichText.cjs");
|
|
5
|
+
const RichTextFieldRenderer = require("./src/components/RichTextFieldRenderer.cjs");
|
|
6
|
+
const RichTextBlocksRenderer = require("./src/components/RichTextBlocksRenderer.cjs");
|
|
7
|
+
const RichTextRenderer = require("./src/components/RichTextRenderer.cjs");
|
|
8
|
+
const useRichTextFieldSource = require("./src/hooks/useRichTextFieldSource.cjs");
|
|
9
|
+
const useRichTextBlocksSource = require("./src/hooks/useRichTextBlocksSource.cjs");
|
|
10
10
|
exports.RichTextRendererError = RichTextRendererError.RichTextRendererError;
|
|
11
11
|
exports.RichText = RichText.RichText;
|
|
12
12
|
exports.RichTextFieldRenderer = RichTextFieldRenderer.RichTextFieldRenderer;
|
package/dist/production/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { RichTextRendererError } from "./RichTextRendererError.js";
|
|
2
|
-
import { RichText } from "./components/RichText.js";
|
|
3
|
-
import { RichTextFieldRenderer } from "./components/RichTextFieldRenderer.js";
|
|
4
|
-
import { RichTextBlocksRenderer } from "./components/RichTextBlocksRenderer.js";
|
|
5
|
-
import { RichTextRenderer } from "./components/RichTextRenderer.js";
|
|
6
|
-
import { useRichTextFieldSource } from "./hooks/useRichTextFieldSource.js";
|
|
7
|
-
import { useRichTextBlocksSource } from "./hooks/useRichTextBlocksSource.js";
|
|
1
|
+
import { RichTextRendererError } from "./src/RichTextRendererError.js";
|
|
2
|
+
import { RichText } from "./src/components/RichText.js";
|
|
3
|
+
import { RichTextFieldRenderer } from "./src/components/RichTextFieldRenderer.js";
|
|
4
|
+
import { RichTextBlocksRenderer } from "./src/components/RichTextBlocksRenderer.js";
|
|
5
|
+
import { RichTextRenderer } from "./src/components/RichTextRenderer.js";
|
|
6
|
+
import { useRichTextFieldSource } from "./src/hooks/useRichTextFieldSource.js";
|
|
7
|
+
import { useRichTextBlocksSource } from "./src/hooks/useRichTextBlocksSource.js";
|
|
8
8
|
export {
|
|
9
9
|
RichText,
|
|
10
10
|
RichTextBlocksRenderer,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextRendererError.cjs","sources":["../../../../packages/react-richtext-renderer/src/RichTextRendererError.ts"],"sourcesContent":["export class RichTextRendererError extends Error {}\n"],"names":[],"mappings":";;AAAO,MAAM,8BAA8B,MAAM;AAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextRendererError.js","sources":["../../../../packages/react-richtext-renderer/src/RichTextRendererError.ts"],"sourcesContent":["export class RichTextRendererError extends Error {}\n"],"names":[],"mappings":"AAAO,MAAM,8BAA8B,MAAM;AAAC;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const renderChildren = require("../internal/renderChildren.cjs");
|
|
6
6
|
const RichText = ({
|
|
7
7
|
blocks,
|
|
@@ -12,7 +12,7 @@ const RichText = ({
|
|
|
12
12
|
referenceRenderers,
|
|
13
13
|
undefinedReferenceHandler
|
|
14
14
|
}) => {
|
|
15
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: blocks.map((block, i) =>
|
|
15
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: blocks.map((block, i) => React.createElement(
|
|
16
16
|
renderBlock,
|
|
17
17
|
{
|
|
18
18
|
block,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichText.cjs","sources":["../../../../../packages/react-richtext-renderer/src/components/RichText.tsx"],"sourcesContent":["import { createElement } from 'react'\nimport { renderChildren } from '../internal/renderChildren'\nimport type { RichTextBlock } from '../types'\nimport { RichTextElement, RichTextLeaf, RichTextRenderingOptions } from '../types'\n\nexport type RichTextProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> =\n\t& {\n\t\tblocks: RichTextBlock<CustomElements, CustomLeaves>[]\n\t}\n\t& RichTextRenderingOptions<CustomElements, CustomLeaves>\n\n/**\n * Accepts normalized decoded RichText blocks and renders them using the provided renderers.\n * To use decoders, use `RichTextBlocksRenderer` or `RichTextFieldRenderer` instead.\n *\n * @group Content rendering\n */\nexport const RichText = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\tblocks,\n\trenderElement,\n\trenderLeaf,\n\trenderBlock = ({ children }) => <>{children}</>,\n\tattributeNamePrefix,\n\treferenceRenderers,\n\tundefinedReferenceHandler,\n}: RichTextProps<CustomElements, CustomLeaves>) => {\n\treturn (\n\t\t<>\n\t\t\t{blocks.map((block, i) => (\n\t\t\t\tcreateElement(\n\t\t\t\t\trenderBlock, {\n\t\t\t\t\t\tblock,\n\t\t\t\t\t\tkey: block.id ?? i,\n\t\t\t\t\t}, renderChildren(block.content.children, {\n\t\t\t\t\t\treferenceRenderers,\n\t\t\t\t\t\trenderBlock,\n\t\t\t\t\t\trenderLeaf,\n\t\t\t\t\t\trenderElement,\n\t\t\t\t\t\tattributeNamePrefix,\n\t\t\t\t\t\tundefinedReferenceHandler,\n\t\t\t\t\t}, block),\n\t\t\t\t)\n\t\t\t))}\n\t\t</>\n\t)\n}\n"],"names":["jsx","Fragment","createElement","renderChildren"],"mappings":";;;;;AAoBO,MAAM,WAAW,CAGtB;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC,EAAE,SAAS,4DAAS,UAAS;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AACD,MAAmD;AAClD,SAEGA,2BAAA,IAAAC,WAAA,UAAA,EAAA,UAAA,OAAO,IAAI,CAAC,OAAO,MACnBC,MAAA;AAAA,IACC;AAAA,IAAa;AAAA,MACZ;AAAA,MACA,KAAK,MAAM,MAAM;AAAA,IAClB;AAAA,IAAGC,8BAAe,MAAM,QAAQ,UAAU;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,OACE,KAAK;AAAA,EAET,CAAA,EACF,CAAA;AAEF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichText.js","sources":["../../../../../packages/react-richtext-renderer/src/components/RichText.tsx"],"sourcesContent":["import { createElement } from 'react'\nimport { renderChildren } from '../internal/renderChildren'\nimport type { RichTextBlock } from '../types'\nimport { RichTextElement, RichTextLeaf, RichTextRenderingOptions } from '../types'\n\nexport type RichTextProps<\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n> =\n\t& {\n\t\tblocks: RichTextBlock<CustomElements, CustomLeaves>[]\n\t}\n\t& RichTextRenderingOptions<CustomElements, CustomLeaves>\n\n/**\n * Accepts normalized decoded RichText blocks and renders them using the provided renderers.\n * To use decoders, use `RichTextBlocksRenderer` or `RichTextFieldRenderer` instead.\n *\n * @group Content rendering\n */\nexport const RichText = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\tblocks,\n\trenderElement,\n\trenderLeaf,\n\trenderBlock = ({ children }) => <>{children}</>,\n\tattributeNamePrefix,\n\treferenceRenderers,\n\tundefinedReferenceHandler,\n}: RichTextProps<CustomElements, CustomLeaves>) => {\n\treturn (\n\t\t<>\n\t\t\t{blocks.map((block, i) => (\n\t\t\t\tcreateElement(\n\t\t\t\t\trenderBlock, {\n\t\t\t\t\t\tblock,\n\t\t\t\t\t\tkey: block.id ?? i,\n\t\t\t\t\t}, renderChildren(block.content.children, {\n\t\t\t\t\t\treferenceRenderers,\n\t\t\t\t\t\trenderBlock,\n\t\t\t\t\t\trenderLeaf,\n\t\t\t\t\t\trenderElement,\n\t\t\t\t\t\tattributeNamePrefix,\n\t\t\t\t\t\tundefinedReferenceHandler,\n\t\t\t\t\t}, block),\n\t\t\t\t)\n\t\t\t))}\n\t\t</>\n\t)\n}\n"],"names":[],"mappings":";;;AAoBO,MAAM,WAAW,CAGtB;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc,CAAC,EAAE,SAAS,sCAAS,UAAS;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AACD,MAAmD;AAClD,SAEG,oBAAA,UAAA,EAAA,UAAA,OAAO,IAAI,CAAC,OAAO,MACnB;AAAA,IACC;AAAA,IAAa;AAAA,MACZ;AAAA,MACA,KAAK,MAAM,MAAM;AAAA,IAClB;AAAA,IAAG,eAAe,MAAM,QAAQ,UAAU;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,OACE,KAAK;AAAA,EAET,CAAA,EACF,CAAA;AAEF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextBlocksRenderer.cjs","sources":["../../../../../packages/react-richtext-renderer/src/components/RichTextBlocksRenderer.tsx"],"sourcesContent":["import { RichTextBlockSource, RichTextElement, RichTextLeaf, RichTextRenderingOptions } from '../types'\nimport { RichText } from './RichText'\nimport { useRichTextBlocksSource } from '../hooks'\n\nexport type { RichTextBlockSource }\n\nexport type RichTextBlocksRendererProps<CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf> =\n\t& RichTextBlockSource<CustomElements, CustomLeaves>\n\t& RichTextRenderingOptions<CustomElements, CustomLeaves>\n\n/**\n * Accepts raw RichText blocks and renders them using the provided renderers.\n *\n * @group Content rendering\n */\nexport const RichTextBlocksRenderer = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\trenderElement,\n\trenderLeaf,\n\trenderBlock = ({ children }) => <>{children}</>,\n\tattributeNamePrefix,\n\treferenceRenderers,\n\tundefinedReferenceHandler,\n\t...props\n}: RichTextBlocksRendererProps<CustomElements, CustomLeaves>) => {\n\tconst blocks = useRichTextBlocksSource<CustomElements, CustomLeaves>(props)\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\treferenceRenderers={referenceRenderers}\n\t\t\tundefinedReferenceHandler={undefinedReferenceHandler}\n\t\t\tattributeNamePrefix={attributeNamePrefix}\n\t\t/>\n\t)\n}\n"],"names":["useRichTextBlocksSource","jsx","RichText"],"mappings":";;;;;AAeO,MAAM,yBAAyB,CAGpC;AAAA,EACD;AAAA,EACA;AAAA,EACA,cAAc,CAAC,EAAE,SAAS,4DAAS,UAAS;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAiE;AAC1D,QAAA,SAASA,gDAAsD,KAAK;AAEzE,SAAAC,2BAAA;AAAA,IAACC,SAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAGH;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextBlocksRenderer.js","sources":["../../../../../packages/react-richtext-renderer/src/components/RichTextBlocksRenderer.tsx"],"sourcesContent":["import { RichTextBlockSource, RichTextElement, RichTextLeaf, RichTextRenderingOptions } from '../types'\nimport { RichText } from './RichText'\nimport { useRichTextBlocksSource } from '../hooks'\n\nexport type { RichTextBlockSource }\n\nexport type RichTextBlocksRendererProps<CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf> =\n\t& RichTextBlockSource<CustomElements, CustomLeaves>\n\t& RichTextRenderingOptions<CustomElements, CustomLeaves>\n\n/**\n * Accepts raw RichText blocks and renders them using the provided renderers.\n *\n * @group Content rendering\n */\nexport const RichTextBlocksRenderer = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>({\n\trenderElement,\n\trenderLeaf,\n\trenderBlock = ({ children }) => <>{children}</>,\n\tattributeNamePrefix,\n\treferenceRenderers,\n\tundefinedReferenceHandler,\n\t...props\n}: RichTextBlocksRendererProps<CustomElements, CustomLeaves>) => {\n\tconst blocks = useRichTextBlocksSource<CustomElements, CustomLeaves>(props)\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\treferenceRenderers={referenceRenderers}\n\t\t\tundefinedReferenceHandler={undefinedReferenceHandler}\n\t\t\tattributeNamePrefix={attributeNamePrefix}\n\t\t/>\n\t)\n}\n"],"names":[],"mappings":";;;AAeO,MAAM,yBAAyB,CAGpC;AAAA,EACD;AAAA,EACA;AAAA,EACA,cAAc,CAAC,EAAE,SAAS,sCAAS,UAAS;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAiE;AAC1D,QAAA,SAAS,wBAAsD,KAAK;AAEzE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAGH;"}
|
|
@@ -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;AACzD,QAAA,SAASA,8CAAuB,MAAM;AAG3C,SAAAC,2BAAA;AAAA,IAACC,SAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAGH;;"}
|
|
@@ -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;AACzD,QAAA,SAAS,uBAAuB,MAAM;AAG3C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAGH;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const RichTextFieldRenderer = require("./RichTextFieldRenderer.cjs");
|
|
6
6
|
const RichTextBlocksRenderer = require("./RichTextBlocksRenderer.cjs");
|
|
7
|
-
const RichTextRenderer =
|
|
7
|
+
const RichTextRenderer = React.memo(function RichTextRenderer2(props) {
|
|
8
8
|
if ("source" in props) {
|
|
9
9
|
return /* @__PURE__ */ jsxRuntime.jsx(RichTextFieldRenderer.RichTextFieldRenderer, { ...props });
|
|
10
10
|
}
|
|
@@ -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\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\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":";;;;;;AAkBO,MAAM,mBAAmBA,MAAA,KAAK,SAASC,kBAG5C,OAA4D;AAE7D,MAAI,YAAY,OAAO;AACf,WAAAC,2BAAA,IAACC,sBAAqD,uBAAA,EAAA,GAAG,MAAO,CAAA;AAAA,EACxE;AAEO,SAAAD,2BAAA,IAACE,uBAAsD,wBAAA,EAAA,GAAG,MAAO,CAAA;AACzE,CAAC;;"}
|
|
@@ -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\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\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":";;;;AAkBO,MAAM,mBAAmB,KAAK,SAASA,kBAG5C,OAA4D;AAE7D,MAAI,YAAY,OAAO;AACf,WAAA,oBAAC,uBAAqD,EAAA,GAAG,MAAO,CAAA;AAAA,EACxE;AAEO,SAAA,oBAAC,wBAAsD,EAAA,GAAG,MAAO,CAAA;AACzE,CAAC;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const defaultDeserialize = require("../internal/defaultDeserialize.cjs");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const RichTextRendererError = require("../RichTextRendererError.cjs");
|
|
6
6
|
const useRichTextBlocksSource = ({
|
|
7
7
|
deserialize = defaultDeserialize.defaultDeserialize,
|
|
@@ -10,7 +10,7 @@ const useRichTextBlocksSource = ({
|
|
|
10
10
|
sourceField,
|
|
11
11
|
referenceDiscriminationField
|
|
12
12
|
}) => {
|
|
13
|
-
return
|
|
13
|
+
return React.useMemo(() => {
|
|
14
14
|
const sourceFieldResolved = sourceField ?? "source";
|
|
15
15
|
const referencesFieldResolved = referencesField ?? "references";
|
|
16
16
|
const referenceDiscriminationFieldResolved = referenceDiscriminationField ?? "type";
|
|
@@ -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(sourceField === undefined\n\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: `That is what the 'sourceField' prop has been set to, and so either this is a typo, ` +\n\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`has been encountered. Unless this is just a typo, ` +\n\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 = 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(Array.from(references as Iterable<RichTextReference>).map(reference => {\n\t\t\t\t\tif (!('id' in reference)) {\n\t\t\t\t\t\tthrow new RichTextRendererError(`Found a reference without an id field.`)\n\t\t\t\t\t}\n\t\t\t\t\tif (!(referenceDiscriminationFieldResolved in reference) || typeof reference[referenceDiscriminationFieldResolved] !== 'string') {\n\t\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t\t`Found a reference without a '${referenceDiscriminationFieldResolved}' field. ` +\n\t\t\t\t\t\t\t(referenceDiscriminationField === undefined\n\t\t\t\t\t\t\t\t? `The 'referenceDiscriminationField' prop has not been supplied, ` +\n\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: `That is what the 'referenceDiscriminationField' prop has been set to, ` +\n\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)\n\t\t\t\t\t}\n\t\t\t\t\treturn [reference.id, {\n\t\t\t\t\t\t...reference,\n\t\t\t\t\t\ttype: reference[referenceDiscriminationFieldResolved] as string,\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,mBAAA;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAyD;AACxD,SAAOC,cAAQ,MAAqD;AACnE,UAAM,sBAAsB,eAAe;AAC3C,UAAM,0BAA0B,mBAAmB;AACnD,UAAM,uCAAuC,gCAAgC;AAEtE,WAAA,OAAO,IAAI,CAAS,UAAA;AACtB,UAAA,EAAE,uBAAuB,QAAQ;AACpC,cAAM,IAAIC,sBAAA;AAAA,UACT,4BAA4B,mBAAmB,eAC9C,gBAAgB,SACd,yDAAyD,mBAAmB,6BAC5E;AAAA,QAAA;AAAA,MAGL;AACM,YAAA,SAAS,MAAM,mBAAmB;AACxC,UAAI,OAAO,WAAW,aAAa,OAAO,WAAW,YAAY,WAAW,OAAO;AAC5E,cAAA,IAAIA,4CAAsB,0DAA0D;AAAA,MAC3F;AAEA,UAAI,oBAAoB,UAAa,EAAE,2BAA2B,QAAQ;AACzE,cAAM,IAAIA,sBAAA;AAAA,UACT,yCAAyC,uBAAuB;AAAA,QAAA;AAAA,MAIlE;AACM,YAAA,aAAa,MAAM,uBAAuB;AAEhD,UAAI,uBAAsE;AAC1E,UAAI,YAAY;AACf,YAAI,OAAO,OAAO,UAAU,EAAE,OAAO,QAAQ,MAAM,YAAY;AACxD,gBAAA,IAAIA,4CAAsB,4CAA4C;AAAA,QAC7E;AAEA,+BAAuB,OAAO,YAAY,MAAM,KAAK,UAAyC,EAAE,IAAI,CAAa,cAAA;AAC5G,cAAA,EAAE,QAAQ,YAAY;AACnB,kBAAA,IAAIA,4CAAsB,wCAAwC;AAAA,UACzE;AACA,cAAI,EAAE,wCAAwC,cAAc,OAAO,UAAU,oCAAoC,MAAM,UAAU;AAChI,kBAAM,IAAIA,sBAAA;AAAA,cACT,gCAAgC,oCAAoC,eACnE,iCAAiC,SAC/B,0EACS,oCAAoC,6BAC7C;AAAA,YAAA;AAAA,UAGL;AACO,iBAAA,CAAC,UAAU,IAAI;AAAA,YACrB,GAAG;AAAA,YACH,MAAM,UAAU,oCAAoC;AAAA,UAAA,CACpD;AAAA,QACD,CAAA,CAAC;AAAA,MACH;AACO,aAAA;AAAA,QACN,IAAI,OAAO,MAAM,OAAO,WAAW,MAAM,KAAK;AAAA,QAC9C,SAAS,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI;AAAA,QAC5D,YAAY;AAAA,MAAA;AAAA,IACb,CACA;AAAA,EAAA,GACC,CAAC,QAAQ,aAAa,8BAA8B,iBAAiB,WAAW,CAAC;AACrF;;"}
|
|
@@ -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(sourceField === undefined\n\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: `That is what the 'sourceField' prop has been set to, and so either this is a typo, ` +\n\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`has been encountered. Unless this is just a typo, ` +\n\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 = 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(Array.from(references as Iterable<RichTextReference>).map(reference => {\n\t\t\t\t\tif (!('id' in reference)) {\n\t\t\t\t\t\tthrow new RichTextRendererError(`Found a reference without an id field.`)\n\t\t\t\t\t}\n\t\t\t\t\tif (!(referenceDiscriminationFieldResolved in reference) || typeof reference[referenceDiscriminationFieldResolved] !== 'string') {\n\t\t\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t\t\t`Found a reference without a '${referenceDiscriminationFieldResolved}' field. ` +\n\t\t\t\t\t\t\t(referenceDiscriminationField === undefined\n\t\t\t\t\t\t\t\t? `The 'referenceDiscriminationField' prop has not been supplied, ` +\n\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: `That is what the 'referenceDiscriminationField' prop has been set to, ` +\n\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)\n\t\t\t\t\t}\n\t\t\t\t\treturn [reference.id, {\n\t\t\t\t\t\t...reference,\n\t\t\t\t\t\ttype: reference[referenceDiscriminationFieldResolved] as string,\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;AAEtE,WAAA,OAAO,IAAI,CAAS,UAAA;AACtB,UAAA,EAAE,uBAAuB,QAAQ;AACpC,cAAM,IAAI;AAAA,UACT,4BAA4B,mBAAmB,eAC9C,gBAAgB,SACd,yDAAyD,mBAAmB,6BAC5E;AAAA,QAAA;AAAA,MAGL;AACM,YAAA,SAAS,MAAM,mBAAmB;AACxC,UAAI,OAAO,WAAW,aAAa,OAAO,WAAW,YAAY,WAAW,OAAO;AAC5E,cAAA,IAAI,sBAAsB,0DAA0D;AAAA,MAC3F;AAEA,UAAI,oBAAoB,UAAa,EAAE,2BAA2B,QAAQ;AACzE,cAAM,IAAI;AAAA,UACT,yCAAyC,uBAAuB;AAAA,QAAA;AAAA,MAIlE;AACM,YAAA,aAAa,MAAM,uBAAuB;AAEhD,UAAI,uBAAsE;AAC1E,UAAI,YAAY;AACf,YAAI,OAAO,OAAO,UAAU,EAAE,OAAO,QAAQ,MAAM,YAAY;AACxD,gBAAA,IAAI,sBAAsB,4CAA4C;AAAA,QAC7E;AAEA,+BAAuB,OAAO,YAAY,MAAM,KAAK,UAAyC,EAAE,IAAI,CAAa,cAAA;AAC5G,cAAA,EAAE,QAAQ,YAAY;AACnB,kBAAA,IAAI,sBAAsB,wCAAwC;AAAA,UACzE;AACA,cAAI,EAAE,wCAAwC,cAAc,OAAO,UAAU,oCAAoC,MAAM,UAAU;AAChI,kBAAM,IAAI;AAAA,cACT,gCAAgC,oCAAoC,eACnE,iCAAiC,SAC/B,0EACS,oCAAoC,6BAC7C;AAAA,YAAA;AAAA,UAGL;AACO,iBAAA,CAAC,UAAU,IAAI;AAAA,YACrB,GAAG;AAAA,YACH,MAAM,UAAU,oCAAoC;AAAA,UAAA,CACpD;AAAA,QACD,CAAA,CAAC;AAAA,MACH;AACO,aAAA;AAAA,QACN,IAAI,OAAO,MAAM,OAAO,WAAW,MAAM,KAAK;AAAA,QAC9C,SAAS,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI;AAAA,QAC5D,YAAY;AAAA,MAAA;AAAA,IACb,CACA;AAAA,EAAA,GACC,CAAC,QAAQ,aAAa,8BAA8B,iBAAiB,WAAW,CAAC;AACrF;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const React = require("react");
|
|
4
4
|
const defaultDeserialize = require("../internal/defaultDeserialize.cjs");
|
|
5
5
|
const useRichTextFieldSource = ({
|
|
6
6
|
source,
|
|
7
7
|
deserialize = defaultDeserialize.defaultDeserialize
|
|
8
8
|
}) => {
|
|
9
|
-
return
|
|
9
|
+
return React.useMemo(() => {
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
12
12
|
content: source ? typeof source === "string" ? deserialize(source) : source : {
|
|
@@ -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,mBAAA;AACf,MAAwG;AACvG,SAAOC,cAAQ,MAAM;AACb,WAAA;AAAA,MACN;AAAA,QACC,SAAS,SACL,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI,SACpD;AAAA,UACD,eAAe;AAAA,UACf,UAAU,CAAC;AAAA,QACZ;AAAA,QACD,IAAI;AAAA,QACJ,iBAAiB;AAAA,QACjB,8BAA8B;AAAA,QAC9B,oBAAoB,CAAC;AAAA,QACrB,YAAY;AAAA,MACb;AAAA,IAAA;AAAA,EACD,GACE,CAAC,aAAa,MAAM,CAAC;AACzB;;"}
|
|
@@ -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;AACb,WAAA;AAAA,MACN;AAAA,QACC,SAAS,SACL,OAAO,WAAW,WAAW,YAAY,MAAM,IAAI,SACpD;AAAA,UACD,eAAe;AAAA,UACf,UAAU,CAAC;AAAA,QACZ;AAAA,QACD,IAAI;AAAA,QACJ,iBAAiB;AAAA,QACjB,8BAA8B;AAAA,QAC9B,oBAAoB,CAAC;AAAA,QACrB,YAAY;AAAA,MACb;AAAA,IAAA;AAAA,EACD,GACE,CAAC,aAAa,MAAM,CAAC;AACzB;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const renderChildren = require("../renderChildren.cjs");
|
|
6
6
|
const RenderElementFallback = require("./RenderElementFallback.cjs");
|
|
7
7
|
const useReferenceMetadata = require("../useReferenceMetadata.cjs");
|
|
8
8
|
function ElementRenderer({ element, children, options, block }) {
|
|
9
9
|
const referenceMetadata = useReferenceMetadata.useReferenceMetadata(element, options, block);
|
|
10
10
|
const fallback = /* @__PURE__ */ jsxRuntime.jsx(RenderElementFallback.RenderElementFallback, { element, options, block, children });
|
|
11
|
-
return options.renderElement ?
|
|
11
|
+
return options.renderElement ? React.createElement(options.renderElement, {
|
|
12
12
|
...referenceMetadata,
|
|
13
13
|
formatVersion: block.content.formatVersion,
|
|
14
14
|
block,
|
|
@@ -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\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> element={element as BuiltinElements<CustomElements, CustomLeaves>} options={options} block={block}>\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":";;;;;;;AAsBO,SAAS,gBAGd,EAAE,SAAS,UAAU,SAAS,SAA6D;AAC5F,QAAM,oBAAoBA,qBAAA,qBAAmD,SAAS,SAAS,KAAK;AAEpG,QAAM,WACJC,2BAAA,IAAAC,6CAAA,EAAoD,SAAmE,SAAkB,OACxI,SACF,CAAA;AAGD,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,EACvB,CAAA,IACC;AACJ;;"}
|
|
@@ -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\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> element={element as BuiltinElements<CustomElements, CustomLeaves>} options={options} block={block}>\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":";;;;;AAsBO,SAAS,gBAGd,EAAE,SAAS,UAAU,SAAS,SAA6D;AAC5F,QAAM,oBAAoB,qBAAmD,SAAS,SAAS,KAAK;AAEpG,QAAM,WACJ,oBAAA,uBAAA,EAAoD,SAAmE,SAAkB,OACxI,SACF,CAAA;AAGD,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,EACvB,CAAA,IACC;AACJ;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const RenderLeafFallback = require("./RenderLeafFallback.cjs");
|
|
6
6
|
function LeafRenderer({
|
|
7
7
|
leaf,
|
|
@@ -9,7 +9,7 @@ function LeafRenderer({
|
|
|
9
9
|
block: { content: { formatVersion } }
|
|
10
10
|
}) {
|
|
11
11
|
const fallback = /* @__PURE__ */ jsxRuntime.jsx(RenderLeafFallback.RenderLeafFallback, { leaf });
|
|
12
|
-
return renderLeaf ?
|
|
12
|
+
return renderLeaf ? React.createElement(
|
|
13
13
|
renderLeaf,
|
|
14
14
|
{
|
|
15
15
|
formatVersion,
|
|
@@ -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,WAAW;AAAA,EACtB,OAAO,EAAE,SAAS,EAAE,gBAAgB;AACrC,GAAoD;AAC7C,QAAA,WAAYA,2BAAA,IAAAC,mBAAA,oBAAA,EAAmB,KAAY,CAAA;AAEjD,SAAO,aACJC,MAAA;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,KAAK;AAAA,IAChB;AAAA,EAEC,IAAA;AACJ;;"}
|
|
@@ -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,WAAW;AAAA,EACtB,OAAO,EAAE,SAAS,EAAE,gBAAgB;AACrC,GAAoD;AAC7C,QAAA,WAAY,oBAAA,oBAAA,EAAmB,KAAY,CAAA;AAEjD,SAAO,aACJ;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,KAAK;AAAA,IAChB;AAAA,EAEC,IAAA;AACJ;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const renderChildren = require("../renderChildren.cjs");
|
|
6
6
|
const useReferenceMetadata = require("../useReferenceMetadata.cjs");
|
|
7
7
|
const getElementDataAttributes = (element, attributeNamePrefix = "contember-") => {
|
|
@@ -19,7 +19,7 @@ function RenderElementFallback({ element, children, options, block }) {
|
|
|
19
19
|
case "anchor":
|
|
20
20
|
return /* @__PURE__ */ jsxRuntime.jsx("a", { ...attributes, href: element.href, children });
|
|
21
21
|
case "heading":
|
|
22
|
-
return
|
|
22
|
+
return React.createElement(`h${element.level}`, attributes, children);
|
|
23
23
|
case "horizontalRule":
|
|
24
24
|
return /* @__PURE__ */ jsxRuntime.jsx("hr", { ...attributes });
|
|
25
25
|
case "listItem":
|
|
@@ -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\telementMetadata.referenceType === undefined ||\n\t\telementMetadata.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,CAAG,EAAA,KAAK,MAAM;AACtB,YAAM,IAAI,OAAO;AACjB,aAAO,MAAM,YAAY,MAAM,YAAY,MAAM;AAAA,IACjD,CAAA,EACA,IAAI,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,QAAQ,mBAAmB,GAAG,UAAU,YAAa,CAAA,IAAI,KAAK,CAAC;AAAA,EAAA;AAEhG;AAEO,SAAS,sBAGd,EAAE,SAAS,UAAU,SAAS,SAAmE;AAClG,QAAM,aAAa,yBAAyB,SAAS,QAAQ,mBAAmB;AAEhF,UAAQ,QAAQ,MAAM;AAAA,IACrB,KAAK;4CAEF,KAAG,EAAA,GAAG,YAAY,MAAM,QAAQ,MAC/B,SAAA,CACF;AAAA,IAEF,KAAK;AACJ,aAAOA,oBAAc,IAAI,QAAQ,KAAK,IAAI,YAAY,QAAQ;AAAA,IAC/D,KAAK;AACG,aAACC,2BAAA,IAAA,MAAI,EAAA,GAAG,WAAY,CAAA;AAAA,IAC5B,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,KAAK;AACJ,4CAAQ,KAAA,EAAG,GAAG,YAAa,SAAS,CAAA;AAAA,IACrC,KAAK,aAAa;AACjB,4CAAQ,0BAAA,EAAyB,SAAkB,UAAoB,SAAkB,OAAc;AAAA,IACxG;AAAA,IACA,KAAK;4CAEF,QAAM,EAAA,GAAG,YAAY,IAAI,QAAQ,YAChC,SAAA,CACF;AAAA,IAEF,KAAK,SAAS;AACP,YAAA,WAAW,QAAQ,SAAS,CAAC;AACnC,UAAI,CAAC,YAAY,SAAS,gBAAgB,SAAS;AAClD,eACEA,+BAAA,SAAO,EAAA,GAAG,YACV,UAACA,2BAAA,IAAA,SAAA,EAAO,SAAS,CAAA,EAClB,CAAA;AAAA,MAEF;AAEC,aAACC,2BAAA,KAAA,SAAO,EAAA,GAAG,YACV,UAAA;AAAA,QAAAD,+BAAC,WAAO,UAA6CE,eAAA,eAAA,CAAC,QAAQ,GAAG,SAAS,KAAK,GAAE;AAAA,QAChFF,2BAAAA,IAAA,SAAO,EAAA,UAAAE,eAA6C,eAAA,QAAQ,SAAS,MAAM,CAAC,GAAU,SAAS,KAAK,GAAE;AAAA,SACxG;AAAA,IAEF;AAAA,IACA,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,KAAK,aAAa;AACjB,UAAI,QAAQ,aAAa;8CAEtB,MAAI,EAAA,GAAG,YAAY,OAAO,QAAQ,aACjC,SAAA,CACF;AAAA,MAEF;AACA,4CAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC;AAAA,IACA,KAAK;AACJ,4CAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,SAAS;AAKD;AACC,eAAA;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACD;AASA,SAAS,yBAGP,EAAE,SAAS,UAAU,SAAS,SAAsE;AACrG,QAAM,kBAAkBC,qBAAAA,qBAAmD,SAAS,SAAS,OAAO,IAAI;AAGvG,MAAA,gBAAgB,sBAAsB,UACtC,gBAAgB,kBAAkB,UAClC,gBAAgB,cAAc,QAC7B;AACM,WAAA;AAAA,EACR;AAEA,MAAI,WAAW,gBAAgB;AAG7B,SAAAH,+BAAAI,WAAAA,UAAA,EAAA,UAAAJ,2BAAA;AAAA,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,KAEH;AAEF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderElementFallback.js","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\telementMetadata.referenceType === undefined ||\n\t\telementMetadata.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":[],"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,CAAG,EAAA,KAAK,MAAM;AACtB,YAAM,IAAI,OAAO;AACjB,aAAO,MAAM,YAAY,MAAM,YAAY,MAAM;AAAA,IACjD,CAAA,EACA,IAAI,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,QAAQ,mBAAmB,GAAG,UAAU,YAAa,CAAA,IAAI,KAAK,CAAC;AAAA,EAAA;AAEhG;AAEO,SAAS,sBAGd,EAAE,SAAS,UAAU,SAAS,SAAmE;AAClG,QAAM,aAAa,yBAAyB,SAAS,QAAQ,mBAAmB;AAEhF,UAAQ,QAAQ,MAAM;AAAA,IACrB,KAAK;iCAEF,KAAG,EAAA,GAAG,YAAY,MAAM,QAAQ,MAC/B,SAAA,CACF;AAAA,IAEF,KAAK;AACJ,aAAO,cAAc,IAAI,QAAQ,KAAK,IAAI,YAAY,QAAQ;AAAA,IAC/D,KAAK;AACG,aAAC,oBAAA,MAAI,EAAA,GAAG,WAAY,CAAA;AAAA,IAC5B,KAAK;AACJ,iCAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,KAAK;AACJ,iCAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,KAAK;AACJ,iCAAQ,KAAA,EAAG,GAAG,YAAa,SAAS,CAAA;AAAA,IACrC,KAAK,aAAa;AACjB,iCAAQ,0BAAA,EAAyB,SAAkB,UAAoB,SAAkB,OAAc;AAAA,IACxG;AAAA,IACA,KAAK;iCAEF,QAAM,EAAA,GAAG,YAAY,IAAI,QAAQ,YAChC,SAAA,CACF;AAAA,IAEF,KAAK,SAAS;AACP,YAAA,WAAW,QAAQ,SAAS,CAAC;AACnC,UAAI,CAAC,YAAY,SAAS,gBAAgB,SAAS;AAClD,eACE,oBAAA,SAAO,EAAA,GAAG,YACV,UAAC,oBAAA,SAAA,EAAO,SAAS,CAAA,EAClB,CAAA;AAAA,MAEF;AAEC,aAAC,qBAAA,SAAO,EAAA,GAAG,YACV,UAAA;AAAA,QAAA,oBAAC,WAAO,UAA6C,eAAA,CAAC,QAAQ,GAAG,SAAS,KAAK,GAAE;AAAA,QAChF,oBAAA,SAAO,EAAA,UAAA,eAA6C,QAAQ,SAAS,MAAM,CAAC,GAAU,SAAS,KAAK,GAAE;AAAA,SACxG;AAAA,IAEF;AAAA,IACA,KAAK;AACJ,iCAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,KAAK,aAAa;AACjB,UAAI,QAAQ,aAAa;mCAEtB,MAAI,EAAA,GAAG,YAAY,OAAO,QAAQ,aACjC,SAAA,CACF;AAAA,MAEF;AACA,iCAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC;AAAA,IACA,KAAK;AACJ,iCAAQ,MAAA,EAAI,GAAG,YAAa,SAAS,CAAA;AAAA,IACtC,SAAS;AAKD;AACC,eAAA;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACD;AASA,SAAS,yBAGP,EAAE,SAAS,UAAU,SAAS,SAAsE;AACrG,QAAM,kBAAkB,qBAAmD,SAAS,SAAS,OAAO,IAAI;AAGvG,MAAA,gBAAgB,sBAAsB,UACtC,gBAAgB,kBAAkB,UAClC,gBAAgB,cAAc,QAC7B;AACM,WAAA;AAAA,EACR;AAEA,MAAI,WAAW,gBAAgB;AAG7B,SAAA,oBAAA,UAAA,EAAA,UAAA;AAAA,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,KAEH;AAEF;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
function jsxN2br(text) {
|
|
6
6
|
const lines = text.split("\n");
|
|
7
7
|
if (lines.length <= 1) {
|
|
8
8
|
return text;
|
|
9
9
|
}
|
|
10
|
-
return lines.map((line, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10
|
+
return lines.map((line, i) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
11
11
|
!!i && /* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
12
12
|
line
|
|
13
13
|
] }, i));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderLeafFallback.cjs","sources":["../../../../../../packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx"],"sourcesContent":["import { Fragment, ReactNode } from 'react'\nimport type { BuiltinLeaves } from '../../types/builtin/BuiltinLeaves'\n\nexport interface RenderLeafFallbackProps {\n\tleaf: BuiltinLeaves\n}\n\nfunction jsxN2br(text: string): ReactNode {\n\tconst lines = text.split('\\n')\n\tif (lines.length <= 1) {\n\t\treturn text\n\t}\n\treturn lines.map((line, i) => (\n\t\t<Fragment key={i}>\n\t\t\t{!!i && <br />}\n\t\t\t{line}\n\t\t</Fragment>\n\t))\n}\n\nexport function RenderLeafFallback({ leaf }: RenderLeafFallbackProps) {\n\tlet element = jsxN2br(leaf.text)\n\n\tif ('isCode' in leaf && leaf.isCode === true) {\n\t\telement = <code>{element}</code>\n\t}\n\tif ('isStruckThrough' in leaf && leaf.isStruckThrough === true) {\n\t\telement = <s>{element}</s>\n\t}\n\tif ('isHighlighted' in leaf && leaf.isHighlighted === true) {\n\t\telement = <em>{element}</em>\n\t}\n\tif ('isUnderlined' in leaf && leaf.isUnderlined === true) {\n\t\telement = <u>{element}</u>\n\t}\n\tif ('isItalic' in leaf && leaf.isItalic === true) {\n\t\telement = <i>{element}</i>\n\t}\n\tif ('isBold' in leaf && leaf.isBold === true) {\n\t\telement = <b>{element}</b>\n\t}\n\treturn <>{element}</>\n}\n"],"names":["jsxs","Fragment","jsx"],"mappings":";;;;AAOA,SAAS,QAAQ,MAAyB;AACnC,QAAA,QAAQ,KAAK,MAAM,IAAI;AACzB,MAAA,MAAM,UAAU,GAAG;AACf,WAAA;AAAA,EACR;AACA,SAAO,MAAM,IAAI,CAAC,MAAM,MACvBA,gCAACC,MAAAA,UAAA,EACC,UAAA;AAAA,IAAC,CAAA,CAAC,KAAKC,+BAAC,MAAG,CAAA,CAAA;AAAA,IACX;AAAA,EAAA,EAAA,GAFa,CAGf,CACA;AACF;AAEgB,SAAA,mBAAmB,EAAE,QAAiC;AACjE,MAAA,UAAU,QAAQ,KAAK,IAAI;AAE/B,MAAI,YAAY,QAAQ,KAAK,WAAW,MAAM;AACnC,cAAAA,2BAAA,IAAC,UAAM,UAAQ,QAAA,CAAA;AAAA,EAC1B;AACA,MAAI,qBAAqB,QAAQ,KAAK,oBAAoB,MAAM;AACrD,cAAAA,2BAAA,IAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,MAAI,mBAAmB,QAAQ,KAAK,kBAAkB,MAAM;AACjD,cAAAA,2BAAA,IAAC,QAAI,UAAQ,QAAA,CAAA;AAAA,EACxB;AACA,MAAI,kBAAkB,QAAQ,KAAK,iBAAiB,MAAM;AAC/C,cAAAA,2BAAA,IAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,MAAI,cAAc,QAAQ,KAAK,aAAa,MAAM;AACvC,cAAAA,2BAAA,IAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,MAAI,YAAY,QAAQ,KAAK,WAAW,MAAM;AACnC,cAAAA,2BAAA,IAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,+DAAU,UAAQ,QAAA,CAAA;AACnB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderLeafFallback.js","sources":["../../../../../../packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx"],"sourcesContent":["import { Fragment, ReactNode } from 'react'\nimport type { BuiltinLeaves } from '../../types/builtin/BuiltinLeaves'\n\nexport interface RenderLeafFallbackProps {\n\tleaf: BuiltinLeaves\n}\n\nfunction jsxN2br(text: string): ReactNode {\n\tconst lines = text.split('\\n')\n\tif (lines.length <= 1) {\n\t\treturn text\n\t}\n\treturn lines.map((line, i) => (\n\t\t<Fragment key={i}>\n\t\t\t{!!i && <br />}\n\t\t\t{line}\n\t\t</Fragment>\n\t))\n}\n\nexport function RenderLeafFallback({ leaf }: RenderLeafFallbackProps) {\n\tlet element = jsxN2br(leaf.text)\n\n\tif ('isCode' in leaf && leaf.isCode === true) {\n\t\telement = <code>{element}</code>\n\t}\n\tif ('isStruckThrough' in leaf && leaf.isStruckThrough === true) {\n\t\telement = <s>{element}</s>\n\t}\n\tif ('isHighlighted' in leaf && leaf.isHighlighted === true) {\n\t\telement = <em>{element}</em>\n\t}\n\tif ('isUnderlined' in leaf && leaf.isUnderlined === true) {\n\t\telement = <u>{element}</u>\n\t}\n\tif ('isItalic' in leaf && leaf.isItalic === true) {\n\t\telement = <i>{element}</i>\n\t}\n\tif ('isBold' in leaf && leaf.isBold === true) {\n\t\telement = <b>{element}</b>\n\t}\n\treturn <>{element}</>\n}\n"],"names":["Fragment"],"mappings":";;AAOA,SAAS,QAAQ,MAAyB;AACnC,QAAA,QAAQ,KAAK,MAAM,IAAI;AACzB,MAAA,MAAM,UAAU,GAAG;AACf,WAAA;AAAA,EACR;AACA,SAAO,MAAM,IAAI,CAAC,MAAM,MACvB,qBAACA,YAAA,EACC,UAAA;AAAA,IAAC,CAAA,CAAC,KAAK,oBAAC,MAAG,CAAA,CAAA;AAAA,IACX;AAAA,EAAA,EAAA,GAFa,CAGf,CACA;AACF;AAEgB,SAAA,mBAAmB,EAAE,QAAiC;AACjE,MAAA,UAAU,QAAQ,KAAK,IAAI;AAE/B,MAAI,YAAY,QAAQ,KAAK,WAAW,MAAM;AACnC,cAAA,oBAAC,UAAM,UAAQ,QAAA,CAAA;AAAA,EAC1B;AACA,MAAI,qBAAqB,QAAQ,KAAK,oBAAoB,MAAM;AACrD,cAAA,oBAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,MAAI,mBAAmB,QAAQ,KAAK,kBAAkB,MAAM;AACjD,cAAA,oBAAC,QAAI,UAAQ,QAAA,CAAA;AAAA,EACxB;AACA,MAAI,kBAAkB,QAAQ,KAAK,iBAAiB,MAAM;AAC/C,cAAA,oBAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,MAAI,cAAc,QAAQ,KAAK,aAAa,MAAM;AACvC,cAAA,oBAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,MAAI,YAAY,QAAQ,KAAK,WAAW,MAAM;AACnC,cAAA,oBAAC,OAAG,UAAQ,QAAA,CAAA;AAAA,EACvB;AACA,yCAAU,UAAQ,QAAA,CAAA;AACnB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultDeserialize.cjs","sources":["../../../../../packages/react-richtext-renderer/src/internal/defaultDeserialize.ts"],"sourcesContent":["import type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport type { RootEditorNode } from '../types/structure/RootEditorNode'\n\nexport const defaultDeserialize = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>(\n\tsource: string,\n): RootEditorNode<CustomElements, CustomLeaves> => {\n\ttry {\n\t\treturn JSON.parse(source)\n\t} catch (e) {\n\t\treturn {\n\t\t\tformatVersion: 0,\n\t\t\tchildren: [],\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAIa,MAAA,qBAAqB,CAIjC,WACkD;AAC9C,MAAA;AACI,WAAA,KAAK,MAAM,MAAM;AAAA,WAChB,GAAG;AACJ,WAAA;AAAA,MACN,eAAe;AAAA,MACf,UAAU,CAAC;AAAA,IAAA;AAAA,EAEb;AACD;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultDeserialize.js","sources":["../../../../../packages/react-richtext-renderer/src/internal/defaultDeserialize.ts"],"sourcesContent":["import type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport type { RootEditorNode } from '../types/structure/RootEditorNode'\n\nexport const defaultDeserialize = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>(\n\tsource: string,\n): RootEditorNode<CustomElements, CustomLeaves> => {\n\ttry {\n\t\treturn JSON.parse(source)\n\t} catch (e) {\n\t\treturn {\n\t\t\tformatVersion: 0,\n\t\t\tchildren: [],\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAIa,MAAA,qBAAqB,CAIjC,WACkD;AAC9C,MAAA;AACI,WAAA,KAAK,MAAM,MAAM;AAAA,WAChB,GAAG;AACJ,WAAA;AAAA,MACN,eAAe;AAAA,MACf,UAAU,CAAC;AAAA,IAAA;AAAA,EAEb;AACD;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderChildren.cjs","sources":["../../../../../packages/react-richtext-renderer/src/internal/renderChildren.tsx"],"sourcesContent":["import type { ReactElement } from 'react'\nimport { ElementRenderer } from './components/ElementRenderer'\nimport { LeafRenderer } from './components/LeafRenderer'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport { RichTextRenderingOptions } from '../types/RichTextRenderingOptions'\nimport { RichTextBlock } from '../types/RichTextBlock'\nimport { RichTextChild } from '../types/structure/RichTextChild'\n\nexport const renderChildren = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>(\n\tchildren:\n\t\t| RichTextChild<CustomElements, CustomLeaves>\n\t\t| readonly RichTextChild<CustomElements, CustomLeaves>[],\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>,\n\tblock: RichTextBlock<CustomElements, CustomLeaves>,\n): ReactElement => {\n\treturn (\n\t\t<>\n\t\t\t{(Array.isArray(children) ? children : [children]).map((child, i) => {\n\t\t\t\tif ('text' in child) {\n\t\t\t\t\treturn <LeafRenderer<CustomElements, CustomLeaves> key={i} leaf={child} options={options} block={block} />\n\t\t\t\t}\n\t\t\t\tif ('children' in child) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ElementRenderer<CustomElements, CustomLeaves> key={i} element={child} options={options} block={block}>\n\t\t\t\t\t\t\t{renderChildren<CustomElements, CustomLeaves>(child.children as typeof children, options, block)}\n\t\t\t\t\t\t</ElementRenderer>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn null // Throw?\n\t\t\t})}\n\t\t</>\n\t)\n}\n"],"names":["jsx","Fragment","LeafRenderer","ElementRenderer"],"mappings":";;;;;AASO,MAAM,iBAAiB,CAI7B,UAGA,SACA,UACkB;AAClB,SAEIA,2BAAAA,IAAAC,WAAAA,UAAA,EAAA,WAAA,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,MAAM;AACpE,QAAI,UAAU,OAAO;AACpB,4CAAQC,aAAmD,cAAA,EAAA,MAAM,OAAO,SAAkB,SAAlC,CAAgD;AAAA,IACzG;AACA,QAAI,cAAc,OAAO;AACxB,aACEF,2BAAAA,IAAAG,gBAAAA,iBAAA,EAAsD,SAAS,OAAO,SAAkB,OACvF,UAA6C,eAAA,MAAM,UAA6B,SAAS,KAAK,EAAA,GAD5C,CAEpD;AAAA,IAEF;AACO,WAAA;AAAA,EACP,CAAA,EACF,CAAA;AAEF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderChildren.js","sources":["../../../../../packages/react-richtext-renderer/src/internal/renderChildren.tsx"],"sourcesContent":["import type { ReactElement } from 'react'\nimport { ElementRenderer } from './components/ElementRenderer'\nimport { LeafRenderer } from './components/LeafRenderer'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport { RichTextRenderingOptions } from '../types/RichTextRenderingOptions'\nimport { RichTextBlock } from '../types/RichTextBlock'\nimport { RichTextChild } from '../types/structure/RichTextChild'\n\nexport const renderChildren = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n>(\n\tchildren:\n\t\t| RichTextChild<CustomElements, CustomLeaves>\n\t\t| readonly RichTextChild<CustomElements, CustomLeaves>[],\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves>,\n\tblock: RichTextBlock<CustomElements, CustomLeaves>,\n): ReactElement => {\n\treturn (\n\t\t<>\n\t\t\t{(Array.isArray(children) ? children : [children]).map((child, i) => {\n\t\t\t\tif ('text' in child) {\n\t\t\t\t\treturn <LeafRenderer<CustomElements, CustomLeaves> key={i} leaf={child} options={options} block={block} />\n\t\t\t\t}\n\t\t\t\tif ('children' in child) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ElementRenderer<CustomElements, CustomLeaves> key={i} element={child} options={options} block={block}>\n\t\t\t\t\t\t\t{renderChildren<CustomElements, CustomLeaves>(child.children as typeof children, options, block)}\n\t\t\t\t\t\t</ElementRenderer>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn null // Throw?\n\t\t\t})}\n\t\t</>\n\t)\n}\n"],"names":[],"mappings":";;;AASO,MAAM,iBAAiB,CAI7B,UAGA,SACA,UACkB;AAClB,SAEI,oBAAA,UAAA,EAAA,WAAA,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,MAAM;AACpE,QAAI,UAAU,OAAO;AACpB,iCAAQ,cAAmD,EAAA,MAAM,OAAO,SAAkB,SAAlC,CAAgD;AAAA,IACzG;AACA,QAAI,cAAc,OAAO;AACxB,aACE,oBAAA,iBAAA,EAAsD,SAAS,OAAO,SAAkB,OACvF,UAA6C,eAAA,MAAM,UAA6B,SAAS,KAAK,EAAA,GAD5C,CAEpD;AAAA,IAEF;AACO,WAAA;AAAA,EACP,CAAA,EACF,CAAA;AAEF;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const RichTextRendererError = require("../RichTextRendererError.cjs");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const emptyReference = {
|
|
6
6
|
reference: void 0,
|
|
7
7
|
referenceType: void 0,
|
|
@@ -10,7 +10,7 @@ const emptyReference = {
|
|
|
10
10
|
const useReferenceMetadata = (element, options, block, expectReference = false) => {
|
|
11
11
|
const undefinedReferenceHandler = options.undefinedReferenceHandler;
|
|
12
12
|
const referenceRenderers = options.referenceRenderers;
|
|
13
|
-
return
|
|
13
|
+
return React.useMemo(() => {
|
|
14
14
|
const id = element["referenceId"];
|
|
15
15
|
if (typeof id !== "string") {
|
|
16
16
|
return emptyReference;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferenceMetadata.cjs","sources":["../../../../../packages/react-richtext-renderer/src/internal/useReferenceMetadata.ts"],"sourcesContent":["import type { BuiltinElements } from '../types/builtin/BuiltinElements'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextReferenceMetadata } from '../types/RichTextReferenceMetadata'\nimport { RichTextReferenceEmptyMetadata } from '../types/RichTextReferenceMetadata'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport type { RichTextReference } from '../types/RichTextReference'\nimport { RichTextRendererError } from '../RichTextRendererError'\nimport { RichTextBlock } from '../types/RichTextBlock'\nimport { RichTextRenderingOptions } from '../types/RichTextRenderingOptions'\nimport { useMemo } from 'react'\n\nconst emptyReference: RichTextReferenceEmptyMetadata = {\n\treference: undefined,\n\treferenceType: undefined,\n\treferenceRenderer: undefined,\n}\nexport const useReferenceMetadata = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n\tReference extends RichTextReference = RichTextReference,\n>(\n\telement: CustomElements | BuiltinElements<CustomElements, CustomLeaves>,\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves, Reference>,\n\tblock: RichTextBlock<CustomElements, CustomLeaves>,\n\texpectReference: boolean = false,\n): RichTextReferenceMetadata<CustomElements, CustomLeaves, Reference> => {\n\tconst undefinedReferenceHandler = options.undefinedReferenceHandler\n\tconst referenceRenderers = options.referenceRenderers\n\n\treturn useMemo(() => {\n\t\tconst id = element['referenceId']\n\n\t\tif (typeof id !== 'string') {\n\t\t\tif (import.meta.env.DEV && expectReference) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Expected element to have a referenceId.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn emptyReference\n\t\t}\n\n\t\tconst reference: Reference | undefined = block.references?.[id] as Reference | undefined\n\n\t\tif (reference === undefined) {\n\t\t\tif (undefinedReferenceHandler) {\n\t\t\t\treturn undefinedReferenceHandler(id) ?? emptyReference\n\t\t\t} else {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Cannot find reference id '${id}'`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tconst referenceRenderer = referenceRenderers?.[reference.type]\n\n\t\treturn {\n\t\t\treference,\n\t\t\treferenceType: reference.type,\n\t\t\treferenceRenderer,\n\t\t}\n\t}, [block.references, element, expectReference, referenceRenderers, undefinedReferenceHandler])\n}\n"],"names":["useMemo","RichTextRendererError"],"mappings":";;;;AAWA,MAAM,iBAAiD;AAAA,EACtD,WAAW;AAAA,EACX,eAAe;AAAA,EACf,mBAAmB;AACpB;AACO,MAAM,uBAAuB,CAKnC,SACA,SACA,OACA,kBAA2B,UAC6C;AACxE,QAAM,4BAA4B,QAAQ;AAC1C,QAAM,qBAAqB,QAAQ;AAEnC,SAAOA,cAAQ,MAAM;AACd,UAAA,KAAK,QAAQ,aAAa;AAE5B,QAAA,OAAO,OAAO,UAAU;AAMpB,aAAA;AAAA,IACR;AAEM,UAAA,YAAmC,MAAM,aAAa,EAAE;AAE9D,QAAI,cAAc,QAAW;AAC5B,UAAI,2BAA2B;AACvB,eAAA,0BAA0B,EAAE,KAAK;AAAA,MAAA,OAClC;AACN,cAAM,IAAIC,sBAAA;AAAA,UACT,+CAA+C,EAAE;AAAA,QAAA;AAAA,MAEnD;AAAA,IACD;AAEM,UAAA,oBAAoB,qBAAqB,UAAU,IAAI;AAEtD,WAAA;AAAA,MACN;AAAA,MACA,eAAe,UAAU;AAAA,MACzB;AAAA,IAAA;AAAA,EACD,GACE,CAAC,MAAM,YAAY,SAAS,iBAAiB,oBAAoB,yBAAyB,CAAC;AAC/F;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferenceMetadata.js","sources":["../../../../../packages/react-richtext-renderer/src/internal/useReferenceMetadata.ts"],"sourcesContent":["import type { BuiltinElements } from '../types/builtin/BuiltinElements'\nimport type { RichTextElement } from '../types/structure/RichTextElement'\nimport type { RichTextReferenceMetadata } from '../types/RichTextReferenceMetadata'\nimport { RichTextReferenceEmptyMetadata } from '../types/RichTextReferenceMetadata'\nimport type { RichTextLeaf } from '../types/structure/RichTextLeaf'\nimport type { RichTextReference } from '../types/RichTextReference'\nimport { RichTextRendererError } from '../RichTextRendererError'\nimport { RichTextBlock } from '../types/RichTextBlock'\nimport { RichTextRenderingOptions } from '../types/RichTextRenderingOptions'\nimport { useMemo } from 'react'\n\nconst emptyReference: RichTextReferenceEmptyMetadata = {\n\treference: undefined,\n\treferenceType: undefined,\n\treferenceRenderer: undefined,\n}\nexport const useReferenceMetadata = <\n\tCustomElements extends RichTextElement = never,\n\tCustomLeaves extends RichTextLeaf = RichTextLeaf,\n\tReference extends RichTextReference = RichTextReference,\n>(\n\telement: CustomElements | BuiltinElements<CustomElements, CustomLeaves>,\n\toptions: RichTextRenderingOptions<CustomElements, CustomLeaves, Reference>,\n\tblock: RichTextBlock<CustomElements, CustomLeaves>,\n\texpectReference: boolean = false,\n): RichTextReferenceMetadata<CustomElements, CustomLeaves, Reference> => {\n\tconst undefinedReferenceHandler = options.undefinedReferenceHandler\n\tconst referenceRenderers = options.referenceRenderers\n\n\treturn useMemo(() => {\n\t\tconst id = element['referenceId']\n\n\t\tif (typeof id !== 'string') {\n\t\t\tif (import.meta.env.DEV && expectReference) {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Expected element to have a referenceId.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn emptyReference\n\t\t}\n\n\t\tconst reference: Reference | undefined = block.references?.[id] as Reference | undefined\n\n\t\tif (reference === undefined) {\n\t\t\tif (undefinedReferenceHandler) {\n\t\t\t\treturn undefinedReferenceHandler(id) ?? emptyReference\n\t\t\t} else {\n\t\t\t\tthrow new RichTextRendererError(\n\t\t\t\t\t`RichTextRenderer: Cannot find reference id '${id}'`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tconst referenceRenderer = referenceRenderers?.[reference.type]\n\n\t\treturn {\n\t\t\treference,\n\t\t\treferenceType: reference.type,\n\t\t\treferenceRenderer,\n\t\t}\n\t}, [block.references, element, expectReference, referenceRenderers, undefinedReferenceHandler])\n}\n"],"names":[],"mappings":";;AAWA,MAAM,iBAAiD;AAAA,EACtD,WAAW;AAAA,EACX,eAAe;AAAA,EACf,mBAAmB;AACpB;AACO,MAAM,uBAAuB,CAKnC,SACA,SACA,OACA,kBAA2B,UAC6C;AACxE,QAAM,4BAA4B,QAAQ;AAC1C,QAAM,qBAAqB,QAAQ;AAEnC,SAAO,QAAQ,MAAM;AACd,UAAA,KAAK,QAAQ,aAAa;AAE5B,QAAA,OAAO,OAAO,UAAU;AAMpB,aAAA;AAAA,IACR;AAEM,UAAA,YAAmC,MAAM,aAAa,EAAE;AAE9D,QAAI,cAAc,QAAW;AAC5B,UAAI,2BAA2B;AACvB,eAAA,0BAA0B,EAAE,KAAK;AAAA,MAAA,OAClC;AACN,cAAM,IAAI;AAAA,UACT,+CAA+C,EAAE;AAAA,QAAA;AAAA,MAEnD;AAAA,IACD;AAEM,UAAA,oBAAoB,qBAAqB,UAAU,IAAI;AAEtD,WAAA;AAAA,MACN;AAAA,MACA,eAAe,UAAU;AAAA,MACzB;AAAA,IAAA;AAAA,EACD,GACE,CAAC,MAAM,YAAY,SAAS,iBAAiB,oBAAoB,yBAAyB,CAAC;AAC/F;"}
|
|
@@ -9,5 +9,5 @@ export type RichTextProps<CustomElements extends RichTextElement = never, Custom
|
|
|
9
9
|
*
|
|
10
10
|
* @group Content rendering
|
|
11
11
|
*/
|
|
12
|
-
export declare const RichText: <CustomElements extends RichTextElement
|
|
12
|
+
export declare const RichText: <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf>({ blocks, renderElement, renderLeaf, renderBlock, attributeNamePrefix, referenceRenderers, undefinedReferenceHandler, }: RichTextProps<CustomElements, CustomLeaves>) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
//# sourceMappingURL=RichText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../../src/components/RichText.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAElF,MAAM,MAAM,aAAa,CACxB,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,YAAY,IAE9C;IACD,MAAM,EAAE,aAAa,CAAC,cAAc,EAAE,YAAY,CAAC,EAAE,CAAA;CACrD,GACC,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../../src/components/RichText.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAElF,MAAM,MAAM,aAAa,CACxB,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,YAAY,IAE9C;IACD,MAAM,EAAE,aAAa,CAAC,cAAc,EAAE,YAAY,CAAC,EAAE,CAAA;CACrD,GACC,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACpB,cAAc,SAAS,eAAe,UACtC,YAAY,SAAS,YAAY,0IAS/B,aAAa,CAAC,cAAc,EAAE,YAAY,CAAC,4CAoB7C,CAAA"}
|
|
@@ -6,5 +6,5 @@ export type RichTextBlocksRendererProps<CustomElements extends RichTextElement =
|
|
|
6
6
|
*
|
|
7
7
|
* @group Content rendering
|
|
8
8
|
*/
|
|
9
|
-
export declare const RichTextBlocksRenderer: <CustomElements extends RichTextElement
|
|
9
|
+
export declare const RichTextBlocksRenderer: <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf>({ renderElement, renderLeaf, renderBlock, attributeNamePrefix, referenceRenderers, undefinedReferenceHandler, ...props }: RichTextBlocksRendererProps<CustomElements, CustomLeaves>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
//# sourceMappingURL=RichTextBlocksRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextBlocksRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextBlocksRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAIvG,YAAY,EAAE,mBAAmB,EAAE,CAAA;AAEnC,MAAM,MAAM,2BAA2B,CAAC,cAAc,SAAS,eAAe,GAAG,KAAK,EAAE,YAAY,SAAS,YAAY,GAAG,YAAY,IACrI,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,GACjD,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"RichTextBlocksRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextBlocksRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAIvG,YAAY,EAAE,mBAAmB,EAAE,CAAA;AAEnC,MAAM,MAAM,2BAA2B,CAAC,cAAc,SAAS,eAAe,GAAG,KAAK,EAAE,YAAY,SAAS,YAAY,GAAG,YAAY,IACrI,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,GACjD,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAClC,cAAc,SAAS,eAAe,UACtC,YAAY,SAAS,YAAY,2IAS/B,2BAA2B,CAAC,cAAc,EAAE,YAAY,CAAC,4CAa3D,CAAA"}
|
|
@@ -6,5 +6,5 @@ export type RichTextFieldRendererProps<CustomElements extends RichTextElement =
|
|
|
6
6
|
*
|
|
7
7
|
* @group Content rendering
|
|
8
8
|
*/
|
|
9
|
-
export declare const RichTextFieldRenderer: <CustomElements extends RichTextElement
|
|
9
|
+
export declare const RichTextFieldRenderer: <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf>({ renderLeaf, renderBlock, renderElement, attributeNamePrefix, undefinedReferenceHandler, ...source }: RichTextFieldRendererProps<CustomElements, CustomLeaves>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
//# sourceMappingURL=RichTextFieldRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextFieldRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextFieldRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAGvG,YAAY,EAAE,mBAAmB,EAAE,CAAA;AAEnC,MAAM,MAAM,0BAA0B,CACrC,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,YAAY,IAE9C,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,GACjD,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"RichTextFieldRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextFieldRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAGvG,YAAY,EAAE,mBAAmB,EAAE,CAAA;AAEnC,MAAM,MAAM,0BAA0B,CACrC,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,YAAY,IAE9C,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,GACjD,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GACjC,cAAc,SAAS,eAAe,UACtC,YAAY,SAAS,YAAY,wHAQ/B,0BAA0B,CAAC,cAAc,EAAE,YAAY,CAAC,4CAa1D,CAAA"}
|
|
@@ -8,5 +8,5 @@ export type RichTextRendererProps<CustomElements extends RichTextElement = never
|
|
|
8
8
|
* @deprecated Use `RichTextBlocksRenderer` or `RichTextFieldRenderer` instead, or directly use `RichText`.
|
|
9
9
|
* @group Content rendering
|
|
10
10
|
*/
|
|
11
|
-
export declare const RichTextRenderer: <CustomElements extends RichTextElement
|
|
11
|
+
export declare const RichTextRenderer: <CustomElements extends RichTextElement = never, CustomLeaves extends RichTextLeaf = RichTextLeaf>(props: RichTextRendererProps<CustomElements, CustomLeaves>) => ReactElement;
|
|
12
12
|
//# sourceMappingURL=RichTextRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAyB,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AAC3F,OAAO,EAA0B,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAG9F,MAAM,MAAM,qBAAqB,CAChC,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,YAAY,IAE9C,0BAA0B,CAAC,cAAc,EAAE,YAAY,CAAC,GACxD,2BAA2B,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAE5D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"RichTextRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/RichTextRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAyB,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AAC3F,OAAO,EAA0B,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAG9F,MAAM,MAAM,qBAAqB,CAChC,cAAc,SAAS,eAAe,GAAG,KAAK,EAC9C,YAAY,SAAS,YAAY,GAAG,YAAY,IAE9C,0BAA0B,CAAC,cAAc,EAAE,YAAY,CAAC,GACxD,2BAA2B,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAE5D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAUvB,CAAC,cAA8C,SAAvB,eAAe,GAAG,KAAK,EAAE,YAAgD,SAA3B,YAAY,GAAG,YAAY,EACtG,KAAK,EAAE,qBAAqB,CAAC,cAAc,EAAE,YAAY,CAAC,KACtD,YAAY,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RichTextBlock, RichTextBlockSource, RichTextElement, RichTextLeaf } from '../types';
|
|
2
|
-
export declare const useRichTextBlocksSource: <CustomElements extends RichTextElement
|
|
2
|
+
export declare const useRichTextBlocksSource: <CustomElements extends RichTextElement, CustomLeaves extends RichTextLeaf>({ deserialize, blocks, referencesField, sourceField, referenceDiscriminationField, }: RichTextBlockSource<CustomElements, CustomLeaves>) => RichTextBlock<CustomElements, CustomLeaves>[];
|
|
3
3
|
//# sourceMappingURL=useRichTextBlocksSource.d.ts.map
|