45 Commits
Author SHA1 Message Date
DolanandClaude Opus 5.5 2243d74c22 fix: write one w:pStyle for a paragraph with both heading and style (#3940)
A paragraph with both `heading` and `style` wrote a w:pStyle for each, and
CT_PPrBase has one, so the Open XML SDK validator rejected the document.
Word applies the last of the two, `style`, so `style` now takes the place
of `heading`, and Word shows the paragraph as it did. The layout module and
the table of contents' heading entries read the first w:pStyle, the
heading, and now read the style Word shows.

The ListParagraph that a bullet or numbered paragraph gets without a style
of its own goes in the same if/else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 17:36:05 +08:00
yschoi9733andClaude Opus 5.5 893ca85c8b fix: write one w:pBdr for a paragraph with both border and thematicBreak (#3935)
A paragraph with both options got a w:pBdr from each, and CT_PPrBase has
one, so the Open XML SDK validator rejects the document. The same went for
paragraph styles, and for htmlToContent with an <hr> in a <div> with a
border.

The thematic break's line is now written in the w:pBdr of border, in place
of its bottom, as Word reads the two elements: ThematicBreak extends Border
and takes the paragraph's other borders. The layout module, which read only
the first w:pBdr, now gives the line its room, as Word does.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:58:40 +08:00
yschoi9733andClaude Opus 5.5 bc5e98e1a3 feat: add autoSpaceLatinAndEastAsianText for the space beside Latin letters (#3916)
Word can put a small space between Chinese, Japanese or Korean text and
a Latin letter or a digit beside it. autoSpaceEastAsianText controls the
space beside digits (w:autoSpaceDN), and autoSpaceLatinAndEastAsianText
now does the same for Latin letters (w:autoSpaceDE).

Both can be set in paragraph styles, numbering levels and the document
defaults too, and are written after w:overflowPunct and before w:bidi,
the order CT_PPrBase gives them. To keep that order, w:suppressLineNumbers
moves to its place after w:numPr, and w:wordWrap and w:overflowPunct now
come after w:tabs. A test sets an option for each element
ParagraphProperties writes and checks their order against the schema.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 03:31:12 +00:00
DolanandClaude Opus 5.5 ea6bff070c docs: say a hanging paragraph's left is where the lines after the first start (#3874)
The `left` row in the indentation table ended with "With `hanging`, of
the lines after the first", which has no verb and doesn't say what
`left` does there. It now reads like the TSDoc on `left` in indent.ts.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 14:48:36 +00:00
Dolan d08294a09a docs: say Word's dialog shows a hanging paragraph's Left where its first line starts (#3860) 2026-10-29 13:05:58 +00:00
DolanandClaude Opus 5.5 b26d269153 feat: make a new paragraph with other options from a paragraph, with Paragraph's with() (#3330) (#3831)
paragraph.with({ indent }) makes a new paragraph with the paragraph's options and those given, which replace its
own, such as to lay out the paragraphs a parser made, without casting to reach their children. The paragraph is
left as it is. paragraph.options gives the options it was made with, so an option can be extended rather than
replaced.


Claude-Session: https://claude.ai/code/session_01X5zGDL3sgGVBMXPfny376c

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 01:00:44 +01:00
Dolan 7826217f8d docs: fix mistakes found while answering discussions (#3748) 2026-10-12 13:42:45 +01:00
DolanandClaude Opus 5.5 5da78710c5 fix: keep LEFT and RIGHT on their side of the page in a right-to-left paragraph (#3587)
Word reads w:jc left and right as the start and end of the paragraph, so a
bidirectional paragraph with AlignmentType.RIGHT was left-aligned. Write left
and right swapped when the paragraph is bidirectional.

Closes #3419


Claude-Session: https://claude.ai/code/session_01NijyutGmb3bNR3dNRWJken

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:54:50 +01:00
DolanandClaude Opus 5.5 c169dd1a83 feat: live examples in the docs, which run, draw the document next to the code, and can be edited and downloaded (#3556)
* feat: live examples in the docs, which run, draw the document next to the code, and can be edited and downloaded

The docs' code examples were plain snippets, often fragments that couldn't run. A code block marked ```ts live is now
an example readers can see and change: the page runs it with docx, draws the document it makes next to the code with
docx-preview, and offers the .docx to download. Clicking the code opens an editor (Monaco) that knows docx's types,
the pages are drawn again as the code changes, and View closes the editor. Split, Code and Preview show the code and
the pages side by side, or one of them. The demos a page includes are live too.

Every example in the docs that builds or patches a document is now live: 443 of them, each a whole file with its
imports, so it runs as written. Code about other things, such as installing, bundlers or servers, stays plain.

Running them showed docs that were wrong, fixed here:
- Landscape: docx swaps a landscape page's width and height itself, so the docs' swapped sizes made a tall page
  marked as landscape
- Comments: `comments.children` takes plain objects, not `new Comment(...)`
- Custom properties are text only
- APIs that no longer exist: MathText, Row, `.then` on Packer.toStream, patchDocument(buffer, ...),
  createParagraph().heading1(), a border's `value`, TextRun's `.break()`
- The templates and patcher examples read files that aren't in the repository. They now patch the templates in
  demo/assets, or make their own

`npm run build.docs` copies docx's browser builds into docs/live-examples/lib, so the docs use the docx they
describe, and the Pages workflow runs it. The folder is gitignored, and cspell and ESLint skip it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ

* docs: the bullet examples draw a bullet, and the patcher's usage writes the patched document

"ὠ" is U+1F60, a Greek omega, since \u takes four hex digits, so the two live bullet examples on
the numbering page drew it as each item's bullet. They use "•" now. The patcher's usage example
now awaits patchDocument and writes the document it makes, as the example after it does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 13:00:29 +01:00
DolanandClaude Opus 5.5 e0ff13ee3d chore: organise the demos into a folder for each topic (#3552)
* chore: organise the demos into a folder for each topic

The demos were one flat list of 124 numbered files, which made it hard to
find the one you wanted. Each is now in a folder for its topic, such as
demo/tables/basic-table.ts, with a name that says what it shows instead of
a number.

npm run demo lists every demo and narrows the list as you type. It also
takes a demo's path or name, a topic, or search words.

The demos' images moved to demo/assets/images, as images is now a topic.
The docs' links, the Demos workflow, the shape render script and its
reference images use the new paths and names.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ

* fix: list only a topic's own demos, and drop stale output file names

npm run demo text also offered the text-boxes demos and others with
"text" in their name, so a topic now searches for "text/". Three demos
logged their old numbered file name after writing My Document.docx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 01:40:45 +01:00
Dolan 764d5423f3 feat: theme colours for text, underlines, borders and shading (#3537) 2026-09-24 23:34:57 +01:00
DolanandDolan Miu 224b95a25e docs: Improve documentation, JSDoc comments, and troubleshooting guides (#3433)
* docs: Write documentation and comments

Upgrade and remove dependencies

* Add more demos to the run

* Add more tests to fill coverage to 100%

---------

Co-authored-by: Dolan Miu <>
2026-05-24 17:52:35 +01:00
hehecat 6a32b4e163 feat(paragraph): add firstLineChars indent support (#3420) 2026-05-24 14:31:46 +01:00
Dolan 3539c06e92 docs: Improve inline docs and docs website (#3353)
* docs: Improve inline docs and docs website

* Fix lint

* Fix spelling
2026-02-14 03:54:25 +00:00
Ecaratti 1994e00c98 Add between borders for paragraphs following http://officeopenxml.com/WPborders.php (#3312) 2025-11-21 01:19:59 +00:00
Devin Brown bd01690b66 fix: MS article URL in docs (#3197) 2025-08-23 12:30:53 +01:00
Dolan Miu ec379f2e4d Update documentation 2023-03-26 04:05:41 +01:00
Dolan Miu 9b874b0061 #1784 Add more alignment options according to spec 2022-11-19 20:14:15 +00:00
Dolan Miu 251eafe103 #1773 Add exact for spacing 2022-11-19 15:51:41 +00:00
Hunter Wilhelm 8b165e93e1 Specify which borders could look like a <hr/> 2022-09-28 09:19:18 -06:00
Hunter Wilhelm 321969eb85 Added the name horizontal line or horizontal rules
There was some confusion in https://github.com/dolanmiu/docx/issues/437 because the docs don't mention anything called horizontal lines or horizontal rules. Microsoft calls them by that name here https://support.microsoft.com/en-us/office/insert-a-line-9bf172f6-5908-4791-9bb9-2c952197b1a9
This will make it easier for people to find this in the docs.
2022-09-26 10:22:32 -06:00
wvbe aa02261248 docs: Fix property name accuracy in describing paragraph borders 2022-07-06 11:51:10 +02:00
Graham Charles 2140ed63cd added possible values for LineRuleType 2021-09-22 16:54:40 -07:00
Tom Hunkapiller bb8ac8b9d8 Fix broken links in documentation. 2021-05-18 17:15:29 +03:00
Ismail Magomedov abc7c8dc72 Fixed typos in usage documentation 2021-03-25 19:21:27 +03:00
Dolan 3299c557a0 Make .addSection fully declarative 2021-03-19 20:53:56 +00:00
Dolan caf188caae Make adding images declarative and simple 2021-03-18 02:48:37 +00:00
Dolan 4fe2973473 Add enum to lineRule and create demo 2021-03-15 19:23:40 +00:00
Dolan cc32a7b2d3 Add text frame documentation 2021-03-14 18:12:52 +00:00
Dolan 60eb686d05 Add shading to paragraph 2020-10-28 01:05:31 +00:00
Dolan 8eff6bd0cf Declarative numbering work 2019-11-01 01:57:01 +00:00
Dolan 2536fbe752 Merge branch 'master' of github.com:dolanmiu/docx into feat/declaritive-styles-and-tab-stop
# Conflicts:
#	src/file/paragraph/paragraph.ts
2019-10-03 20:48:34 +01:00
James Montalvo dfb910defb Add SymbolRun to allow adding symbols inline 2019-10-01 12:29:07 -05:00
Dolan 04b6d8e54a Declarative hyperlinks, bookmarks, tab stops and page breaks 2019-09-30 22:56:21 +01:00
Dolan 535f2d75b0 Fix embed links in documentation 2019-08-20 22:23:14 +01:00
Dolan Miu 820e5edc1e Using const rather than var and let, and using ts rather than js examples 2019-08-06 17:51:13 +01:00
Dolan Miu b5503e7b9b Add documentation for AlignmentType 2019-08-06 17:36:05 +01:00
Dolan Miu 5a005365b2 Add more documentation 2019-08-06 17:15:45 +01:00
Dolan cb699e17b3 Paragraph documentation 2019-08-05 23:24:43 +01:00
Dolan c2c05b0140 Adding some documentation 2019-08-03 13:42:24 +01:00
Dolan e2574ec23b Turn methods into "add()" 2019-06-25 23:17:56 +01:00
Eli Flanagan a24d745d75 fix broken documentation links 2019-04-25 09:49:44 -04:00
fmuscolino 9c89c1ab59 Update docs 2019-04-12 13:46:05 +02:00
Dolan 7d116d1ce9 Add more documentation 2018-08-04 03:28:27 +01:00
Dolan 73267ac4e5 Add docsify documentation 2018-08-03 23:26:14 +01:00