From e302e1b71c9976c72fec9aaef959502043e739dc Mon Sep 17 00:00:00 2001 From: Deependra Solanki Date: Fri, 23 Feb 2024 12:56:55 +0530 Subject: [PATCH] [FIX] web_editor: carry attributes of all tag other than LI Commit [1] changed the behavior of `setTagName` to only carry the attributes of paragraph related elements. Ideally, this should not carry the attributes of `
  • ` element only. [1]: fcb3846 task-3764154 closes odoo/odoo#155448 X-original-commit: 0a47626dba4019fabaf4e399db3369b3db2e712e Signed-off-by: Antoine Guenet (age) Signed-off-by: Deependra Solanki (deso) --- .../js/editor/odoo-editor/src/utils/utils.js | 2 +- .../editor/odoo-editor/test/spec/list.test.js | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) 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 3fe8d65936d..697da70a6db 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 @@ -2132,7 +2132,7 @@ export function setTagName(el, newTagName) { return el; } const n = document.createElement(newTagName); - if (paragraphRelatedElements.includes(el.nodeName)) { + if (el.nodeName !== 'LI') { const attributes = el.attributes; for (const attr of attributes) { n.setAttribute(attr.name, attr.value); diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js index 377d261860c..33f89acf04d 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js @@ -38,6 +38,20 @@ describe('List', () => { contentAfter: '
    • ab[]cd
    ', }); }); + it('should turn a ordered list into a unordered list', async () => { + await testEditor(BasicEditor, { + contentBefore: '
    1. ab[]cd
    ', + stepFunction: toggleUnorderedList, + contentAfter: '
    • ab[]cd
    ', + }); + }); + it('should turn a checked list into a unordered list', async () => { + await testEditor(BasicEditor, { + contentBefore: '
    • ab[]cd
    ', + stepFunction: toggleUnorderedList, + contentAfter: '
    • ab[]cd
    ', + }); + }); it('should turn a heading into a list', async () => { await testEditor(BasicEditor, { contentBefore: '

    ab[]cd

    ', @@ -307,6 +321,20 @@ describe('List', () => { contentAfter: '
    1. ab[]cd
    ', }); }); + it('should turn a unordered list into a ordered list', async () => { + await testEditor(BasicEditor, { + contentBefore: '
    • ab[]cd
    ', + stepFunction: toggleOrderedList, + contentAfter: '
    1. ab[]cd
    ', + }); + }); + it('should turn a checked list into a ordered list', async () => { + await testEditor(BasicEditor, { + contentBefore: '
    • ab[]cd
    ', + stepFunction: toggleOrderedList, + contentAfter: '
    1. ab[]cd
    ', + }); + }); it('should turn a heading into a list', async () => { await testEditor(BasicEditor, { contentBefore: '

    ab[]cd

    ', @@ -525,6 +553,22 @@ describe('List', () => { contentAfter: '
    • ab[]cd
    ', }); }); + it('should turn a ordered list into a checklist', async () => { + await testEditor(BasicEditor, { + removeCheckIds: true, + contentBefore: '
    1. ab[]cd
    ', + stepFunction: toggleCheckList, + contentAfter: '
    • ab[]cd
    ', + }); + }); + it('should turn a unordered list into a checklist', async () => { + await testEditor(BasicEditor, { + removeCheckIds: true, + contentBefore: '
    • ab[]cd
    ', + stepFunction: toggleCheckList, + contentAfter: '
    • ab[]cd
    ', + }); + }); it('should turn a heading into a checklist', async () => { await testEditor(BasicEditor, { removeCheckIds: true,