getFileWithBlockId
getFileWithBlockId(blockId: string): TFile | nullReturns the file that defines the given block ID, or null if not found.
Parameters
blockId— Block ID without the^prefix. Case-sensitive (matching Obsidian behavior).
Returns
TFile | null — the file object, or null.
Notes
- Block IDs are unique within a vault.
- This is the only query method that returns
TFileinstead ofReadonlySet<string>, since each block ID maps to exactly one file. - Block IDs are stored as-is (no normalization).
"myBlock"and"myblock"are different IDs.
Example
const file = cache.getFileWithBlockId("important-note");
if (file) {
console.log(`Block ^important-note is in ${file.path}`);
}