diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:08:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:08:48 +0000 |
commit | f7dae0cdcb70ecb71c1d65f099e9d96b27a4548c (patch) | |
tree | e53baffa847c4fd37c8e335e4d93d603c75f9f02 /app/assets/javascripts/dropzone_input.js | |
parent | b98fa9ef3d5bead417ae2f325cb64637883264e9 (diff) | |
download | gitlab-ce-f7dae0cdcb70ecb71c1d65f099e9d96b27a4548c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/dropzone_input.js')
-rw-r--r-- | app/assets/javascripts/dropzone_input.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/assets/javascripts/dropzone_input.js b/app/assets/javascripts/dropzone_input.js index 86590865892..0e2dd59092a 100644 --- a/app/assets/javascripts/dropzone_input.js +++ b/app/assets/javascripts/dropzone_input.js @@ -259,8 +259,15 @@ export default function dropzoneInput(form) { const insertToTextArea = (filename, url) => { const $child = $(child); - $child.val((index, val) => val.replace(`{{${filename}}}`, url)); - + const textarea = $child.get(0); + const caretStart = textarea.selectionStart; + const caretEnd = textarea.selectionEnd; + const formattedText = `{{${filename}}}`; + $child.val((index, val) => val.replace(formattedText, url)); + textarea.setSelectionRange( + caretStart - formattedText.length + url.length, + caretEnd - formattedText.length + url.length, + ); $child.trigger('change'); }; |