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

164
Visualizações
Change default text color in TinyMCE after loading initial content from DB

I have a simple HTML page which is loading content (from a database) into a TinyMCE v5 textarea upon initialisation. I'd like to switch the default text color or highlight after the content has loaded so that any changes the user makes are discernable from the original text. If possible, I'd like to lock the option to change further formatting. The idea is basically a poor-man's track changes.

My current code looks like this:

<script>
  var txtcontent = '{!! str_replace(["\r", "\n"], "", $examQuestionInstance->question) !!}';
  tinymce.init({
    selector: 'textarea#answer_given_text',
    toolbar: 'undo redo | forecolor strikethrough',
    custom_colors: false,
    color_map: ['FF0000', 'Red', '000000', 'Black',],
    content_style: '.correction { color: red; }',
    statusbar: false,
    menubar: false,
    setup: function (editor) {
      editor.on('init', function (e) {
        editor.setContent(txtcontent);
      });
      editor.on('change', function (e) {
        @this.set('examQuestionInstance.answer_given_text', editor.getContent());
      });
    }
  });
</script>

I'd really appreciate thoughts and ideas on how to best handle this. Thanks!

about 4 years ago · Juan Pablo Isaza
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