Skip to content

Commit

Permalink
[FIX] web_editor: two editor and image bar buttons
Browse files Browse the repository at this point in the history
Some image functionalities of the inline summernote would only take the
first of multiple editor into account when selecting the targeted image
of an image button action (image size, image padding, ...).

This commit select the appropriate editor given the current editable.

closes odoo#11474
opw-668861
  • Loading branch information
nle-odoo committed Mar 25, 2016
1 parent 62792a8 commit 85eda0c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions addons/web_editor/static/src/js/rte.summernote.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,12 @@ eventHandler.modules.handle.update = function ($handle, oStyle, isAirMode) {
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/* hack for image and link editor */

function getImgTarget () {
return $(".note-control-selection").data('target');
function getImgTarget ($editable) {
var $handle = $editable ? dom.makeLayoutInfo($editable).handle() : undefined;
return $(".note-control-selection", $handle).data('target');
}
eventHandler.modules.editor.padding = function ($editable, sValue) {
var $target = $(getImgTarget());
var $target = $(getImgTarget($editable));
var paddings = "small medium large xl".split(/\s+/);
$editable.data('NoteHistory').recordUndo();
if (sValue.length) {
Expand All @@ -309,24 +310,24 @@ eventHandler.modules.editor.padding = function ($editable, sValue) {
$target.removeClass("padding-" + paddings.join(" padding-"));
};
eventHandler.modules.editor.resize = function ($editable, sValue) {
var $target = $(getImgTarget());
var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
var width = ($target.attr('style') || '').match(/(^|;|\s)width:\s*([0-9]+)%/);
if (width) {
width = width[2]/100;
}
$(getImgTarget()).css('width', width != sValue ? (sValue * 100) + '%' : '');
$target.css('width', width != sValue ? (sValue * 100) + '%' : '');
};
eventHandler.modules.editor.resizefa = function ($editable, sValue) {
var $target = $(getImgTarget());
var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
$target.attr('class', $target.attr('class').replace(/\s*fa-[0-9]+x/g, ''));
if (+sValue > 1) {
$target.addClass('fa-'+sValue+'x');
}
};
eventHandler.modules.editor.floatMe = function ($editable, sValue) {
var $target = $(getImgTarget());
var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
switch (sValue) {
case 'center': $target.toggleClass('center-block').removeClass('pull-right pull-left'); break;
Expand All @@ -335,7 +336,7 @@ eventHandler.modules.editor.floatMe = function ($editable, sValue) {
}
};
eventHandler.modules.editor.imageShape = function ($editable, sValue) {
var $target = $(getImgTarget());
var $target = $(getImgTarget($editable));
$editable.data('NoteHistory').recordUndo();
$target.toggleClass(sValue);
};
Expand Down

0 comments on commit 85eda0c

Please sign in to comment.