import { Mouse, UiFinder } from '@ephox/agar'; import { describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyDom, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import Plugin from 'tinymce/plugins/quickbars/Plugin'; import { pAssertToolbarNotVisible, pAssertToolbarVisible } from '../module/test/Utils'; describe('browser.tinymce.plugins.quickbars.ContentEditableTest', () => { const hook = TinyHooks.bddSetup({ plugins: 'quickbars link', inline: true, toolbar: false, menubar: false, base_url: '/project/tinymce/js/tinymce' }, [ Plugin ], true); it('TBA: Text selection toolbar is not shown with contenteditable=false', async () => { const editor = hook.editor(); editor.setContent('

abc

cab

'); TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 1); await pAssertToolbarVisible(); TinySelections.select(editor, 'p[contenteditable=false]', []); await pAssertToolbarNotVisible(); }); it('TBA: Text selection toolbar is not shown with contenteditable=false parent, select parent', async () => { const editor = hook.editor(); editor.setContent('

abc

cab

'); TinySelections.select(editor, 'div', []); await pAssertToolbarVisible(); TinySelections.select(editor, 'div[contenteditable=false]', []); await pAssertToolbarNotVisible(); }); it('TBA: Text selection toolbar is not shown with contenteditable=false parent, select child of parent', async () => { const editor = hook.editor(); editor.setContent('

abc

cab

'); TinySelections.select(editor, 'div p', []); await pAssertToolbarVisible(); TinySelections.select(editor, 'div[contenteditable=false] p', []); await pAssertToolbarNotVisible(); }); it('TBA: Text selection toolbar is not shown with contenteditable=false span, select span', async () => { const editor = hook.editor(); editor.setContent('

abc

abc click on me 123

'); TinySelections.setSelection(editor, [ 0, 0 ], 0, [ 0, 0 ], 1); await pAssertToolbarVisible(); TinySelections.select(editor, 'p span', []); await pAssertToolbarNotVisible(); }); it('TINY-9190: Toolbar is not shown in the fake caret', async () => { const editor = hook.editor(); editor.setContent('

CEF element

'); // Selection is in the fake caret TinyAssertions.assertCursor(editor, [ 0 ], 0); TinyAssertions.assertContentPresence(editor, { 'p[data-mce-bogus="all"]': 1, 'p[data-mce-caret="before"]': 1 }); await pAssertToolbarNotVisible(); }); it('TINY-9305: Toolbar is not shown when dragging', async () => { const editor = hook.editor(); const emptyP = '

 

'; editor.setContent(emptyP + emptyP + emptyP + '

CEF element

' + emptyP + emptyP + emptyP); const elem = UiFinder.findIn(TinyDom.body(editor), '#cefElement').getOrDie(); Mouse.mouseDown(elem); Mouse.mouseMoveTo(elem, 10, -75); await pAssertToolbarNotVisible(); }); it('TINY-9305: Dragging CEF elements outside the editor should not prevent successive triggers of the quickbars', async () => { const editor = hook.editor(); const emptyP = '

 

'; editor.setContent(emptyP + emptyP + emptyP + '

CEF element

' + emptyP + emptyP + emptyP); const elem = UiFinder.findIn(TinyDom.body(editor), '#cefElement').getOrDie(); Mouse.mouseDown(elem); Mouse.mouseMoveTo(elem, -1000, -1000); Mouse.mouseUp(elem); TinySelections.setSelection(editor, [ 0 ], 0, [ 0 ], 0); await pAssertToolbarVisible(); }); });