From ff366852fe44957a9b100721a327983bf811e08d Mon Sep 17 00:00:00 2001 From: vishal padhiyar Date: Thu, 14 Jul 2022 11:57:28 +0000 Subject: [PATCH] [FIX] web_editor: remove copy paste unwanted newline Before this commit: - When you try to paste text beside a text which is in code formate it puts the new text in new line with smaller font. - When we try to paste text in code formate in new line then it will give a blank space below the pasted text After this commit: - when you try to paste text beside a text which is in code formate it puts the pasted text in new line with original fontsize. - When we paste the text in code formate in new line then it will not give a empty line below it, Task-2683455 closes odoo/odoo#106488 X-original-commit: bf7835e80ffa70236dca4b4b8fb4edb45d42f46a Signed-off-by: David Monjoie (dmo) --- .../static/src/js/editor/odoo-editor/src/commands/commands.js | 4 ++++ .../static/src/js/editor/odoo-editor/src/utils/utils.js | 1 + 2 files changed, 5 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js index 038e4f3a4dd..844e4835552 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js @@ -20,6 +20,7 @@ import { isBlock, isColorGradient, isContentTextNode, + isEmptyBlock, isSelectionFormat, isShrunkBlock, isVisible, @@ -262,6 +263,9 @@ export const editorCommands = { if (offset) { const [left, right] = splitElement(currentNode.parentElement, offset); currentNode = insertBefore ? right : left; + if (isEmptyBlock(right)) { + right.remove(); + } } else { currentNode = currentNode.parentElement; } diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js index eb2fe644074..989fcda972a 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js @@ -1443,6 +1443,7 @@ const paragraphRelatedElements = [ 'H4', 'H5', 'H6', + 'PRE', ]; /**