Skip to content

reference

Contains utility functions for handling references in Obsidian.

Interface Description
CanvasFileNodeReference A reference within a file node in a canvas.
CanvasReference A reference within a canvas.
CanvasTextNodeReference A reference within a text node in a canvas.
OffsetRange A range within a file’s content, expressed in character offsets. Both bounds are inclusive: a reference whose own offsets coincide exactly with OffsetRange.startOffset / OffsetRange.endOffset is inside the range.
Function Description
isCanvasFileNodeReference Checks if a reference is a canvas file node reference.
isCanvasReference Checks if a reference is a canvas reference.
isCanvasTextNodeReference Checks if a reference is a canvas text node reference.
isReferenceInOffsetRange Checks if a reference is fully contained within an offset range. Only a reference that carries a position within the file’s content can be in a range. A FrontmatterLinkCache — a frontmatter link, a multi-link frontmatter value entry, or any canvas reference — carries no such position and is therefore never in range. Its startOffset / endOffset, where present, locate the link within its own property value rather than within the file, so they are deliberately not compared against the range. Containment is full and both bounds are inclusive: a reference that only partially overlaps the range is not in it, because rewriting part of a link corrupts it.
referenceToFileChange Converts a reference to a file change.
sortReferences Sorts references by their type and position.