- `paths` draws a custom shape from several paths, each filled with the
shape's fill, not at all, or lighter or darker, and with or without its line
- A closed part of a path inside another is a hole, whichever way round it
is drawn: parts are turned round so both fill rules cut the same holes
- `textArea` sets where a custom shape's text goes, and "fitText" fits it
- `connectionPoints` gives a custom shape its own connection points
- Connection sites and text areas are guides that keep their share of the
shape when it is resized, as PowerPoint writes freeforms
- Demo 120, with a reference render, and docs in shapes.md
Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Document's background.color takes a ThemeColor, written with w:themeColor,
w:themeTint or w:themeShade and the hex colour it comes to. The released
themeColor, themeTint and themeShade strings still work, and are deprecated.
- patchDocument reads the template's theme colours (a:srgbClr, a:sysClr), so
theme colours in patches get the template's hex value rather than Office's.
- Demo 119 has a page background in a theme colour. Docs updated.
Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Shapes in a ShapeGroupRun or the new ShapeCanvasRun can have an `id`, and a
child with `type: "connector"` joins two of them:
{ type: "connector", from: "start", to: { id: "step", side: "top" }, route: "elbow" }
The connector is drawn from one shape to the other, so it needs no size or
position. It attaches at the shapes' connection sites (a:stCxn/a:endCxn),
choosing the facing sides unless a side is given, and routes as Word does:
a straight line, or elbow and curved connectors that leave and arrive at right
angles and loop around shapes when they have to.
Word only keeps connectors attached when shapes move on a drawing canvas, so
ShapeCanvasRun writes a wpc:wpc canvas with an optional background and outline.
Connection sites come from the preset shape definitions of ECMA-376:
scripts/generate-preset-shape-geometry.ts extracts each shape's sites and the
guides they depend on, and a small evaluator calculates them for a shape's size
and adjustments. A test also checks the adjustments table against the
definitions.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
OOXML abbreviates or numbers many names (roundRect, snip2DiagRect, ribbon2,
bentConnector3, sysDot, lgDash, sm/med/lg). The public API now uses names
that say what each value is, and maps them to OOXML names when writing XML:
- 49 of the 187 preset shape types, e.g. rectangle, roundedRectangle,
diagonalSnippedCornersRectangle, ribbonUp, elbowConnector, lineCallout
- Line dashes: longDash, shortDot, shortDashDot, ...
- Arrowhead sizes: small, medium, large
- Gradient path: rectangle
Passing an OOXML shape name throws an error that suggests the new name.
A new Shape Types docs page lists every shape with its OOXML name.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* watermark added
* fix: resolve final eslint identifier denylist error for string key
* fix: resolve verbatimModuleSyntax errors by using type-only imports
* style: format watermark files with prettier
* style: format watermark files with prettier
* fix: bypass prettier and eslint conflict using computed property for string key
* fix: replace explicit any with unknown array in mock context
* fix: replace explicit any with unknown array in mock context
* fix: replace explicit any with unknown array in mock context
* feat: add text and image watermarks on a generic VML drawing layer
Adds TextWatermark and ImageWatermark, inline elements that go inside a
header paragraph and emit the same markup Word writes for its own
watermarks (WordArt shape type 136 for text, picture frame type 75 for
images, PowerPlusWaterMarkObject / WordPictureWatermark ids), so Word
recognizes them and can remove or replace them from Design > Watermark.
The watermarks are built on a new src/file/vml module: typed builders for
w:pict, v:shape, v:shapetype, v:fill, v:stroke, v:textpath, v:imagedata,
v:path, v:formulas, v:handles and o:lock, plus the Word preset shape types.
The existing Textbox now uses the same builders, and future VML drawing
features can compose them too.
Compared with the original draft, rotation is written in degrees in the
shape style as Word does (not 65536-based fixed point), the shape type
definition is included, colours are normalized for VML, the default height
keeps letters in proportion for the text length, and image watermarks
register their media and header relationship like ImageRun.
Also adds docs/usage/watermarks.md, a sidebar entry, a cross-link from the
headers and footers page, and two demos.
Resolves#3017
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: unknown <yusuf.unal@nordisglobal.com>
Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
The cover page linked to "#Welcome", but the README heading was renamed to
"Welcome to docx", so docsify resolved it to "#/?id=welcome" which matches
nothing. Point it at the current heading id instead.
Also lift the GitHub corner above the cover page. The theme gives both
".cover-main" and ".github-corner" z-index 1 and the cover is rendered later
in the DOM, so once scrolled the cover overlapped the corner and made the
link unclickable.
Fixes#3477
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* fix(table): emit numeric pct widths in fiftieths of a percent
createTableWidthElement wrote a numeric PERCENTAGE size as a "50%" string.
Both that string and the fiftieths-of-a-percent integer (50% = 2500) are
valid under ST_MeasurementOrPercent, but Word writes the integer, and
stricter consumers — Google Docs and Apple Pages/QuickLook/Mail — misread
the string form and collapse table columns to one character.
Emit the integer (Math.round(size * 50)) for numeric pct sizes to match
Word's output. Callers who want the literal percent string can still pass a
Percentage (e.g. "50%"), which is left untouched. Adds table-width.spec.ts
and updates the two specs that asserted the old string output.
* fix(table): derive tblGrid from table and cell widths so tables render in Google Docs and Pages
Writing pct widths as fiftieths of a percent (previous commit) is correct but
does not fix#1457 on its own. Google Docs, Apple Pages, QuickLook and other
consumers lay a table out from w:tblGrid alone and ignore w:tblW / w:tcW
percentages, while docx wrote a placeholder grid of 100 twips per column
whenever columnWidths was omitted. Every percentage-width table therefore
collapsed to one character per column in those readers (#1457, #349, #216,
#3015). Word recomputes the layout from the preferred widths, which is why it
was never affected.
When columnWidths is omitted the grid is now derived, in twips, the way Word
writes it after laying the table out:
- percentages resolve against the text width of the section the table is in
(page width minus margins and gutter, per column in multi-column sections),
or against the parent cell for nested tables, at serialization time
- dxa and universal-measure widths are used as they are
- columns without a width share what is left of the table width equally
- column spans and the continuation cells inserted for rowSpan are honoured
Explicit columnWidths are written unchanged. Tables formatted without a
document (bare Formatter, patcher) resolve against the default A4 page, and
formatting a table more than once is idempotent.
New: SectionProperties.AvailableTextWidth, Body.getSectionPropertiesFor,
universalMeasureToTwips, Table.ColumnWidths and Table.getCellWidth. Adds a
demo, documents columnWidths, and applies the review nits on table-width.spec.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* test: use a cspell-friendly malformed measure in the universalMeasureToTwips spec
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* 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 <>
* chore(gitignore): build folder
* chore(demo): passing demo number as argument will run that demo
* feat(table-of-contents): cached data
* chore(table-of-contents): clean up
This commit can be squashed with the previous one if necessary
* test(table-of-contents): cached entries
* docs(table-of-contents): added cached entries section
* Improve coverage
* Fix tests
* feat(table-of-contents): use style with levels in cached entries
---------
Co-authored-by: Dolan Miu <>
* Added the table look parameter to new Table class to enable controlling various conditional formatting table properties (first row, first column etc)
* Improve documentation
---------
Co-authored-by: Dolan <dolan_miu@hotmail.com>
* feat(footnotes): Support lists and images in footnotes
* fix numbering in headers/footers
* Fix tests and add documentation
---------
Co-authored-by: Dolan <dolan_miu@hotmail.com>
* feat: add endnotes support to docx library
- Add comprehensive endnotes implementation with EndnoteReferenceRun component
- Create Endnotes class and EndnotesWrapper for document integration
- Add endnote attributes, reference runs, and separator components
- Update documentation to cover both footnotes and endnotes usage
- Include demo file demonstrating endnotes functionality with multiple sections
- Integrate endnotes into compiler pipeline and content types
- Add comprehensive test coverage for endnote components
Endnotes appear at the end of the document, unlike footnotes which appear at the bottom of each page, making them ideal for academic papers and formal documents.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts:
# src/export/packer/next-compiler.ts
# src/file/paragraph/run/empty-children.ts
# src/file/styles/style/default-styles.ts
* Fix tests
* Add documentation
* Add and fix test
---------
Co-authored-by: matt <matthew.ed.keller@gmail.com>
* docs(numbering): add docs for `instance` option and update full example
- Documented `numbering.instance` for ordered lists
- Explains continuation vs restart behavior
- Added example usage with multiple instances
- Updated full example to reflect latest numbering behavior
resolves 3037, fixes 3037
* clean up lock file
* fix numbering reference
* Remove example update
* fix: separate vertical alignment enums for table and section properties
- Introduced `VerticalAlignTable` for table-cell vertical alignment with valid values: `top`, `center`, and `bottom`.
- Added `VerticalAlignSection` for section properties, extending `VerticalAlignTable` with an additional value `both`.
- Marked the original `VerticalAlign` as deprecated for backward compatibility, directing users to the new enums.
- Updated type definitions for better clarity on valid vertical alignments.
* refactor: update vertical alignment imports and types for section and table properties
- Renamed `VerticalAlign` to `VerticalAlignSection` in section properties and `VerticalAlignTable` in table-cell properties for clarity.
- Updated type definitions to reflect the new enum names, ensuring better organization and understanding of vertical alignment options.
- Adjusted related test cases to utilize the new imports and types.
* refactor: update demos to use new enums for table and section properties for vertical alignment