import { Pipeline } from '@ephox/agar'; import { UnitTest } from '@ephox/bedrock'; import { LegacyUnit, TinyLoader } from '@ephox/mcagar'; import Plugin from 'tinymce/plugins/lists/Plugin'; import Theme from 'tinymce/themes/modern/Theme'; UnitTest.asynctest('tinymce.lists.browser.IndentTest', function () { const success = arguments[arguments.length - 2]; const failure = arguments[arguments.length - 1]; const suite = LegacyUnit.createSuite(); Plugin(); Theme(); suite.test('Indent single LI in OL', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '
    ' + '
  1. a
  2. ' + '
' ); editor.focus(); LegacyUnit.setSelection(editor, 'li', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '
    ' + '
  1. a
  2. ' + '
' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI'); }); suite.test('Indent middle LI in OL', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '
    ' + '
  1. a
  2. ' + '
  3. b
  4. ' + '
  5. c
  6. ' + '
' ); editor.focus(); LegacyUnit.setSelection(editor, 'li:nth-child(2)', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
  3. c
  4. ' + '
' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI'); }); suite.test('Indent single LI in OL and retain OLs list style in the new OL', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '
    ' + '
  1. a
  2. ' + '
  3. b
  4. ' + '
' ); editor.focus(); LegacyUnit.setSelection(editor, 'li:nth-child(2)', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
' ); }); suite.test('Indent last LI in OL', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '
    ' + '
  1. a
  2. ' + '
  3. b
  4. ' + '
' ); editor.focus(); LegacyUnit.setSelection(editor, 'li:last', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI'); }); suite.test('Indent in table cell in table inside of list should not do anything', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '
    ' + '
  1. ' + '' + '' + '' + '' + '
    ' + '
  2. ' + '
' ); editor.focus(); LegacyUnit.setSelection(editor, 'td', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '
    ' + '
  1. ' + '' + '' + '' + '' + '
    ' + '
  2. ' + '
' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'TD'); }); suite.test('Indent last LI to same level as middle LI', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
  3. c
  4. ' + '
' ); editor.focus(); LegacyUnit.setSelection(editor, 'li:last', 1); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    3. c
    4. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI'); }); suite.test('Indent first LI and nested LI OL', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
' ); editor.focus(); LegacyUnit.setSelection(editor, 'li', 0, 'li li', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '
    ' + '
  1. a' + '
      ' + '
    1. b
    2. ' + '
    ' + '
  2. ' + '
' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI'); }); suite.test('Indent second LI to same level as nested LI', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '' ); editor.focus(); LegacyUnit.setSelection(editor, 'li:nth-child(2)', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI'); }); suite.test('Indent second LI to same level as nested LI 2', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '' ); editor.focus(); LegacyUnit.setSelection(editor, 'li:nth-child(2)', 1); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '' ); LegacyUnit.equal(editor.selection.getNode().nodeName, 'LI'); }); suite.test('Indent second and third LI', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '' ); editor.focus(); LegacyUnit.setSelection(editor, 'li:nth-child(2)', 0, 'li:last', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '' ); }); suite.test('Indent second second li with next sibling to nested li', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '' ); editor.focus(); LegacyUnit.setSelection(editor, 'ul > li:nth-child(2)', 1); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '' ); }); suite.test('Indent on second li with inner block element', function (editor) { editor.getBody().innerHTML = LegacyUnit.trimBrs( '' ); editor.focus(); LegacyUnit.setSelection(editor, 'ul > li:nth-child(2) > p', 0); LegacyUnit.execCommand(editor, 'Indent'); LegacyUnit.equal(editor.getContent(), '' ); }); TinyLoader.setup(function (editor, onSuccess, onFailure) { Pipeline.async({}, suite.toSteps(editor), onSuccess, onFailure); }, { 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],' + 'ul[style|class|data-custom],dl,dt,dd,em,strong,span,#p,div,br,table,tr,td', 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' }, skin_url: '/project/js/tinymce/skins/lightgray' }, success, failure); });