import React from "react"; import { chakra, Heading, ListItem, OrderedList, Table, Td, Tr, UnorderedList, Image, SimpleGrid, Text, FlexProps, Box, } from "@chakra-ui/react"; import { GalleryView } from "./gallery"; import { HTMLCodeBlockView } from "./html-code-block"; import { AccordionView } from "./accordion"; import { CardsView } from "./cards/CardsView"; import { TabsView } from "./tabs"; import { BaseFlexboxComponent, BaseFlexboxItemComponent } from "./flexbox"; import ButtonLink from "../buttons/ButtonLink"; import { LinkView } from "./link/LinkView"; import { TextView } from "./text/TextView"; export function renderJSON(content: any[]) { return ( content?.map?.((item) => { console.log(item); const { attrs, content, type, text, marks } = item; try { switch (type) { case "custom-link": case "customLink": return ( {renderJSON(content)} ); case "flexbox": return ( ); case "flexboxItem": return ( ); case "tabs": return ; case "card-list": case "cardList": return ; case "gallery": return ; case "chakraImage": return ; case "blockquote": return {renderJSON(content)} ; case "text": return ; case "paragraph": return content ? renderJSON(content) : ""; case "htmlCodeBlock": return ; case "heading": { const { level, ...props } = attrs as { level: 1 | 2 | 3 | 4; textAlign: "left" | "right" | "center"; }; return ( {renderJSON(content)} ); } case "accordion": return ( {renderJSON(content)} ); case "orderedList": return {renderJSON(content)}; case "listItem": return {renderJSON(content)}; case "table": return {renderJSON(content)}
; case "tableRow": return {renderJSON(content)}; case "tableCell": return {renderJSON(content)}; case "bulletList": return {renderJSON(content)}; case "bulletListItem": return {renderJSON(content)}; } } catch { } return content ? renderJSON(content) : <>; }) || <> ); }