summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2020-03-31 11:47:54 +0000
committerSamuel Degueldre <sad@odoo.com>2020-04-03 07:21:20 +0000
commit0c9eb9e5c7fe260579aae1117a1d46eb75830e5a (patch)
tree77f2d1fa78a24d4089429c98f47f6bd1382d45bf /addons/web_editor/static/src
parent98161fc61ab4667d0333975b2639547ec8a031fd (diff)
[FIX] web_editor: fix dialogs (link, media, alt, crop) not opening
In 3f4092d837d50d25d6c9630d84f67545cf586c7a, the SummernoteManager that was previously owned by RTE was removed, this was because the wysiwyg already has one. One problem with this however is that when an editor is created in an iframe, the wysiwyg is instanciated outside, while the editor is instanciated inside. This means that they don't have the same core.bus to listen for and trigger events, such as those used to open the various editor dialogs. This commit fixes that by always using the top-level core.bus when opening dialogs. This also has the advantage that the dialogs are no longer confined to the iframe and can take up the whole screen, making them more comfortable to use. closes odoo/odoo#48932 X-original-commit: 68ac735aa7e17e66910f51706829035697dfcc1e Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.summernote.js29
-rw-r--r--addons/web_editor/static/src/scss/web_editor.backend.scss2
2 files changed, 18 insertions, 13 deletions
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 cb7d64f4e56..b3b94a1367d 100644
--- a/addons/web_editor/static/src/js/editor/rte.summernote.js
+++ b/addons/web_editor/static/src/js/editor/rte.summernote.js
@@ -4,6 +4,11 @@ odoo.define('web_editor.rte.summernote', function (require) {
var Class = require('web.Class');
const concurrency = require('web.concurrency');
var core = require('web.core');
+// Use the top window's core.bus for dialog events so that they take the whole window
+// instead of being confined to an iframe. This means that the event triggered on
+// the bus by summernote in an iframe will be caught by the wysiwyg's SummernoteManager
+// outside the iframe.
+const topBus = window.top.odoo.__DEBUG__.services['web.core'].bus;
const ColorpickerDialog = require('web.ColorpickerDialog');
var ColorPaletteWidget = require('web_editor.ColorPalette').ColorPaletteWidget;
var mixins = require('web.mixins');
@@ -395,7 +400,7 @@ eventHandler.modules.linkDialog.showLinkDialog = function ($editable, $dialog, l
}
var def = new $.Deferred();
- core.bus.trigger('link_dialog_demand', {
+ topBus.trigger('link_dialog_demand', {
$editable: $editable,
linkInfo: linkInfo,
onSave: function (linkInfo) {
@@ -417,7 +422,7 @@ eventHandler.modules.imageDialog.showImageDialog = function ($editable) {
var media = $(r.sc).parents().addBack().filter(function (i, el) {
return dom.isImg(el);
})[0];
- core.bus.trigger('media_dialog_demand', {
+ topBus.trigger('media_dialog_demand', {
$editable: $editable,
media: media,
options: {
@@ -437,7 +442,7 @@ eventHandler.modules.imageDialog.showImageDialog = function ($editable) {
$.summernote.pluginEvents.alt = function (event, editor, layoutInfo, sorted) {
var $editable = layoutInfo.editable();
var $selection = layoutInfo.handle().find('.note-control-selection');
- core.bus.trigger('alt_dialog_demand', {
+ topBus.trigger('alt_dialog_demand', {
$editable: $editable,
media: $selection.data('target'),
});
@@ -445,7 +450,7 @@ $.summernote.pluginEvents.alt = function (event, editor, layoutInfo, sorted) {
$.summernote.pluginEvents.cropImage = function (event, editor, layoutInfo, sorted) {
var $editable = layoutInfo.editable();
var $selection = layoutInfo.handle().find('.note-control-selection');
- core.bus.trigger('crop_image_dialog_demand', {
+ topBus.trigger('crop_image_dialog_demand', {
$editable: $editable,
media: $selection.data('target'),
});
@@ -1059,10 +1064,10 @@ var SummernoteManager = Class.extend(mixins.EventDispatcherMixin, ServicesMixin,
mixins.EventDispatcherMixin.init.call(this);
this.setParent(parent);
- core.bus.on('alt_dialog_demand', this, this._onAltDialogDemand);
- core.bus.on('crop_image_dialog_demand', this, this._onCropImageDialogDemand);
- core.bus.on('link_dialog_demand', this, this._onLinkDialogDemand);
- core.bus.on('media_dialog_demand', this, this._onMediaDialogDemand);
+ topBus.on('alt_dialog_demand', this, this._onAltDialogDemand);
+ topBus.on('crop_image_dialog_demand', this, this._onCropImageDialogDemand);
+ topBus.on('link_dialog_demand', this, this._onLinkDialogDemand);
+ topBus.on('media_dialog_demand', this, this._onMediaDialogDemand);
},
/**
* @override
@@ -1070,10 +1075,10 @@ var SummernoteManager = Class.extend(mixins.EventDispatcherMixin, ServicesMixin,
destroy: function () {
mixins.EventDispatcherMixin.destroy.call(this);
- core.bus.off('alt_dialog_demand', this, this._onAltDialogDemand);
- core.bus.off('crop_image_dialog_demand', this, this._onCropImageDialogDemand);
- core.bus.off('link_dialog_demand', this, this._onLinkDialogDemand);
- core.bus.off('media_dialog_demand', this, this._onMediaDialogDemand);
+ topBus.off('alt_dialog_demand', this, this._onAltDialogDemand);
+ topBus.off('crop_image_dialog_demand', this, this._onCropImageDialogDemand);
+ topBus.off('link_dialog_demand', this, this._onLinkDialogDemand);
+ topBus.off('media_dialog_demand', this, this._onMediaDialogDemand);
},
/**
diff --git a/addons/web_editor/static/src/scss/web_editor.backend.scss b/addons/web_editor/static/src/scss/web_editor.backend.scss
index 385bb370fd7..c0355ff6d9c 100644
--- a/addons/web_editor/static/src/scss/web_editor.backend.scss
+++ b/addons/web_editor/static/src/scss/web_editor.backend.scss
@@ -72,7 +72,7 @@
z-index: 1001 !important;
border: 0;
}
- * {
+ > :not(.modal):not(.modal-backdrop) {
display: none;
}
.o_form_fullscreen_ancestor {