Cannot distinguish paste vs. drag behavior in transformPasted

Hi Marijn,

I’ve found that after updating to commit 90a8bfbf3989febaf83dee41b0c089385567a921, drop events now unexpectedly trigger transformPasted in my implementation. To handle this, I need to skip certain transformPasted logic specifically for drop events, but there’s no way to distinguish between paste and drag actions in the current implementation.

Potential Solutions:

  1. Defer null assignment: Set view.dragging = null after executing transformPasted in the paste handler, enabling drag state detection during transform.

  2. Modify deletion order: Execute tr.deleteSelection() before transformPasted for drag operations. This better aligns with the drag’s “cut-paste” nature (vs. “copy-paste”), as the source content is removed first.

What kind of transformation are you applying that needs to be done for regular paste but not drop?

I defined “id” attribute in node schema, and need to make sure ids in the doc remain unique. In transformPasted, I check for duplicate node ids between the slice and the doc - if there’s a duplicate, I assign a new id. This way, when cutting and pasting, the id stays the same, but when copying and pasting, the id changes (which is what I want).However, the problem is that dragging causes the id to change too, which isn’t what I expected.

That makes sense. This patch moves the clearing of view.dragging to happen only after the drop event has been handled.

3 Likes