import { Keys } from '@ephox/agar'; import { describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyContentActions, TinyHooks, TinySelections, TinyUiActions } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import Plugin from 'tinymce/plugins/lists/Plugin'; describe('browser.tinymce.plugins.lists.ToggleListWithEmptyLiTest', () => { const hook = TinyHooks.bddSetupLight({ indent: false, plugins: 'lists table', toolbar: 'bullist', base_url: '/project/tinymce/js/tinymce' }, [ Plugin ], true); const wrapInsideTable = (content: string): string => `
${content}
`; const wrapInsideTableWithList = (content: string): string => `
  • ${content}
`; it('TINY-6853: toggle list inside table cell with anchor outside of anchor to the left of the anchor should include the anchor in the list', () => { const editor = hook.editor(); const content = 'link'; editor.setContent(wrapInsideTable(content)); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 0 ], 0); // Needed to move the cursor outside of the link TinyContentActions.keystroke(editor, Keys.left()); TinyUiActions.clickOnToolbar(editor, 'button[aria-label="Bullet list"]'); TinyAssertions.assertContent(editor, wrapInsideTableWithList(content)); }); it('TINY-6853: toggle list inside table cell with anchor containing an img tag outside of anchor to the left of the anchor should include the anchor in the list', () => { const editor = hook.editor(); const content = ''; editor.setContent(wrapInsideTable(content)); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 0 ], 0); TinyUiActions.clickOnToolbar(editor, 'button[aria-label="Bullet list"]'); TinyAssertions.assertContent(editor, wrapInsideTableWithList(content)); }); it('TINY-6853: toggle list inside table cell with anchor outside of anchor to the right of the anchor should include the anchor in the list', () => { const editor = hook.editor(); const content = 'link'; editor.setContent(wrapInsideTable(content)); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 0 ], 1); // Needed to move the cursor outside of the link TinyContentActions.keystroke(editor, Keys.right()); TinyUiActions.clickOnToolbar(editor, 'button[aria-label="Bullet list"]'); TinyAssertions.assertContent(editor, wrapInsideTableWithList(content)); }); it('TINY-6853: toggle list inside table cell with anchor and other inline elements before the anchor should include all the inline elements in the list', () => { const editor = hook.editor(); const content = 'abc def link'; editor.setContent(wrapInsideTable(content)); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 0 ], 1); TinyUiActions.clickOnToolbar(editor, 'button[aria-label="Bullet list"]'); TinyAssertions.assertContent(editor, wrapInsideTableWithList(content)); }); it('TINY-6853: toggle list inside table cell with anchor and other inline elements after the anchor should include all the inline elements in the list', () => { const editor = hook.editor(); const content = 'link abc def'; editor.setContent(wrapInsideTable(content)); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 2, 0 ], 1); TinyUiActions.clickOnToolbar(editor, 'button[aria-label="Bullet list"]'); TinyAssertions.assertContent(editor, wrapInsideTableWithList(content)); }); it('TINY-6853: toggle list inside table cell with anchor and other inline elements around the anchor should include all the inline elements in the list', () => { const editor = hook.editor(); const content = 'abc def link efg hij'; editor.setContent(wrapInsideTable(content)); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 1, 0 ], 1); TinyUiActions.clickOnToolbar(editor, 'button[aria-label="Bullet list"]'); TinyAssertions.assertContent(editor, wrapInsideTableWithList(content)); }); it('TINY-6853: toggle list inside table cell with cursor between two anchors should include both anchors in the list', () => { const editor = hook.editor(); const content = 'ab'; editor.setContent(wrapInsideTable(content)); TinySelections.setCursor(editor, [ 0, 1, 0, 0, 1 ], 0); // Needed to move the cursor outside of the link TinyContentActions.keystroke(editor, Keys.left()); TinyUiActions.clickOnToolbar(editor, 'button[aria-label="Bullet list"]'); TinyAssertions.assertContent(editor, wrapInsideTableWithList(content)); }); });