Skip to content

Files dropped in between text nodes result in blocks 1 position lower then the original drop point #1851

Description

@kruszczynski

Describe the bug

Dropping images after text blocks works fine:

Screen.Recording.2025-07-16.at.18.44.12.mov

However if you drop the image between the text blocks it uploads in a wrong place, 1 too far.

Screen.Recording.2025-07-16.at.18.44.31.mov

My guess is that the following lines in getNearestBlockPos can be related to this.

if ($pos.nodeAfter && $pos.nodeAfter.type.isInGroup("bnBlock")) {
return {
posBeforeNode: $pos.pos,
node: $pos.nodeAfter,
};
}

I'll try to come up with a fix, I welcome all advice.

To Reproduce

I've created a stackblitz. It's base template with 2 paragraphs and a css file that adds margin in between to help illustrate the point.

https://stackblitz.com/edit/github-js2gzz96?file=App.tsx

Just upload any image or file like in the videos above to reproduce

Misc

  • Node version: Reproduces locally on Bun and on stackblitz
  • Package manager:
  • Browser:
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖

Activity

  1. kruszczynski commented on Jul 18, 2025

    @kruszczynski
    Author

    @nperez0111 this still occurs on v0.34 - I've updated the stackblitz from the description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions