overleaf/services/web/frontend/js/features/ide-react/util/find-doc-entity-by-id.ts

12 lines
377 B
TypeScript
Raw Normal View History

import { findInTree } from '@/features/file-tree/util/find-in-tree'
import { Folder } from '../../../../../types/folder'
import { Doc } from '../../../../../types/doc'
export function findDocEntityById(fileTreeData: Folder, docId: string) {
const item = findInTree(fileTreeData, docId)
if (!item || item.type !== 'doc') {
return null
}
return item.entity as Doc
}