Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TehBunk opened this issue Nov 18, 2023 · 2 comments

Comments

@TehBunk
Copy link

TehBunk commented Nov 18, 2023

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?
})
  1. 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
#202
#224
#194

CC @brunolemos

@Drashti-Shah
Copy link

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

@TehBunk
Copy link
Author

TehBunk commented Apr 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants