-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
when I enter the first character. calling the getSelection()
gets the index
is 0
#4513
Comments
Each line is incorrect after entering the first character to calling So. I'm dealing with this temporarily cursorIndex.value -= 1;
// 第一行第一个字符光标位置 hack
if (cursorIndex.value < 0) cursorIndex.value = 0;
// 其他行第一个字符光标位置 hack
if (editor!.getText(cursorIndex.value).startsWith("\n")) {
cursorIndex.value += 1;
} |
+1 |
Use delta to determine the location of the character |
What do you means "use delta" ? |
you can actually derive the location from retain and insert's length |
Sorry i'm not sure to clearly understand as i'm not fully expert on quill. Do you have any example to share ? |
@remyBerrebi-fi I'm sorry. I don't understand what you mean . Do you mean ask about my usage scenario? I customize the content block format. display the section when entering So if I get the wrong selection position. I can't accurately delete the previously entered |
Try something like this
|
create a base example for the quill. when I enter the first character. calling the
getSelection()
gets theindex
is0
the code is simple such as:
But. when enter the second character. I can get it's index is
2
.However. when I delete the second character , I can get it's index is
1
This is confusing.
Steps for Reproduction
add some code of the
text-change
eventExpected behavior:
enter the first character. calling
getSelection()
is1
Actual behavior:
now is
0
. But when delete rest one character is1
Platforms:
mac m2 . chrome 131
Version:
quill@2.0.2
The text was updated successfully, but these errors were encountered: