Files
AFFiNE-Mirror/packages/y-provider/src/utils.ts
2023-07-21 05:23:18 +00:00

15 lines
293 B
TypeScript

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