clipper: append head for node selection clips

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2025-06-20 12:36:25 +05:00
committed by Abdullah Atta
parent 5d1775151d
commit a3e11b62e0

View File

@@ -199,7 +199,11 @@ function enterNodeSelectionMode(doc: Document, config?: Config) {
`.${CLASSES.nodeSelected}`
);
const div = document.createElement("div");
const { head } = await getPage(document, config, false);
const html = document.createElement("html");
html.append(head!);
const body = document.createElement("body");
html.append(body);
for (const node of selectedNodes) {
node.classList.remove(CLASSES.nodeSelected);
const inlined = await getInlinedNode(node as HTMLElement, {
@@ -212,9 +216,9 @@ function enterNodeSelectionMode(doc: Document, config?: Config) {
}
});
if (!inlined) continue;
div.appendChild(inlined);
body.appendChild(inlined);
}
resolve(div?.outerHTML);
resolve(html?.outerHTML);
},
() => reject("Cancelled.")
);