Conversation
gohabereg
approved these changes
Jun 20, 2024
Member
gohabereg
left a comment
There was a problem hiding this comment.
Looks good overall, just a minor comment
| "navigator": true | ||
| }, | ||
| "rules": { | ||
| "jsdoc/require-returns-type": "off" |
src/components/modules/caret.ts
Outdated
| } | ||
|
|
||
| const { nextInput, currentInput } = currentBlock; | ||
| const isAtEnd = currentInput !== undefined ? caretUtils.isAtEndOfInput(currentInput) : undefined; |
Member
There was a problem hiding this comment.
Similar expression is used several times, maybe worth to extract it to a function. Or allow caret utils to accept undefined
Member
Author
There was a problem hiding this comment.
I believe that utility methods like isAtStartOfInput() should not handle case when input is undefined . Module should explicitly handle the cases when block has no inputs or there is no currentBlock at all since it is a part of business logic.
TatianaFomina
approved these changes
Jun 25, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
If block starts with several spaces, they can't be deleted. Caret jumps to the previous block.
Resolves #2429
Resolves #1382
Resolves #1179
Resolves #2521
Cause
There are two whitespace handling in HTML
Our
Caret.isAtStartmethod covers only case №1 and treats all whitespaces like "empty".Solution
I've rewrote
isAtStart()andisAtEnd()methods.this.BlockManagerhas been removed. Now methods acceptinputas argument. (so we'll be able to expose them to the api or some package)isAtEndOfInput()) to the caret position, clone its content to the temporary div and check its textContentisCollapsedWhitespaces()is used for it.