ueberdosis/tiptap · error

[tiptap error]: there is no window object available, so this

Error message

[tiptap error]: there is no window object available, so this function cannot be used

What it means

Error "[tiptap error]: there is no window object available, so this function cannot be used" thrown in ueberdosis/tiptap.

Source

Thrown at packages/core/src/utilities/elementFromString.ts:19

const removeWhitespaces = (node: HTMLElement) => {
  const children = node.childNodes

  for (let i = children.length - 1; i >= 0; i -= 1) {
    const child = children[i]

    if (child.nodeType === 3 && child.nodeValue && /^(\n\s\s|\n)$/.test(child.nodeValue)) {
      node.removeChild(child)
    } else if (child.nodeType === 1) {
      removeWhitespaces(child as HTMLElement)
    }
  }

  return node
}

export function elementFromString(value: string): HTMLElement {
  if (typeof window === 'undefined') {
    throw new Error(
      '[tiptap error]: there is no window object available, so this function cannot be used',
    )
  }
  // add a wrapper to preserve leading and trailing whitespace
  const wrappedValue = `<body>${value}</body>`

  const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body

  return removeWhitespaces(html)
}

View on GitHub (pinned to 496d53afd7)

When it happens

Trigger: Thrown at packages/core/src/utilities/elementFromString.ts:19 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ueberdosis/tiptap@496d53afd7 (2026-08-26). Data as JSON: /api/errors/dc0d73dc45528603. Report an issue: GitHub.