From 972a1c99209d19ff7a75e5b22d071c8d458b3b89 Mon Sep 17 00:00:00 2001 From: Gorash Date: Mon, 4 Mar 2019 08:33:53 +0000 Subject: [PATCH] [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". --- addons/web_editor/static/lib/summernote/summernote.js | 2 +- .../web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js | 2 ++ addons/web_editor/static/src/xml/wysiwyg.xml | 10 +++------- 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 @@