UNPKG

obsidian-dev-utils

Version:

This is the collection of useful functions that you can use for your Obsidian plugin development

76 lines (75 loc) 2.13 kB
/** * @packageDocumentation * * Contains utility functions for handling rename and delete events in Obsidian. */ import type { Plugin } from 'obsidian'; /** * A behavior of the rename/delete handler when deleting empty attachment folders. */ export declare enum EmptyAttachmentFolderBehavior { /** * Delete the empty attachment folder. */ Delete = "Delete", /** * Delete the empty attachment folder and all its empty parents. */ DeleteWithEmptyParents = "DeleteWithEmptyParents", /** * Keep the empty attachment folder. */ Keep = "Keep" } /** * Settings for the rename/delete handler. */ export interface RenameDeleteHandlerSettings { /** * A behavior of the rename/delete handler when deleting empty attachment folders. */ emptyAttachmentFolderBehavior: EmptyAttachmentFolderBehavior; /** * Whether the path is a note. */ isNote(path: string): boolean; /** * Whether to ignore the path. */ isPathIgnored(path: string): boolean; /** * Whether to delete conflicting attachments. */ shouldDeleteConflictingAttachments: boolean; /** * Whether to handle deletions. */ shouldHandleDeletions: boolean; /** * Whether to handle renames. */ shouldHandleRenames: boolean; /** * Whether to rename attachment files when a note is renamed. */ shouldRenameAttachmentFiles: boolean; /** * Whether to rename attachment folder when a note is renamed. */ shouldRenameAttachmentFolder: boolean; /** * Whether to update file name aliases when a note is renamed. */ shouldUpdateFileNameAliases: boolean; } interface AbortablePlugin extends Plugin { abortSignal?: AbortSignal; } /** * Registers the rename/delete handlers. * * @param plugin - The plugin instance. * @param settingsBuilder - A function that returns the settings for the rename delete handler. */ export declare function registerRenameDeleteHandlers(plugin: AbortablePlugin, settingsBuilder: () => Partial<RenameDeleteHandlerSettings>): void; export {};