> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Table of Contents extension

export const SourceCodeLink = ({extension, path}) => {
  const githubPath = path || `packages/super-editor/src/editors/v1/extensions/${extension.toLowerCase()}`;
  const githubUrl = `https://github.com/superdoc-dev/superdoc/tree/main/${githubPath}`;
  return <div>
      <p>
        <a href={githubUrl} target="_blank" rel="noopener noreferrer">
          View on GitHub →
        </a>
      </p>
    </div>;
};

Display Word-generated tables of contents with heading hierarchy preservation.

Tables of contents imported from Word documents render as block elements containing the original TOC paragraphs and page references.

<Info>
  Table of contents blocks are managed automatically during Word document import and export. There are no commands to programmatically create or update a TOC.
</Info>

## Word export

Tables of contents export as Word structured document tags with field instructions:

```xml theme={null}
<w:sdt>
  <w:sdtPr>
    <w:docPartObj/>
  </w:sdtPr>
  <w:sdtContent>
    <w:p>
      <w:r><w:fldChar w:fldCharType="begin"/></w:r>
      <w:r><w:instrText>TOC \o "1-3"</w:instrText></w:r>
      <w:r><w:fldChar w:fldCharType="end"/></w:r>
    </w:p>
  </w:sdtContent>
</w:sdt>
```

## Source code

<SourceCodeLink path="packages/super-editor/src/editors/v1/extensions/table-of-contents/table-of-contents.js" />
