Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

FEAT: add image styling in markdown (#2441)

Yash_112481c5a21b8d2f
diff --git a/web/app/components/base/markdown.tsx b/web/app/components/base/markdown.tsx
index 5fab36fa312..fb0cf5bb445 100644
--- a/web/app/components/base/markdown.tsx
+++ b/web/app/components/base/markdown.tsx
@@ -143,6 +143,37 @@ export function Markdown(props: { content: string; className?: string }) {
</code>
)
},
+ img({ src, alt, ...props }) {
+ return (
+ // eslint-disable-next-line @next/next/no-img-element
+ <img
+ src={src}
+ alt={alt}
+ width={250}
+ height={250}
+ className="max-w-full h-auto align-middle border-none rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 ease-in-out mt-2 mb-2"
+ {...props}
+ />
+ )
+ },
+ p: (paragraph) => {
+ const { node }: any = paragraph
+ if (node.children[0].tagName === 'img') {
+ const image = node.children[0]
+
+ return (
+ // eslint-disable-next-line @next/next/no-img-element
+ <img
+ src={image.properties.src}
+ width={250}
+ height={250}
+ className="max-w-full h-auto align-middle border-none rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 ease-in-out mt-2 mb-2"
+ alt={image.properties.alt}
+ />
+ )
+ }
+ return <p>{paragraph.children}</p>
+ },
}}
linkTarget='_blank'
>