Merge pull request #2007 from dolanmiu/feat/autoSpaceDN

#1949 - Add auto space DN feature
This commit is contained in:
Dolan
2023-03-17 02:34:53 +00:00
committed by GitHub
2 changed files with 24 additions and 0 deletions

View File

@ -125,6 +125,21 @@ describe("ParagraphProperties", () => {
}); });
}); });
it("should create with the autoSpaceEastAsianText property", () => {
const properties = new ParagraphProperties({
autoSpaceEastAsianText: true,
});
const tree = new Formatter().format(properties);
expect(tree).to.deep.equal({
"w:pPr": [
{
"w:autoSpaceDN": {},
},
],
});
});
it("should create with the wordWrap property", () => { it("should create with the wordWrap property", () => {
const properties = new ParagraphProperties({ const properties = new ParagraphProperties({
wordWrap: true, wordWrap: true,

View File

@ -53,6 +53,11 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp
readonly suppressLineNumbers?: boolean; readonly suppressLineNumbers?: boolean;
readonly wordWrap?: boolean; readonly wordWrap?: boolean;
readonly scale?: number; readonly scale?: number;
/**
* This element specifies whether inter-character spacing shall automatically be adjusted between regions of numbers and regions of East Asian text in the current paragraph. These regions shall be determined by the Unicode character values of the text content within the paragraph.
* This only works in Microsoft Word. It is not part of the ECMA-376 OOXML standard.
*/
readonly autoSpaceEastAsianText?: boolean;
} }
export class ParagraphProperties extends IgnoreIfEmptyXmlComponent { export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
@ -179,6 +184,10 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent {
if (options.suppressLineNumbers !== undefined) { if (options.suppressLineNumbers !== undefined) {
this.push(new OnOffElement("w:suppressLineNumbers", options.suppressLineNumbers)); this.push(new OnOffElement("w:suppressLineNumbers", options.suppressLineNumbers));
} }
if (options.autoSpaceEastAsianText !== undefined) {
this.push(new OnOffElement("w:autoSpaceDN", options.autoSpaceEastAsianText));
}
} }
public push(item: XmlComponent): void { public push(item: XmlComponent): void {