mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 05:47:45 +08:00
FIX: allows to use open attribute with details (#29116)
Supporting `open` allows to show a `details` block open by default. Usage: ``` [details open] my visible content [/details] ```
This commit is contained in:
parent
85774cc214
commit
fd15562939
|
@ -2,9 +2,13 @@ const rule = {
|
||||||
tag: "details",
|
tag: "details",
|
||||||
before(state, tagInfo) {
|
before(state, tagInfo) {
|
||||||
const attrs = tagInfo.attrs;
|
const attrs = tagInfo.attrs;
|
||||||
state.push("bbcode_open", "details", 1);
|
const details = state.push("bbcode_open", "details", 1);
|
||||||
state.push("bbcode_open", "summary", 1);
|
state.push("bbcode_open", "summary", 1);
|
||||||
|
|
||||||
|
if (attrs.open === "") {
|
||||||
|
details.attrs = [["open", ""]];
|
||||||
|
}
|
||||||
|
|
||||||
let token = state.push("text", "", 0);
|
let token = state.push("text", "", 0);
|
||||||
token.content = attrs["_default"] || "";
|
token.content = attrs["_default"] || "";
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,25 @@ RSpec.describe PrettyText do
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "supports open attribute" do
|
||||||
|
cooked_html = PrettyText.cook <<~MARKDOWN
|
||||||
|
[details open]
|
||||||
|
bar
|
||||||
|
[/details]
|
||||||
|
MARKDOWN
|
||||||
|
|
||||||
|
expect(cooked_html).to match_html <<~HTML
|
||||||
|
<details open="">
|
||||||
|
<summary></summary>
|
||||||
|
<p>bar</p>
|
||||||
|
</details>
|
||||||
|
HTML
|
||||||
|
end
|
||||||
|
|
||||||
it "deletes elided content" do
|
it "deletes elided content" do
|
||||||
cooked_html = PrettyText.cook <<~MARKDOWN
|
cooked_html = PrettyText.cook <<~MARKDOWN
|
||||||
Hello World
|
Hello World
|
||||||
|
|
||||||
<details class='elided'>42</details>
|
<details class='elided'>42</details>
|
||||||
MARKDOWN
|
MARKDOWN
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user