@contember/react-richtext-renderer 1.3.0-alpha.9 → 2.0.0-alpha.2
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/dist/development/components/RichText.cjs +12 -4
- package/dist/development/components/RichText.cjs.map +1 -1
- package/dist/development/components/RichText.js +12 -4
- package/dist/development/components/RichText.js.map +1 -1
- package/dist/development/components/RichTextBlocksRenderer.cjs +16 -4
- package/dist/development/components/RichTextBlocksRenderer.cjs.map +1 -1
- package/dist/development/components/RichTextBlocksRenderer.js +16 -4
- package/dist/development/components/RichTextBlocksRenderer.js.map +1 -1
- package/dist/development/components/RichTextFieldRenderer.cjs +11 -3
- package/dist/development/components/RichTextFieldRenderer.cjs.map +1 -1
- package/dist/development/components/RichTextFieldRenderer.js +11 -3
- package/dist/development/components/RichTextFieldRenderer.js.map +1 -1
- package/dist/development/components/RichTextRenderer.cjs +11 -3
- package/dist/development/components/RichTextRenderer.cjs.map +1 -1
- package/dist/development/components/RichTextRenderer.js +11 -3
- package/dist/development/components/RichTextRenderer.js.map +1 -1
- package/dist/development/hooks/useRichTextBlocksSource.cjs +4 -4
- package/dist/development/hooks/useRichTextBlocksSource.cjs.map +1 -1
- package/dist/development/hooks/useRichTextBlocksSource.js +4 -4
- package/dist/development/hooks/useRichTextBlocksSource.js.map +1 -1
- package/dist/development/internal/components/ElementRenderer.cjs +6 -2
- package/dist/development/internal/components/ElementRenderer.cjs.map +1 -1
- package/dist/development/internal/components/ElementRenderer.js +6 -2
- package/dist/development/internal/components/ElementRenderer.js.map +1 -1
- package/dist/development/internal/components/LeafRenderer.cjs +6 -2
- package/dist/development/internal/components/LeafRenderer.cjs.map +1 -1
- package/dist/development/internal/components/LeafRenderer.js +6 -2
- package/dist/development/internal/components/LeafRenderer.js.map +1 -1
- package/dist/development/internal/components/RenderElementFallback.cjs +100 -21
- package/dist/development/internal/components/RenderElementFallback.cjs.map +1 -1
- package/dist/development/internal/components/RenderElementFallback.js +100 -21
- package/dist/development/internal/components/RenderElementFallback.js.map +1 -1
- package/dist/development/internal/components/RenderLeafFallback.cjs +47 -11
- package/dist/development/internal/components/RenderLeafFallback.cjs.map +1 -1
- package/dist/development/internal/components/RenderLeafFallback.js +47 -11
- package/dist/development/internal/components/RenderLeafFallback.js.map +1 -1
- package/dist/development/internal/renderChildren.cjs +17 -5
- package/dist/development/internal/renderChildren.cjs.map +1 -1
- package/dist/development/internal/renderChildren.js +17 -5
- package/dist/development/internal/renderChildren.js.map +1 -1
- package/dist/development/internal/useReferenceMetadata.cjs +5 -0
- package/dist/development/internal/useReferenceMetadata.cjs.map +1 -1
- package/dist/development/internal/useReferenceMetadata.js +5 -0
- package/dist/development/internal/useReferenceMetadata.js.map +1 -1
- package/dist/production/hooks/useRichTextBlocksSource.cjs +4 -4
- package/dist/production/hooks/useRichTextBlocksSource.cjs.map +1 -1
- package/dist/production/hooks/useRichTextBlocksSource.js +4 -4
- package/dist/production/hooks/useRichTextBlocksSource.js.map +1 -1
- package/dist/types/components/RichText.d.ts.map +1 -1
- package/dist/types/components/RichTextBlocksRenderer.d.ts.map +1 -1
- package/dist/types/components/RichTextFieldRenderer.d.ts.map +1 -1
- package/dist/types/components/RichTextRenderer.d.ts.map +1 -1
- package/dist/types/hooks/useRichTextBlocksSource.d.ts.map +1 -1
- package/dist/types/hooks/useRichTextFieldSource.d.ts.map +1 -1
- package/dist/types/internal/defaultDeserialize.d.ts.map +1 -1
- package/dist/types/internal/renderChildren.d.ts.map +1 -1
- package/dist/types/internal/useReferenceMetadata.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/hooks/useRichTextBlocksSource.ts +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { createElement } from "react";
|
|
3
3
|
import { RenderLeafFallback } from "./RenderLeafFallback.js";
|
|
4
4
|
function LeafRenderer({
|
|
@@ -6,7 +6,11 @@ function LeafRenderer({
|
|
|
6
6
|
options: { renderLeaf },
|
|
7
7
|
block: { content: { formatVersion } }
|
|
8
8
|
}) {
|
|
9
|
-
const fallback = /* @__PURE__ */
|
|
9
|
+
const fallback = /* @__PURE__ */ jsxDEV(RenderLeafFallback, { leaf }, void 0, false, {
|
|
10
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/LeafRenderer.tsx",
|
|
11
|
+
lineNumber: 23,
|
|
12
|
+
columnNumber: 19
|
|
13
|
+
}, this);
|
|
10
14
|
return renderLeaf ? createElement(
|
|
11
15
|
renderLeaf,
|
|
12
16
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeafRenderer.js","sources":["../../../../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\t\trenderLeaf,\n\t\t\t\t{\n\t\t\t\t\tformatVersion,\n\t\t\t\t\tleaf,\n\t\t\t\t\tfallback,\n\t\t\t\t\tchildren: leaf.text,\n\t\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,
|
|
1
|
+
{"version":3,"file":"LeafRenderer.js","sources":["../../../../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\t\trenderLeaf,\n\t\t\t\t{\n\t\t\t\t\tformatVersion,\n\t\t\t\t\tleaf,\n\t\t\t\t\tfallback,\n\t\t\t\t\tchildren: leaf.text,\n\t\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,uBAAA,oBAAA,EAAmB,QAApB,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAgC,GAAA,IAAA;AAEjD,SAAO,aACJ;AAAA,IACA;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU,KAAK;AAAA,IAChB;AAAA,EAEA,IAAA;AACJ;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const renderChildren = require("../renderChildren.cjs");
|
|
6
6
|
const useReferenceMetadata = require("../useReferenceMetadata.cjs");
|
|
7
|
+
const RichTextRendererError = require("../../RichTextRendererError.cjs");
|
|
7
8
|
const getElementDataAttributes = (element, attributeNamePrefix = "contember-") => {
|
|
8
9
|
const { children, referenceId, ...extendedSpecifics } = element;
|
|
9
10
|
return Object.fromEntries(
|
|
@@ -17,45 +18,111 @@ function RenderElementFallback({ element, children, options, block }) {
|
|
|
17
18
|
const attributes = getElementDataAttributes(element, options.attributeNamePrefix);
|
|
18
19
|
switch (element.type) {
|
|
19
20
|
case "anchor":
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("a", { ...attributes, href: element.href, children }, void 0, false, {
|
|
22
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
23
|
+
lineNumber: 51,
|
|
24
|
+
columnNumber: 5
|
|
25
|
+
}, this);
|
|
21
26
|
case "heading":
|
|
22
27
|
return react.createElement(`h${element.level}`, attributes, children);
|
|
23
28
|
case "horizontalRule":
|
|
24
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("hr", { ...attributes }, void 0, false, {
|
|
30
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
31
|
+
lineNumber: 58,
|
|
32
|
+
columnNumber: 11
|
|
33
|
+
}, this);
|
|
25
34
|
case "listItem":
|
|
26
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("li", { ...attributes, children }, void 0, false, {
|
|
36
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
37
|
+
lineNumber: 60,
|
|
38
|
+
columnNumber: 11
|
|
39
|
+
}, this);
|
|
27
40
|
case "orderedList":
|
|
28
|
-
return /* @__PURE__ */
|
|
41
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("ol", { ...attributes, children }, void 0, false, {
|
|
42
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
43
|
+
lineNumber: 62,
|
|
44
|
+
columnNumber: 11
|
|
45
|
+
}, this);
|
|
29
46
|
case "paragraph":
|
|
30
|
-
return /* @__PURE__ */
|
|
47
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("p", { ...attributes, children }, void 0, false, {
|
|
48
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
49
|
+
lineNumber: 64,
|
|
50
|
+
columnNumber: 11
|
|
51
|
+
}, this);
|
|
31
52
|
case "reference": {
|
|
32
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(ReferenceElementFallback, { element, children, options, block }, void 0, false, {
|
|
54
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
55
|
+
lineNumber: 66,
|
|
56
|
+
columnNumber: 11
|
|
57
|
+
}, this);
|
|
33
58
|
}
|
|
34
59
|
case "scrollTarget":
|
|
35
|
-
return /* @__PURE__ */
|
|
60
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("span", { ...attributes, id: element.identifier, children }, void 0, false, {
|
|
61
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
62
|
+
lineNumber: 70,
|
|
63
|
+
columnNumber: 5
|
|
64
|
+
}, this);
|
|
36
65
|
case "table": {
|
|
37
66
|
const firstRow = element.children[0];
|
|
38
67
|
if (!firstRow || firstRow.headerScope !== "table") {
|
|
39
|
-
return /* @__PURE__ */
|
|
68
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("table", { ...attributes, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV("tbody", { children }, void 0, false, {
|
|
69
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
70
|
+
lineNumber: 79,
|
|
71
|
+
columnNumber: 7
|
|
72
|
+
}, this) }, void 0, false, {
|
|
73
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
74
|
+
lineNumber: 78,
|
|
75
|
+
columnNumber: 6
|
|
76
|
+
}, this);
|
|
40
77
|
}
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
|
|
78
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("table", { ...attributes, children: [
|
|
79
|
+
/* @__PURE__ */ jsxDevRuntime.jsxDEV("thead", { children: renderChildren.renderChildren([firstRow], options, block) }, void 0, false, {
|
|
80
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
81
|
+
lineNumber: 85,
|
|
82
|
+
columnNumber: 6
|
|
83
|
+
}, this),
|
|
84
|
+
/* @__PURE__ */ jsxDevRuntime.jsxDEV("tbody", { children: renderChildren.renderChildren(element.children.slice(1), options, block) }, void 0, false, {
|
|
85
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
86
|
+
lineNumber: 86,
|
|
87
|
+
columnNumber: 6
|
|
88
|
+
}, this)
|
|
89
|
+
] }, void 0, true, {
|
|
90
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
91
|
+
lineNumber: 84,
|
|
92
|
+
columnNumber: 5
|
|
93
|
+
}, this);
|
|
45
94
|
}
|
|
46
95
|
case "tableRow":
|
|
47
|
-
return /* @__PURE__ */
|
|
96
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("tr", { ...attributes, children }, void 0, false, {
|
|
97
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
98
|
+
lineNumber: 91,
|
|
99
|
+
columnNumber: 11
|
|
100
|
+
}, this);
|
|
48
101
|
case "tableCell": {
|
|
49
102
|
if (element.headerScope) {
|
|
50
|
-
return /* @__PURE__ */
|
|
103
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("th", { ...attributes, scope: element.headerScope, children }, void 0, false, {
|
|
104
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
105
|
+
lineNumber: 95,
|
|
106
|
+
columnNumber: 6
|
|
107
|
+
}, this);
|
|
51
108
|
}
|
|
52
|
-
return /* @__PURE__ */
|
|
109
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("td", { ...attributes, children }, void 0, false, {
|
|
110
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
111
|
+
lineNumber: 100,
|
|
112
|
+
columnNumber: 11
|
|
113
|
+
}, this);
|
|
53
114
|
}
|
|
54
115
|
case "unorderedList":
|
|
55
|
-
return /* @__PURE__ */
|
|
116
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV("ul", { ...attributes, children }, void 0, false, {
|
|
117
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
118
|
+
lineNumber: 103,
|
|
119
|
+
columnNumber: 11
|
|
120
|
+
}, this);
|
|
56
121
|
default: {
|
|
57
122
|
{
|
|
58
|
-
|
|
123
|
+
throw new RichTextRendererError.RichTextRendererError(
|
|
124
|
+
`RichTextRenderer: unknown element of type '${element.type}'.`
|
|
125
|
+
);
|
|
59
126
|
}
|
|
60
127
|
}
|
|
61
128
|
}
|
|
@@ -66,7 +133,7 @@ function ReferenceElementFallback({ element, children, options, block }) {
|
|
|
66
133
|
return children;
|
|
67
134
|
}
|
|
68
135
|
let Renderer = elementMetadata.referenceRenderer;
|
|
69
|
-
return /* @__PURE__ */
|
|
136
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
70
137
|
Renderer,
|
|
71
138
|
{
|
|
72
139
|
referenceType: elementMetadata.referenceType,
|
|
@@ -77,8 +144,20 @@ function ReferenceElementFallback({ element, children, options, block }) {
|
|
|
77
144
|
options,
|
|
78
145
|
element,
|
|
79
146
|
children
|
|
80
|
-
}
|
|
81
|
-
|
|
147
|
+
},
|
|
148
|
+
void 0,
|
|
149
|
+
false,
|
|
150
|
+
{
|
|
151
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
152
|
+
lineNumber: 140,
|
|
153
|
+
columnNumber: 4
|
|
154
|
+
},
|
|
155
|
+
this
|
|
156
|
+
) }, void 0, false, {
|
|
157
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
158
|
+
lineNumber: 139,
|
|
159
|
+
columnNumber: 3
|
|
160
|
+
}, this);
|
|
82
161
|
}
|
|
83
162
|
exports.RenderElementFallback = RenderElementFallback;
|
|
84
163
|
//# sourceMappingURL=RenderElementFallback.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderElementFallback.cjs","sources":["../../../../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","
|
|
1
|
+
{"version":3,"file":"RenderElementFallback.cjs","sources":["../../../../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","jsxDEV","renderChildren","RichTextRendererError","useReferenceMetadata","Fragment"],"mappings":";;;;;;;AAoBA,MAAM,2BAA2B,CAIhC,SACA,sBAA8B,iBAG1B;AACJ,QAAM,EAAE,UAAU,aAAa,GAAG,sBAAsB;AAExD,SAA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;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,IATF;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAA;AAAA,EAAA,KADD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,KAYA,IAAA;AAEF;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { createElement } from "react";
|
|
3
3
|
import { renderChildren } from "../renderChildren.js";
|
|
4
4
|
import { useReferenceMetadata } from "../useReferenceMetadata.js";
|
|
5
|
+
import { RichTextRendererError } from "../../RichTextRendererError.js";
|
|
5
6
|
const getElementDataAttributes = (element, attributeNamePrefix = "contember-") => {
|
|
6
7
|
const { children, referenceId, ...extendedSpecifics } = element;
|
|
7
8
|
return Object.fromEntries(
|
|
@@ -15,45 +16,111 @@ function RenderElementFallback({ element, children, options, block }) {
|
|
|
15
16
|
const attributes = getElementDataAttributes(element, options.attributeNamePrefix);
|
|
16
17
|
switch (element.type) {
|
|
17
18
|
case "anchor":
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ jsxDEV("a", { ...attributes, href: element.href, children }, void 0, false, {
|
|
20
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
21
|
+
lineNumber: 51,
|
|
22
|
+
columnNumber: 5
|
|
23
|
+
}, this);
|
|
19
24
|
case "heading":
|
|
20
25
|
return createElement(`h${element.level}`, attributes, children);
|
|
21
26
|
case "horizontalRule":
|
|
22
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ jsxDEV("hr", { ...attributes }, void 0, false, {
|
|
28
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
29
|
+
lineNumber: 58,
|
|
30
|
+
columnNumber: 11
|
|
31
|
+
}, this);
|
|
23
32
|
case "listItem":
|
|
24
|
-
return /* @__PURE__ */
|
|
33
|
+
return /* @__PURE__ */ jsxDEV("li", { ...attributes, children }, void 0, false, {
|
|
34
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
35
|
+
lineNumber: 60,
|
|
36
|
+
columnNumber: 11
|
|
37
|
+
}, this);
|
|
25
38
|
case "orderedList":
|
|
26
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ jsxDEV("ol", { ...attributes, children }, void 0, false, {
|
|
40
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
41
|
+
lineNumber: 62,
|
|
42
|
+
columnNumber: 11
|
|
43
|
+
}, this);
|
|
27
44
|
case "paragraph":
|
|
28
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ jsxDEV("p", { ...attributes, children }, void 0, false, {
|
|
46
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
47
|
+
lineNumber: 64,
|
|
48
|
+
columnNumber: 11
|
|
49
|
+
}, this);
|
|
29
50
|
case "reference": {
|
|
30
|
-
return /* @__PURE__ */
|
|
51
|
+
return /* @__PURE__ */ jsxDEV(ReferenceElementFallback, { element, children, options, block }, void 0, false, {
|
|
52
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
53
|
+
lineNumber: 66,
|
|
54
|
+
columnNumber: 11
|
|
55
|
+
}, this);
|
|
31
56
|
}
|
|
32
57
|
case "scrollTarget":
|
|
33
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ jsxDEV("span", { ...attributes, id: element.identifier, children }, void 0, false, {
|
|
59
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
60
|
+
lineNumber: 70,
|
|
61
|
+
columnNumber: 5
|
|
62
|
+
}, this);
|
|
34
63
|
case "table": {
|
|
35
64
|
const firstRow = element.children[0];
|
|
36
65
|
if (!firstRow || firstRow.headerScope !== "table") {
|
|
37
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ jsxDEV("table", { ...attributes, children: /* @__PURE__ */ jsxDEV("tbody", { children }, void 0, false, {
|
|
67
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
68
|
+
lineNumber: 79,
|
|
69
|
+
columnNumber: 7
|
|
70
|
+
}, this) }, void 0, false, {
|
|
71
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
72
|
+
lineNumber: 78,
|
|
73
|
+
columnNumber: 6
|
|
74
|
+
}, this);
|
|
38
75
|
}
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
|
|
42
|
-
|
|
76
|
+
return /* @__PURE__ */ jsxDEV("table", { ...attributes, children: [
|
|
77
|
+
/* @__PURE__ */ jsxDEV("thead", { children: renderChildren([firstRow], options, block) }, void 0, false, {
|
|
78
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
79
|
+
lineNumber: 85,
|
|
80
|
+
columnNumber: 6
|
|
81
|
+
}, this),
|
|
82
|
+
/* @__PURE__ */ jsxDEV("tbody", { children: renderChildren(element.children.slice(1), options, block) }, void 0, false, {
|
|
83
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
84
|
+
lineNumber: 86,
|
|
85
|
+
columnNumber: 6
|
|
86
|
+
}, this)
|
|
87
|
+
] }, void 0, true, {
|
|
88
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
89
|
+
lineNumber: 84,
|
|
90
|
+
columnNumber: 5
|
|
91
|
+
}, this);
|
|
43
92
|
}
|
|
44
93
|
case "tableRow":
|
|
45
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ jsxDEV("tr", { ...attributes, children }, void 0, false, {
|
|
95
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
96
|
+
lineNumber: 91,
|
|
97
|
+
columnNumber: 11
|
|
98
|
+
}, this);
|
|
46
99
|
case "tableCell": {
|
|
47
100
|
if (element.headerScope) {
|
|
48
|
-
return /* @__PURE__ */
|
|
101
|
+
return /* @__PURE__ */ jsxDEV("th", { ...attributes, scope: element.headerScope, children }, void 0, false, {
|
|
102
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
103
|
+
lineNumber: 95,
|
|
104
|
+
columnNumber: 6
|
|
105
|
+
}, this);
|
|
49
106
|
}
|
|
50
|
-
return /* @__PURE__ */
|
|
107
|
+
return /* @__PURE__ */ jsxDEV("td", { ...attributes, children }, void 0, false, {
|
|
108
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
109
|
+
lineNumber: 100,
|
|
110
|
+
columnNumber: 11
|
|
111
|
+
}, this);
|
|
51
112
|
}
|
|
52
113
|
case "unorderedList":
|
|
53
|
-
return /* @__PURE__ */
|
|
114
|
+
return /* @__PURE__ */ jsxDEV("ul", { ...attributes, children }, void 0, false, {
|
|
115
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
116
|
+
lineNumber: 103,
|
|
117
|
+
columnNumber: 11
|
|
118
|
+
}, this);
|
|
54
119
|
default: {
|
|
55
120
|
{
|
|
56
|
-
|
|
121
|
+
throw new RichTextRendererError(
|
|
122
|
+
`RichTextRenderer: unknown element of type '${element.type}'.`
|
|
123
|
+
);
|
|
57
124
|
}
|
|
58
125
|
}
|
|
59
126
|
}
|
|
@@ -64,7 +131,7 @@ function ReferenceElementFallback({ element, children, options, block }) {
|
|
|
64
131
|
return children;
|
|
65
132
|
}
|
|
66
133
|
let Renderer = elementMetadata.referenceRenderer;
|
|
67
|
-
return /* @__PURE__ */
|
|
134
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: /* @__PURE__ */ jsxDEV(
|
|
68
135
|
Renderer,
|
|
69
136
|
{
|
|
70
137
|
referenceType: elementMetadata.referenceType,
|
|
@@ -75,8 +142,20 @@ function ReferenceElementFallback({ element, children, options, block }) {
|
|
|
75
142
|
options,
|
|
76
143
|
element,
|
|
77
144
|
children
|
|
78
|
-
}
|
|
79
|
-
|
|
145
|
+
},
|
|
146
|
+
void 0,
|
|
147
|
+
false,
|
|
148
|
+
{
|
|
149
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
150
|
+
lineNumber: 140,
|
|
151
|
+
columnNumber: 4
|
|
152
|
+
},
|
|
153
|
+
this
|
|
154
|
+
) }, void 0, false, {
|
|
155
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderElementFallback.tsx",
|
|
156
|
+
lineNumber: 139,
|
|
157
|
+
columnNumber: 3
|
|
158
|
+
}, this);
|
|
80
159
|
}
|
|
81
160
|
export {
|
|
82
161
|
RenderElementFallback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderElementFallback.js","sources":["../../../../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":"
|
|
1
|
+
{"version":3,"file":"RenderElementFallback.js","sources":["../../../../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,U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ict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
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__ */
|
|
11
|
-
!!i && /* @__PURE__ */
|
|
10
|
+
return lines.map((line, i) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(react.Fragment, { children: [
|
|
11
|
+
!!i && /* @__PURE__ */ jsxDevRuntime.jsxDEV("br", {}, void 0, false, {
|
|
12
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
13
|
+
lineNumber: 15,
|
|
14
|
+
columnNumber: 12
|
|
15
|
+
}, this),
|
|
12
16
|
line
|
|
13
|
-
] }, i
|
|
17
|
+
] }, i, true, {
|
|
18
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
19
|
+
lineNumber: 14,
|
|
20
|
+
columnNumber: 3
|
|
21
|
+
}, this));
|
|
14
22
|
}
|
|
15
23
|
function RenderLeafFallback({ leaf }) {
|
|
16
24
|
let element = jsxN2br(leaf.text);
|
|
17
25
|
if ("isCode" in leaf && leaf.isCode === true) {
|
|
18
|
-
element = /* @__PURE__ */
|
|
26
|
+
element = /* @__PURE__ */ jsxDevRuntime.jsxDEV("code", { children: element }, void 0, false, {
|
|
27
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
28
|
+
lineNumber: 25,
|
|
29
|
+
columnNumber: 13
|
|
30
|
+
}, this);
|
|
19
31
|
}
|
|
20
32
|
if ("isStruckThrough" in leaf && leaf.isStruckThrough === true) {
|
|
21
|
-
element = /* @__PURE__ */
|
|
33
|
+
element = /* @__PURE__ */ jsxDevRuntime.jsxDEV("s", { children: element }, void 0, false, {
|
|
34
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
35
|
+
lineNumber: 28,
|
|
36
|
+
columnNumber: 13
|
|
37
|
+
}, this);
|
|
22
38
|
}
|
|
23
39
|
if ("isHighlighted" in leaf && leaf.isHighlighted === true) {
|
|
24
|
-
element = /* @__PURE__ */
|
|
40
|
+
element = /* @__PURE__ */ jsxDevRuntime.jsxDEV("em", { children: element }, void 0, false, {
|
|
41
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
42
|
+
lineNumber: 31,
|
|
43
|
+
columnNumber: 13
|
|
44
|
+
}, this);
|
|
25
45
|
}
|
|
26
46
|
if ("isUnderlined" in leaf && leaf.isUnderlined === true) {
|
|
27
|
-
element = /* @__PURE__ */
|
|
47
|
+
element = /* @__PURE__ */ jsxDevRuntime.jsxDEV("u", { children: element }, void 0, false, {
|
|
48
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
49
|
+
lineNumber: 34,
|
|
50
|
+
columnNumber: 13
|
|
51
|
+
}, this);
|
|
28
52
|
}
|
|
29
53
|
if ("isItalic" in leaf && leaf.isItalic === true) {
|
|
30
|
-
element = /* @__PURE__ */
|
|
54
|
+
element = /* @__PURE__ */ jsxDevRuntime.jsxDEV("i", { children: element }, void 0, false, {
|
|
55
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
56
|
+
lineNumber: 37,
|
|
57
|
+
columnNumber: 13
|
|
58
|
+
}, this);
|
|
31
59
|
}
|
|
32
60
|
if ("isBold" in leaf && leaf.isBold === true) {
|
|
33
|
-
element = /* @__PURE__ */
|
|
61
|
+
element = /* @__PURE__ */ jsxDevRuntime.jsxDEV("b", { children: element }, void 0, false, {
|
|
62
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
63
|
+
lineNumber: 40,
|
|
64
|
+
columnNumber: 13
|
|
65
|
+
}, this);
|
|
34
66
|
}
|
|
35
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: element }, void 0, false, {
|
|
68
|
+
fileName: "/__w/interface/interface/packages/react-richtext-renderer/src/internal/components/RenderLeafFallback.tsx",
|
|
69
|
+
lineNumber: 42,
|
|
70
|
+
columnNumber: 9
|
|
71
|
+
}, this);
|
|
36
72
|
}
|
|
37
73
|
exports.RenderLeafFallback = RenderLeafFallback;
|
|
38
74
|
//# sourceMappingURL=RenderLeafFallback.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderLeafFallback.cjs","sources":["../../../../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":["
|
|
1
|
+
{"version":3,"file":"RenderLeafFallback.cjs","sources":["../../../../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":["jsxDEV","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,MACvBA,qCAACC,MAAAA,UAAA,EACC,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