DragManager
Unofficial
Manager for drag-and-drop operations throughout the application.
Import:
import type { DragManager } from '@obsidian-typings/obsidian-catalyst-latest';Signature:
export interface DragManagerConstructor
new DragManager(app: App)Constructor.
To get the constructor instance, use getDragManagerConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| actionEl | HTMLElement | null | Element displaying the current drop action label. | |
| app | App | Reference to the app. | |
| draggable | Draggable | null | Currently active draggable item. | |
| dragStart | DragStartEvent | null | Information about the initial drag start event. | |
| edgeScroll | DragManagerEdgeScroll | null | The automatic scroll running while a drag hovers near the edge of a scrollable element, or null when none is. | |
| ghostEl | HTMLElement | null | Ghost element shown while dragging. | |
| hoverClass | string | CSS class currently applied to the hover target. | |
| hoverEl | HTMLElement | null | Element currently being hovered over during drag. | |
| overlayEl | HTMLElement | Overlay element shown during drag operations to indicate drop zones. | |
| shouldClearAction | boolean | Whether the drop action text should be cleared after the current drag-over, unless a drop target calls DragManager.setAction first. | |
| shouldClearHover | boolean | Whether the hover highlight should be cleared after the current drag-over, unless a drop target calls DragManager.updateHover first. | |
| shouldHideOverlay | boolean | Whether the overlay should be hidden on the next update. | |
| sourceClass | string | CSS class applied to the source elements during drag. | |
| sourceEls | HTMLElement[] | null | Elements from which the drag originated. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| dragFile($event, file, source?) | Draggable | Start a drag operation for a single file. | |
| dragFiles($event, files, source?) | Draggable | null | Start a drag operation for multiple files. | |
| dragFolder($event, folder, source?) | Draggable | Start a drag operation for a folder. | |
| dragLink($event, linkText, sourcePath, title?, source?) | Draggable | Start a drag operation for a link. | |
| handleDrag(el, draggableGetter) | void | Register an element as a drag source with a callback to produce a draggable. | |
| handleDrop(el, dropHandler, draggable?) | void | Register an element as a drop target with a handler callback. | |
| hideOverlay() | void | Hide the drop zone overlay. | |
| onDragEnd() | void | Handle the end of a drag operation, cleaning up state. | |
| onDragLeave($event) | void | Handle the drag-leave event on a drop target. | |
| onDragOver($event) | void | Handle the drag-over event to update hover state. | |
| onDragOverFirst() | void | Handle the first drag-over event when entering a drop zone. | |
| onDragStart($event, draggable) | void | Handle the start of a drag operation with a draggable item. | |
| onDragStartGlobal($event) | void | Handle a global drag start event. | |
| onTouchEnd($event) | void | Handle touch end event for mobile drag operations. | |
| removeOverlay() | void | Remove the drop zone overlay element from the DOM. | |
| setAction(action) | void | Set the current drop action label. | |
| showOverlay(doc, rect) | void | Show the drop zone overlay at the specified position. | |
| updateHover(hoverEl, hoverClass) | void | Update the hover target element and its CSS class. | |
| updateSource(sourceEls, sourceClass) | void | Update the drag source elements and their CSS class. |
Links to this page: