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

259
Visualizações
Quill js Question :- When I make changes to the delta will it also do changes to DOM?

Problem :- So when I insert an image in quill js editor it uploads image as data base64 format. Which is very big to move around different pages.

Aim :- I want to make a program so that when an image is inserted in editor I download the image, through laravel backend and return image url to replace the img src in the dom. I have already done the downloading of image and url returning part of the code.

Main Question :- If I edit Delta of quill js will it change the img src in the dom too??

P.S. :- I don't have a code yet to submit I am just curious to know if delta changes will reflect in DOM or not. Please comment if you need more info, Thanks

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

0

So I figured it out I stored delta to a variable, then I made changes to that variable and then I setContents(delta) to the editor and that changed the data base 64 to url.

emailEditor.on('editor-change', function(eventName,args) {
 var delta = ( emailEditor.getContents() );
 if (eventName === 'text-change') {

 let arr = (args['ops']);
 if (args['ops'].length == 1 && !(arr[0].hasOwnProperty('delete'))){
   if (args['ops'][0]['insert']['image'] != null){
    for (let index = 0; index < delta['ops'].length; index++) {          
     if (delta['ops'][index]['insert'].hasOwnProperty('image') && args['ops'][0]['insert']['image'] == delta['ops'][index]['insert']['image']) {
      saveImage(index);
     }
    }
   }
  }
  else if (args['ops'].length == 2 && !(arr[1].hasOwnProperty('delete'))){
   if (args['ops'][1]['insert']['image'] != null){
    for (let index = 0; index < delta['ops'].length; index++) {          
     if (delta['ops'][index]['insert'].hasOwnProperty('image') && args['ops'][1]['insert']['image'] == delta['ops'][index]['insert']['image']) {
      saveImage(index);
     }
    }
   }
  }
 }

 function saveImage(key) {
  let imageURL = JSON.stringify(delta['ops'][key]['insert']['image']);
  $.ajax({
   headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
   },
   type: "POST",
   url: "url-to-backend",
   data: { "imageURL": imageURL },
   success: function (data) {
    delta['ops'][key]['insert']['image'] = (data);
    emailEditor.setContents(delta);
   },
   error: function (data) {
    alert("some Error");
   }
  });
 }
});

My code is not perfect, but it works for me, if you find this not suitable for community or if you want me to add comments on working let me know I will delete/edit the Question/Answer.

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