From f38f8930f0436a40f675fa1d054a9d46f550d440 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 13 Jun 2016 11:37:09 +0200 Subject: [PATCH] [FIX] web_editor: test jinja content to load editor in codeview The preview change the content because the browser try to fix the dom. If a user use jinja and activate the preview, the jinja code is (re)moved by the browser and broke the template. --- .../static/src/js/mass_mailing_editor.js | 12 +- .../mass_mailing/views/editor_field_html.xml | 6 +- addons/web/static/src/less/notification.less | 2 +- .../lib/summernote/src/js/EventHandler.js | 2 +- .../lib/summernote/src/js/summernote.js | 1 + addons/web_editor/static/src/js/backend.js | 90 ++++++++-- addons/web_editor/static/src/js/iframe.js | 50 +++++- addons/web_editor/static/src/js/inline.js | 70 ++++---- .../static/src/js/rte.summernote.js | 159 ++++++++++++------ addons/web_editor/static/src/js/tour.rte.js | 4 +- 10 files changed, 293 insertions(+), 103 deletions(-) diff --git a/addons/mass_mailing/static/src/js/mass_mailing_editor.js b/addons/mass_mailing/static/src/js/mass_mailing_editor.js index 7b312373e8d..95e7bc648b0 100644 --- a/addons/mass_mailing/static/src/js/mass_mailing_editor.js +++ b/addons/mass_mailing/static/src/js/mass_mailing_editor.js @@ -239,9 +239,9 @@ window.top.odoo[callback+"_updown"] = function (value, fields_values, field_name delete odoo_top[callback+"_updown"]; return; } - + var se = snippets_editor.instance; var $editable = $("#editable_area"); - var _val = $editable.prop("innerHTML"); + var _val = se.get_codesource(); var editor_enable = $('body').hasClass('editor_enable'); value = value || ""; @@ -250,12 +250,16 @@ window.top.odoo[callback+"_updown"] = function (value, fields_values, field_name if (value !== fields_values[field_name]) { rte.history.recordUndo($editable); } - snippets_editor.instance.make_active(false); + se.make_active(false); } if (value.indexOf('on_change_model_and_list') === -1) { - $editable.html(value); + if (!$editable.hasClass('codeview')) { + $('.note-popover button[data-name="codeview"]').click(); + } + $('textarea.codesource').val(value).data('indexOfnit', value); + $('.note-popover button[data-name="codeview"]').click(); if (editor_enable) { web_editor.editor_bar.display_theme_from_html(); diff --git a/addons/mass_mailing/views/editor_field_html.xml b/addons/mass_mailing/views/editor_field_html.xml index 11224aa4fbb..a1938d83d0b 100644 --- a/addons/mass_mailing/views/editor_field_html.xml +++ b/addons/mass_mailing/views/editor_field_html.xml @@ -24,8 +24,8 @@
-
-
+
+