Skip to content

Dropcursor

Dropcursor shows a visual line when dragging content over the editor, indicating where the content will be dropped. It renders a horizontal bar for block-level drops and a vertical line for inline drops.

Included in StarterKit by default.

Dropcursor is included in StarterKit, so it works out of the box. To use it standalone:

import { Editor, Document, Paragraph, Text, Dropcursor } from '@domternal/core';
import '@domternal/theme';
const editor = new Editor({
element: document.getElementById('editor')!,
extensions: [Document, Paragraph, Text, Dropcursor],
content: '<p>Drag content over the editor to see the drop cursor.</p>',
});

To configure Dropcursor in StarterKit:

StarterKit.configure({
dropcursor: { color: '#3b82f6', width: 2 },
})

To disable Dropcursor in StarterKit:

StarterKit.configure({ dropcursor: false })
OptionTypeDefaultDescription
colorstring'currentColor'CSS color of the drop cursor line
widthnumber1Width of the drop cursor line in pixels
classstringundefinedCSS class name added to the drop cursor element
import { Dropcursor } from '@domternal/core';
const editor = new Editor({
extensions: [
Dropcursor.configure({
color: '#3b82f6',
width: 2,
class: 'my-drop-cursor',
}),
],
});

Dropcursor does not register any commands.

Dropcursor does not register any keyboard shortcuts.

Dropcursor does not register any input rules.

Dropcursor does not register any toolbar items.

Dropcursor creates a ProseMirror dropCursor() plugin that listens for four DOM events on the editor:

  • dragover - calculates the drop position using ProseMirror’s coordinate system and shows/updates the cursor element. The cursor auto-removes after 5 seconds if the drag stalls.
  • dragleave - hides the cursor immediately when the drag leaves the editor area
  • dragend - removes the cursor after a 20ms delay when the drag ends
  • drop - removes the cursor after a 20ms delay when content is dropped

The cursor is a simple <div> element with absolute positioning (z-index: 50) and pointer-events: none so it does not interfere with the drag operation. It is appended to the editor’s offset parent, not rendered as a ProseMirror decoration.

The cursor renders differently depending on the drop target:

  • Block drops (between paragraphs, headings, etc.) - a horizontal bar spanning the full width of the editor. The CSS class prosemirror-dropcursor-block is added.
  • Inline drops (within a text node) - a vertical line at the cursor position. The CSS class prosemirror-dropcursor-inline is added.

Individual node types can disable the drop cursor by setting disableDropCursor in their ProseMirror node spec:

// Static: always disable
{ disableDropCursor: true }
// Dynamic: disable based on context
{ disableDropCursor: (view, pos, event) => /* ... */ }
import { Dropcursor } from '@domternal/core';
import type { DropcursorOptions } from '@domternal/core';
ExportTypeDescription
DropcursorExtensionThe dropcursor extension
DropcursorOptionsTypeScript typeOptions for Dropcursor.configure()

@domternal/core - Dropcursor.ts