summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-08-04 14:09:05 +0200
committerqsm-odoo <qsm@odoo.com>2017-08-28 12:04:06 +0200
commit9486ec33c4035fe6155e0a9d5905ee38106761fa (patch)
treee3a940b9790ddb29405f6756de95764f7e8c7d74 /addons/web_editor/static/src
parent3fb4159ad9c9b9488912292b7b339d9f1fd2ce3c (diff)
[FIX] web_editor: properly not allow edition of non editable parts
Before this commit, (double) clicking an image/link in a non editable environment still opened a dialog / change the editor bar for edition.
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js5
-rw-r--r--addons/web_editor/static/src/js/editor/rte.summernote.js15
-rw-r--r--addons/web_editor/static/src/js/editor/summernote.js5
3 files changed, 18 insertions, 7 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index fb86f92b25a..f97a97b8b46 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -569,7 +569,7 @@ var RTEWidget = Widget.extend({
var $target = $(ev.target);
var $editable = $target.closest('.o_editable');
- if (!$editable.length) {
+ if (!$editable.length || $.summernote.core.dom.isContentEditableFalse($target)) {
return;
}
@@ -604,8 +604,7 @@ var RTEWidget = Widget.extend({
}, 150); // setTimeout to remove flickering when change to editable zone (re-create an editor)
this.$last = null;
}
- if ($editable.length && (!this.$last || this.$last[0] !== $editable[0]) &&
- ($target.closest('[contenteditable]').attr('contenteditable') || '').toLowerCase() !== 'false') {
+ if ($editable.length && (!this.$last || this.$last[0] !== $editable[0])) {
$editable.summernote(this._getConfig($editable));
$editable.data('NoteHistory', history);
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 01b83530e48..141fb6ea229 100644
--- a/addons/web_editor/static/src/js/editor/rte.summernote.js
+++ b/addons/web_editor/static/src/js/editor/rte.summernote.js
@@ -771,7 +771,7 @@ eventHandler.attach = function (oLayoutInfo, options) {
});
}
oLayoutInfo.editable().on('mousedown', function (e) {
- if (dom.isImg(e.target)) {
+ if (dom.isImg(e.target) && dom.isContentEditable(e.target)) {
range.createFromNode(e.target).select();
}
});
@@ -836,7 +836,12 @@ eventHandler.attach = function (oLayoutInfo, options) {
var show_tooltip = true;
oLayoutInfo.editor().on("dblclick", selector, function (e) {
- if ($(e.target).closest(".note-toolbar").length) return; // prevent icon edition of top bar for default summernote
+ var $target = $(e.target);
+ if (!dom.isContentEditable($target)) {
+ // Prevent edition of non editable parts
+ return;
+ }
+
show_tooltip = false;
callback();
e.stopImmediatePropagation();
@@ -844,7 +849,11 @@ eventHandler.attach = function (oLayoutInfo, options) {
oLayoutInfo.editor().on("click", selector, function (e) {
var $target = $(e.target);
- if ($target.closest(".note-toolbar").length) return; // prevent icon edition of top bar for default summernote
+ if (!dom.isContentEditable($target)) {
+ // Prevent edition of non editable parts
+ return;
+ }
+
show_tooltip = true;
setTimeout(function () {
if (!show_tooltip) return;
diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js
index 4860931ea6b..f054eca48eb 100644
--- a/addons/web_editor/static/src/js/editor/summernote.js
+++ b/addons/web_editor/static/src/js/editor/summernote.js
@@ -649,7 +649,10 @@ dom.isNotBreakable = function (node) {
return !dom.isText(node) && !dom.isBR(dom.firstChild(node)) && dom.isVoid(dom.firstChild(node));
};
dom.isContentEditable = function (node) {
- return $(node).closest('[contenteditable]').is('[contenteditable="true"]');
+ return $(node).closest('[contenteditable]').prop('contenteditable') === 'true';
+};
+dom.isContentEditableFalse = function (node) {
+ return $(node).closest('[contenteditable]').prop('contenteditable') === 'false';
};
dom.isFont = function (node) {
var nodeName = node && node.nodeName.toUpperCase();