feat(v2.7): 接入协作治理前端体验

This commit is contained in:
2026-07-08 16:31:06 +08:00
parent bcbe84bb6e
commit 9ba9449c1a
23 changed files with 987 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
export interface CommentMentionMember {
id: string;
name: string;
}
export interface MergeMentionMemberIdsInput {
content: string;
explicitMemberIds: string[];
members: CommentMentionMember[];
}
export function extractMentionNames(content: string): string[] {
const names: string[] = [];
const pattern = /@([\p{L}\p{N}_\-.]+)/gu;
for (const match of content.matchAll(pattern)) {
if (match[1]) names.push(match[1]);
}
return names;
}
export function mergeMentionMemberIds(input: MergeMentionMemberIdsInput): string[] {
const ids = new Set<string>();
const names = new Set(extractMentionNames(input.content).map(normalizeName));
for (const member of input.members) {
if (names.has(normalizeName(member.name))) ids.add(member.id);
}
for (const id of input.explicitMemberIds) {
const normalized = id.trim();
if (normalized) ids.add(normalized);
}
return Array.from(ids);
}
function normalizeName(name: string): string {
return name.trim().toLowerCase();
}