diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index 0e559b6664f..92ab133263a 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -535,7 +535,6 @@ var RTE = Widget.extend({ } if ($editable.length && (!this.$last || this.$last[0] !== $editable[0]) && ($target.closest('[contenteditable]').attr('contenteditable') || "").toLowerCase() !== 'false') { - $editable.summernote(this.config($editable)); $editable.data('NoteHistory', history); @@ -578,6 +577,17 @@ var RTE = Widget.extend({ _.defer(function () { self.historyRecordUndo($target, 'activate', true); }); + + // To Fix Google Chrome Tripleclick Issue, which selects the ending + // whitespace characters (so Tripleclicking then typing text will remove + // the whole paragraph instead of its content). + // http://stackoverflow.com/questions/38467334/why-does-google-chrome-always-add-space-after-selected-text + if ($.browser.chrome === true && event.originalEvent.detail === 3) { + var currentSelection = range.create(); + if (currentSelection.sc.parentNode === currentSelection.ec) { + range.create(currentSelection.sc, currentSelection.so, currentSelection.sc, currentSelection.sc.length).select(); + } + } }, editable: function () { diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js index 4ab1e7bed06..979211cd4d7 100644 --- a/addons/web_editor/static/src/js/rte.summernote.js +++ b/addons/web_editor/static/src/js/rte.summernote.js @@ -67,8 +67,8 @@ renderer.createPalette = function ($container, options) { var $palettes = $container.find(".note-color .note-color-palette"); $palettes.prepend(html); - var $bg = $palettes.first().find("button:not(.note-color-btn)").addClass("note-color-btn"); - var $fore = $palettes.last().find("button:not(.note-color-btn)").addClass("note-color-btn"); + var $bg = $palettes.filter(":even").find("button:not(.note-color-btn)").addClass("note-color-btn"); + var $fore = $palettes.filter(":odd").find("button:not(.note-color-btn)").addClass("note-color-btn"); $bg.each(function () { var $el = $(this); var className = 'bg-' + $el.data('color'); @@ -146,10 +146,7 @@ renderer.tplPopovers = function (lang, options) { })).appendTo($resizefa); } var $colorfa = $airPopover.find('.note-color').clone(); - $colorfa.find(".btn-group:first").remove(); $colorfa.find("ul.dropdown-menu").css('min-width', '172px'); - $colorfa.find('button[data-event="color"]').attr('data-value', '{"foreColor": "#f00"}') - .find("i").css({'background': '', 'color': '#f00'}); $resizefa.after($colorfa); // show dialog box and delete @@ -454,7 +451,7 @@ $.summernote.pluginEvents.visible = function (event, editor, layoutInfo) { if (($node.is('[data-oe-type="html"]') || $node.is('[data-oe-field="arch"]')) && $node.hasClass("o_editable") && !$node[0].children.length && - "h1 h2 h3 h4 h5 h6 p b bold i u code sup strong small pre th td".toUpperCase().indexOf($node[0].nodeName) === -1) { + "h1 h2 h3 h4 h5 h6 p b bold i u code sup strong small pre th td span".toUpperCase().indexOf($node[0].nodeName) === -1) { var p = $('


')[0]; $node.append( p ); range.createFromNode(p.firstChild).select(); @@ -849,6 +846,7 @@ eventHandler.attach = function (oLayoutInfo, options) { if ($(e.target).closest(".note-toolbar").length) return; // prevent icon edition of top bar for default summernote show_tooltip = false; callback(); + e.stopImmediatePropagation(); }); oLayoutInfo.editor().on("click", selector, function (e) { diff --git a/addons/web_editor/static/src/js/snippets.options.js b/addons/web_editor/static/src/js/snippets.options.js index 1444f404ff6..c3c97505305 100644 --- a/addons/web_editor/static/src/js/snippets.options.js +++ b/addons/web_editor/static/src/js/snippets.options.js @@ -585,7 +585,7 @@ odoo.define('web_editor.snippets.options', function (require) { .on("background-color-event.background-option", (function (e, type) { e.stopPropagation(); if (e.currentTarget !== e.target) return; - this.$el.find("li:first > a").trigger(type); + this.$el.find("li[data-background=''] > a").trigger(type); }).bind(this)); }, background: function (type, value, $li) { diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 71647828cc6..c2e2ea54dca 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -1872,23 +1872,51 @@ $.summernote.pluginEvents.removeFormat = function (event, editor, layoutInfo, va var fn_boutton_updateRecentColor = eventHandler.modules.toolbar.button.updateRecentColor; eventHandler.modules.toolbar.button.updateRecentColor = function (elBtn, sEvent, sValue) { fn_boutton_updateRecentColor.call(this, elBtn, sEvent, sValue); - var font = $(elBtn).closest('.note-color').find('.note-recent-color i')[0]; + var $recentcolor = $.find('.note-recent-color i'); + var $recentcolorbtn = $.find('.note-recent-color'); - if (sEvent === "foreColor") { - if (sValue.indexOf('text-') !== -1) { - font.className += ' ' + sValue; - font.style.color = ''; + //find last used color for fonts or for icons + //set this color into recentcolor button of both font and icon + for (var i in $recentcolor) { + var $font = $recentcolor[i]; + var $button = $($recentcolorbtn[i]); + var className = $font.className.split(/\s+/); + if (sEvent === "foreColor") { + //set class for forecolor to recentcolor button font-icon + for (var k=2; k section .row > div:first h1 font:eq(2)', @@ -218,7 +218,7 @@ odoo.define('web_editor.tour', function (require) { }, { content: "add ul content", trigger: '#editable_area > section .row > div:first', - extra_trigger: 'body:not(:has(#editable_area > section .row > div:first p:eq(4), #editable_area > section .row > div:eq(3))) #editable_area > section .row > div:first p:eq(3)', + extra_trigger: 'body:not(:has(#editable_area > section .row > div:first p:eq(5), #editable_area > section .row > div:eq(3))) #editable_area > section .row > div:first p:eq(3)', run: function () { var html = '