-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
update insertText logic when selection is not collapsed #4804
Conversation
🦋 Changeset detectedLatest commit: 0552d9e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @suilang . I'm not sure if it matters here, but have you checked selecting in reverse to make sure we don't break due to the direction of the selection (some parts of the codebase are good about reversing the selection and some are not).
@dylans Thank reply. You mean selecting text from back to front? In there i use |
The error is because with a selection like that the range This PR gave me a bad feeling but I didn't have time to confirm whether it was a mistake. Thank you @imbolo for confirming it is. @dylans we need to revert. I don't know if there's a nice way to fix OP's problem. Maybe a smarter way to pick whether to use the start or end ref? Or perhaps just store two point refs for start and end if start becomes null use the end. |
Also experiencing errors with this in production. We've reverted back to 0.72.3. |
…tion it caused
Reverted as noted above. Hopefully we can find a better solution for the issue identified in this original PR without breaking other behavior. |
@TheSpyder @dylans I'm sorry it happened. like you say, the paragraph is deleted. I still think the cursor should be placed at the starting position. As the picture above shows, The text style should be the same as before I have fix this error, by store two point refs for start and end . like this,
I am not sure whether I should submit the PR again. I hope to get your opinion |
@suilang it's ok, rich text editing is not easy. Feel free to raise a new PR with tests and we'll evaluate it. |
…or#4804) * update insertText logic when selection is not collapsed * add changeset * fix bug when end of range is void Co-authored-by: zhangpengcheng15 <zhangpengcheng15@jd.com>
Description
When I select a paragraph with different styles of text, for example, bold and plain, and then insert the letter q. What I want is to insert a non-bold letter.
Example
this is old code, the q is bold
this is new code, the q is normal
Context
Normally, when we insert the character q between unbold and bold, it is unbold. the style use position of anchor. but when selection is not collapsed, selection be set by focus or end of range.
The processing logic is inconsistent for different actions. also, the cursor should be placed at the starting position. If the deleted area has elements that cannot be deleted, like table, the cursor position will be incorrect
Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)