summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/xml
diff options
context:
space:
mode:
authorGorash <chm@odoo.com>2019-08-08 15:08:09 +0000
committerDavid Monjoie <dmo@odoo.com>2019-08-22 06:41:05 +0000
commit56d0c1ed97784a2d2e6608caf8feafc5fa611d68 (patch)
tree0ef4b5e9db4cbe39ca2d411792dd450ce5adf13c /addons/web_editor/static/src/xml
parent1eb1c2b029c7216c70becbf4cd0d9e6535deea96 (diff)
[REF] web_editor, mass_mailing: new iframe mechanism
Since we reverted the saas-12.2 editor in favor of the 12.0 one, we faced a dilemna regarding how the editor iframe is handled in mass_mailing. The 12.0 version was using a special controller to get the website assets required for mass_mailing while the saas-12.2 version used a completely different mechanism that was, obviously, not handled by the 12.0 version. We did not want to reintroduce the old controllers who were considered to be a hack to load the assets in the mass_mailing iframe. However, we were very cautious about changing the editor itself to avoid introducing new bugs in the editor core of 13.0. The approach we chose at the end, is to use the loadAsset mechanism introduced in saas-12.2 to load the necessary assets and inject them in the mass_mailing iframe. This did not reintroduce the controllers nor did it require to change the code of the editor itself. However, it required moderate changes to the wysiwyg interface. Part of PR 35677. Co-authored-by: Nicolas Bayet <nby@odoo.com> Co-authored-by: Antoine Guenet <age@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/xml')
-rw-r--r--addons/web_editor/static/src/xml/wysiwyg.xml68
1 files changed, 46 insertions, 22 deletions
diff --git a/addons/web_editor/static/src/xml/wysiwyg.xml b/addons/web_editor/static/src/xml/wysiwyg.xml
index b5372892fe5..b9b29a8984e 100644
--- a/addons/web_editor/static/src/xml/wysiwyg.xml
+++ b/addons/web_editor/static/src/xml/wysiwyg.xml
@@ -9,32 +9,56 @@
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
- <t t-foreach="asset.cssLibs || []" t-as="cssLib">
- <link type="text/css" rel="stylesheet" t-att-href="cssLib"/>
- </t>
- <t t-foreach="asset.cssContents || []" t-as="cssContent">
- <style type="text/css" t-raw="cssContent"/>
- </t>
- <t t-foreach="asset.jsContents || []" t-as="jsContent" t-if="jsContent.indexOf('inline asset') !== -1">
- <script type="text/javascript" t-raw="jsContent"/>
+ <t t-foreach="assets || []" t-as="asset">
+ <t t-foreach="asset.cssLibs || []" t-as="cssLib">
+ <link type="text/css" rel="stylesheet" t-att-href="cssLib"/>
+ </t>
+ <t t-foreach="asset.cssContents || []" t-as="cssContent">
+ <style type="text/css" t-raw="cssContent"/>
+ </t>
+ <t t-foreach="asset.jsLibs || []" t-as="jsLib">
+ <script type="text/javascript" t-att-src="jsLib"/>
+ </t>
+ <t t-foreach="asset.jsContents || []" t-as="jsContent" t-if="jsContent.indexOf('inline asset') !== -1">
+ <script type="text/javascript" t-raw="jsContent"/>
+ </t>
</t>
- </head>
- <body class="o_in_iframe">
- <div id="iframe_target" style="height: calc(100vh - 6px);"/>
<script type="text/javascript">
- window.$ = window.jQuery = window.top.jQuery;
+ odoo.define('web.session', function () {
+ return window.top.odoo.__DEBUG__.services['web.session'];
+ });
+
+ odoo.define('root.widget', function (require) {
+ 'use strict';
+ var Widget = require('web.Widget');
+ var widget = new Widget();
+ widget.appendTo(document.body);
+ return widget;
+ });
+
+ odoo.define('web.core.top', function (require) {
+ var core = require('web.core');
+ core.qweb.templates = window.top.odoo.__DEBUG__.services['web.core'].qweb.templates;
+ });
</script>
- <script type="text/javascript" src="/web_editor/static/lib/summernote/summernote.js"/>
+ </head>
+ <body id="iframe_target" class="o_in_iframe">
+ <div id="web_editor-top-edit"></div>
+ <div id="wrapwrap">
+ <div data-oe-model="model" data-oe-type="html" class="o_editable oe_structure"></div>
+ </div>
<script type="text/javascript">
- window._summernoteSlave = $.summernote;
- window._summernoteSlave.iframe = true;
- window._summernoteSlave.lang = window.top._summernoteMaster.lang;
- window._fnSummenoteSlave = $.fn.summernote;
- $.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"/>);
- }
+ odoo.define('web_editor.wysiwyg.iniframe', function (require) {
+ 'use strict';
+ var editor = require('web_editor.editor');
+
+ window._summernoteSlave = $.summernote;
+ window._summernoteSlave.iframe = true;
+ window._summernoteSlave.lang = window.top.$.summernote.lang;
+ if (window.top.<t t-esc="updateIframeId"/>) {
+ window.top.<t t-esc="updateIframeId"/>(editor.Class, <t t-esc="avoidDoubleLoad"/>);
+ }
+ });
</script>
</body>
</t>