2017-06-09 06:02:30 +08:00
|
|
|
const rule = {
|
|
|
|
tag: 'details',
|
2017-07-22 04:16:07 +08:00
|
|
|
before: function(state, tagInfo) {
|
|
|
|
const attrs = tagInfo.attrs;
|
2017-06-09 06:02:30 +08:00
|
|
|
state.push('bbcode_open', 'details', 1);
|
|
|
|
state.push('bbcode_open', 'summary', 1);
|
|
|
|
|
|
|
|
let token = state.push('text', '', 0);
|
|
|
|
token.content = attrs['_default'] || '';
|
|
|
|
|
|
|
|
state.push('bbcode_close', 'summary', -1);
|
|
|
|
},
|
|
|
|
|
|
|
|
after: function(state) {
|
|
|
|
state.push('bbcode_close', 'details', -1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-15 02:31:51 +08:00
|
|
|
export function setup(helper) {
|
2016-07-07 01:12:21 +08:00
|
|
|
helper.whiteList([
|
|
|
|
'summary',
|
|
|
|
'summary[title]',
|
|
|
|
'details',
|
2016-07-21 01:30:36 +08:00
|
|
|
'details[open]',
|
2016-07-07 01:12:21 +08:00
|
|
|
'details.elided'
|
|
|
|
]);
|
|
|
|
|
2017-07-14 20:27:28 +08:00
|
|
|
helper.registerPlugin(md => {
|
2017-07-18 04:21:47 +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
|
|
|
}
|