2

I'm using editor.js for the first time, and I got stuck on this part: After selecting image from my gallery I want to re-render editor js with new image: this is my code for now

let url = `/${this.selectedImg.image.id}/${this.selectedImg.image.name}`
  this.editor.configuration.data.blocks.push({
    data: {
      caption: "",
      file: {url: url},
      stretched: false,
      withBackground: false,
      withBorder: false,
    },
    type: "image"
  })
  console.log(this.editor,'editor')
  this.editor.render()

but this.editor.render() doesn't work, what am I missing? this is console.log screenshot

I would appreciate any help!

1 Answer 1

2
 editor.save().then((data) => {
     data.blocks.push({
       type: "image",
       data: {
         caption: "",
         file: {url: url},
         stretched: false,
         withBackground: false,
         withBorder: false,
       },
     })
     this.editor.render(data)
     this.$emit('close', true)
   })

this was the answer, I misread the docs :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.