diff --git a/src/linkengine.js b/src/linkengine.js index 7862253..470759c 100644 --- a/src/linkengine.js +++ b/src/linkengine.js @@ -49,7 +49,8 @@ export default class LinkEngine extends Plugin { // Build converter from view to model for data pipeline. buildViewConverter().for( data.viewToModel ) - .fromElement( 'a' ) + // Convert with href (value doesn't matter). + .from( { name: 'a', attribute: { href: /.?/ } } ) .toAttribute( viewElement => ( { key: 'linkHref', value: viewElement.getAttribute( 'href' ) diff --git a/tests/linkengine.js b/tests/linkengine.js index 1a5caf9..3140dac 100644 --- a/tests/linkengine.js +++ b/tests/linkengine.js @@ -71,6 +71,24 @@ describe( 'LinkEngine', () => { expect( editor.getData() ).to.equal( '

foobar

' ); } ); + + // https://github.com/ckeditor/ckeditor5/issues/500 + it( 'should not pick up `
`', () => { + editor.setData( '

foobar

' ); + + expect( getModelData( doc, { withoutSelection: true } ) ) + .to.equal( 'foobar' ); + } ); + + // CKEditor 4 does. And CKEditor 5's balloon allows creating such links. + it( 'should pick up ``', () => { + editor.setData( '

foobar

' ); + + expect( getModelData( doc, { withoutSelection: true } ) ) + .to.equal( '<$text linkHref="">foobar' ); + + expect( editor.getData() ).to.equal( '

foobar

' ); + } ); } ); describe( 'editing pipeline conversion', () => {