options.callbacks being overwritten
So, now one has to add callbacks to all summernote elements instead of just one global location like a shared summernote options object.
Why not keep reference to the original callbacks object, and call those functions if they exist? Like this:
var callbacks = {}, originalCallbacks = summernoteConfig.callbacks||{};
callbacks.onEnter = function(evt) {
$scope.enter({evt:evt});
!evt.defaultPrevented && angular.isFunction(originalCallbacks.onEnter) && originalCallbacks.onEnter(evt)
};
Geez, an even worse issue is that you're modifying the config object and you're not even making a copy of it first! Bad form ;) If you're going to muck with my configs, have the decency to not do it to the original object. This prevents one from having a global config.
I didn't understand why !evt.defaultPrevented && angular.isFunction(originalCallbacks.onEnter) && originalCallbacks.onEnter(evt) parts are needed?
But I agree with you for making a copy of the config object.
well, !evt.defaultPrevented isn't really needed I suppose
I don't understand originalCallbacks.onEnter(evt) part, too. $scope.enter({evt:evt}); call a function which a user bind it to callback. Why it invoke callbacks again?
Ok, try re-reading the opening issue (making a copy of the config object is just a side issue). Basically, I want to be able to have a globally shared config object for all my summernotes, which contains these event callbacks. Currently, you overwrite these values on the config object, forcing one to add "on-event" attributes in the HTML, to each of the (possibly) dozens of summernote forms. This is a hassle. If summernote would just check for these event handlers on the config object, as well as accepting "on-event" attributes, then I wouldn't need to add event listeners to each instance.
Basically you accept a summernote config object, and then overwrite some pretty important things, before passing it to summernote. It'd be better if you didn't do that.