import { describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import Plugin from 'tinymce/plugins/autolink/Plugin'; import * as KeyUtils from '../module/test/KeyUtils'; describe('browser.tinymce.plugins.autolink.FragmentedTextTest.ts', () => { const hook = TinyHooks.bddSetupLight({ plugins: 'autolink', indent: false, base_url: '/project/tinymce/js/tinymce' }, [ Plugin ], true); it('TINY-3723: should detect URLs over fragmented text in inline elements', () => { const editor = hook.editor(); editor.setContent('

www.tiny.cloud

'); TinySelections.setCursor(editor, [ 0, 1 ], '.tiny.cloud'.length); KeyUtils.type(editor, ' '); TinyAssertions.assertContent(editor, '

www.tiny.cloud 

'); }); it('TINY-3723: should detect URLs over fragmented text nodes', () => { const editor = hook.editor(); editor.setContent('

http://www.tiny.cloud/

'); // Setup fragmented text nodes const para = editor.dom.select('p')[0]; const textNode = para.firstChild as Text; textNode.splitText('http://'.length); TinySelections.setCursor(editor, [ 0, 1 ], 'www.tiny.cloud/'.length); KeyUtils.type(editor, ' '); TinyAssertions.assertContent(editor, '

http://www.tiny.cloud/ 

'); }); it('TINY-3723: should not detect URLs separated by a line break', () => { const editor = hook.editor(); editor.setContent('

http://www
.tiny.cloud/

'); TinySelections.setCursor(editor, [ 0, 2 ], '.tiny.cloud/'.length); KeyUtils.type(editor, ' '); TinyAssertions.assertContent(editor, '

http://www
.tiny.cloud/ 

'); editor.setContent('

http://www

.tiny.cloud/

'); TinySelections.setCursor(editor, [ 1, 0 ], '.tiny.cloud/'.length); KeyUtils.type(editor, ' '); TinyAssertions.assertContent(editor, '

http://www

.tiny.cloud/ 

'); }); it('TINY-3723: should not detect URLs across cef boundaries', () => { const editor = hook.editor(); editor.setContent('

http://www.tiny.cloud/

'); TinySelections.setCursor(editor, [ 0, 2 ], '.tiny.cloud/'.length); KeyUtils.type(editor, ' '); TinyAssertions.assertContent(editor, '

http://www.tiny.cloud/ 

'); }); });