Skip to content

unexpected copy-paste behavior of nested block #1651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task
YKX-A opened this issue Apr 30, 2025 · 1 comment
Open
1 task

unexpected copy-paste behavior of nested block #1651

YKX-A opened this issue Apr 30, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@YKX-A
Copy link

YKX-A commented Apr 30, 2025

Describe the bug
Perhaps this is not really a bug.

when we copy something like this


- 1
    - | 2
- 3 |

-> paste here

"|" means the cursor positon

Paste it in the "top-level" place, then nothing happens, but if you paste it into a nested place like 2-level or deeper, it's fine.

The general rule here seems to be that, let's define selection = [start, end], when the start_depth > end_depth (like in the first example, "2"'s depth is 2 while "3"'s depth is 1), then you can only have the expected behavior when the paste_cursor_depth >= start_depth.

This issue can be simply reproduced in the BlockNote playground

Image

after pasted, nothing happen

Image

more example, copy these content and paste it also won't work

Image

I think this makes sense to some extent. When you paste this content, if the "2" is supposed to be at the top level (which we define as depth = 1), then the "3" would need to be at level 0 (or event -1 / -2 ... when there are more nested structures), which is impossible.

I think maybe one of the better behaviors is that we adjust the nest structure to make it able to adapt to the target position. For example, in the first case, we could adjust and paste it as flattened content if it violates the rule (paste_cursor_depth should >= start_depth).

- 2
- 3

To Reproduce
This issue can be simply reproduced in the BlockNote playground.

Misc

  • Node version:
  • Package manager: latest
  • Browser: chrome
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖
@YKX-A YKX-A added the bug Something isn't working label Apr 30, 2025
@Paarth-K
Copy link

Paarth-K commented May 5, 2025

The same thing happens when you try and parse the blocks from HTML, using editor.tryParseHTMLToBlocks. Everything seems to get indented. #1643 is a similar bug to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants