diff options
author | Phil Hughes <me@iamphill.com> | 2016-12-19 15:26:10 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-12-21 11:32:41 +0000 |
commit | a713a29aadd2908c0ad7079f5b24033736a96d9c (patch) | |
tree | c2773cf4a9819043a555f6dd8b25499210e40454 /app/assets | |
parent | fecebc7991283e5f9aff89119bb2e4dcde9deeab (diff) | |
download | gitlab-ce-a713a29aadd2908c0ad7079f5b24033736a96d9c.tar.gz |
Fixed first newline not workingmarkdown-button-newline-bug-fix
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/lib/utils/text_utility.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js index cf286dc30ee..5066e3282d7 100644 --- a/app/assets/javascripts/lib/utils/text_utility.js +++ b/app/assets/javascripts/lib/utils/text_utility.js @@ -44,8 +44,15 @@ } }; gl.text.insertText = function(textArea, text, tag, blockTag, selected, wrap) { - var insertText, inserted, selectedSplit, startChar, removedLastNewLine; + var insertText, inserted, selectedSplit, startChar, removedLastNewLine, removedFirstNewLine; removedLastNewLine = false; + removedFirstNewLine = false; + + // Remove the first newline + if (selected.indexOf('\n') === 0) { + removedFirstNewLine = true; + selected = selected.replace(/\n+/, ''); + } // Remove the last newline if (textArea.selectionEnd - textArea.selectionStart > selected.replace(/\n$/, '').length) { @@ -72,6 +79,10 @@ insertText = "" + startChar + tag + selected + (wrap ? tag : ' '); } + if (removedFirstNewLine) { + insertText = '\n' + insertText; + } + if (removedLastNewLine) { insertText += '\n'; } |