summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-06-06 11:54:35 +0200
committerChristophe Simonis <chs@odoo.com>2019-06-06 11:54:35 +0200
commit71a50a2214748fec413c5a0f042d0e7172ae6ea9 (patch)
tree2e9ee11551350e23923390d9c53baf630b6ed834 /addons/web_editor/static/src
parenta7621137cb0d75ec545152d5e1d413c9d3548e45 (diff)
parent409679866b2ee8352a8cb27460e7332563526924 (diff)
[MERGE] forward port branch saas-12.3 up to 409679866b2
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/backend/field_html.js2
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js7
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/plugin/media.js6
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/plugin/text.js5
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/widgets/media.js1
5 files changed, 16 insertions, 5 deletions
diff --git a/addons/web_editor/static/src/js/backend/field_html.js b/addons/web_editor/static/src/js/backend/field_html.js
index 14f6d59b05c..40456961aeb 100644
--- a/addons/web_editor/static/src/js/backend/field_html.js
+++ b/addons/web_editor/static/src/js/backend/field_html.js
@@ -296,7 +296,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
resolver();
};
- this.$iframe.one('load', function onLoad() {
+ this.$iframe.on('load', function onLoad() {
var _avoidDoubleLoad = ++avoidDoubleLoad;
ajax.loadAsset(self.nodeOptions.cssReadonly).then(function (asset) {
if (_avoidDoubleLoad !== avoidDoubleLoad) {
diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js b/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js
index dc2a444384b..6a516dd2ad5 100644
--- a/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js
+++ b/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js
@@ -165,10 +165,10 @@ var BulletPlugin = AbstractPlugin.extend({
// convert ul <-> ol
var ul;
+ $(ol).removeClass('o_checklist');
if (sorted === 'checklist' && current === "ul") {
ul = ol;
} else if (sorted === 'ul' && current === 'checklist') {
- $(ol).removeClass('o_checklist');
ul = ol;
} else {
ul = this.document.createElement(sorted === "ol" ? "ol" : "ul");
@@ -321,7 +321,7 @@ var BulletPlugin = AbstractPlugin.extend({
var self = this;
var nodes = [];
var isWithinElem;
- var ancestor = range.commonAncestor();
+ var ancestor = range.commonAncestor() || this.editable;
var $dom = $(ancestor);
if (!dom.isList(ancestor)) {
@@ -344,7 +344,8 @@ var BulletPlugin = AbstractPlugin.extend({
if (!$dom.length) {
// if the selection is contained in a single HTML node, we indent
// the first ancestor 'content block' (P, H1, PRE, ...) or TD
- $dom = $(range.sc).closest(this.options.styleTags.join(',') + ',td');
+ var nodes = this.context.invoke('HelperPlugin.getSelectedNodes');
+ $dom = $(this._filterEditableFormatNodes(nodes));
}
}
diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/media.js b/addons/web_editor/static/src/js/wysiwyg/plugin/media.js
index b11c15b2564..71365e4348f 100644
--- a/addons/web_editor/static/src/js/wysiwyg/plugin/media.js
+++ b/addons/web_editor/static/src/js/wysiwyg/plugin/media.js
@@ -44,6 +44,7 @@ var MediaPlugin = AbstractPlugin.extend({
},
mousePosition: {},
+ _modalOpen: false,
//--------------------------------------------------------------------------
// Public
@@ -53,6 +54,10 @@ var MediaPlugin = AbstractPlugin.extend({
* Open the image dialog and listen to its saved/closed events.
*/
showImageDialog: function () {
+ if (this._modalOpen) {
+ return;
+ }
+ this._modalOpen = true;
this.context.invoke('editor.saveRange');
var media = this.context.invoke('editor.restoreTarget');
@@ -79,6 +84,7 @@ var MediaPlugin = AbstractPlugin.extend({
});
mediaDialog.on('closed', this, function () {
this.context.invoke('editor.restoreRange');
+ this._modalOpen = false;
});
mediaDialog.open();
},
diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/text.js b/addons/web_editor/static/src/js/wysiwyg/plugin/text.js
index 16e22939cd4..f2834c531f7 100644
--- a/addons/web_editor/static/src/js/wysiwyg/plugin/text.js
+++ b/addons/web_editor/static/src/js/wysiwyg/plugin/text.js
@@ -229,8 +229,11 @@ var TextPlugin = AbstractPlugin.extend({
$(br).before(emptyText).remove();
range = this.context.invoke('editor.setRange', emptyText, 0, emptyText, 1);
} else {
+ var offset = range.so;
this.context.invoke('HelperPlugin.insertTextInline', '\u200B');
- range.eo += 1;
+ range = this.context.invoke('editor.createRange');
+ range.so = offset;
+ range.eo = offset + 1;
}
range.select();
}
diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js
index 545f06a38e2..198dbd14244 100644
--- a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js
+++ b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js
@@ -10,6 +10,7 @@ var fonts = require('wysiwyg.fonts');
var ImageOptimizeDialog = require('wysiwyg.widgets.image_optimize_dialog').ImageOptimizeDialog;
var utils = require('web.utils');
var Widget = require('web.Widget');
+var session = require('web.session');
var QWeb = core.qweb;
var _t = core._t;