Skip to content

Commit 20c1fd6

Browse files
committed
fix(web): wrap formatted links with the production context
1 parent 3f8d57f commit 20c1fd6

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎apps/web/src/components/chat/MarkdownExternalLink.browser.test.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { expect, it } from "vite-plus/test";
33
import { render } from "../../../test/render";
44
import "../../index.css";
55

6+
import { MarkdownLinkContext } from "./ChatMarkdownMedia";
67
import { MarkdownExternalLinkContent } from "./MarkdownExternalLink";
78

89
it.each(["plain", "formatted"] as const)(
@@ -19,8 +20,10 @@ it.each(["plain", "formatted"] as const)(
1920
host="github.com"
2021
plainText={kind === "plain" ? url : null}
2122
>
22-
{url}
23-
{kind === "formatted" ? <strong> details</strong> : null}
23+
<MarkdownLinkContext value>
24+
{url}
25+
{kind === "formatted" ? <strong> details</strong> : null}
26+
</MarkdownLinkContext>
2427
</MarkdownExternalLinkContent>
2528
</a>
2629
</td>
@@ -40,6 +43,7 @@ it.each(["plain", "formatted"] as const)(
4043
expect(anchor.getAttribute("href")).toBe(longUrl);
4144
expect(anchor.textContent).toBe(longUrl + (kind === "formatted" ? " details" : ""));
4245
expect(anchor.querySelectorAll("*")).toHaveLength(initialElementCount);
46+
if (kind === "formatted") expect(anchor.querySelector("strong")?.textContent).toBe(" details");
4347
expect(table.scrollWidth).toBeLessThanOrEqual(screen.container.firstElementChild!.clientWidth);
4448
},
4549
);

‎apps/web/src/components/chat/MarkdownExternalLink.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function MarkdownExternalLinkContent({
108108

109109
return (
110110
<>
111-
<span className="whitespace-nowrap">
111+
<span className="[overflow-wrap:anywhere]">
112112
<MarkdownLinkFavicon host={host} />
113113
{firstChild}
114114
</span>

0 commit comments

Comments
 (0)