mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
perf: lazy doc provider factory (#3330)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
14
packages/y-provider/src/utils.ts
Normal file
14
packages/y-provider/src/utils.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { Doc } from 'yjs';
|
||||
|
||||
export function getDoc(doc: Doc, guid: string): Doc | undefined {
|
||||
if (doc.guid === guid) {
|
||||
return doc;
|
||||
}
|
||||
for (const subdoc of doc.subdocs) {
|
||||
const found = getDoc(subdoc, guid);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user