FIX: ensures placeholders works in lists (#63)

Prior to this fix the following cases wouldn't work:
- nested lists
- a link in a list
This commit is contained in:
Joffrey JAFFEUX
2025-09-29 15:40:42 +02:00
committed by GitHub
parent a3c2edf721
commit e0234b5e0b
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import DiscoursePlaceholderBuilder from "../components/modal/discourse-placeholder-builder";
const VALID_TAGS =
"h1, h2, h3, h4, h5, h6, p, code, blockquote, .md-table, li p";
"h1, h2, h3, h4, h5, h6, p, code, blockquote, .md-table, li, li > *";
const DELIMITER = "=";
const EXPIRE_AFTER_DAYS = 7;
const EXPIRE_AFTER_SECONDS = EXPIRE_AFTER_DAYS * 24 * 60 * 60;
+22
View File
@@ -68,5 +68,27 @@ RSpec.describe "Placeholder", system: true do
expect(page).to have_link(href: "https://example.com/bar")
end
context "when placeholder is used in a[href] of list item" do
fab!(:post) { Fabricate(:post, raw: <<~MD) }
[wrap=placeholder key=\"TEST1\"][/wrap]
- test
- [Some link](https://example.com/=TEST1=)
MD
it "replaces string in href" do
topic_page.visit_topic(post.topic)
expect(page).to have_link(href: "https://example.com/=TEST1=")
page.find('.discourse-placeholder-value[data-key="TEST1"]').fill_in(with: "foo")
expect(page).to have_link(href: "https://example.com/foo")
page.find('.discourse-placeholder-value[data-key="TEST1"]').fill_in(with: "bar")
expect(page).to have_link(href: "https://example.com/bar")
end
end
end
end