unlayer / react-email-editor

Drag-n-Drop Email Editor Component for React.js
https://unlayer.com/embed
MIT License
4.51k stars 728 forks source link

Impossible to dynamically update data without re-rendering the entire Editor #372

Open TehBunk opened 9 months ago

TehBunk commented 9 months ago

Seems like a severe limitation of unlayer is the inability to update options or data after the component has been initialized.

There's a clear way to pass data to a custom tool but passing data in this manor will trigger a re-render when updated.

When building a custom tool much like the product library custom tool you are forced to re-render if you want to update the products they can select from.

  1. Is it possible to add a method on the unlayer editor to update tool data dynamically? This would allow users to update data for their tools, without reloading unlocking tons of possibilities. Or maybe the addition of some alternative method of dynamically showing data without re-renders.

  2. Is it possible to allow users to define custom events for their custom tools? This would allow users to trigger code within in react components that have access to the emailEditorRef

    // Similar to 
    unlayer.addEventListener('design:loaded', function (data) {
    console.log('design:loaded', data);
    })
    // or maybe callback if possible even
    unlayer.registerCallback('selectImage', function (data: any, done) {
    done({ url: "" })
    })
    // would be nice to have it be able to edit the data for the custom tools
    unlayer.registerCallback('custom#tool', function (data: any, done) {
    done(data) // <- returns updated data?
    })
  3. Is it possible to add the addition of methods to change the device option -> from mobile, tablet, desktop dynamically

    unlayer.setDevice("email")

Similar issues OR issues that this would fix https://github.com/unlayer/react-email-editor/issues/202 https://github.com/unlayer/react-email-editor/issues/224 https://github.com/unlayer/react-email-editor/issues/194

CC @brunolemos

Drashti-Shah commented 4 months ago

@TehBunk @brunolemos Did you guys find the solution to this issue?

TehBunk commented 4 months ago

Did you guys find the solution to this issue?

No, this is still an issue that needs to be addressed. I am currently using logic similar to that seen in the product library custom tool but it leaves a-lot to be desired and still doesn't quite work as you would hope.

It requires a re-render every time data is updated/added, is slow, and only supports limited usage/use cases