# Dragging whole Paragraphs leaves empty Paragraph

**URL:** <https://discuss.prosemirror.net/t/dragging-whole-paragraphs-leaves-empty-paragraph/8544>\
**Category:** Uncategorized\
**Created:** [September 1, 2025, 8:51am UTC](https://discuss.prosemirror.net/t/dragging-whole-paragraphs-leaves-empty-paragraph/8544 "2025-09-01T08:51:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlyingMonkey](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/f/96bed5/32.png) [@FlyingMonkey](https://discuss.prosemirror.net/u/FlyingMonkey)\
**Post date:** [September 1, 2025, 8:51am UTC](https://discuss.prosemirror.net/t/dragging-whole-paragraphs-leaves-empty-paragraph/8544/1 "2025-09-01T08:51:13Z")

</div>

Hey, I’m working on a project where I want to remove a paragraph if the whole content has been selected and moved (eg drag&drop).

Currently an empty paragraph, with the standard break for later editing, remains but I want it gone too. I wrote a plugin for that which works for all but one case: moving the node to the end

```ts
handleDrop: (view: EditorView, _event: DragEvent, slice: Slice, moved: boolean) => {
                    if (!moved) return false;
                    const {
                        selection: { from, to },
                        doc,
                        tr,
                    } = view.state;
                    const first = doc.resolve(from).node();
                    const last = doc.resolve(to).node();
                    const firstMovedNode = slice.content.child(0);
                    const lastMovedNode = slice.content.child(slice.content.childCount - 1);
                    if (first.nodeSize === firstMovedNode.nodeSize && last.nodeSize === lastMovedNode.nodeSize) {
                        /*
                            we know:
                            - it's a move
                            - the first and last nodes are the same size
                                -> may be the same if only 1 node is moved

                            => we assume whole nodes have been moved
                         */
                        view.dispatch(tr.delete(from - 1, to + 1));
                    }
                    return false;
                },

```

when moving to the doc end I get an OutOfRange Error. Most likely because of the tr.delete which somehow gets handled before the drop-handler is done. Thus the drop position does not exist anymore.

Is there an easier way to have the whole paragraph removed automagically via schema magic?

Greetings

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [September 2, 2025, 2:36pm UTC](https://discuss.prosemirror.net/t/dragging-whole-paragraphs-leaves-empty-paragraph/8544/2 "2025-09-02T14:36:56Z")

</div>

When `handleDrop` returns `false` it is assumed to not have messed with the editor state. You’ll need to handle the insertion as well and return `true` from the handler.
