diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index ef7603caae8..e7f722a3ed2 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -3709,9 +3709,10 @@ export class OdooEditor extends EventTarget { // Tab const tabHtml = '\u0009\u200B'; const sel = this.document.getSelection(); - if (closestElement(sel.anchorNode, 'table')) { + const closestLi = closestElement(sel.anchorNode, 'li'); + if (closestElement(sel.anchorNode, 'table') && !closestLi) { this._onTabulationInTable(ev); - } else if (!ev.shiftKey && sel.isCollapsed && !closestElement(sel.anchorNode, 'li')) { + } else if (!ev.shiftKey && sel.isCollapsed && !closestLi) { // Indent text (collapsed selection). this.execCommand('insert', parseHTML(tabHtml)); } else { 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 c05de19de3e..941e77eb647 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 @@ -14,6 +14,7 @@ import { toggleCheckList, toggleOrderedList, toggleUnorderedList, + triggerEvent, unformat, } from '../utils.js'; @@ -7441,6 +7442,105 @@ describe('List', () => { `), }); }); + it('should indent unordered list inside a table cell', async () => { + await testEditor(BasicEditor, { + contentBefore: unformat(` + + + + + + + + +
+
    +
  • abc
  • +
  • def[]
  • +
+
+ ghi + + jkl +
+ `), + stepFunction: async editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab' }), + contentAfter: unformat(` + + + + + + + + +
+
    +
  • abc
  • +
  • +
      +
    • def[]
    • +
    +
  • +
+
+ ghi + + jkl +
+ `), + }); + }); + it('should indent checklist inside a table cell', async() => { + await testEditor(BasicEditor, { + removeCheckIds: true, + contentBefore: unformat(` + + + + + + + + +
+
    +
  • abc
  • +
  • def[]
  • +
+
+ ghi + + jkl +
+ `), + stepFunction: async editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab' }), + contentAfter: unformat(` + + + + + + + + +
+
    +
  • abc
  • +
  • +
      +
    • def[]
    • +
    +
  • +
+
+ ghi + + jkl +
+ `), + }); + }); }); describe('with selection', () => { it('should indent the first element of a list', async () => { @@ -7855,6 +7955,55 @@ describe('List', () => {

after]

`), }); }); + it('should indent ordered list inside a table cell', async() => { + await testEditor(BasicEditor, { + contentBefore: unformat(` + + + + + + + + +
+
    +
  1. abc
  2. +
  3. [def]
  4. +
+
+ ghi + + jkl +
+ `), + stepFunction: async editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab' }), + contentAfter: unformat(` + + + + + + + + +
+
    +
  1. abc
  2. +
  3. +
      +
    1. [def]
    2. +
    +
  4. +
+
+ ghi + + jkl +
+ `), + }); + }); }); }); describe('outdent', () => { @@ -7992,6 +8141,105 @@ describe('List', () => { `), }); }); + it('should outdent unordered list inside a table cell', async() => { + await testEditor(BasicEditor, { + contentBefore: unformat(` + + + + + + + + +
+ ghi + +
    +
  • abc
  • +
  • +
      +
    • def[]
    • +
    +
  • +
+
+ jkl +
+ `), + stepFunction: editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab', shiftKey: true }), + contentAfter: unformat(` + + + + + + + + +
+ ghi + +
    +
  • abc
  • +
  • def[]
  • +
+
+ jkl +
+ `), + }); + }); + it('should outdent checklist inside a table cell', async() => { + await testEditor(BasicEditor, { + removeCheckIds: true, + contentBefore: unformat(` + + + + + + + + +
+ ghi + +
    +
  • abc
  • +
  • +
      +
    • def[]
    • +
    +
  • +
+
+ jkl +
+ `), + stepFunction: editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab', shiftKey: true }), + contentAfter: unformat(` + + + + + + + + +
+ ghi + +
    +
  • abc
  • +
  • def[]
  • +
+
+ jkl +
+ `), + }); + }); }); describe('with selection', () => { it('should outdent the middle element of a list', async () => { @@ -8184,6 +8432,55 @@ describe('List', () => {

after]

`), }); }); + it('should outdent a ordered list inside a table cell', async() => { + await testEditor(BasicEditor, { + contentBefore: unformat(` + + + + + + + + +
+ ghi + +
    +
  1. abc
  2. +
  3. +
      +
    1. [def]
    2. +
    +
  4. +
+
+ jkl +
+ `), + stepFunction: editor => triggerEvent(editor.editable, 'keydown', { key: 'Tab', shiftKey: true }), + contentAfter: unformat(` + + + + + + + + +
+ ghi + +
    +
  1. abc
  2. +
  3. [def]
  4. +
+
+ jkl +
+ `), + }); + }); }); }); });