From 1bf36009e846ee5953261e6f89680905729de30e Mon Sep 17 00:00:00 2001 From: Dolan Date: Mon, 25 Dec 2023 04:09:54 +0000 Subject: [PATCH] #916 Add overflow punctuation (#2478) * #916 Add overflow punctuation * Fix tests --- src/file/paragraph/properties.spec.ts | 15 +++++++++++++++ src/file/paragraph/properties.ts | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/file/paragraph/properties.spec.ts b/src/file/paragraph/properties.spec.ts index 5b9794f7c1a..40879566f31 100644 --- a/src/file/paragraph/properties.spec.ts +++ b/src/file/paragraph/properties.spec.ts @@ -159,6 +159,21 @@ describe("ParagraphProperties", () => { }); }); + it("should create with the overflowPunct property", () => { + const properties = new ParagraphProperties({ + overflowPunctuation: true, + }); + const tree = new Formatter().format(properties); + + expect(tree).to.deep.equal({ + "w:pPr": [ + { + "w:overflowPunct": {}, + }, + ], + }); + }); + it("should create with the run property", () => { const properties = new ParagraphProperties({ run: { diff --git a/src/file/paragraph/properties.ts b/src/file/paragraph/properties.ts index c427717115c..4f520595a18 100644 --- a/src/file/paragraph/properties.ts +++ b/src/file/paragraph/properties.ts @@ -60,6 +60,7 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp readonly frame?: IFrameOptions; readonly suppressLineNumbers?: boolean; readonly wordWrap?: boolean; + readonly overflowPunctuation?: 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. @@ -152,6 +153,10 @@ export class ParagraphProperties extends IgnoreIfEmptyXmlComponent { this.push(new WordWrap()); } + if (options.overflowPunctuation) { + this.push(new OnOffElement("w:overflowPunct", options.overflowPunctuation)); + } + /** * FIX: Multitab support for Libre Writer * Ensure there is only one w:tabs tag with multiple w:tab