mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 09:34:17 +08:00
31 lines
626 B
JavaScript
31 lines
626 B
JavaScript
const rule = {
|
|
tag: 'details',
|
|
before: function(state, attrs) {
|
|
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);
|
|
}
|
|
};
|
|
|
|
export function setup(helper) {
|
|
helper.whiteList([
|
|
'summary',
|
|
'summary[title]',
|
|
'details',
|
|
'details[open]',
|
|
'details.elided'
|
|
]);
|
|
|
|
helper.registerPlugin(md => {
|
|
md.block.bbcode_ruler.push('details', rule);
|
|
});
|
|
}
|