mirror of
https://github.com/friendica/friendica
synced 2025-02-05 17:38:50 +00:00
do not change cursor position while replacing upload-placeholder
fixes #14695 Save caret position just before replacing the upload-placeholder. replace upload-placeholder Set caret position to the position in textarea as before replacing action. Setting caret position considers the position before or after placeholder and therefore the textlength of server-response to find the right place.
This commit is contained in:
parent
47946b1cb7
commit
c47323e358
1 changed files with 7 additions and 1 deletions
|
@ -35,7 +35,13 @@ var DzFactory = function (max_imagesize) {
|
|||
if (targetTextarea.setRangeText) {
|
||||
//if setRangeText function is supported by current browser
|
||||
let u = "[upload-" + file.name + "]";
|
||||
targetTextarea.setRangeText(serverResponse, targetTextarea.value.indexOf(u), targetTextarea.value.indexOf(u) + u.length, "end");
|
||||
let c = targetTextarea.selectionStart;
|
||||
if (c > targetTextarea.value.indexOf(u)) {
|
||||
c = c + serverResponse.length - u.length;
|
||||
}
|
||||
targetTextarea.setRangeText(serverResponse, targetTextarea.value.indexOf(u), targetTextarea.value.indexOf(u) + u.length);
|
||||
targetTextarea.selectionStart = c;
|
||||
targetTextarea.selectionEnd = c;
|
||||
} else {
|
||||
targetTextarea.focus();
|
||||
document.execCommand('insertText', false /*no UI*/, serverResponse);
|
||||
|
|
Loading…
Add table
Reference in a new issue