2017-06-09 06:02:30 +08:00
|
|
|
const rule = {
|
2018-06-16 00:42:20 +08:00
|
|
|
tag: "details",
|
2021-11-13 21:01:55 +08:00
|
|
|
before(state, tagInfo) {
|
2017-07-22 04:16:07 +08:00
|
|
|
const attrs = tagInfo.attrs;
|
2018-06-16 00:42:20 +08:00
|
|
|
state.push("bbcode_open", "details", 1);
|
|
|
|
state.push("bbcode_open", "summary", 1);
|
2017-06-09 06:02:30 +08:00
|
|
|
|
2018-06-16 00:42:20 +08:00
|
|
|
let token = state.push("text", "", 0);
|
|
|
|
token.content = attrs["_default"] || "";
|
2017-06-09 06:02:30 +08:00
|
|
|
|
2018-06-16 00:42:20 +08:00
|
|
|
state.push("bbcode_close", "summary", -1);
|
2017-06-09 06:02:30 +08:00
|
|
|
},
|
|
|
|
|
2021-11-13 21:01:55 +08:00
|
|
|
after(state) {
|
2018-06-16 00:42:20 +08:00
|
|
|
state.push("bbcode_close", "details", -1);
|
2017-06-09 06:02:30 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-06-15 02:31:51 +08:00
|
|
|
export function setup(helper) {
|
2020-10-28 10:22:06 +08:00
|
|
|
helper.allowList([
|
2018-06-16 00:42:20 +08:00
|
|
|
"summary",
|
|
|
|
"summary[title]",
|
|
|
|
"details",
|
|
|
|
"details[open]",
|
|
|
|
"details.elided",
|
2016-07-07 01:12:21 +08:00
|
|
|
]);
|
|
|
|
|
2017-07-14 20:27:28 +08:00
|
|
|
helper.registerPlugin((md) => {
|
2018-06-16 00:42:20 +08:00
|
|
|
md.block.bbcode.ruler.push("details", rule);
|
2017-07-14 20:27:28 +08:00
|
|
|
});
|
2016-06-15 02:31:51 +08:00
|
|
|
}
|