mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-18 12:04:45 +08:00
fix(frontend): citations display + refactor link/citation utils
- Citations: no underline while streaming (message links); artifact markdown external links as citation cards - Refactor: add isExternalUrl, syntheticCitationFromLink in core/citations; shared externalLinkClass in lib/utils; simplify message-list-item and artifact-file-detail link rendering 修复引用展示并抽离链接/引用工具 - 引用:流式输出时链接不这下划线;Artifact 内 Markdown 外链以引用卡片展示 - 重构:core/citations 新增 isExternalUrl、syntheticCitationFromLink;lib/utils 共享 externalLinkClass;精简消息与 Artifact 中的链接渲染逻辑 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
export {
|
||||
parseCitations,
|
||||
buildCitationMap,
|
||||
extractDomainFromUrl,
|
||||
isCitationsBlockIncomplete,
|
||||
isExternalUrl,
|
||||
parseCitations,
|
||||
removeAllCitations,
|
||||
syntheticCitationFromLink,
|
||||
} from "./utils";
|
||||
|
||||
export type { Citation, ParseCitationsResult } from "./utils";
|
||||
|
||||
@@ -118,6 +118,25 @@ export function buildCitationMap(
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the URL is external (http/https).
|
||||
*/
|
||||
export function isExternalUrl(url: string): boolean {
|
||||
return url.startsWith("http://") || url.startsWith("https://");
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a synthetic Citation from a link (e.g. in artifact markdown without <citations> block).
|
||||
*/
|
||||
export function syntheticCitationFromLink(href: string, title: string): Citation {
|
||||
return {
|
||||
id: `artifact-cite-${href}`,
|
||||
title: title || href,
|
||||
url: href,
|
||||
snippet: "",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the domain name from a URL for display
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user