|
@@ -14,16 +14,15 @@ import Link from '@ckeditor/ckeditor5-link/src/link';
|
|
|
import ShiftEnter from '@ckeditor/ckeditor5-enter/src/shiftenter';
|
|
import ShiftEnter from '@ckeditor/ckeditor5-enter/src/shiftenter';
|
|
|
|
|
|
|
|
import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
-import { expectPaste } from '../../_utils/utils';
|
|
|
|
|
-
|
|
|
|
|
-import withinText from '../../_data/link/within-text/input.word2016.html';
|
|
|
|
|
-import combined from '../../_data/link/combined/input.word2016.html';
|
|
|
|
|
-import twoLine from '../../_data/link/two-line/input.word2016.html';
|
|
|
|
|
|
|
+import { getFixtures } from '../../_utils/fixtures';
|
|
|
|
|
+import { expectModel } from '../../_utils/utils';
|
|
|
|
|
|
|
|
describe( 'Link – integration', () => {
|
|
describe( 'Link – integration', () => {
|
|
|
- let element, editor;
|
|
|
|
|
|
|
+ let element, editor, input;
|
|
|
|
|
|
|
|
before( () => {
|
|
before( () => {
|
|
|
|
|
+ input = getFixtures( 'link' ).input;
|
|
|
|
|
+
|
|
|
element = document.createElement( 'div' );
|
|
element = document.createElement( 'div' );
|
|
|
|
|
|
|
|
document.body.appendChild( element );
|
|
document.body.appendChild( element );
|
|
@@ -45,122 +44,29 @@ describe( 'Link – integration', () => {
|
|
|
element.remove();
|
|
element.remove();
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- // Pastes: 'Regular <a href="https://ckeditor.com/">link</a>1'
|
|
|
|
|
- // Input same for: Chrome, Firefox and Edge.
|
|
|
|
|
- describe( 'within text', () => {
|
|
|
|
|
- it( 'pastes in the empty editor', () => {
|
|
|
|
|
- expectPaste( editor, withinText, '<paragraph>Regular ' +
|
|
|
|
|
- '<$text linkHref="https://ckeditor.com/">link</$text>1[]</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the paragraph', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph>More [] text</paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, withinText, '<paragraph>More Regular ' +
|
|
|
|
|
- '<$text linkHref="https://ckeditor.com/">link</$text>1[] text</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the different block context', () => {
|
|
|
|
|
- setData( editor.model, '<heading1>More [] text</heading1>' );
|
|
|
|
|
|
|
+ // Pastes:
|
|
|
|
|
+ // 'Regular <a href="https://ckeditor.com/">link</a>1'
|
|
|
|
|
+ it( 'pastes link within text', () => {
|
|
|
|
|
+ const expected = '<paragraph>Regular <$text linkHref="https://ckeditor.com/">link</$text>1</paragraph>';
|
|
|
|
|
|
|
|
- expectPaste( editor, withinText, '<heading1>More Regular ' +
|
|
|
|
|
- '<$text linkHref="https://ckeditor.com/">link</$text>1[] text</heading1>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the inline styling context', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph><$text bold="true">Bo[]ld</$text></paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, withinText, '<paragraph><$text bold="true">Bo</$text>' +
|
|
|
|
|
- 'Regular <$text linkHref="https://ckeditor.com/">link</$text>1[]<$text bold="true">ld</$text></paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ expectModel( editor, input.withinText, expected );
|
|
|
|
|
+ } );
|
|
|
|
|
|
|
|
- it( 'pastes inside another link element', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph>1<$text linkHref="#test">tes[]t</$text>2</paragraph>' );
|
|
|
|
|
|
|
+ // Pastes:
|
|
|
|
|
+ // '<a href="https://ckeditor.com/">CKEditor</a><a href="https://cksource.com/">CKSource</a> 2'
|
|
|
|
|
+ it( 'pastes combined links', () => {
|
|
|
|
|
+ const expected = '<paragraph><$text linkHref="https://ckeditor.com/">CKEditor</$text>' +
|
|
|
|
|
+ '<$text linkHref="https://cksource.com/">CKSource</$text> 2</paragraph>';
|
|
|
|
|
|
|
|
- expectPaste( editor, withinText, '<paragraph>1<$text linkHref="#test">tes</$text>' +
|
|
|
|
|
- 'Regular <$text linkHref="https://ckeditor.com/">link</$text>1[]<$text linkHref="#test">t</$text>2</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ expectModel( editor, input.combined, expected );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- // Pastes: '<a href="https://ckeditor.com/">CKEditor</a><a href="https://cksource.com/">CKSource</a> 2'
|
|
|
|
|
- // Input same for: Chrome, Firefox and Edge.
|
|
|
|
|
- describe( 'combined', () => {
|
|
|
|
|
- it( 'pastes in the empty editor', () => {
|
|
|
|
|
- expectPaste( editor, combined, '<paragraph><$text linkHref="https://ckeditor.com/">CKEditor</$text>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">CKSource</$text> 2[]</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the paragraph', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph>More [] text</paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, combined, '<paragraph>More <$text linkHref="https://ckeditor.com/">CKEditor</$text>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">CKSource</$text> 2[] text</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the different block context', () => {
|
|
|
|
|
- setData( editor.model, '<heading1>More [] text</heading1>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, combined, '<heading1>More <$text linkHref="https://ckeditor.com/">CKEditor</$text>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">CKSource</$text> 2[] text</heading1>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the inline styling context', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph><$text bold="true">Bo[]ld</$text></paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, combined, '<paragraph><$text bold="true">Bo</$text>' +
|
|
|
|
|
- '<$text linkHref="https://ckeditor.com/">CKEditor</$text>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">CKSource</$text> 2[]' +
|
|
|
|
|
- '<$text bold="true">ld</$text></paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes inside another link element', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph>1<$text linkHref="#test">tes[]t</$text>2</paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, combined, '<paragraph>1<$text linkHref="#test">tes</$text>' +
|
|
|
|
|
- '<$text linkHref="https://ckeditor.com/">CKEditor</$text>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">CKSource</$text> 2[]' +
|
|
|
|
|
- '<$text linkHref="#test">t</$text>2</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ // Pastes:
|
|
|
|
|
+ // '<a href="https://cksource.com/">Long link <br> WITH spaces</a>'
|
|
|
|
|
+ it( 'pastes two line link', () => {
|
|
|
|
|
+ const expected = '<paragraph><$text linkHref="https://cksource.com/">Long link </$text><softBreak></softBreak>' +
|
|
|
|
|
+ '<$text linkHref="https://cksource.com/">WITH spaces</$text></paragraph>';
|
|
|
|
|
|
|
|
- // Pastes: '<a href="https://cksource.com/">Long link <br> WITH spaces</a>'
|
|
|
|
|
- // Input same for: Chrome, Firefox and Edge.
|
|
|
|
|
- describe( 'two line', () => {
|
|
|
|
|
- it( 'pastes in the empty editor', () => {
|
|
|
|
|
- expectPaste( editor, twoLine, '<paragraph><$text linkHref="https://cksource.com/">Long link </$text><softBreak></softBreak>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">WITH spaces[]</$text></paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the paragraph', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph>More [] text</paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, twoLine, '<paragraph>More <$text linkHref="https://cksource.com/">Long link </$text>' +
|
|
|
|
|
- '<softBreak></softBreak><$text linkHref="https://cksource.com/">WITH spaces[]</$text> text</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the different block context', () => {
|
|
|
|
|
- setData( editor.model, '<heading1>More [] text</heading1>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, twoLine, '<heading1>More <$text linkHref="https://cksource.com/">Long link </$text>' +
|
|
|
|
|
- '<softBreak></softBreak><$text linkHref="https://cksource.com/">WITH spaces[]</$text> text</heading1>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes in the inline styling context', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph><$text bold="true">Bo[]ld</$text></paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, twoLine, '<paragraph><$text bold="true">Bo</$text>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">Long link </$text>' +
|
|
|
|
|
- '<softBreak></softBreak><$text linkHref="https://cksource.com/">WITH spaces[]</$text>' +
|
|
|
|
|
- '<$text bold="true">ld</$text></paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'pastes inside another link element', () => {
|
|
|
|
|
- setData( editor.model, '<paragraph>1<$text linkHref="#test">tes[]t</$text>2</paragraph>' );
|
|
|
|
|
-
|
|
|
|
|
- expectPaste( editor, twoLine, '<paragraph>1<$text linkHref="#test">tes</$text>' +
|
|
|
|
|
- '<$text linkHref="https://cksource.com/">Long link </$text>' +
|
|
|
|
|
- '<softBreak></softBreak><$text linkHref="https://cksource.com/">WITH spaces[]</$text>' +
|
|
|
|
|
- '<$text linkHref="#test">t</$text>2</paragraph>' );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ expectModel( editor, input.twoLine, expected );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|