docs: explain that wordWrap lets lines break inside words (#3936)

* docs: explain that wordWrap lets lines break inside words

The option writes <w:wordWrap w:val="0"/>, 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 <noreply@anthropic.com>

---------

Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ethan
2026-11-26 16:59:07 +08:00
committed by GitHub
co-authored by Claude Opus 5.5 Dolan Miu
parent 688588a362
commit 48eca6f39a
2 changed files with 10 additions and 2 deletions
+3 -1
View File
@@ -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";
+7 -1
View File
@@ -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 `<w:wordWrap w:val="0"/>`, 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;