summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-10-21 15:22:36 +0200
committerChristophe Simonis <chs@odoo.com>2017-10-21 15:22:36 +0200
commitde987831da237ed5f9c96d50a9e51d083e072aa0 (patch)
treeef714d2d98693eae3446620d28bb48314573018a /addons/web_editor/static/src/js
parentea2a976f31b2611b6b4ff69f4a5cdc2ffc7798fe (diff)
parentd70518d04f8f8061c8c683ea4ba8c95ae631ae45 (diff)
[MERGE] forward port branch 11.0 up to d70518d04f8
Diffstat (limited to 'addons/web_editor/static/src/js')
-rw-r--r--addons/web_editor/static/src/js/backend/fields.js2
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js22
-rw-r--r--addons/web_editor/static/src/js/editor/rte.summernote.js4
3 files changed, 25 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/backend/fields.js b/addons/web_editor/static/src/js/backend/fields.js
index 2486fea9b81..bf83e5b8dec 100644
--- a/addons/web_editor/static/src/js/backend/fields.js
+++ b/addons/web_editor/static/src/js/backend/fields.js
@@ -399,7 +399,7 @@ var FieldTextHtml = AbstractField.extend({
var layoutInfo = this.editor.rte.editable().data('layoutInfo');
$.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo, false);
}
- this.editor.snippetsMenu.cleanForSave();
+ this.editor.snippetsMenu && this.editor.snippetsMenu.cleanForSave();
this._setValue(this.$content.html());
return this._super.apply(this, arguments);
},
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index f97a97b8b46..4d2f6fe977a 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -654,6 +654,28 @@ var RTEWidget = Widget.extend({
// 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) {
+ _selectSC(currentSelection);
+ } else if (currentSelection.eo === 0) {
+ var $hasNext = $(currentSelection.sc).parent();
+ while (!$hasNext.next().length && !$hasNext.is('body')) {
+ $hasNext = $hasNext.parent();
+ }
+ if ($hasNext.next()[0] === currentSelection.ec) {
+ _selectSC(currentSelection);
+ }
+ }
+ }
+ function _selectSC(selection) {
+ range.create(selection.sc, selection.so, selection.sc, selection.sc.length).select();
+ }
+
+ // 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 && ev.originalEvent.detail === 3) {
var currentSelection = range.create();
if (currentSelection.sc.parentNode === currentSelection.ec) {
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 141fb6ea229..7f82df2cb28 100644
--- a/addons/web_editor/static/src/js/editor/rte.summernote.js
+++ b/addons/web_editor/static/src/js/editor/rte.summernote.js
@@ -446,7 +446,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 span".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 label".toUpperCase().indexOf($node[0].nodeName) === -1) {
var p = $('<p><br/></p>')[0];
$node.append( p );
range.createFromNode(p.firstChild).select();
@@ -761,7 +761,7 @@ eventHandler.attach = function (oLayoutInfo, options) {
* Open Link Dialog on double click on a link/button.
* Shows a tooltip on click to say to the user he can double click.
*/
- create_dblclick_feature("a[href], .btn", function () {
+ create_dblclick_feature("a[href], a.btn, button.btn", function () {
eventHandler.modules.linkDialog.show(oLayoutInfo);
});