summaryrefslogtreecommitdiff
path: root/addons/web_editor
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-11-17 14:48:43 +0100
committerChristophe Simonis <chs@odoo.com>2016-11-17 14:48:43 +0100
commit1ef4061e68a6a9f07effe5efcdbd3fb3e5054cf6 (patch)
tree32918613ae611e9b55ec5a08904a9a649bc6fd54 /addons/web_editor
parentd7004d7dc0859056f982052184d5500846c13716 (diff)
parent3b2f4e244f51b37050f61629bf01e6dc38cc4817 (diff)
[MERGE] forward port branch saas-11 up to 3b2f4e2
Diffstat (limited to 'addons/web_editor')
-rw-r--r--addons/web_editor/static/src/js/backend.js10
-rw-r--r--addons/web_editor/static/src/js/rte.summernote.js2
2 files changed, 12 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js
index 17ce8c3c1a1..3b414d45cb5 100644
--- a/addons/web_editor/static/src/js/backend.js
+++ b/addons/web_editor/static/src/js/backend.js
@@ -161,6 +161,11 @@ var FieldTextHtmlSimple = widget.extend({
return !this.get('value') || this.get('value') === "<p><br/></p>" || !this.get('value').match(/\S/);
},
commit_value: function () {
+ // leave code view before saving
+ if (this.$content.prev('textarea').length === 1) {
+ var layoutInfo = { 'editor': function() { return this.$content; }.bind(this) };
+ $.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo);
+ }
if (this.options['style-inline']) {
transcoder.class_to_style(this.$content);
transcoder.font_to_img(this.$content);
@@ -374,6 +379,11 @@ var FieldTextHtml = widget.extend({
this._dirty_flag = false;
return this.editor.save();
} else if (this._dirty_flag && this.editor && this.editor.buildingBlock) {
+ // leave code view before saving
+ if (this.$content.prev('textarea').length === 1) {
+ var layoutInfo = { 'editor': function() { return this.$content; }.bind(this) };
+ $.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo);
+ }
this.editor.buildingBlock.clean_for_save();
this.internal_set_value( this.$content.html() );
}
diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js
index a83e9136a06..5c621ebbe70 100644
--- a/addons/web_editor/static/src/js/rte.summernote.js
+++ b/addons/web_editor/static/src/js/rte.summernote.js
@@ -538,6 +538,8 @@ function prettify_html(html) {
}
return result;
}
+
+// Change Warning: called with dummy arguments to quit code view before saving
$.summernote.pluginEvents.codeview = function (event, editor, layoutInfo) {
if (layoutInfo.toolbar) {
return eventHandler.modules.codeview.toggle(layoutInfo);