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

83
Visualizações
draft.js Replace paste image

Currently we have a demand for this feature

  1. Paste the image in draft.js
  2. Replace the pasted image in step1 with a new image a moment later

We have successfully, implemented step1, but have no idea on how to implement step2

enter image description here enter image description here

For step1, our code is like this

   const currentContent = editorState.getCurrentContent()
   const entity = currentContent.createEntity('image', 'IMMUTABLE', {
     src: base64,
     id: id,
   })
   const newState = EditorState.set(editorState, {
     currentContent: entity,
   })
   const lastKey = entity.getLastCreatedEntityKey()
   setEditorState(AtomicBlockUtils.insertAtomicBlock(newState, lastKey, ' '))

For Step2, we tried the api like this.

 Modifier.replaceWithFragment

But Could not figured it out

Does anyone knows the solution?

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