mirror of
https://github.com/discourse/discourse.git
synced 2025-02-28 08:19:13 +00:00
FIX: don't strip / mangle full quotes
This commit is contained in:
parent
8bea398cc1
commit
66423e62dc
@ -63,7 +63,7 @@ export default DiscourseController.extend({
|
|||||||
const composer = this;
|
const composer = this;
|
||||||
|
|
||||||
return this.store.find('post', postId).then(function(post) {
|
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.appendBlockAtCursor(quote);
|
||||||
composer.set('model.loading', false);
|
composer.set('model.loading', false);
|
||||||
});
|
});
|
||||||
|
@ -3,8 +3,11 @@ Discourse.Quote = {
|
|||||||
REGEXP: /\[quote=([^\]]*)\]((?:[\s\S](?!\[quote=[^\]]*\]))*?)\[\/quote\]/im,
|
REGEXP: /\[quote=([^\]]*)\]((?:[\s\S](?!\[quote=[^\]]*\]))*?)\[\/quote\]/im,
|
||||||
|
|
||||||
// Build the BBCode quote around the selected text
|
// 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 contents_hashed, result, sansQuotes, stripped, stripped_hashed, tmp;
|
||||||
|
var full = opts && opts["full"];
|
||||||
|
var raw = opts && opts["raw"];
|
||||||
|
|
||||||
if (!contents) contents = "";
|
if (!contents) contents = "";
|
||||||
|
|
||||||
sansQuotes = contents.replace(this.REGEXP, '').trim();
|
sansQuotes = contents.replace(this.REGEXP, '').trim();
|
||||||
@ -30,8 +33,8 @@ Discourse.Quote = {
|
|||||||
contents_hashed = contents.replace(/[^a-zA-Z0-9]/g, '');
|
contents_hashed = contents.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
|
|
||||||
/* If the quote is the full message, attribute it as such */
|
/* If the quote is the full message, attribute it as such */
|
||||||
if (stripped_hashed === contents_hashed) result += ", full:true";
|
if (full || stripped_hashed === contents_hashed) result += ", full:true";
|
||||||
result += "\"]\n" + sansQuotes + "\n[/quote]\n\n";
|
result += "\"]\n" + (raw ? contents : sansQuotes) + "\n[/quote]\n\n";
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,7 @@ Post.reopenClass({
|
|||||||
loadQuote(postId) {
|
loadQuote(postId) {
|
||||||
return Discourse.ajax("/posts/" + postId + ".json").then(function (result) {
|
return Discourse.ajax("/posts/" + postId + ".json").then(function (result) {
|
||||||
const post = Discourse.Post.create(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…
x
Reference in New Issue
Block a user