fix: cursor jumping at the beginning#371
Conversation
danoaky-tiny
left a comment
There was a problem hiding this comment.
It'd be nice to have a test for this in FormControlTest.ts. Thanks for the fix!
|
Sure, I fixed your tests and also added a test related to my fix. |
|
Ah thank you. #367 also has a fix for this failing test. Once that's merged I'll rereview |
|
Hi! Is there any plan to incorporate this fix soon? Thank you |
|
@davidediak This needs a merge from main. Just to do with the tests, won't need much change from you. |
|
@danoaky-tiny sure, done. |
|
Hello davidediak, Thank you for your code contribution, in order for Tiny Inc to accept your code, we will need permission to use your code contribution, this can be done through the Tiny Contributor License Agreement (Tiny CLA). Please contact legal@tiny.cloud to sign the Tiny CLA agreement. |
|
@EkimChau you have my permission to use my code, given the fact that I spent time fixing the bug and did open a PR. |
|
This is clearly stated in the contributing guide. We don't have an automated system for it at the moment. tinymce-angular/CONTRIBUTING.md Line 8 in 5bcfde8 The CLA protects us, our open-source community and our customers from the distribution of unauthorised code. It's non-negotiable, sorry. |
|
Btw guys, you can copy-paste my changes and open another PR, I won't mind. |
|
@davidediak I‘ll use your PR if it looks good to me once I fork the Angular integration for my HugeRTE fork of TinyMCE. |
There was a problem hiding this comment.
const cursor = this._editor.selection.getBookmark(3) as any
if (cursor['start'] && cursor['start'].startsWith('text()')) {
// do nothing because the cursor initially jumps back to first line with 'text()'
// while pasting in text from outside; moving to this bookmark after set content
// creates this cursor jump which should be avoided;
// if you paste in text from inside the editor or write text by keyboard
// the cursor starts with a paragraph tag created by TMCE like
// 'p[element_index]/text()[0]'
} else {
this._editor.setContent(isNullOrUndefined(value) ? '' : value);
try {
this._editor.selection.moveToBookmark(cursor);
} catch (e) {
/* ignore */
}
}
https: //github.com/tinymce/tinymce-angular/pull/371/commits/3c7808e44637cf63977adea04f5eebbfb189db83 Change-Id: I18e9bd812bb5f9e99765c2d8d9bb5fad199956f4 Reviewed-on: https://forge.frm2.tum.de/review/c/mlz/eln/frontend/+/36616 Reviewed-by: Wojian Wang <wojian.wang@frm2.tum.de> Tested-by: Wojian Wang <wojian.wang@frm2.tum.de>
#321