fix: set cursor inside block after input rule #2345
+9
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix cursor position after creating a block via input rules (e.g., typing ``` + space for code block). Previously, the cursor would move to the next paragraph instead of inside the newly created block.
Rationale
When users type ``` followed by a space to create a code block, they expect the cursor to be positioned inside the code block so they can immediately start typing code. However, the cursor was incorrectly placed in the paragraph below the code block, requiring users to manually click inside the code block to start typing.
Changes
Impact
Testing
Screenshots/Video
before
https://github.com/user-attachments/assets/1aeb3742-fbff-428b-8616-a21096f72b47
after
https://github.com/user-attachments/assets/7c683737-e823-4a16-b969-b7f237f0b5ef
Checklist
Additional Notes
Related issue: The comment in updateBlock.ts:255-258 mentions that selection should be reset after replaceWith, but this was not implemented. This PR addresses that by handling it in the input rule handler.