Commit 82197e99 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'fixes-caret-position-after-pasting-an-image-15011' into 'master'

Fixes caret position after pasting an image #15011

See merge request gitlab-org/gitlab!21382
parents c58d90fe 1247cef0
......@@ -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');
};
......
---
title: Fixes caret position after pasting an image 15011
merge_request: 21382
author: Carolina Carvalhosa
type: fixed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment