Skip to content

MisplacedAttachmentIndex

The verdicts of a walk over every reference to an attachment, grouped by the note that makes the reference.

It keeps every external reference, every note that uses each attachment, and each attachment’s proper notes: the notes that reference it and whose own folder holds it. Which entries count as reported depends on the ExternalAttachmentLinkMode and on the proper notes, which are known only once the whole vault has been walked, so ask MisplacedAttachmentIndex.getReported after the walk.

Import:

import { MisplacedAttachmentIndex } from '@mnaoumov/obsidian-lib/misplaced-attachment';

Signature:

export class MisplacedAttachmentIndex extends Map<string, MisplacedAttachmentEntry[]>

Extends: Map<string, MisplacedAttachmentEntry[]>

Constructor

new MisplacedAttachmentIndex(mode?: ExternalAttachmentLinkMode)

Creates an empty index.

Methods

MethodReturnsDescription
add(notePath, entry)voidRecords a reference to an attachment outside the referencing note's folder.
addUser(attachmentPath, notePath)voidRecords that a note references an attachment, wherever the attachment sits.
getOtherUserNotePaths(attachmentPath, notePath)string[]The notes that use an attachment besides the given one, its proper notes first, each group in walk order.
getProperNotePaths(attachmentPath)string[]The proper notes of an attachment: the notes that reference it and whose own folder holds it, in walk order.
getReported()Map<string, MisplacedAttachmentEntry[]>The entries to report, after the mode is applied, grouped by note, with a note left out once none of its entries survive.
isProperNote(attachmentPath, notePath)booleanWhether a note is a proper note of an attachment: it references it, and its own folder holds it.
markHomed(attachmentPath, notePath)voidRecords that an attachment sits in the folder configured for a note that references it, which makes that note its proper note.

Links to this page: