obsidian-dev-utils
Version:
This is the collection of useful functions that you can use for your Obsidian plugin development
72 lines (71 loc) • 2.04 kB
text/typescript
/**
* @packageDocumentation
*
* Contains utility functions for handling rename and delete events in Obsidian.
*/
import type { Plugin } from 'obsidian';
/**
* The 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 {
/**
* The 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;
}
/**
* 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: Plugin, settingsBuilder: () => Partial<RenameDeleteHandlerSettings>): void;