1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Lexical: Source code input changes

- Increased default source code view size.
- Updated HTML generation to output each top-level block on its own
  line.
This commit is contained in:
Dan Brown
2025-07-24 17:24:59 +01:00
parent ae4d1d804a
commit 865e5aecc9
5 changed files with 41 additions and 22 deletions

View File

@@ -146,7 +146,7 @@ describe('HTML', () => {
});
expect(html).toBe(
'<p>Hello</p><p>World</p>',
'<p>Hello</p>\n<p>World</p>',
);
});

View File

@@ -85,7 +85,18 @@ export function $generateHtmlFromNodes(
$appendNodesToHTML(editor, topLevelNode, container, selection);
}
return container.innerHTML;
const nodeCode = [];
for (const node of container.childNodes) {
if ("outerHTML" in node) {
nodeCode.push(node.outerHTML)
} else {
const wrap = document.createElement('div');
wrap.appendChild(node.cloneNode(true));
nodeCode.push(wrap.innerHTML);
}
}
return nodeCode.join('\n');
}
function $appendNodesToHTML(