How can I pull off nested numbering? #1569
-
I want to do something that looks like this:
Getting that extra line shown above in bold is confusing to do with DOCX because its technically part of item one so I can't make it a new paragraph that's just indented. Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I figured it out for anyone who finds this. In Word/DOCX a paragraph just refers to a block of text. To get the above to work,
To see exactly how paragraphs work in word, open up a document, format it how you want. Then click the ¶ symbol. This will show you the outline that you will need to replicate in the DOCX code. Hopefully this helps someone one day... |
Beta Was this translation helpful? Give feedback.
-
Generating a sub paragraph with nested looping of the parent paragraphI see your answer working statically. When I make attempt at this with a dynamic approach I am hitting a wall. I am using React in my case and I want this outcome: 1 Parent Paragraph lorem ipsum etc My approach is call the function in the UI, this function does return the parent paragraph or the sub paragraph but generating a sub paragraph of the parent is the problem I am trying to solve My guess is looping through a nested iteration doesn't play well with the const paragraphsAndSubs = () => {
const arr = paragraphs.map((paraItem) => {
if (paraItem.subParagraph.length > 0) {
return paraItem.subParagraph.map((subItem) => (
new Paragraph({
text: subItem.text,
numbering: {
reference: 'my-sub-paragraph-reference',
level: 1
}
})
),
new Paragraph({
text: paraItem.paragraph,
numbering: {
reference: 'my-number-numbering-reference',
level: 0
}
})
)
}
return new Paragraph({
text: paraItem.paragraph,
numbering: {
reference: 'my-number-numbering-reference',
level: 0
}
});
}).flat()
console.log('arr', arr);
const sectionObj = {
properties: { type: SectionType.CONTINUOUS },
margins: {
top: '1in',
bottom: '1in',
right: '1in',
left: '1in'
},
children: arr
};
return sectionObj;
}; |
Beta Was this translation helpful? Give feedback.
-
Here is the console.log(arr), xml is not my forte and having trouble understanding what this array is actually capturing |
Beta Was this translation helpful? Give feedback.
I figured it out for anyone who finds this. In Word/DOCX a paragraph just refers to a block of text. To get the above to work,
To see exactly how paragraphs work in word, open up a document, format it how you want. Then click the ¶ symbol. This will show you the outline that you will need to replicate in the DOCX code.
Hopefully this helps someone one day...