fix(core): block link recognition in self-hosted (#8340)
Part of [BS-1445](https://linear.app/affine-design/issue/BS-1445/点击-affine-link-时识别应用内链接,以触发应用内跳转) <div class='graphite__hidden'> <div>🎥 Video uploaded on Graphite:</div> <a href="https://app.graphite.dev/media/video/8ypiIKZXudF5a0tIgIzf/fae580bc-7d30-4711-a70e-7a5cf26c76f1.mov"> <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/8ypiIKZXudF5a0tIgIzf/fae580bc-7d30-4711-a70e-7a5cf26c76f1.mov"> </a> </div> <video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/8ypiIKZXudF5a0tIgIzf/fae580bc-7d30-4711-a70e-7a5cf26c76f1.mov">Screen Recording 2024-09-21 at 10.50.12.mov</video>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { toURLSearchParams } from '@affine/core/modules/navigation';
|
||||
import type { ReferenceParams } from '@blocksuite/blocks';
|
||||
import type { WorkspaceService } from '@toeverything/infra';
|
||||
import {
|
||||
fromPromise,
|
||||
@@ -278,17 +279,14 @@ export class DocsSearchService extends Service {
|
||||
}
|
||||
);
|
||||
|
||||
const refs: {
|
||||
docId: string;
|
||||
mode?: string;
|
||||
blockIds?: string[];
|
||||
elementIds?: string[];
|
||||
}[] = nodes.flatMap(node => {
|
||||
const { ref } = node.fields;
|
||||
return typeof ref === 'string'
|
||||
? [JSON.parse(ref)]
|
||||
: ref.map(item => JSON.parse(item));
|
||||
});
|
||||
const refs: ({ docId: string } & ReferenceParams)[] = nodes.flatMap(
|
||||
node => {
|
||||
const { ref } = node.fields;
|
||||
return typeof ref === 'string'
|
||||
? [JSON.parse(ref)]
|
||||
: ref.map(item => JSON.parse(item));
|
||||
}
|
||||
);
|
||||
|
||||
const docData = await this.indexer.docIndex.getAll(
|
||||
Array.from(new Set(refs.map(ref => ref.docId)))
|
||||
@@ -352,17 +350,14 @@ export class DocsSearchService extends Service {
|
||||
.pipe(
|
||||
switchMap(({ nodes }) => {
|
||||
return fromPromise(async () => {
|
||||
const refs: {
|
||||
docId: string;
|
||||
mode?: string;
|
||||
blockIds?: string[];
|
||||
elementIds?: string[];
|
||||
}[] = nodes.flatMap(node => {
|
||||
const { ref } = node.fields;
|
||||
return typeof ref === 'string'
|
||||
? [JSON.parse(ref)]
|
||||
: ref.map(item => JSON.parse(item));
|
||||
});
|
||||
const refs: ({ docId: string } & ReferenceParams)[] = nodes.flatMap(
|
||||
node => {
|
||||
const { ref } = node.fields;
|
||||
return typeof ref === 'string'
|
||||
? [JSON.parse(ref)]
|
||||
: ref.map(item => JSON.parse(item));
|
||||
}
|
||||
);
|
||||
|
||||
const docData = await this.indexer.docIndex.getAll(
|
||||
Array.from(new Set(refs.map(ref => ref.docId)))
|
||||
|
||||
Reference in New Issue
Block a user