[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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user