fix(frontend): fix dompurify.sanitize import

The update to dompurify 3.2.4 broke the import of dompurify.sanitize,
which now fails with a TypeScript error (likely related to the
introduction of type definitions in 3.2.0). Using the DOMPurify default
export fixes the issue.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
Matthias Schiffer
2025-07-07 21:55:52 +02:00
committed by Erik Michelson
parent 1f3e3545a0
commit 4e9d15280d
@@ -6,8 +6,7 @@
import { measurePerformance } from '../../../utils/measure-performance'
import type { ParserOptions } from '@hedgedoc/html-to-react'
import { convertHtmlToReact } from '@hedgedoc/html-to-react'
import type DOMPurify from 'dompurify'
import { sanitize } from 'dompurify'
import DOMPurify from 'dompurify'
import React, { Fragment, useMemo } from 'react'
export interface HtmlToReactProps {
@@ -28,7 +27,7 @@ const REGEX_URI_SCHEME_NO_SCRIPTS = /^(?!.*script:).+:?/i
export const HtmlToReact: React.FC<HtmlToReactProps> = ({ htmlCode, domPurifyConfig, parserOptions }) => {
const elements = useMemo(() => {
const sanitizedHtmlCode = measurePerformance('html-to-react: sanitize', () => {
return sanitize(htmlCode, {
return DOMPurify.sanitize(htmlCode, {
...domPurifyConfig,
RETURN_DOM_FRAGMENT: false,
RETURN_DOM: false,