+ 5

Override some functions from another javascript file (summernote.js)

I am changing summernote-lite.js to extend it's functionality and now I'm facing an issue: new version lunches and what now? I have to change it again if I want to use it on my websites. I think the best for me is to override functions that are already in that file and store that in separate js file, but how to do it? For example here is beginning of the summernote-lite.js file: (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) : typeof define === 'function' && define.amd ? define(['jquery'], factory) : (factory(global.jQuery)); }(this, (function ($1) { then here are couple functions that I want to override: var imageDialog = function (opt) { .... } Next: var ImageDialog = /* @class */ (function () { ... ImageDialog.prototype.initialize = function () { ... } ImageDialog.prototype.show = function () { ... } ImageDialog.prototype.showImageDialog = function () {

18th Mar 2019, 5:54 AM
Dejan Dozet
Dejan Dozet - avatar
4 Réponses
+ 8
It would help if you placed your code in Code Playground to make it convenient for review. Or if you have a link to a repo, that could be useful.
18th Mar 2019, 6:28 AM
David Carroll
David Carroll - avatar
+ 5
de do I'm not familiar with summernote-lite.js. I'm assuming it's part of the jQuery WYSIWYG editor. Is that code found in the summernote-lite.js file or is that in your web app? The code, as it's written, doesn't make sense. The IIFE is passing a reference to global. Is this supposed to be another global than the one already globally available? Since the global value isn't referenced in the code, it seems like it's not needed. I'm assuming the $1 is initialized earlier in the code. It's not clear what this is for or what values it can hold. There are so many more questions about the code with the overrides. I will wait until there is more to reference.
18th Mar 2019, 6:46 AM
David Carroll
David Carroll - avatar
+ 4
Yes, I see that code is all messed up and cut off. Ok will try to post it there, thanks
18th Mar 2019, 6:30 AM
Dejan Dozet
Dejan Dozet - avatar
+ 3
David Carroll , I think it is not possible to override those functions anyway. By investigating more i've found prototype to invoke that calls function from modules if defined and also looking on their documentation they mention those modules, so probably I have to go that way
18th Mar 2019, 7:08 AM
Dejan Dozet
Dejan Dozet - avatar