Allow disabling numbering inherited from a paragraph style (#2531)
This commit is contained in:
@ -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,
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user