odoo.define('web_editor.field.html', function (require) { 'use strict'; var ajax = require('web.ajax'); var basic_fields = require('web.basic_fields'); var config = require('web.config'); var core = require('web.core'); var Wysiwyg = require('web_editor.wysiwyg.root'); var field_registry = require('web.field_registry'); // must wait for web/ to add the default html widget, otherwise it would override the web_editor one require('web._field_registry'); var _lt = core._lt; var TranslatableFieldMixin = basic_fields.TranslatableFieldMixin; var QWeb = core.qweb; var assetsLoaded; var jinjaRegex = /(^|\n)\s*%\s(end|set\s)/; /** * FieldHtml Widget * Intended to display HTML content. This widget uses the wysiwyg editor * improved by odoo. * * nodeOptions: * - style-inline => convert class to inline style (no re-edition) => for sending by email * - no-attachment * - cssEdit * - cssReadonly * - snippets * - wrapper */ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { description: _lt("Html"), className: 'oe_form_field oe_form_field_html', supportedFieldTypes: ['html'], custom_events: { wysiwyg_focus: '_onWysiwygFocus', wysiwyg_blur: '_onWysiwygBlur', wysiwyg_change: '_onChange', wysiwyg_attachment: '_onAttachmentChange', }, /** * @override */ willStart: function () { var self = this; this.isRendered = false; this._onUpdateIframeId = 'onLoad_' + _.uniqueId('FieldHtml'); var defAsset; if (this.nodeOptions.cssReadonly) { defAsset = ajax.loadAsset(this.nodeOptions.cssReadonly); } if (!assetsLoaded) { // avoid flickering when begin to edit assetsLoaded = new Promise(function (resolve) { var wysiwyg = new Wysiwyg(self, {}); wysiwyg.attachTo($('