From b10ca1f6094b7c8e6e222aa0ea3d1f891e79379a Mon Sep 17 00:00:00 2001
From: Nicolas Lempereur <nle@odoo.com>
Date: Tue, 28 Jul 2020 14:14:53 +0000
Subject: [PATCH] [FIX] web_editor: carriage return in source mode

Enter keypress browser event were removed in 3c372d1da8b.

It was reintroduced in text fields with d2f024d2543 and this PR do the
same and reintroduce it for source mode of FieldHtml (`html` widget).

opw-2302605
closes #55066

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
---
 .../web_editor/static/src/js/backend/field_html.js  | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/addons/web_editor/static/src/js/backend/field_html.js b/addons/web_editor/static/src/js/backend/field_html.js
index 82169c53fbac..66e74a8f2077 100644
--- a/addons/web_editor/static/src/js/backend/field_html.js
+++ b/addons/web_editor/static/src/js/backend/field_html.js
@@ -450,6 +450,19 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
             $(this).attr('id', 'checklist-id-' + (++max));
         });
     },
+    /**
+     * Allows Enter keypress in a textarea (source mode)
+     *
+     * @private
+     * @param {OdooEvent} ev
+     */
+    _onKeydown: function (ev) {
+        if (ev.which === $.ui.keyCode.ENTER && $(ev.target).is('textarea')) {
+            ev.stopPropagation();
+            return;
+        }
+        this._super.apply(this, arguments);
+    },
     /**
      * Method called when wysiwyg triggers a change.
      *
-- 
GitLab