{"record":{"id":"dc0d73dc45528603","repo":"ueberdosis/tiptap","slug":"tiptap-error-there-is-no-window-object-availabl","errorCode":null,"errorMessage":"[tiptap error]: there is no window object available, so this function cannot be used","messagePattern":"\\[tiptap error\\]: there is no window object available, so this function cannot be used","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/utilities/elementFromString.ts","lineNumber":19,"sourceCode":"const removeWhitespaces = (node: HTMLElement) => {\n  const children = node.childNodes\n\n  for (let i = children.length - 1; i >= 0; i -= 1) {\n    const child = children[i]\n\n    if (child.nodeType === 3 && child.nodeValue && /^(\\n\\s\\s|\\n)$/.test(child.nodeValue)) {\n      node.removeChild(child)\n    } else if (child.nodeType === 1) {\n      removeWhitespaces(child as HTMLElement)\n    }\n  }\n\n  return node\n}\n\nexport function elementFromString(value: string): HTMLElement {\n  if (typeof window === 'undefined') {\n    throw new Error(\n      '[tiptap error]: there is no window object available, so this function cannot be used',\n    )\n  }\n  // add a wrapper to preserve leading and trailing whitespace\n  const wrappedValue = `<body>${value}</body>`\n\n  const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body\n\n  return removeWhitespaces(html)\n}\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/ueberdosis/tiptap/blob/496d53afd7e4e3c7424b4749adeff4f45e27ddb0/packages/core/src/utilities/elementFromString.ts#L1-L30","documentation":"Error \"[tiptap error]: there is no window object available, so this function cannot be used\" thrown in ueberdosis/tiptap.","triggerScenarios":"Thrown at packages/core/src/utilities/elementFromString.ts:19 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"}