odoo.define('web_editor.field.html', function (require) { 'use strict'; var ajax = require('web.ajax'); var basic_fields = require('web.basic_fields'); var core = require('web.core'); var Wysiwyg = require('web_editor.wysiwyg.root'); var field_registry = require('web.field_registry'); var TranslatableFieldMixin = basic_fields.TranslatableFieldMixin; var QWeb = core.qweb; var assetsLoaded = false; /** * 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, { 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 () { this._onUpdateIframeId = 'onLoad_' + _.uniqueId('FieldHtml'); var defAsset = null; if (this.nodeOptions.cssReadonly) { defAsset = ajax.loadAsset(this.nodeOptions.cssReadonly); } if (!assetsLoaded) { // avoid flickering when begin to edit assetsLoaded = $.Deferred(); var wysiwyg = new Wysiwyg(this, {}); wysiwyg.attachTo($('