Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

345
Visualizações
How to apply TinyMCE styles to published content?

I am using TinyMCE editor in my React app. Its CSS is working in the Editor but not working on published content.

I am rendering an element like this:

 <div 
   dangerouslySetInnerHTML={{ __html: article.content }}
 ></div>

TinyMCE React Component:

 <TinyMCE
        tinymceScriptSrc={
          process.env.PUBLIC_URL + "/tinymce/js/tinymce/tinymce.min.js"
        }
        onEditorChange={log}
        init={{
          height: 500,
          plugins:
            "preview importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap  pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons",
          menubar: false,
          toolbar:
            "undo redo | bold italic underline strikethrough h2 h3 h4 link codesample align fontselect fontsizeselect formatselect outdent indent preview fullscreen forecolor backcolor removeformat emoticons",
        }}
      />

When using the Editor:

enter image description here

and its output like this on target page:

Css file link

How can i do this? I read its documentation but i couldn't find anything about this. Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It looks as though you're using the codesample plugin based on your screenshots. In that case, you need to include a syntax highlighter alongside your published content to make it appear similar to how it renders inside TinyMCE. The TinyMCE documentation has details on how to do this using Prism.js here: https://www.tiny.cloud/docs/plugins/opensource/codesample/#usingprismjsonyourwebpage

So basically, you need to ensure both the prism.css and prism.js stylesheet/script is included alongside your published content (either bundled or as external resources). As you're using React, you may also need to setup an effect hook to actually trigger syntax highlighting like so:

  useEffect(() => {
    Prism.highlightAll();
  }, []);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda