From 48eca6f39a4c5ffe557e41f6f094d2030d7ad559 Mon Sep 17 00:00:00 2001 From: Ethan <80470138+ethan3011@users.noreply.github.com> Date: Thu, 26 Nov 2026 17:59:07 +0900 Subject: [PATCH] docs: explain that wordWrap lets lines break inside words (#3936) * docs: explain that wordWrap lets lines break inside words The option writes , Word's "Allow Latin text to wrap in the middle of a word", so Word also breaks Korean words when it is set. Say so in the option's JSDoc and the demo comment, as docs/usage/layout.md already does. * docs: note that an unset wordWrap keeps the style's setting * docs: limit the wordWrap default note to space-separated text * docs: say that wordWrap breaks only the words of East Asian runs w:wordWrap w:val="0" lets Word break inside the words of runs in an East Asian font or language, as docs/usage/layout.md and docx/layout's isEastAsianRun have it. Words in other runs, such as English in Calibri, still break at their spaces. The demo's comment says so too, and that an unset wordWrap keeps words whole only when the paragraph's style doesn't set it. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Dolan Miu Co-authored-by: Claude Opus 5.5 --- demo/text/word-wrap.ts | 4 +++- src/file/paragraph/properties.ts | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/demo/text/word-wrap.ts b/demo/text/word-wrap.ts index 442de9ebd4..b03a0a8de2 100644 --- a/demo/text/word-wrap.ts +++ b/demo/text/word-wrap.ts @@ -1,4 +1,6 @@ -// Example on how to preserve word wrap text. Works with all languages. +// Example of `wordWrap`, Word's "Allow Latin text to wrap in the middle of a word", which lets lines break inside the words +// of runs in an East Asian font or language, Korean words too, which Word otherwise keeps together. Words in other runs still +// break at their spaces. Leave it unset to keep Korean words whole, unless the paragraph's style sets it. import * as fs from "fs"; import { Document, Packer, Paragraph, TextRun } from "docx"; diff --git a/src/file/paragraph/properties.ts b/src/file/paragraph/properties.ts index d5bd98c730..087d0a1c28 100644 --- a/src/file/paragraph/properties.ts +++ b/src/file/paragraph/properties.ts @@ -166,7 +166,13 @@ export type IParagraphPropertiesOptionsBase = { readonly frame?: IFrameOptions; /** Whether to suppress line numbers for this paragraph */ readonly suppressLineNumbers?: boolean; - /** Whether to allow word wrapping */ + /** + * Word's "Allow Latin text to wrap in the middle of a word". `true` writes ``, which lets lines + * break inside the words of runs in an East Asian font or language, Latin and Korean words alike, where Word otherwise + * keeps words together. Words in other runs, such as English in Calibri, still break at their spaces. When it is unset, the + * paragraph keeps its style's setting, so Latin and Korean text breaks at the spaces between words unless a style sets + * `w:wordWrap` to `0`. + */ readonly wordWrap?: boolean; /** Whether to allow punctuation to extend beyond text margins */ readonly overflowPunctuation?: boolean;