Skip to content

DragManager

Unofficial

Manager for drag-and-drop operations throughout the application.

Import:

import type { DragManager } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface DragManager

Constructor

new DragManager(app: App)

Constructor.

To get the constructor instance, use getDragManagerConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
actionElHTMLElement | nullElement displaying the current drop action label.
appAppReference to the app.
draggableDraggable | nullCurrently active draggable item.
dragStartDragStartEvent | nullInformation about the initial drag start event.
ghostElHTMLElement | nullGhost element shown while dragging.
hoverClassstringCSS class currently applied to the hover target.
hoverElHTMLElement | nullElement currently being hovered over during drag.
isDragOverHandledbooleanWhether the drag-over event has been handled by a drop target.
overlayElHTMLElementOverlay element shown during drag operations to indicate drop zones.
shouldHideOverlaybooleanWhether the overlay should be hidden on the next update.
sourceClassstringCSS class applied to the source elements during drag.
sourceElsHTMLElement[] | nullElements from which the drag originated.

Methods

MethodReturnsDescription
dragFile(event, file, source?)DraggableStart a drag operation for a single file.
dragFiles(event, files, source?)Draggable | nullStart a drag operation for multiple files.
dragFolder(event, folder, source?)DraggableStart a drag operation for a folder.
dragLink(event, linkText, sourcePath, title?, source?)DraggableStart a drag operation for a link.
handleDrag(el, draggableGetter)voidRegister an element as a drag source with a callback to produce a draggable.
handleDrop(el, dropHandler, draggable?)voidRegister an element as a drop target with a handler callback.
hideOverlay()voidHide the drop zone overlay.
onDragEnd()voidHandle the end of a drag operation, cleaning up state.
onDragLeave(event)voidHandle the drag-leave event on a drop target.
onDragOver(event)voidHandle the drag-over event to update hover state.
onDragOverFirst()voidHandle the first drag-over event when entering a drop zone.
onDragStart(event, draggable)voidHandle the start of a drag operation with a draggable item.
onDragStartGlobal(event)voidHandle a global drag start event.
onTouchEnd(event)voidHandle touch end event for mobile drag operations.
removeOverlay()voidRemove the drop zone overlay element from the DOM.
setAction(action)voidSet the current drop action label.
showOverlay(doc, rect)voidShow the drop zone overlay at the specified position.
updateHover(hoverEl, hoverClass)voidUpdate the hover target element and its CSS class.
updateSource(sourceEls, sourceClass)voidUpdate the drag source elements and their CSS class.

Links to this page: