Skip to content

obsidian/reference

Contains utility functions for handling references in Obsidian.

InterfaceDescription
CanvasFileNodeReferenceA reference within a file node in a canvas.
CanvasReferenceA reference within a canvas.
CanvasTextNodeReferenceA reference within a text node in a canvas.
OffsetRangeA 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.
FunctionDescription
isCanvasFileNodeReferenceChecks if a reference is a canvas file node reference.
isCanvasReferenceChecks if a reference is a canvas reference.
isCanvasTextNodeReferenceChecks if a reference is a canvas text node reference.
isReferenceInOffsetRangeChecks 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.
referenceToFileChangeConverts a reference to a file change.
sortReferencesSorts references by their type and position.