{"record":{"id":"76dff662e996e1f7","repo":"ueberdosis/tiptap","slug":"tableofcontents-extension-name-extensionname","errorCode":null,"errorMessage":"TableOfContents extension (name: \"${extensionName}\") not found in the extensions array","messagePattern":"TableOfContents extension \\(name: \"(.+?)\"\\) not found in the extensions array","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/extension-table-of-contents/src/generate-toc-ids.ts","lineNumber":48,"sourceCode":" * // → heading now has `id` and `data-toc-id` attributes\n * const html = renderToHTMLString({ content: docWithIds, extensions: [...] })\n *\n * @param doc - A Tiptap JSON document to add anchor IDs to.\n * @param extensions - The extensions to use. Must include the `TableOfContents` extension (or one extending it).\n * @param extensionName - Optional name of the `TableOfContents` extension to look up. Defaults to `'tableOfContents'`. Override this if you have extended the base extension and changed its `name`.\n * @returns The updated Tiptap JSON document.\n */\nexport function generateTocIds(\n  doc: JSONContent,\n  extensions: Extensions,\n  extensionName = 'tableOfContents',\n): JSONContent {\n  const tocExtension = extensions.find(ext => ext.name === extensionName) as\n    | typeof TableOfContents\n    | undefined\n\n  if (!tocExtension) {\n    throw new Error(\n      `TableOfContents extension (name: \"${extensionName}\") not found in the extensions array`,\n    )\n  }\n\n  const schema = getSchema([...extensions.filter(ext => ext.name !== extensionName), tocExtension])\n  const anchorTypes = tocExtension.options.anchorTypes ?? ['heading']\n  const getId = tocExtension.options.getId ?? (() => uuidv4())\n\n  const contentNode = PMNode.fromJSON(schema, doc)\n\n  // Mirrors the TableOfContents plugin's appendTransaction in `plugin.ts`:\n  // an anchor node gets a fresh id when its `data-toc-id` is missing or\n  // already seen earlier in the document. We track original ids — including\n  // null — to match the plugin's behavior exactly.\n  type Update = { pos: number; attrs: Record<string, unknown> }\n  const updates: Update[] = []\n  const existingIds: Array<string | null | undefined> = []\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/ueberdosis/tiptap/blob/496d53afd7e4e3c7424b4749adeff4f45e27ddb0/packages/extension-table-of-contents/src/generate-toc-ids.ts#L30-L66","documentation":"Error \"TableOfContents extension (name: \"${extensionName}\") not found in the extensions array\" thrown in ueberdosis/tiptap.","triggerScenarios":"Thrown at packages/extension-table-of-contents/src/generate-toc-ids.ts:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"496d53afd7e4e3c7424b4749adeff4f45e27ddb0","analyzedAt":"2026-08-26T22:41:43.400Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}