diff --git a/addons/web_editor/static/src/js/backend/fields.js b/addons/web_editor/static/src/js/backend/fields.js index ab4828fe89d..2486fea9b81 100644 --- a/addons/web_editor/static/src/js/backend/fields.js +++ b/addons/web_editor/static/src/js/backend/fields.js @@ -7,6 +7,7 @@ var config = require('web.config'); var core = require('web.core'); var session = require('web.session'); var field_registry = require('web.field_registry'); +var SummernoteManager = require('web_editor.rte.summernote'); var transcoder = require('web_editor.transcoder'); var TranslatableFieldMixin = basic_fields.TranslatableFieldMixin; @@ -25,6 +26,14 @@ var FieldTextHtmlSimple = basic_fields.DebouncedField.extend(TranslatableFieldMi className: 'oe_form_field oe_form_field_html_text', supportedFieldTypes: ['html'], + /** + * @override + */ + start: function () { + new SummernoteManager(this); + return this._super.apply(this, arguments); + }, + //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js index fffe8786f91..fb86f92b25a 100644 --- a/addons/web_editor/static/src/js/editor/rte.js +++ b/addons/web_editor/static/src/js/editor/rte.js @@ -269,10 +269,6 @@ var RTEWidget = Widget.extend({ $.fn.carousel = this.edit_bootstrap_carousel; - core.bus.on('alt_dialog_demand', this, this._onAltDialogDemand); - core.bus.on('link_dialog_demand', this, this._onLinkDialogDemand); - core.bus.on('media_dialog_demand', this, this._onMediaDialogDemand); - $(document).on('mousedown.rte activate.rte', this, this._onMousedown.bind(this)); $(document).on('mouseup.rte', this, this._onMouseup.bind(this)); @@ -342,10 +338,6 @@ var RTEWidget = Widget.extend({ $.fn.carousel = this.init_bootstrap_carousel; - core.bus.off('alt_dialog_demand', this, this._onAltDialogDemand); - core.bus.off('link_dialog_demand', this, this._onLinkDialogDemand); - core.bus.off('media_dialog_demand', this, this._onMediaDialogDemand); - $(document).off('.rte'); $('#wrapwrap, .o_editable').off('.rte'); @@ -566,66 +558,6 @@ var RTEWidget = Widget.extend({ _onClick: function (e) { e.preventDefault(); }, - /** - * Called when a demand to open a alt dialog is received on the bus. - * - * @private - * @param {Object} data - */ - _onAltDialogDemand: function (data) { - var altDialog = new weWidgets.alt(this, - data.options || {}, - data.$editable, - data.media - ); - if (data.onSave) { - altDialog.on('save', this, data.onSave); - } - if (data.onCancel) { - altDialog.on('cancel', this, data.onCancel); - } - altDialog.open(); - }, - /** - * Called when a demand to open a link dialog is received on the bus. - * - * @private - * @param {Object} data - */ - _onLinkDialogDemand: function (data) { - var linkDialog = new weWidgets.LinkDialog(this, - data.options || {}, - data.$editable, - data.linkInfo - ); - if (data.onSave) { - linkDialog.on('save', this, data.onSave); - } - if (data.onCancel) { - linkDialog.on('cancel', this, data.onCancel); - } - linkDialog.open(); - }, - /** - * Called when a demand to open a media dialog is received on the bus. - * - * @private - * @param {Object} data - */ - _onMediaDialogDemand: function (data) { - var mediaDialog = new weWidgets.MediaDialog(this, - data.options || {}, - data.$editable, - data.media - ); - if (data.onSave) { - mediaDialog.on('save', this, data.onSave); - } - if (data.onCancel) { - mediaDialog.on('cancel', this, data.onCancel); - } - mediaDialog.open(); - }, /** * Called when the mouse is pressed on the document -> activate element * edition. diff --git a/addons/web_editor/static/src/js/editor/rte.summernote.js b/addons/web_editor/static/src/js/editor/rte.summernote.js index 7067ab28af6..01b83530e48 100644 --- a/addons/web_editor/static/src/js/editor/rte.summernote.js +++ b/addons/web_editor/static/src/js/editor/rte.summernote.js @@ -1,11 +1,13 @@ odoo.define('web_editor.rte.summernote', function (require) { 'use strict'; -var core = require('web.core'); var ajax = require('web.ajax'); +var Class = require('web.Class'); +var core = require('web.core'); +var mixins = require('web.mixins'); var weContext = require('web_editor.context'); -var widgets = require('web_editor.widget'); var rte = require('web_editor.rte'); +var weWidgets = require('web_editor.widget'); var QWeb = core.qweb; var _t = core._t; @@ -422,8 +424,8 @@ dom.isImgFont = function (node) { var className = (node && node.className || ""); if (node && (nodeName === "SPAN" || nodeName === "I") && className.length) { var classNames = className.split(/\s+/); - for (var k=0; k