toc_insert
Inserts a table of contents field after a specified paragraph as tracked changes. Run field.update to populate entries and page numbers.
Instructions
Insert a table of contents (a TOC field) after a body paragraph after (p1#a1b2c3d4), as tracked insertions: a title (default "Contents", "" for none), the field listing heading levels levels (default "1-3") with a placeholder result, and a closing paragraph. Run field.update next to fill in the entries and page numbers (until then field.list shows it stale). Backed up and undoable (history.undo); dry_run previews. Returns the field paragraph's address.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc | Yes | Path to the .docx. | |
| tag | No | Appended to the author. | |
| after | Yes | Address of the body paragraph it goes after. | |
| title | No | Title paragraph above it (default "Contents"); "" for none. | |
| author | No | Revision author. | |
| expect | No | Write guard: the sha256 read earlier (doc.info, or a reply's doc.sha256), e.g. {"sha256": "9f86d081…"}; a file changed since is DOC_CHANGED_ON_DISK. | |
| levels | No | Heading levels it lists, e.g. "1-3" (default) or "2". | |
| dry_run | No | Preview only; write nothing. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Always true on success. | |
| op | Yes | The operation that ran. | |
| api | Yes | API version (1.0). | |
| doc | No | The document read or written: path, sha256 and paragraph count. | |
| next | Yes | Cursor for the next page (pass as cursor), or null. | |
| result | Yes | What the operation returns. | |
| warnings | Yes | Things to know about the result. |