import { describe, it } from '@ephox/bedrock-client'; import { LegacyUnit, TinyAssertions, TinySelections, TinyHooks } from '@ephox/wrap-mcagar'; import { assert } from 'chai'; import Editor from 'tinymce/core/api/Editor'; import Plugin from 'tinymce/plugins/lists/Plugin'; describe('browser.tinymce.plugins.lists.OutdentTest', () => { const hook = TinyHooks.bddSetupLight({ plugins: 'lists', add_unload_trigger: false, disable_nodechange: true, indent: false, entities: 'raw', valid_elements: 'li[style|class|data-custom],ol[style|class|data-custom|start],' + 'ul[style|class|data-custom],dl,dt,dd,em,strong,span,#p,div,br', valid_styles: { '*': 'color,font-size,font-family,background-color,font-weight,' + 'font-style,text-decoration,float,margin,margin-top,margin-right,' + 'margin-bottom,margin-left,display,position,top,left,list-style-type' }, base_url: '/project/tinymce/js/tinymce' }, [ Plugin ], true); it('TBA: Outdent inside LI in beginning of OL in LI', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'li li', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a
  2. ' + '
  3. b' + '
      ' + '
    1. c
    2. ' + '
    ' + '
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent inside LI in middle of OL in LI', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    5. d
    6. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'li li:nth-child(2)', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
  3. c' + '
      ' + '
    1. d
    2. ' + '
    ' + '
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent inside LI in end of OL in LI', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'li li:last-of-type', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
  3. c
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); // Nested lists in OL elements it('TBA: Outdent inside LI in beginning of OL in OL', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a
  2. ' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
' ); LegacyUnit.setSelection(editor, 'ol ol li', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a
  2. ' + '
  3. b' + '
      ' + '
    1. c
    2. ' + '
    ' + '
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent inside LI in middle of OL in OL', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a
  2. ' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    5. d
    6. ' + '
    ' + '
' ); LegacyUnit.setSelection(editor, 'ol ol li:nth-child(2)', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
  3. c' + '
      ' + '
    1. d
    2. ' + '
    ' + '
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent inside first/last LI in inner OL', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. 1' + '
      ' + '
    1. 2
    2. ' + '
    3. 3
    4. ' + '
    ' + '
  2. ' + '
  3. 4
  4. ' + '
' ); LegacyUnit.setSelection(editor, 'ol ol li:nth-child(1)', 0, 'ol ol li:nth-child(2)', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. 1
  2. ' + '
  3. 2
  4. ' + '
  5. 3
  6. ' + '
  7. 4
  8. ' + '
' ); LegacyUnit.equal(editor.selection.getRng().startContainer.nodeValue, '2'); LegacyUnit.equal(editor.selection.getRng().endContainer.nodeValue, '3'); }); it('TBA: Outdent inside first LI in inner OL where OL is single child of parent LI', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a
  2. ' + '
  3. ' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
  4. ' + '
' ); LegacyUnit.setSelection(editor, 'ol ol li:first-of-type', 0); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a
  2. ' + '
  3. b' + '
      ' + '
    1. c
    2. ' + '
    ' + '
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent inside LI in end of OL in OL', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a
  2. ' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
' ); LegacyUnit.setSelection(editor, 'ol ol li:last-of-type', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
  3. c
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent inside only child LI in OL in OL', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'ol ol li', 0); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a
  2. ' + '
  3. b
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent multiple LI in OL and nested OL', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'li', 0, 'li li', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '

a

' + '
    ' + '
  1. b
  2. ' + '
' ); }); it('TBA: Outdent on li with inner block element', () => { const editor = hook.editor(); editor.setContent( '' ); LegacyUnit.setSelection(editor, 'ul li:nth-child(2) p', 0); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '' + '

b

' + '' ); }); it('TBA: Outdent on nested li with inner block element', () => { const editor = hook.editor(); editor.setContent( '' ); LegacyUnit.setSelection(editor, 'ul li:nth-child(1) li p', 0); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '' ); }); it('Outdent nested ul in ol', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. ' + '
      ' + '
    • a
    • ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'ul', 0); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '' ); }); it('Outdenting an item should not affect its attributes', () => { const editor = hook.editor(); editor.setContent( '' ); LegacyUnit.setSelection(editor, 'ul ul li', 0); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '' ); }); it('TBA: Outdent inside LI in beginning of OL in LI with start attribute', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'li li', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a
  2. ' + '
  3. b' + '
      ' + '
    1. c
    2. ' + '
    ' + '
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TBA: Outdent inside LI in beginning of OL in LI with start attribute on both OL', () => { const editor = hook.editor(); editor.setContent( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.setSelection(editor, 'li li', 1); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, '
    ' + '
  1. a
  2. ' + '
  3. b' + '
      ' + '
    1. c
    2. ' + '
    ' + '
  4. ' + '
' ); assert.equal(editor.selection.getNode().nodeName, 'LI'); }); it('TINY-8068: Outdent list inside a div inside a list item should only remove the nested list', () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0, 0, 0, 0, 0, 0 ], 0); editor.execCommand('Outdent'); TinyAssertions.assertContent(editor, ''); }); });