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:
Joffrey JAFFEUX
2024-10-08 11:13:44 +09:00
committed by GitHub
parent 85774cc214
commit fd15562939
2 changed files with 21 additions and 2 deletions

View File

@ -2,9 +2,13 @@ const rule = {
tag: "details",
before(state, tagInfo) {
const attrs = tagInfo.attrs;
state.push("bbcode_open", "details", 1);
const details = state.push("bbcode_open", "details", 1);
state.push("bbcode_open", "summary", 1);
if (attrs.open === "") {
details.attrs = [["open", ""]];
}
let token = state.push("text", "", 0);
token.content = attrs["_default"] || "";