michelson / dante2

A complete rewrite of dante editor in draft-js
https://michelson.github.io/dante2/
Other
912 stars 121 forks source link

How do I get default widgets after adding widget prop? #163

Closed kumarabhirup closed 5 years ago

kumarabhirup commented 5 years ago

I've added ImageBlockConfig() in widgets array. Due to it, I lost other widgets that were in there by default. I lost the Video and Embed Block.

To add them, I tried using VideoBlockConfig() and EmbedBlockConfig(). Though I see the buttons, but they don't work without configuration. How should I configure them to work like before?

Do you have some function like DanteTooltipConfig() which gives default tooltips?

Code 👇

<Dante
      .....
        widgets={[
          ImageBlockConfig({
              options: {
                  upload_handler: async (file, imageBlock) => {

                    const data = new FormData()
                    data.append('file', file)
                    data.append('upload_preset', 'paprinkEditor')

                    await fetch(`https://api.cloudinary.com/v1_1/${process.env.CLOUDINARY_USERNAME}/image/upload`, {
                      method: 'POST',
                      body: data
                    })
                    .then(async res => {
                      const payload = await res.json()
                      imageBlock.uploadCompleted(payload.secure_url)
                    })
                    .catch(err => {
                      imageBlock.uploadFailed()
                    })

               }
            }
        })
     ]}
     ....
/>
kumarabhirup commented 5 years ago

Seems like I solved it. Pasted the code from documentation. @michelson thanks for help and efforts.

makivlach commented 4 years ago

@michelson Would you, please, include link to this issue (or the whole code) to the documentation? I think it would fit perfectly somewhere here: https://michelson.github.io/dante2/#/src-widgets