Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
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) => {
|
||||
|
||||
Reference in New Issue
Block a user