mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 19:01:52 +08:00
FIX: Do not show duplicate_link notice for quotes (#12481)
Quoting a link from the topic would show a false duplicate_link notice.
This commit is contained in:
parent
bcd6efa98c
commit
e48d055232
|
@ -453,8 +453,25 @@ export default Controller.extend({
|
|||
const post = this.get("model.post");
|
||||
const $links = $("a[href]", $preview);
|
||||
$links.each((idx, l) => {
|
||||
const href = $(l).prop("href");
|
||||
const href = l.href;
|
||||
if (href && href.length) {
|
||||
// skip links in quotes
|
||||
for (let element = l; element; element = element.parentElement) {
|
||||
if (
|
||||
element.tagName === "DIV" &&
|
||||
element.classList.contains("d-editor-preview")
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (
|
||||
element.tagName === "ASIDE" &&
|
||||
element.classList.contains("quote")
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const [warn, info] = linkLookup.check(post, href);
|
||||
|
||||
if (warn) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import { run } from "@ember/runloop";
|
|||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import sinon from "sinon";
|
||||
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
|
||||
import LinkLookup from "discourse/lib/link-lookup";
|
||||
|
||||
acceptance("Composer", function (needs) {
|
||||
needs.user();
|
||||
|
@ -934,4 +935,30 @@ acceptance("Composer", function (needs) {
|
|||
"it does not unescapes script tags in code blocks"
|
||||
);
|
||||
});
|
||||
|
||||
test("Shows duplicate_link notice", async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click("#topic-footer-buttons .create");
|
||||
|
||||
this.container.lookup("controller:composer").set(
|
||||
"linkLookup",
|
||||
new LinkLookup({
|
||||
"github.com": {
|
||||
domain: "github.com",
|
||||
username: "system",
|
||||
posted_at: "2021-01-01T12:00:00.000Z",
|
||||
post_number: 1,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
await fillIn(".d-editor-input", "[](https://discourse.org)");
|
||||
assert.equal(find(".composer-popup").length, 0);
|
||||
|
||||
await fillIn(".d-editor-input", "[quote][](https://github.com)[/quote]");
|
||||
assert.equal(find(".composer-popup").length, 0);
|
||||
|
||||
await fillIn(".d-editor-input", "[](https://github.com)");
|
||||
assert.equal(find(".composer-popup").length, 1);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user