perf: lazy doc provider factory (#3330)

Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
Peng Xiao
2023-07-21 13:23:18 +08:00
committed by GitHub
parent cff741e9ba
commit 869d98d019
11 changed files with 609 additions and 0 deletions

View 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;
}