-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Custom button insertText() resets cursor position #731
Comments
In a collaborative editor the cursor should stay at the same place when the delta adds content after the cursor. |
Having the same problem, var length = quill.getLength() -1;
quill.insertText(length, a_variable_with_some_test_here ); when I insert text at the end, I need to do Any ideas on how to figure this out? |
setTimeout(function() { quill.insertText('Hello', quill.getLength() - 1) }, 5000); and then placing the cursor anywhere in the quilljs.com editor before the 5000ms is working for me. If you are having issues please file a separate Github Issue and fill out all the details. |
As specified in the API for setTimeout(function() {
quill.insertText( quill.getLength() - 1, 'Hello')
}, 5000); In any case, I've tried it and it seems ok, going to do some more tests to see if I need to raise a separate issue. Thanks! |
Yes that was a typo on my part. |
I'm trying to insert a custom button to add scientific symbols to quilljs ( v1.0.0-beta.4) and when the insertion of the symbol happens in the "middle" of a line, it resets the cursor to the beginning of the line. The problem does not occur when the cursor is at the end of the line.
Steps for Reproduction
I reproduced it on the http://beta.quilljs.com/playground/
$('.add-micro').on("click",function(){ var range = quill.getSelection(!quill.hasFocus()); quill.insertText(range.index,$(this).val(),'','',null,'api'); });
<span class="ql-formats"> <button class="add-micro" value="µ" >µ</button> </span>
Expected behavior:
The cursor should increment its position by the size of the inserted text
Actual behavior:
The cursor moves back to the first position of the line
Platforms:
Chrome 51
The text was updated successfully, but these errors were encountered: