Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 18:30:32 +00:00
co-authored by renee-png
parent c0e5d935c0
commit 3da9919e91
@@ -675,8 +675,27 @@ export function CustomFormBuilder() {
}
};
const parseImg = (img: HTMLImageElement, parentAlign: "left" | "center" | "right" = "left") => {
const src = img.getAttribute("src") || "";
if (!src) return;
const w = parseInt(img.getAttribute("width") || "", 10);
const h = parseInt(img.getAttribute("height") || "", 10);
out.push({
kind: "image",
src,
align: parentAlign,
widthPx: Number.isFinite(w) && w > 0 ? w : undefined,
heightPx: Number.isFinite(h) && h > 0 ? h : undefined,
alt: img.getAttribute("alt") || undefined,
});
};
const pushBlock = (el: HTMLElement) => {
const tag = el.tagName.toLowerCase();
if (tag === "img") {
parseImg(el as HTMLImageElement);
return;
}
if (tag === "table") {
const rows: TableCellSeg[][] = [];
el.querySelectorAll("tr").forEach((tr) => {