From 19d1dc370050fc50c2daddd08c567cf8ab96c672 Mon Sep 17 00:00:00 2001 From: Hugo Costa Date: Fri, 18 Nov 2022 08:59:51 -0300 Subject: [PATCH] [NEW] Emphasis Elements (italic, strike and bold) in Message Parser Components (#27003) --- packages/gazzodown/src/elements/LinkSpan.tsx | 32 ++++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/gazzodown/src/elements/LinkSpan.tsx b/packages/gazzodown/src/elements/LinkSpan.tsx index ca326ccd6032..c7c267c03fb0 100644 --- a/packages/gazzodown/src/elements/LinkSpan.tsx +++ b/packages/gazzodown/src/elements/LinkSpan.tsx @@ -34,23 +34,29 @@ type LinkSpanProps = { const LinkSpan = ({ href, label }: LinkSpanProps): ReactElement => { const children = useMemo(() => { - switch (label.type) { - case 'PLAIN_TEXT': - return ; + const labelArray = Array.isArray(label) ? label : [label]; - case 'STRIKE': - return ; + const labelElements = labelArray.map((child, index) => { + switch (child.type) { + case 'PLAIN_TEXT': + return ; - case 'ITALIC': - return ; + case 'STRIKE': + return ; - case 'BOLD': - return ; + case 'ITALIC': + return ; - default: - return null; - } - }, [label.type, label.value]); + case 'BOLD': + return ; + + default: + return null; + } + }); + + return labelElements; + }, [label]); if (isExternal(href)) { return (