import { type ElementGetFeedbackArgs } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'; import type { DropTargetRecord } from '@atlaskit/pragmatic-drag-and-drop/types'; import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'; import type { ServiceIdentifier } from '@blocksuite/global/di'; import { LifeCycleWatcher } from '../lifecycle-watcher.js'; import type { ElementDragEventBaseArgs, ElementDragEventMap, ElementDropEventMap, ElementDropTargetFeedbackArgs, ElementMonitorFeedbackArgs, OriginalAutoScrollOption, OriginalDraggableOption } from './types.js'; export type DragEntity = { type: string; }; export type DragFrom = { at: string; }; export type DragFromBlockSuite = { at: 'blocksuite-editor'; docId: string; }; export type DragPayload = { bsEntity?: E; from?: F; }; export type DropPayload = { edge?: Edge; } & T; export type DropEdge = Edge; export interface DNDEntity { basic: DragEntity; } export type DraggableOption = Pick & { /** * Set drag data for the draggable element. * @see {@link ElementGetFeedbackArgs} for callback arguments * @param callback - callback to set drag */ setDragData?: (args: ElementGetFeedbackArgs) => PayloadEntity; /** * Set external drag data for the draggable element. * @param callback - callback to set external drag data * @see {@link ElementGetFeedbackArgs} for callback arguments */ setExternalDragData?: (args: ElementGetFeedbackArgs) => ReturnType['getInitialDataForExternal']>; /** * Set custom drag preview for the draggable element. * * `setDragPreview` is a function that will be called with a `container` element and other drag data as parameter when the drag preview is generating. * Append the custom element to the `container` which will be used to generate the preview. Once the drag preview is generated, the * `container` element and its children will be removed automatically. * * If you want to completely disable the drag preview, just set `setDragPreview` to `false`. * * @example * dnd.draggable({ * // ... * setDragPreview: ({ container }) => { * const preview = document.createElement('div'); * preview.style.width = '100px'; * preview.style.height = '100px'; * preview.style.backgroundColor = 'red'; * preview.innerText = 'Custom Drag Preview'; * container.appendChild(preview); * * return () => { * // do some cleanup * } * } * }) * * @param callback - callback to set custom drag preview * @returns */ setDragPreview?: false | ((options: ElementDragEventBaseArgs> & { /** * Allows you to use the native `setDragImage` function if you want * Although, we recommend using alternative techniques (see element adapter docs) */ nativeSetDragImage: DataTransfer['setDragImage'] | null; container: HTMLElement; setOffset: (offset: 'preserve' | 'center' | { x: number; y: number; }) => void; }) => void | (() => void)); } & ElementDragEventMap, DropPayload>; export type DropTargetOption = { /** * {@link OriginalDropTargetOption.element} */ element: HTMLElement; /** * Allow drop position for the drop target. */ allowDropPosition?: Edge[]; /** * {@link OriginalDropTargetOption.getDropEffect} */ getDropEffect?: (args: ElementDropTargetFeedbackArgs>) => DropTargetRecord['dropEffect']; /** * {@link OriginalDropTargetOption.canDrop} */ canDrop?: (args: ElementDropTargetFeedbackArgs>) => boolean; /** * {@link OriginalDropTargetOption.getData} */ setDropData?: (args: ElementDropTargetFeedbackArgs>) => DropPayload; /** * {@link OriginalDropTargetOption.getIsSticky} */ getIsSticky?: (args: ElementDropTargetFeedbackArgs>) => boolean; } & ElementDropEventMap, DropPayload>; export type MonitorOption = { /** * {@link OriginalMonitorOption.canMonitor} */ canMonitor?: (args: ElementMonitorFeedbackArgs>) => boolean; } & ElementDragEventMap, DropPayload>; export type AutoScroll = { element: HTMLElement; canScroll?: (args: ElementDragEventBaseArgs>) => void; getAllowedAxis?: (args: ElementDragEventBaseArgs>) => ReturnType['getAllowedAxis']>; getConfiguration?: (args: ElementDragEventBaseArgs>) => ReturnType['getConfiguration']>; }; export declare const DndExtensionIdentifier: ServiceIdentifier; export declare class DndController extends LifeCycleWatcher { static key: string; /** * Make an element draggable. */ draggable(args: DraggableOption>): import("@atlaskit/pragmatic-drag-and-drop/types").CleanupFn; /** * Make an element a drop target. */ dropTarget(args: DropTargetOption>): import("@atlaskit/pragmatic-drag-and-drop/types").CleanupFn; monitor(args: MonitorOption>): import("@atlaskit/pragmatic-drag-and-drop/types").CleanupFn; autoScroll(options: AutoScroll): import("@atlaskit/pragmatic-drag-and-drop/types").CleanupFn; } //# sourceMappingURL=index.d.ts.map