Skip to content
GitHubDiscord

prosekit/extensions/drop-indicator

Options for defineDropIndicator.

onShow?: ShowHandler

A callback that is called when the drop indicator should be shown.

onHide?: VoidFunction

A callback that is called when the drop indicator should be hidden.

onDrag?: DragEventHandler

A callback that is called when the dragover event is fired. You can return false to disable the current drop point and thus hide the drop indicator.


Options for DragEventHandler.

view: EditorView

The editor's view.

pos: number

The drop position in current document.

event: DragEvent

The dragover event.


Options for ShowHandler.

view: EditorView

The editor's view.

pos: number

The ProseMirror position that the drop indicator should be shown at.

line: Line

The line that the drop indicator should be shown at.

type DragEventHandler = (options: DragEventHandlerOptions) => boolean

A function that will be called when the dragover event is fired. You can return false to disable the current drop point and thus hide the drop indicator.


type ShowHandler = (options: ShowHandlerOptions) => void

A function that will be called when the drop indicator should be shown.

function defineDropIndicator(options?: DropIndicatorOptions): PlainExtension

Defines an extension that controls the behavior of the drop indicator.

This extension itself doesn't draw the drop indicator, but it provides the necessary callbacks to do so. You probably don't want to use this extension directly, but rather use the <DropIndicator> component.

You can add this extension multiple times. If any extension has onDrag callback defined, and it returns false, then the drop point will be discarded.