fix(app): preserve nested list clipboard lines

Flattened child list lines were reparented inside the parent item line, so rich paste targets split markers from their content. Keep every flattened line as a sibling and cover cross-structure selection plus inline-code double-click copying.
This commit is contained in:
Mohamed Boudra
2026-08-07 10:25:43 +02:00
parent 64058722e1
commit 84b735fbea
2 changed files with 67 additions and 17 deletions
@@ -162,9 +162,12 @@ function flattenClipboardListMarkup(html: string): string {
items.forEach((item, index) => {
const line = document.createElement("div");
line.append(start === null ? "- " : `${start + index}. `);
const nestedLines: HTMLDivElement[] = [];
let hasParagraph = false;
for (const child of Array.from(item.childNodes)) {
if (child instanceof HTMLParagraphElement) {
if (child instanceof HTMLDivElement) {
nestedLines.push(child);
} else if (child instanceof HTMLParagraphElement) {
if (hasParagraph) {
line.append(document.createElement("br"), document.createElement("br"));
}
@@ -174,7 +177,7 @@ function flattenClipboardListMarkup(html: string): string {
line.append(child);
}
}
replacement.append(line);
replacement.append(line, ...nestedLines);
});
list.replaceWith(replacement);
}