Allow disabling numbering inherited from a paragraph style (#2531)

This commit is contained in:
Max Lay
2024-05-20 14:15:11 +12:00
committed by GitHub
parent e379a7fe04
commit f98f852a55
3 changed files with 96 additions and 6 deletions

View File

@ -65,6 +65,36 @@ describe("ParagraphProperties", () => {
});
});
it("should create with numbering disabled", () => {
const properties = new ParagraphProperties({
numbering: false,
});
const tree = new Formatter().format(properties);
expect(tree).to.deep.equal({
"w:pPr": [
{
"w:numPr": [
{
"w:ilvl": {
_attr: {
"w:val": 0,
},
},
},
{
"w:numId": {
_attr: {
"w:val": 0,
},
},
},
],
},
],
});
});
it("should create with widowControl", () => {
const properties = new ParagraphProperties({
widowControl: true,

View File

@ -37,12 +37,14 @@ export interface ILevelParagraphStylePropertiesOptions {
}
export interface IParagraphStylePropertiesOptions extends ILevelParagraphStylePropertiesOptions {
readonly numbering?: {
readonly reference: string;
readonly level: number;
readonly instance?: number;
readonly custom?: boolean;
};
readonly numbering?:
| {
readonly reference: string;
readonly level: number;
readonly instance?: number;
readonly custom?: boolean;
}
| false;
}
export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOptions {
@ -135,6 +137,8 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
});
this.push(new NumberProperties(`${options.numbering.reference}-${options.numbering.instance ?? 0}`, options.numbering.level));
} else if (options.numbering === false) {
this.push(new NumberProperties(0, 0));
}
if (options.border) {