From eda996e5232c9d0a1dc6c8dc4a19af933a0cf3d0 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 26 Mar 2024 15:25:21 +0800 Subject: [PATCH] fix anchor text can't show both underline and line through on iOS --- .../HTMLRenderers/AnchorRenderer.tsx | 25 +++++++++++++++++-- src/styles/utils/textDecorationLine.ts | 4 +++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.tsx index 465a4f747bcb..d918007e5750 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.tsx @@ -55,6 +55,9 @@ function AnchorRenderer({tnode, style, key}: AnchorRendererProps) { ); } + const hasStrikethroughStyle = 'textDecorationLine' in parentStyle && parentStyle.textDecorationLine === 'line-through'; + const textDecorationLineStyle = hasStrikethroughStyle ? styles.underlineLineThrough : {}; + return ( Link.openLink(attrHref, environmentURL, isAttachment) : undefined} > - + { + if (props.childTnode.tagName === 'br') { + return {'\n'}; + } + if (props.childTnode.type === 'text') { + return ( + + {props.childTnode.data} + + ); + } + return props.childElement; + }} + /> ); } diff --git a/src/styles/utils/textDecorationLine.ts b/src/styles/utils/textDecorationLine.ts index e5f079150e78..5e830cbf08c1 100644 --- a/src/styles/utils/textDecorationLine.ts +++ b/src/styles/utils/textDecorationLine.ts @@ -5,4 +5,8 @@ export default { textDecorationLine: 'line-through', textDecorationStyle: 'solid', }, + underlineLineThrough: { + textDecorationLine: 'underline line-through', + textDecorationStyle: 'solid', + }, } satisfies Record;