diff --git a/src/components/ProposalDetails.js b/src/components/ProposalDetails.js index d3273ab..c72ee72 100644 --- a/src/components/ProposalDetails.js +++ b/src/components/ProposalDetails.js @@ -26,33 +26,37 @@ function ProposalDetails(props) { const { proposal_id, title, description } = proposal const fixDescription = description?.replace(/\\n/g, ' \n') - - const parsedDescription = parse( - micromark(fixDescription, { extensions: [gfm()], htmlExtensions: [gfmHtml()] }), - { replace: transformElement } - ); const transformElement = (node) => { + if (!node || !node.name) { + return node; + } + if (proposal.isSpam && node.name === 'a') { return {node.children[0].data}; } - + switch (node.name) { case 'h1': - return
{node.children[0].data}
; + return
{node.children[0]?.data}
; case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': - return
{node.children[0].data}
; + return
{node.children[0]?.data}
; case 'table': - return {node.children.map((child) => transformElement(child))}
; + return {node.children.map((child, index) => transformElement(child, index))}
; default: return node; } }; + const parsedDescription = parse( + micromark(fixDescription, { extensions: [gfm()], htmlExtensions: [gfmHtml()] }), + { replace: transformElement } + ); + useEffect(() => { if(props.address !== props.wallet?.address && props.granters.includes(props.address)){ setGranter(props.address)