DragManager
Unofficial
Manager for drag-and-drop operations throughout the application.
Import:
import type { DragManager } from '@obsidian-typings/obsidian-public-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. | |
| 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. | |
| isDragOverHandled | boolean | Whether the drag-over event has been handled by a drop target. | |
| overlayEl | HTMLElement | Overlay element shown during drag operations to indicate drop zones. | |
| 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: