Simplify custom modifications
I've monkey-patched the
addImageroutine, also to pick from an internal image list, with our own custom handlers. So I've removed all the blueimp dependencies from my application, but only by duplicating a bunch of plugin code in my app.$editor.data('plugin_mediumInsertImages').add = myAddImageCode;Gross. Extension should be supported by the plugin, since applications will differ so widely...
@jbellsey in #177
@jbellsey I started working on simplifying custom modifications. What are your requirements?
I have this API in mind:
// Initializition stays the same
$('.editable').mediumInsert({ editor: editor });
// Overriding core function
$('.editable').mediumInsert('deprecated', function (oldName, newName, version, since) {
// Your custom content. You could even add new arguments if you need, just make sure the rest of the arguments remains backwards compatible
});
// Calling core function with arguments
$('.editable').mediumInsert('deprecated', 'old()', 'new()', '2.0', '1.7');
// Overriding addon function just by prepending addon name separated with colon
$('.editable').mediumInsert('images:addToolbar', function () {
// Your custom content
});
// Calling addon function
$('.editable').mediumInsert('images:addToolbar');
What do you think? Would this help you with customizing? Or do you need something more than this?
Why not add callback functions to the options object?
var options = {
addons: {
images: {
callbacks: {
newImage: function(opts) { return {url, width, height, title}; },
// etc
}
}
}
You could also let the user add callbacks individually, as you suggested. Perhaps by giving the user an API when they instantiate:
var MI = $obj.mediumInsert(options);
MI.addCallback('newImage', fnc);