mirror of
				https://github.com/langgenius/dify.git
				synced 2025-10-30 18:33:30 +00:00 
			
		
		
		
	
		
			
	
	
		
			28 lines
		
	
	
		
			930 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
		
		
			
		
	
	
			28 lines
		
	
	
		
			930 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
|   | /** | ||
|  |  * @fileoverview Paragraph component for rendering <p> tags in Markdown. | ||
|  |  * Extracted from the main markdown renderer for modularity. | ||
|  |  * Handles special rendering for paragraphs that directly contain an image. | ||
|  |  */ | ||
|  | import React from 'react' | ||
|  | import ImageGallery from '@/app/components/base/image-gallery' | ||
|  | 
 | ||
|  | const Paragraph = (paragraph: any) => { | ||
|  |   const { node }: any = paragraph | ||
|  |   const children_node = node.children | ||
|  |   if (children_node && children_node[0] && 'tagName' in children_node[0] && children_node[0].tagName === 'img') { | ||
|  |     return ( | ||
|  |       <div className="markdown-img-wrapper"> | ||
|  |         <ImageGallery srcs={[children_node[0].properties.src]} /> | ||
|  |         { | ||
|  |           Array.isArray(paragraph.children) && paragraph.children.length > 1 && ( | ||
|  |             <div className="mt-2">{paragraph.children.slice(1)}</div> | ||
|  |           ) | ||
|  |         } | ||
|  |       </div> | ||
|  |     ) | ||
|  |   } | ||
|  |   return <p>{paragraph.children}</p> | ||
|  | } | ||
|  | 
 | ||
|  | export default Paragraph |