From 970450074d402f70b7d84d302a8ac3a20a876604 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Fri, 17 Mar 2023 02:20:51 +0000 Subject: [PATCH] #1949 - Add auto space DN feature --- src/file/paragraph/properties.spec.ts | 15 +++++++++++++++ src/file/paragraph/properties.ts | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/file/paragraph/properties.spec.ts b/src/file/paragraph/properties.spec.ts index 4c4fe41d5b..cfa0d3aced 100644 --- a/src/file/paragraph/properties.spec.ts +++ b/src/file/paragraph/properties.spec.ts @@ -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", () => { const properties = new ParagraphProperties({ wordWrap: true, diff --git a/src/file/paragraph/properties.ts b/src/file/paragraph/properties.ts index 48bcf242b0..39e5a3d28c 100644 --- a/src/file/paragraph/properties.ts +++ b/src/file/paragraph/properties.ts @@ -53,6 +53,11 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp readonly suppressLineNumbers?: boolean; readonly wordWrap?: boolean; 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 { @@ -179,6 +184,10 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent { if (options.suppressLineNumbers !== undefined) { 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 {