odoo.define('web_editor.wysiwyg.iframe', function (require) { 'use strict'; var Wysiwyg = require('web_editor.wysiwyg'); var ajax = require('web.ajax'); var core = require('web.core'); var config = require('web.config'); var qweb = core.qweb; var promiseCommon; var promiseWysiwyg; /** * Add option (inIframe) to load Wysiwyg in an iframe. **/ Wysiwyg.include({ /** * Add options to load Wysiwyg in an iframe. * * @override * @param {boolean} options.inIframe **/ init: function (parent, options) { this._super.apply(this, arguments); if (this.options.inIframe) { this._onUpdateIframeId = 'onLoad_' + this.id; } this.__extraAssetsForIframe = []; }, /** * Load assets to inject into iframe. * * @override **/ willStart: function () { if (!this.options.inIframe) { return this._super(); } var defAsset; if (this.options.iframeCssAssets) { defAsset = ajax.loadAsset(this.options.iframeCssAssets); } else { defAsset = Promise.resolve({ cssLibs: [], cssContents: [] }); } promiseWysiwyg = promiseWysiwyg || ajax.loadAsset('web_editor.wysiwyg_iframe_editor_assets'); this.defAsset = Promise.all([promiseWysiwyg, defAsset]); this.$target = this.$el; return this.defAsset .then(this._loadIframe.bind(this)) .then(this._super.bind(this)); }, //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- /** * Create iframe, inject css and create a link with the content, * then inject the target inside. * * @private * @returns {Promise} */ _loadIframe: function () { var self = this; this.$iframe = $('