mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:59:50 +08:00
FIX: details plugin wasn't working properly
This commit is contained in:
parent
6dc4a3f2d6
commit
a2b9b01d0f
|
@ -1,5 +1,5 @@
|
||||||
const BLOCK_TAGS = ['address', 'article', 'aside', 'audio', 'blockquote', 'canvas', 'dd', 'div',
|
const BLOCK_TAGS = ['address', 'article', 'aside', 'audio', 'blockquote', 'canvas', 'dd', 'details',
|
||||||
'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
|
'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
|
||||||
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'iframe', 'noscript', 'ol', 'output',
|
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'iframe', 'noscript', 'ol', 'output',
|
||||||
'p', 'pre', 'section', 'table', 'tfoot', 'ul', 'video'];
|
'p', 'pre', 'section', 'table', 'tfoot', 'ul', 'video'];
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ function replaceDetails(text) {
|
||||||
|
|
||||||
// add new lines to make sure we *always* have a <p> element after </summary> and around </details>
|
// add new lines to make sure we *always* have a <p> element after </summary> and around </details>
|
||||||
// otherwise we can't hide the content since we can't target text nodes via CSS
|
// otherwise we can't hide the content since we can't target text nodes via CSS
|
||||||
return text.replace(/<\/summary>/ig, "</summary>\n\n").replace(/<\/details>/ig, "\n\n</details>\n\n");
|
return text.replace(/<\/summary>/ig, "</summary>\n\n")
|
||||||
|
.replace(/<\/details>/ig, "\n\n</details>\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
registerOption((siteSettings, opts) => {
|
registerOption((siteSettings, opts) => {
|
||||||
|
@ -20,6 +21,12 @@ registerOption((siteSettings, opts) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
export function setup(helper) {
|
export function setup(helper) {
|
||||||
helper.whiteList('details.elided');
|
helper.whiteList([
|
||||||
|
'summary',
|
||||||
|
'summary[title]',
|
||||||
|
'details',
|
||||||
|
'details.elided'
|
||||||
|
]);
|
||||||
|
|
||||||
helper.addPreProcessor(text => replaceDetails(text));
|
helper.addPreProcessor(text => replaceDetails(text));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user