feat(core): support block links on Bi-Directional Links (#8169)

Clsoes [AF-1348](https://linear.app/affine-design/issue/AF-1348/修复-bi-directional-links-里面的链接地址)

* Links to the current document should be ignored on `Backlinks`
* Links to the current document should be ignored on `Outgoing links`

https://github.com/user-attachments/assets/dbc43cea-5aca-4c6f-886a-356e3a91c1f1
This commit is contained in:
fundon
2024-09-11 11:08:12 +00:00
parent b7d05d2078
commit b74dd1c92e
10 changed files with 221 additions and 98 deletions

View File

@@ -55,25 +55,28 @@ export class DocsQuickSearchSession
if (!query) {
out = of([] as QuickSearchItem<'docs', DocsPayload>[]);
} else {
const resolvedDoc = resolveLinkToDoc(query);
const resolvedDocId = resolvedDoc?.docId;
const resolvedBlockId = resolvedDoc?.blockIds?.[0];
out = this.docsSearchService.search$(query).pipe(
map(docs => {
const resolvedDoc = resolveLinkToDoc(query);
if (
resolvedDoc &&
!docs.some(doc => doc.docId === resolvedDoc.docId)
resolvedDocId &&
!docs.some(doc => doc.docId === resolvedDocId)
) {
return [
{
docId: resolvedDoc.docId,
docId: resolvedDocId,
score: 100,
blockId: resolvedDoc.blockIds?.[0],
blockId: resolvedBlockId,
blockContent: '',
},
...docs,
];
} else {
return docs;
}
return docs;
}),
map(docs =>
docs