Merge branch 'master' of github.com:dolanmiu/docx

This commit is contained in:
Dolan Miu
2021-09-28 22:08:57 +01:00
3 changed files with 55 additions and 0 deletions

View File

@ -830,6 +830,18 @@ describe("Paragraph", () => {
});
});
describe("#suppressLineNumbers", () => {
it("should disable line numbers", () => {
const paragraph = new Paragraph({
suppressLineNumbers: true,
});
const tree = new Formatter().format(paragraph);
expect(tree).to.deep.equal({
"w:p": [{ "w:pPr": [{ "w:suppressLineNumbers": EMPTY_OBJECT }] }],
});
});
});
describe("#outlineLevel", () => {
it("should set paragraph outline level to the given value", () => {
const paragraph = new Paragraph({

View File

@ -1,4 +1,5 @@
// http://officeopenxml.com/WPparagraphProperties.php
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_suppressLineNumbers_topic_ID0ECJAO.html
import { IContext, IgnoreIfEmptyXmlComponent, IXmlableObject, OnOffElement, XmlComponent } from "file/xml-components";
import { DocumentWrapper } from "../document-wrapper";
import { IShadingAttributesProperties, Shading } from "../shading";
@ -52,6 +53,7 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
readonly shading?: IShadingAttributesProperties;
readonly widowControl?: boolean;
readonly frame?: IFrameOptions;
readonly suppressLineNumbers?: boolean;
}
export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
@ -166,6 +168,10 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
if (options.outlineLevel !== undefined) {
this.push(new OutlineLevel(options.outlineLevel));
}
if (options.suppressLineNumbers !== undefined) {
this.push(new OnOffElement("w:suppressLineNumbers", options.suppressLineNumbers));
}
}
public push(item: XmlComponent): void {