summaryrefslogtreecommitdiff
path: root/addons/web_editor/static
diff options
context:
space:
mode:
authorGorash <chm@odoo.com>2019-03-04 08:33:53 +0000
committerGorash <chm@odoo.com>2019-03-04 08:33:53 +0000
commit972a1c99209d19ff7a75e5b22d071c8d458b3b89 (patch)
tree8f32b056dd3d0b9d0b69a6d2b5f11376988bf1be /addons/web_editor/static
parent30bbfff8b43c359814b9a39221aafb5894ab7eb3 (diff)
[FIX] web_editor: Evoid the risk of deleting the summernote library
For iframes, we need to inject summernote because there are references to "document" in it. When loading the iframe, if it is canceled, there is a risk that the library is erased and that it breaks the field html. We must also slightly modify the library to prevent it from making changes to the library of the main "window".
Diffstat (limited to 'addons/web_editor/static')
-rw-r--r--addons/web_editor/static/lib/summernote/summernote.js2
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js2
-rw-r--r--addons/web_editor/static/src/xml/wysiwyg.xml10
3 files changed, 6 insertions, 8 deletions
diff --git a/addons/web_editor/static/lib/summernote/summernote.js b/addons/web_editor/static/lib/summernote/summernote.js
index 2bcb61bb873..0f9dfaef656 100644
--- a/addons/web_editor/static/lib/summernote/summernote.js
+++ b/addons/web_editor/static/lib/summernote/summernote.js
@@ -1695,7 +1695,7 @@ var dom = {
isCustomStyleTag: isCustomStyleTag
};
-$$1.summernote = $$1.summernote || {
+$$1.summernote = {
lang: {}
};
$$1.extend($$1.summernote.lang, {
diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js
index be6ac41e5cb..0d75f360731 100644
--- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js
+++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js
@@ -13,6 +13,8 @@ $.fn.summernote = function () {
var summernote = this[0].ownerDocument.defaultView._fnSummenoteSlave || _fnSummernoteMaster;
return summernote.apply(this, arguments);
};
+window._fnSummernoteMaster = $.fn.summernote;
+window._summernoteMaster = _summernoteMaster;
/**
* Add option (inIframe) to load Wysiwyg in an iframe.
diff --git a/addons/web_editor/static/src/xml/wysiwyg.xml b/addons/web_editor/static/src/xml/wysiwyg.xml
index d28efeee92b..87d984b6fcd 100644
--- a/addons/web_editor/static/src/xml/wysiwyg.xml
+++ b/addons/web_editor/static/src/xml/wysiwyg.xml
@@ -23,19 +23,15 @@
<div id="iframe_target" style="height: calc(100vh - 6px);"/>
<script type="text/javascript">
window.$ = window.jQuery = window.top.jQuery;
- var _summernoteMaster = $.summernote;
- var _fnSummernoteMaster = $.fn.summernote;
- delete $.summernote;
- delete $.fn.summernote;
</script>
<script type="text/javascript" src="/web_editor/static/lib/summernote/summernote.js"/>
<script type="text/javascript">
window._summernoteSlave = $.summernote;
window._summernoteSlave.iframe = true;
- window._summernoteSlave.lang = _summernoteMaster.lang;
+ window._summernoteSlave.lang = window.top._summernoteMaster.lang;
window._fnSummenoteSlave = $.fn.summernote;
- $.summernote = _summernoteMaster;
- $.fn.summernote = _fnSummernoteMaster;
+ $.summernote = window.top._summernoteMaster;
+ $.fn.summernote = window.top._fnSummernoteMaster;
if (window.top.<t t-esc="updateIframeId"/>) {
window.top.<t t-esc="updateIframeId"/>(<t t-esc="avoidDoubleLoad"/>);
}