diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index 65df35cae1f..01698d22b56 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -63,7 +63,7 @@ export default DiscourseController.extend({ const composer = this; return this.store.find('post', postId).then(function(post) { - const quote = Discourse.Quote.build(post, post.get("raw")); + const quote = Discourse.Quote.build(post, post.get("raw"), {raw: true, full: true}); composer.appendBlockAtCursor(quote); composer.set('model.loading', false); }); diff --git a/app/assets/javascripts/discourse/lib/quote.js b/app/assets/javascripts/discourse/lib/quote.js index c93cd5a89b1..f6bf7aab286 100644 --- a/app/assets/javascripts/discourse/lib/quote.js +++ b/app/assets/javascripts/discourse/lib/quote.js @@ -3,8 +3,11 @@ Discourse.Quote = { REGEXP: /\[quote=([^\]]*)\]((?:[\s\S](?!\[quote=[^\]]*\]))*?)\[\/quote\]/im, // Build the BBCode quote around the selected text - build: function(post, contents) { + build: function(post, contents, opts) { var contents_hashed, result, sansQuotes, stripped, stripped_hashed, tmp; + var full = opts && opts["full"]; + var raw = opts && opts["raw"]; + if (!contents) contents = ""; sansQuotes = contents.replace(this.REGEXP, '').trim(); @@ -30,8 +33,8 @@ Discourse.Quote = { contents_hashed = contents.replace(/[^a-zA-Z0-9]/g, ''); /* If the quote is the full message, attribute it as such */ - if (stripped_hashed === contents_hashed) result += ", full:true"; - result += "\"]\n" + sansQuotes + "\n[/quote]\n\n"; + if (full || stripped_hashed === contents_hashed) result += ", full:true"; + result += "\"]\n" + (raw ? contents : sansQuotes) + "\n[/quote]\n\n"; return result; } diff --git a/app/assets/javascripts/discourse/models/post.js.es6 b/app/assets/javascripts/discourse/models/post.js.es6 index e424d8111cb..ba3744ec0a5 100644 --- a/app/assets/javascripts/discourse/models/post.js.es6 +++ b/app/assets/javascripts/discourse/models/post.js.es6 @@ -398,7 +398,7 @@ Post.reopenClass({ loadQuote(postId) { return Discourse.ajax("/posts/" + postId + ".json").then(function (result) { const post = Discourse.Post.create(result); - return Discourse.Quote.build(post, post.get('raw')); + return Discourse.Quote.build(post, post.get('raw'), {raw: true, full: true}); }); },