Commit 19b77e64 by liimin

refactor(markdown): 将Link组件中的空标签替换为div

解决P标签不能直接嵌套img的问题
1 parent 6fec1fb5
...@@ -269,13 +269,13 @@ const Link = ({ node, children, ...props }: any) => { ...@@ -269,13 +269,13 @@ const Link = ({ node, children, ...props }: any) => {
const href = node.properties?.href?.toString() || '' const href = node.properties?.href?.toString() || ''
const isImage = /\.(jpe?g|png|gif|webp|bmp|svg)(\?.*)?$/i.test(href) const isImage = /\.(jpe?g|png|gif|webp|bmp|svg)(\?.*)?$/i.test(href)
return ( return (
<> <div>
{isImage ? ( {isImage ? (
Img({ src: href }) Img({ src: href })
) : ( ) : (
<a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{children || 'Download'}</a> <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{children || 'Download'}</a>
)} )}
</> </div>
) )
// return <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{children || 'Download'}</a> // return <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{children || 'Download'}</a>
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!