mirror of
https://github.com/docmost/docmost.git
synced 2025-11-14 12:51:11 +10:00
feat: nested toggle block (#671)
* feat: nested toggle block * fix: md export * fix detailsButton icon alignment --------- Co-authored-by: Philipinho <16838612+Philipinho@users.noreply.github.com>
This commit is contained in:
@ -79,16 +79,18 @@ function preserveDetail(turndownService: TurndownService) {
|
||||
return node.nodeName === 'DETAILS';
|
||||
},
|
||||
replacement: function (content: any, node: HTMLInputElement) {
|
||||
// TODO: preserve summary of nested details
|
||||
const summary = node.querySelector(':scope > summary');
|
||||
let detailSummary = '';
|
||||
|
||||
if (summary) {
|
||||
detailSummary = `<summary>${turndownService.turndown(summary.innerHTML)}</summary>`;
|
||||
summary.remove();
|
||||
}
|
||||
|
||||
const detailsContent = turndownService.turndown(node.innerHTML);
|
||||
const detailsContent = Array.from(node.childNodes)
|
||||
.filter(child => child.nodeName !== 'SUMMARY')
|
||||
.map(child => (child.nodeType === 1 ? turndownService.turndown((child as HTMLElement).outerHTML) : child.textContent))
|
||||
.join('');
|
||||
|
||||
return `\n<details>\n${detailSummary}\n\n${detailsContent}\n\n</details>\n`;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user