From e557149c2b1fec4bb1af50bb48950e4f8febb2ab Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:27:54 +0000 Subject: [PATCH 1/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/forms/custom-form-builder.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/forms/custom-form-builder.tsx b/src/components/forms/custom-form-builder.tsx index 14f90f6..c30c690 100644 --- a/src/components/forms/custom-form-builder.tsx +++ b/src/components/forms/custom-form-builder.tsx @@ -395,6 +395,7 @@ export function CustomFormBuilder() { indent: number; caption?: boolean; heading?: 0 | 1 | 2 | 3; + marker?: string; // list marker prefix like "1." or "•" } | { kind: "table"; rows: TableCellSeg[][] }; From 6494289d827ad40a7d3a7225211db42fab211004 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:28:16 +0000 Subject: [PATCH 2/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/forms/custom-form-builder.tsx | 44 +++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/components/forms/custom-form-builder.tsx b/src/components/forms/custom-form-builder.tsx index c30c690..7eae9ea 100644 --- a/src/components/forms/custom-form-builder.tsx +++ b/src/components/forms/custom-form-builder.tsx @@ -473,6 +473,44 @@ export function CustomFormBuilder() { tmp.innerHTML = html; const out: Segment[] = []; + const LIST_INDENT = 24; // px per nesting level + + const pushListItems = ( + listEl: HTMLElement, + ordered: boolean, + depth: number, + ) => { + const items = Array.from(listEl.children).filter( + (c) => (c as HTMLElement).tagName.toLowerCase() === "li", + ) as HTMLElement[]; + let n = 1; + for (const li of items) { + // Collect inline runs from this li, excluding nested lists. + const inlineNodes = Array.from(li.childNodes).filter((c) => { + if (c.nodeType !== Node.ELEMENT_NODE) return true; + const t = (c as HTMLElement).tagName.toLowerCase(); + return t !== "ol" && t !== "ul"; + }); + const runs: InlineRun[] = []; + inlineNodes.forEach((n) => runs.push(...collectRuns(n))); + const merged = mergeRuns(runs); + out.push({ + kind: "text", + runs: merged, + align: "left", + indent: depth * LIST_INDENT, + marker: ordered ? `${n}.` : "•", + }); + n += 1; + // Recurse into any nested lists. + Array.from(li.children).forEach((child) => { + const tag = (child as HTMLElement).tagName.toLowerCase(); + if (tag === "ol") pushListItems(child as HTMLElement, true, depth + 1); + else if (tag === "ul") pushListItems(child as HTMLElement, false, depth + 1); + }); + } + }; + const pushBlock = (el: HTMLElement) => { const tag = el.tagName.toLowerCase(); if (tag === "table") { @@ -490,7 +528,9 @@ export function CustomFormBuilder() { out.push({ kind: "table", rows }); return; } - if (["p", "h1", "h2", "h3", "li"].includes(tag)) { + if (tag === "ol") return pushListItems(el, true, 0); + if (tag === "ul") return pushListItems(el, false, 0); + if (["p", "h1", "h2", "h3"].includes(tag)) { const align = (el.style.textAlign as any) || "left"; const indentPx = parseInt(el.style.paddingLeft || "0", 10) || 0; const caption = el.getAttribute("data-caption") === "true"; @@ -505,7 +545,7 @@ export function CustomFormBuilder() { }); return; } - // Recurse into wrappers (lists, etc.) + // Recurse into wrappers we don't recognize. Array.from(el.children).forEach((child) => pushBlock(child as HTMLElement)); }; From afcbf3a52fde7fadf21a0c5da4430342367d9574 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:28:35 +0000 Subject: [PATCH 3/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/forms/custom-form-builder.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/forms/custom-form-builder.tsx b/src/components/forms/custom-form-builder.tsx index 7eae9ea..b593c6c 100644 --- a/src/components/forms/custom-form-builder.tsx +++ b/src/components/forms/custom-form-builder.tsx @@ -758,7 +758,10 @@ export function CustomFormBuilder() { const indentPt = indentPx * 0.75; // px → pt const segMaxW = maxW - indentPt; const startX = margin + indentPt; - const visualLines = runsToLines(seg.runs); + const runsForLayout: InlineRun[] = seg.marker + ? [{ text: `${seg.marker} ` }, ...seg.runs] + : seg.runs; + const visualLines = runsToLines(runsForLayout); if (visualLines.length === 0 || (visualLines.length === 1 && visualLines[0].length === 0)) { y += lineH; } else { From c6cee5409a68be574bb67d5d6a854befc9f075de Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 16:28:50 +0000 Subject: [PATCH 4/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/forms/custom-form-builder.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/forms/custom-form-builder.tsx b/src/components/forms/custom-form-builder.tsx index b593c6c..eeedc0b 100644 --- a/src/components/forms/custom-form-builder.tsx +++ b/src/components/forms/custom-form-builder.tsx @@ -902,12 +902,19 @@ export function CustomFormBuilder() { ? AlignmentType.JUSTIFIED : AlignmentType.LEFT; const indentTwips = Math.round((seg.indent || 0) * 15); // ~px → twips (1px≈15twip) + const baseRuns = buildDocxRuns(seg.runs, { italic: seg.caption }); + const runsWithMarker = seg.marker + ? [ + new TextRun({ text: `${seg.marker}\t`, font: fontFamily, size: fontSize * 2 }), + ...baseRuns, + ] + : baseRuns; children.push( new DocxParagraph({ alignment: align, spacing: docxLineSpacing, - indent: indentTwips ? { left: indentTwips } : undefined, - children: buildDocxRuns(seg.runs, { italic: seg.caption }), + indent: indentTwips ? { left: indentTwips, hanging: seg.marker ? 360 : undefined } : seg.marker ? { left: 360, hanging: 360 } : undefined, + children: runsWithMarker, }), ); }