You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the Editor.unhangRange method returns a path that does not include the image. So when Transforms.delete was deleted, it was not deleted.
The second case:
The "at" path returned seems to be correct, and through the debugging panel on the right, you can see that the text of the first element in editor.children is empty, indicating that Transforms.delete has worked, but the image element is still there.
Then look at it with the right example
Below the image followed by a paragraph with text, you can see that it works as expected
Summarize
So in the end, I concluded that the first one is Editor.unhangRange which seems to have some problems, because in the first case it returns a Path that does not meet the expectations. But I'm not sure why this is happening. I also studied the source code of unhangRange and found that this may be the problem. It only matches text. But I don’t fully understand what this intention is, so I don’t dare to modify the source code easily.
The second one is that I suspect that Transforms.delete also has some problems, because judging from the second example, it returns the correct Path, but it is not exactly as expected. The only difference between it and the normal situation is the offest in Path
I tried to solve these problems, but found some difficulties because I didn't fully understand the specific logic of these functions. So if anyone has any ideas I would be grateful, thank you 🙏
The text was updated successfully, but these errors were encountered:
Description
Prerequisite: the last content is an image (or other block element)
There are two situations:
Recording
https://github.com/ianstormtaylor/slate/assets/120485290/f2be67c6-1277-4222-8af8-9a92aad7ee70
https://github.com/ianstormtaylor/slate/assets/120485290/f75067d0-562a-4e41-a08c-13b745f99022
Steps
After carefully studying and tracing the code, I found that the problem occurred in the insertFragment function.
The first case:
slate/packages/slate/src/transforms-text/insert-fragment.ts
Line 26 in d271c4b
It seems that the Editor.unhangRange method returns a path that does not include the image. So when Transforms.delete was deleted, it was not deleted.
The second case:
The "at" path returned seems to be correct, and through the debugging panel on the right, you can see that the text of the first element in editor.children is empty, indicating that Transforms.delete has worked, but the image element is still there.
slate/packages/slate/src/transforms-text/insert-fragment.ts
Line 39 in d271c4b
Then look at it with the right example
Below the image followed by a paragraph with text, you can see that it works as expected
Summarize
So in the end, I concluded that the first one is Editor.unhangRange which seems to have some problems, because in the first case it returns a Path that does not meet the expectations. But I'm not sure why this is happening. I also studied the source code of unhangRange and found that this may be the problem. It only matches text. But I don’t fully understand what this intention is, so I don’t dare to modify the source code easily.
slate/packages/slate/src/editor/unhang-range.ts
Lines 34 to 40 in d271c4b
The second one is that I suspect that Transforms.delete also has some problems, because judging from the second example, it returns the correct Path, but it is not exactly as expected. The only difference between it and the normal situation is the offest in Path
I tried to solve these problems, but found some difficulties because I didn't fully understand the specific logic of these functions. So if anyone has any ideas I would be grateful, thank you 🙏
The text was updated successfully, but these errors were encountered: