From 12bbcda4c26b350680ba25c49a47e861386f72ea Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 17 Dec 2014 10:38:29 +0100 Subject: [PATCH] [IMP] summernote lib: check if a plugin add a method before the summernote methods because the plugins may be want to overwrite a default comportment. Key and click call plugins with more arguments (to allow the change and use of the lib) and the same arguments (some plugins can use button and key command for the same method) https://github.com/summernote/summernote/pull/809 --- .../lib/summernote/src/js/EventHandler.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/addons/website/static/lib/summernote/src/js/EventHandler.js b/addons/website/static/lib/summernote/src/js/EventHandler.js index 2dba3357d06..97409ac385f 100644 --- a/addons/website/static/lib/summernote/src/js/EventHandler.js +++ b/addons/website/static/lib/summernote/src/js/EventHandler.js @@ -369,8 +369,6 @@ define([ var layoutInfo = makeLayoutInfo(event.target); - event.preventDefault(); - // before command: detect control selection element($target) var $target; if ($.inArray(eventName, ['resize', 'floatMe', 'removeMedia', 'imageShape']) !== -1) { @@ -384,14 +382,16 @@ define([ $btn.parents('.popover').hide(); } - if (editor[eventName]) { // on command + if ($.isFunction($.summernote.pluginEvents[eventName])) { + $.summernote.pluginEvents[eventName](event, editor, layoutInfo, value); + } else if (editor[eventName]) { // on command var $editable = layoutInfo.editable(); $editable.trigger('focus'); editor[eventName]($editable, value, $target); + event.preventDefault(); } else if (commands[eventName]) { commands[eventName].call(this, layoutInfo); - } else if ($.isFunction($.summernote.pluginEvents[eventName])) { - $.summernote.pluginEvents[eventName](layoutInfo, value, $target); + event.preventDefault(); } // after command @@ -585,17 +585,17 @@ define([ eventName = 'visible'; } if (eventName) { - event.preventDefault(); - - if (editor[eventName]) { + if ($.summernote.pluginEvents[eventName]) { + var plugin = $.summernote.pluginEvents[eventName]; + if ($.isFunction(plugin)) { + plugin(event, editor, layoutInfo); + } + } else if (editor[eventName]) { editor[eventName]($editable, $editor.data('options')); + event.preventDefault(); } else if (commands[eventName]) { commands[eventName].call(this, layoutInfo); - } else if ($.summernote.plugins[eventName]) { - var plugin = $.summernote.plugins[eventName]; - if ($.isFunction(plugin.event)) { - plugin.event(event, editor, layoutInfo); - } + event.preventDefault(); } } else if (key.isEdit(event.keyCode)) { editor.afterCommand($editable);