最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - sun-editor styles not getting applied when using dangerouslySetInnerHTML - Stack Overflow

programmeradmin7浏览0评论

I'm trying to render the html created using the rich-text-editor(sun editor). But the min.css import is not getting applied to the dangerouslySetInnerHTML.

import { useLocation } from "react-router-dom"
import { blogDetailsType } from "./BlogForm"
import DOMPurify from "dompurify";
import 'suneditor/dist/css/suneditor.min.css'; 
// import SunEditor from 'suneditor-react';

const Preview = () => {
    const location = useLocation()
    const data: blogDetailsType = location?.state
    const sanitizedHtml = DOMPurify.sanitize(data?.blog_html);
    
    return (
        <div className="tw:text-primary text-responsive-sm tw:py-4">
                <div dangerouslySetInnerHTML={{__html:sanitizedHtml}}></div>
        </div>
    )
}

export default Preview

but the same styles are working to the <SunEditor/> component though, also inline styles are working as usual in dangerouslySetInnerHTML.

I tried to set the min.css on the index.html but no luck.

<link rel="stylesheet" href=".min.css" />
发布评论

评论列表(0)

  1. 暂无评论