Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
581e4ab6cf
commit
94a09ce76b
@@ -564,13 +564,14 @@ export function CustomFormBuilder() {
|
||||
children.push(new DocxParagraph({ text: "" }));
|
||||
}
|
||||
|
||||
const tableBorder = { style: BorderStyle.SINGLE, size: 4, color: "999999" };
|
||||
const cellBorders = {
|
||||
top: tableBorder,
|
||||
bottom: tableBorder,
|
||||
left: tableBorder,
|
||||
right: tableBorder,
|
||||
};
|
||||
const onBorder = { style: BorderStyle.SINGLE, size: 4, color: "999999" };
|
||||
const offBorder = { style: BorderStyle.NONE, size: 0, color: "FFFFFF" };
|
||||
const docxBorders = (b: CellBorders) => ({
|
||||
top: b.t ? onBorder : offBorder,
|
||||
bottom: b.b ? onBorder : offBorder,
|
||||
left: b.l ? onBorder : offBorder,
|
||||
right: b.r ? onBorder : offBorder,
|
||||
});
|
||||
|
||||
for (const seg of segments) {
|
||||
if (seg.kind === "table") {
|
||||
@@ -582,19 +583,21 @@ export function CustomFormBuilder() {
|
||||
width: { size: totalW, type: WidthType.DXA },
|
||||
columnWidths: Array(cols).fill(colW),
|
||||
rows: seg.rows.map(
|
||||
(row, ri) =>
|
||||
(row) =>
|
||||
new DocxTableRow({
|
||||
children: Array.from({ length: cols }).map((_, ci) => {
|
||||
const isHeader = seg.hasHeader && ri === 0;
|
||||
const cell = row[ci];
|
||||
const borders = cell?.borders ?? DEFAULT_BORDERS;
|
||||
const isHeader = cell?.isHeader ?? false;
|
||||
return new DocxTableCell({
|
||||
borders: cellBorders,
|
||||
borders: docxBorders(borders),
|
||||
width: { size: colW, type: WidthType.DXA },
|
||||
margins: { top: 80, bottom: 80, left: 120, right: 120 },
|
||||
children: [
|
||||
new DocxParagraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: applyVariables(row[ci] ?? "", ctx),
|
||||
text: applyVariables(cell?.text ?? "", ctx),
|
||||
font: fontFamily,
|
||||
size: fontSize * 2,
|
||||
bold: isHeader,
|
||||
|
||||
Reference in New Issue
Block a user