Merge remote-tracking branch 'origin/main' into kumareth/workspaces
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # apps/web/app/components/chat-message.tsx
This commit is contained in:
commit
d88ed44521
@ -555,7 +555,7 @@ function createMarkdownComponents(
|
||||
onFilePathClick?: FilePathClickHandler,
|
||||
): Components {
|
||||
return {
|
||||
// Open external links in new tab
|
||||
// Open external links in new tab; intercept local file-path links
|
||||
a: ({ href, children, ...props }) => {
|
||||
const rawHref = typeof href === "string" ? href : "";
|
||||
const normalizedHref = normalizePathReference(rawHref);
|
||||
@ -583,15 +583,18 @@ function createMarkdownComponents(
|
||||
</a>
|
||||
);
|
||||
},
|
||||
// Render images with loading=lazy
|
||||
img: ({ src, alt, ...props }) => (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img src={src} alt={alt ?? ""} loading="lazy" {...props} />
|
||||
),
|
||||
// Route local image paths through raw-file API so workspace images render
|
||||
img: ({ src, alt, ...props }) => {
|
||||
const resolvedSrc = typeof src === "string" && !src.startsWith("http://") && !src.startsWith("https://") && !src.startsWith("data:")
|
||||
? `/api/workspace/raw-file?path=${encodeURIComponent(src)}`
|
||||
: src;
|
||||
return (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img src={resolvedSrc} alt={alt ?? ""} loading="lazy" {...props} />
|
||||
);
|
||||
},
|
||||
// Syntax-highlighted fenced code blocks
|
||||
pre: ({ children, ...props }) => {
|
||||
// react-markdown wraps code blocks in <pre><code>...
|
||||
// Extract the code element to get lang + content
|
||||
const child = Array.isArray(children) ? children[0] : children;
|
||||
if (
|
||||
child &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user