grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[Feature Request]: Expose options parameter to `setStyle` & `setComponents`

Open mcottret opened this issue 6 years ago • 2 comments

Hello again !

Our team has recently been trying to update GrapesJS' canvas programmatically without accidentally triggering an update event. If our understanding is correct, this would mean allowing a call to setStyle or setComponents not to trigger an update event, regardless of the current stepsBeforeSave & changesCount values.

After some research, the avoidStore option seems like a good fit to achieve what we're trying to do, but the problem is that we didn't find any way to use this parameter with the current public API.

A potential solution we found would imply exposing the options parameter to the setStyle & setComponents methods, to be able to do the following:

const options = {avoidStore: true};
this.editor.setStyle([/*...*/], options);
this.editor.setComponents([/*...*/], options);

Do you consider this a valid use case, or is there some other way to achieve this that we could not find ?

As always, I'd be happy to open a PR if so !

Cheers :)

mcottret avatar Jun 25 '20 14:06 mcottret

Yeah, it actually might make sense having options in these methods, so a PR would be welcome.

artf avatar Jul 02 '20 11:07 artf

Great ! #2872 opened.

mcottret avatar Jul 02 '20 13:07 mcottret