Repository navigation
v1.8.0
Minor Changes
-
25ff1b8: Add
useDragCopy— a headless React hook that makes any element draggable and populates itsDataTransferwith structured data ondragstart.Features:
- Structured payloads —
text,html(with plain-text fallback),json, andmulti(arbitrary MIME types). - Zero Clipboard API — works in every browser that supports HTML5 drag-and-drop.
- Always-fresh source — the
sourcecallback reads the latest props/state on every drag, never stale closures. enabledprop — removedraggableand the listener without unmounting; status resets toidle.effectAllowed— controls the browser drag cursor and permitted drop effects.onDragStartprop path — stable callback for use inside render-prop components or when the native listener alone isn't enough.- SSR-safe — no DOM access during server rendering;
draggableis never set on the server. - Framework-agnostic core —
applyDragCopyandregisterDragCopyare also exported fromreact-smart-copy/core.
const { ref } = useDragCopy({ source: () => ({ kind: 'html', html: '<b>Hello</b>', text: 'Hello' }), effectAllowed: 'copy', }); return <div ref={ref}>Drag me</div>;
- Structured payloads —