angular-summernote icon indicating copy to clipboard operation
angular-summernote copied to clipboard

defer initialization

Open timcosta opened this issue 10 years ago • 11 comments

Is there a way to defer initialization of Summernote using this? I want to initialize it when the user clicks something, and right now as soon as is seen in the DOM the editor gets initialized.

timcosta avatar Nov 13 '14 00:11 timcosta

Interesting requirement. I will think about that.

outsideris avatar Nov 13 '14 06:11 outsideris

I'd also like this see this feature! I'm going to set up some sort of work around in the meantime

trickpattyFH20 avatar Dec 01 '14 23:12 trickpattyFH20

This will be interesting. I wonder if this will improve the initial load time. I noticed that when I call summernote multiple times inside a form's ng-repeat through a custom directive, it does take a long time to initialize it.

Mr-Anonymous avatar Jun 24 '15 18:06 Mr-Anonymous

I ended up writing a semi custom wrapper as the inability to defer loading killed this plugin for me (comment tree, nested replies). I suppose that using an ng-if on the summernote element where you flip the boolean on click would work the same though?

timcosta avatar Jun 24 '15 18:06 timcosta

@tjsail33 Was it taking too long for this plugin to load for you too? When I tested in Firefox, the page takes more than 30 seconds to load when I have this directive in that form. Without the summernote directive, it loads in 1-2 sec. Were you facing a similar issue? Is that why you are trying to defer the plugin loading?

Mr-Anonymous avatar Jun 24 '15 18:06 Mr-Anonymous

Yes. Especially when i had close to 30 instances of it on a page that all tried to load at once. I don't think the plugin is inefficient - I just think it needs a way to defer initialization in some way to handle use cases where more than one editor exists in the DOM at once.

timcosta avatar Jun 24 '15 18:06 timcosta

Thanks for confirming that. My situation is similar. I have a form with multiple instances of this editor. When I have more than as little as 2-3 itself, the page pretty much crashes due to long initialization time. For now, I am considering to just use a plain textarea as a temporary solution. I agree, the plugin is not inefficient. Its a very good plugin but unfortunately its close to unworkable when there is a need for multiple instances in 1 page. Hoping there could be a solution for this.

Mr-Anonymous avatar Jun 24 '15 19:06 Mr-Anonymous

@tjsail33 @Mr-Anonymous Do you know other directives has defer initialization or snippets to defer initialization? If so, it is very helpful to resolve this issue. For now, I have no idea about a way how to handle defer initilalization.

outsideris avatar Jun 25 '15 10:06 outsideris

i think that a good way to do this would be a boolean initialization variable. I use it in my custom implementation, and tear down the editor when the boolean is false, initialize it when the boolean is true.

timcosta avatar Aug 18 '15 19:08 timcosta

@tjsail33 So, did you expose the variable as attibute like <sumernote defer="true">?

outsideris avatar Aug 19 '15 01:08 outsideris

I did <cu-summernote initialized="variable.editable">.

timcosta avatar Aug 19 '15 01:08 timcosta