summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/shortcuts_issuable.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/shortcuts_issuable.js')
-rw-r--r--app/assets/javascripts/shortcuts_issuable.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/app/assets/javascripts/shortcuts_issuable.js b/app/assets/javascripts/shortcuts_issuable.js
index 426821873d7..e9ede122ab7 100644
--- a/app/assets/javascripts/shortcuts_issuable.js
+++ b/app/assets/javascripts/shortcuts_issuable.js
@@ -39,26 +39,22 @@
}
ShortcutsIssuable.prototype.replyWithSelectedText = function() {
- var quote, replyField, selectedDocument, selected, selection, separator;
- if (!window.getSelection) return;
+ var quote, replyField, documentFragment, selected, separator;
- selection = window.getSelection();
- if (!selection.rangeCount || selection.rangeCount === 0) return;
+ documentFragment = window.gl.CopyAsGFM.getSelectedFragment();
+ if (!documentFragment) return;
- selectedDocument = selection.getRangeAt(0).cloneContents();
- if (!selectedDocument) return;
-
- selected = window.gl.CopyAsGFM.nodeToGFM(selectedDocument);
+ selected = window.gl.CopyAsGFM.nodeToGFM(documentFragment);
replyField = $('.js-main-target-form #note_note');
if (selected.trim() === "") {
return;
}
quote = _.map(selected.split("\n"), function(val) {
- return "> " + val + "\n";
+ return ("> " + val).trim() + "\n";
});
// If replyField already has some content, add a newline before our quote
- separator = replyField.val().trim() !== "" && "\n" || '';
+ separator = replyField.val().trim() !== "" && "\n\n" || '';
replyField.val(function(_, current) {
return current + separator + quote.join('') + "\n";
});