Improve Markdown file preview readability (#3240)
* feat(app): improve markdown file previews Keep rendered documents on the chat reading rail, surface YAML front matter as readable metadata, and make shared Markdown links retain the chat accent and hover treatment. * fix(app): preserve unsafe frontmatter source * test(app): cover markdown link behavior
This commit is contained in:
@@ -23,9 +23,6 @@ import {
|
||||
useCallback,
|
||||
createContext,
|
||||
useContext,
|
||||
isValidElement,
|
||||
Children,
|
||||
cloneElement,
|
||||
} from "react";
|
||||
import type { ComponentType, ReactNode } from "react";
|
||||
import type MarkdownIt from "markdown-it";
|
||||
@@ -77,6 +74,7 @@ import { HighlightedCodeBlock } from "@/components/highlighted-code-block";
|
||||
import { MarkdownFenceBlock } from "@/components/markdown/fence";
|
||||
import type { MarkdownPhase } from "@/components/markdown/fence/types";
|
||||
import { splitMarkdownBlocks } from "@/utils/split-markdown-blocks";
|
||||
import { colorMarkdownLinkChildren } from "@/components/markdown/link-children";
|
||||
import { createAssistantMarkdownParser } from "@/utils/assistant-markdown-parser";
|
||||
import { formatDuration, formatMessageTimestamp } from "@/utils/time";
|
||||
import { writeMarkdownToRichClipboard } from "@/utils/rich-clipboard";
|
||||
@@ -1863,13 +1861,7 @@ export const AssistantMessage = memo(function AssistantMessage({
|
||||
source={getMarkdownLinkSource(node)}
|
||||
style={styles.link}
|
||||
>
|
||||
{Children.map(children, (child) => {
|
||||
if (!isValidElement(child)) return child;
|
||||
const childProps = child.props as { style?: StyleProp<TextStyle> };
|
||||
return cloneElement(child, {
|
||||
style: [childProps.style, { color: styles.link.color }],
|
||||
} as Partial<{ style: StyleProp<TextStyle> }>);
|
||||
})}
|
||||
{colorMarkdownLinkChildren(children, styles.link.color)}
|
||||
</AssistantMarkdownLink>
|
||||
),
|
||||
image: (
|
||||
|
||||
Reference in New Issue
Block a user