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

96
Visualizações
Updating tinymce editor text between components

So I'm using the tinymce editor for Vue. I'm displaying one Editor in the parent component, and then rendering another Editor in the child which reactively displays what has been typed in the parent. The problem I'm running into is that the child is one character behind. I tried making the editor content its own variable in the child instead of being passed via props, but I couldn't figure out a way to update correctly while also saving the HTML tags that tinymce adds.

Here's what I have:

The parent component:

                        <Editor
                          v-model="body"
                          api-key=****
                          model-events="change keydown blur focus paste undo redo"
                          :init="{
                            height: 300,
                            menubar: false,
                            nonbreaking_force_tab: true,
                            branding: false,
                            init_instance_callback: function (editor) {
                              editor.on('Change', function (e) {
                                setHasChanges(); //this just says the form has updates
                              });
                            },
                            plugins: [
                              'advlist autolink lists link image charmap',
                              'searchreplace visualblocks code fullscreen',
                              'print preview anchor insertdatetime media',
                              'paste code help wordcount table'
                            ],
                            toolbar:
                              'undo redo | formatselect | bold italic | \
                            bullist numlist | \
                            alignleft aligncenter alignright outdent indent | help'
                          }"
                        >
                        </Editor>

And the child:

        <Editor
          :value="body"
          api-key=***
          model-events="change keydown blur focus paste undo redo"
          disabled="true"
          :init="{
            menubar: false,
            branding: false,
            toolbar: false,
            statusbar: false,
            content_style:
              'body { font-size: 12px; line-height: 1.35; margin: 10px auto 0; display: block; position: relative; height: 100px; overflow-x: hidden }'
          }"
        >
        </Editor>

So if the editor of the parent component had this:

<h2>Here is a title!</h2>
<ul>
 <li>and a bullet point</li>
 <li>and another</li>
</ul>

The child would display:

Here is a title!

  1. and a bullet point
  2. and another

How can I update the child reactively while still keeping the HTML tags?

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

0

So I figured it out. All I had to do was add "input" into the model-events of the editor on the parent component.

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