mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Quoting posts (#9378)
Fixes to the quote feature. Most important changes listed below:
* FIX: Correctly attribute quotes when using Reply button
* FIX: Correctly attribute quotes when using replyAsNewTopic
* FIX: Allow quoting a quote
* FIX: Correctly mark quotes as "full"
* FIX: Don't try to create a quote if it's empty
* DEV: Remove an obsolete method `loadQuote`
It isn't used in core anymore, the only use in core has been removed over 4 years ago in 3251bcb. It's not used in any plugins in all-the-plugins and all references to it on GitHub are from outdated forks (https://github.com/search?q=%22Post.loadQuote%22&type=Code)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import Quote from "discourse/lib/quote";
|
||||
import { buildQuote } from "discourse/lib/quote";
|
||||
import Post from "discourse/models/post";
|
||||
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||
@@ -1289,8 +1289,8 @@ QUnit.test("quotes", assert => {
|
||||
topic_id: 2
|
||||
});
|
||||
|
||||
function formatQuote(val, expected, text) {
|
||||
assert.equal(Quote.build(post, val), expected, text);
|
||||
function formatQuote(val, expected, text, opts) {
|
||||
assert.equal(buildQuote(post, val, opts), expected, text);
|
||||
}
|
||||
|
||||
formatQuote(undefined, "", "empty string for undefined content");
|
||||
@@ -1312,12 +1312,13 @@ QUnit.test("quotes", assert => {
|
||||
formatQuote(
|
||||
"lorem ipsum",
|
||||
'[quote="eviltrout, post:1, topic:2, full:true"]\nlorem ipsum\n[/quote]\n\n',
|
||||
"marks quotes as full when the quote is the full message"
|
||||
"marks quotes as full if the `full` option is passed",
|
||||
{ full: true }
|
||||
);
|
||||
|
||||
formatQuote(
|
||||
"**lorem** ipsum",
|
||||
'[quote="eviltrout, post:1, topic:2, full:true"]\n**lorem** ipsum\n[/quote]\n\n',
|
||||
'[quote="eviltrout, post:1, topic:2"]\n**lorem** ipsum\n[/quote]\n\n',
|
||||
"keeps BBCode formatting"
|
||||
);
|
||||
|
||||
@@ -1340,6 +1341,28 @@ QUnit.test("quotes", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("quoting a quote", assert => {
|
||||
const post = Post.create({
|
||||
cooked: new PrettyText(defaultOpts).cook(
|
||||
'[quote="sam, post:1, topic:1, full:true"]\nhello\n[/quote]\n*Test*'
|
||||
),
|
||||
username: "eviltrout",
|
||||
post_number: 1,
|
||||
topic_id: 2
|
||||
});
|
||||
|
||||
const quote = buildQuote(
|
||||
post,
|
||||
'[quote="sam, post:1, topic:1, full:true"]\nhello\n[/quote]'
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
quote,
|
||||
'[quote="eviltrout, post:1, topic:2"]\n[quote="sam, post:1, topic:1, full:true"]\nhello\n[/quote]\n[/quote]\n\n',
|
||||
"allows quoting a quote"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("quote formatting", assert => {
|
||||
assert.cooked(
|
||||
'[quote="EvilTrout, post:123, topic:456, full:true"]\n[sam]\n[/quote]',
|
||||
|
||||
Reference in New Issue
Block a user