From 3f7b1f608344fed2f79d08ec602a700ec34c70cb Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 10 Jan 2017 08:21:25 +0100 Subject: [PATCH] [FIX] web_editor: ignore read only + debug + write In some case (for example the one solved with b51d21c5) we can have write done on a field text in read only mode. With 98ed53ce if : - such a case happened (in b51d21c5 the fix only worked after the given field was written one time) or a similar instance, - and the user was in debug mode, - and the widget used was TextFieldHtmlSimple this could lead to an issue with the code trying to toggle the code view mode whilst the editor is closed. --- addons/web_editor/static/src/js/rte.summernote.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js index 6110820de7d..869ece9cf58 100644 --- a/addons/web_editor/static/src/js/rte.summernote.js +++ b/addons/web_editor/static/src/js/rte.summernote.js @@ -494,13 +494,18 @@ function prettify_html(html) { * disable (false) or enable (true) the code view mode. */ $.summernote.pluginEvents.codeview = function (event, editor, layoutInfo, enable) { + if (layoutInfo === undefined) { + return; + } if (layoutInfo.toolbar) { + // if editor inline (FieldTextHtmlSimple) var is_activated = $.summernote.eventHandler.modules.codeview.isActivated(layoutInfo); if (is_activated === enable) { return; } return eventHandler.modules.codeview.toggle(layoutInfo); } else { + // if editor iframe (FieldTextHtml) var $editor = layoutInfo.editor(); var $textarea = $editor.prev('textarea'); if ($textarea.is('textarea') === enable) {