udecode / plate

Rich-text editor with shadcn
https://platejs.org
Other
10.33k stars 640 forks source link

Select half of the image then delete (backspace) broke editor #2883

Open ngoctu-bic opened 8 months ago

ngoctu-bic commented 8 months ago

Description

Steps to Reproduce

  1. Select a text below the image
  2. Move cursor so that select half of the image (not trigger image selected state)
  3. Press backspace

https://github.com/udecode/plate/assets/129946813/e821d29c-1c21-4a37-a036-2fb3fff14675

Sandbox

This could be reproduce using demo editor on platejs.org

Expected Behavior

TBD

Environment

Bounty

Click here to add a bounty via Algora.

Funding

Fund with Polar

Zum-Gluck commented 7 months ago

The selection may have some wrong which look like a point should be a range, Is there someone give me some advice to fix it?

12joan commented 7 months ago

This is a bug in slate-react. Related issues: https://github.com/ianstormtaylor/slate/issues/5435, https://github.com/ianstormtaylor/slate/pull/5451.

The error occurs inside toSlatePoint, where the anchorNode has been passed in from toSlateRange as a span HTMLElement instead of a Text node.

xHati44 commented 7 months ago

Same issue. It also happens when you select text and also an image until the drag handles show up. How can I prevent it from crashing the page?