Skip to content

Commit 6d76429

Browse files
authored
docs(numbering): add docs for instance option and update full example (#3267)
* 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
1 parent 7111f01 commit 6d76429

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

demo/3-numbering-and-bullet-points.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ const doc = new Document({
233233
level: 0,
234234
},
235235
}),
236+
236237
new Paragraph({
237238
text: "Custom Bullet points",
238239
heading: HeadingLevel.HEADING_1,

docs/usage/numbering.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,37 @@ new Paragraph({
8787
}),
8888
```
8989

90+
### Numbering options
91+
92+
Along with `reference` and `level`, the `numbering` object supports an optional `instance` property:
93+
94+
| Property | Type | Notes |
95+
| --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
96+
| reference | `string` | The numbering style reference, must match a defined config |
97+
| level | `number` | The list level (0 = top-level, 1 = sub-list, etc.) |
98+
| instance | `number` | *(Optional)* Identifies the instance of the list. Lists with the same `instance` (or none) continue numbering across paragraphs. A new `instance` value restarts numbering from `1`. |
99+
100+
Example:
101+
102+
```ts
103+
new Paragraph({
104+
text: "First list item",
105+
numbering: { reference: "my-numbering", level: 0, instance: 1 },
106+
});
107+
108+
new Paragraph({
109+
text: "Second list item",
110+
numbering: { reference: "my-numbering", level: 0, instance: 1 },
111+
});
112+
113+
new Paragraph({
114+
text: "New list, starts again at 1",
115+
numbering: { reference: "my-numbering", level: 0, instance: 2 },
116+
});
117+
```
118+
119+
120+
90121
## Un-ordered lists / Bullet points
91122

92123
Add a `numbering` section to the `Document` to numbering style, define your levels. Use `LevelFormat.BULLET` for the `format` in `levels`:

0 commit comments

Comments
 (0)