diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-05-24 13:02:17 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-05-24 13:02:17 +0300 |
commit | b39b02d4a422ca240916a28bb4600a3a741b6194 (patch) | |
tree | 929cad643e3bc8dc8585578237bded93a83b2972 /app/assets/javascripts/lib | |
parent | 4c78eff2e32ce09fb9d0bc87e89a321b795543c2 (diff) | |
parent | 6127192783171f6fc2b64c674dd21d0544b62707 (diff) |
Merge branch 'dm-paste-code-inside-gfm-code' into 'master'
Don't wrap pasted code when it's already inside code tags
Closes #32507
See merge request !11524
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 7e62773ae6c..a537267643e 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -198,10 +198,12 @@ const textBefore = value.substring(0, selectionStart); const textAfter = value.substring(selectionEnd, value.length); - const newText = textBefore + text + textAfter; + + const insertedText = text instanceof Function ? text(textBefore, textAfter) : text; + const newText = textBefore + insertedText + textAfter; target.value = newText; - target.selectionStart = target.selectionEnd = selectionStart + text.length; + target.selectionStart = target.selectionEnd = selectionStart + insertedText.length; // Trigger autosave $(target).trigger('input'); |