mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: don't strip / mangle full quotes
This commit is contained in:
parent
8bea398cc1
commit
66423e62dc
3 changed files with 8 additions and 5 deletions
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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});
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue