volto icon indicating copy to clipboard operation
volto copied to clipboard

feat: add custom drag layer for enhanced drag-and-drop experience in editor

Open rboixaderg opened this issue 7 months ago • 0 comments

[!CAUTION] The Volto Team has suspended its review of new pull requests from first-time contributors until the release of Plone 7, which is preliminarily scheduled for the second quarter of 2026. Read details.



If your pull request closes an open issue, include the exact text below, immediately followed by the issue number. When your pull request gets merged, then that issue will close automatically.

Closes #


Notes:

  • Introduced CustomDragLayer component to visually represent items being dragged.
  • Integrated CustomDragLayer into PlateEditor for improved user feedback during drag operations.
  • Updated Draggable component to support drag previews and adjusted styles for better UI consistency.

The CustomDragLayer component currently renders only a text-element preview, just to show how we can override the browser’s default drag-and-drop preview. If you want the preview to show the actual content being dragged, you can:

Give the element a type prop when you render it in the editor.

Inside CustomDragLayer, read that type and render the same (or any other) component accordingly.

References Assign a type to the element you’re rendering

https://platejs.org/docs/dnd#usedraggable-opt-type

Read the type in the drag layer to decide what to render in the preview monitor.getItemType():

const { isDragging, item, itemType, currentOffset } = useDragLayer((monitor) => ({
  item: monitor.getItem(),
  itemType: monitor.getItemType(),
  isDragging: monitor.isDragging(),
  currentOffset: monitor.getClientOffset(),
}));

rboixaderg avatar May 30 '25 10:05 rboixaderg