diff --git a/src/linkengine.js b/src/linkengine.js
index 43c9485..3335322 100644
--- a/src/linkengine.js
+++ b/src/linkengine.js
@@ -31,7 +31,7 @@ export default class LinkEngine extends Plugin {
const editing = editor.editing;
// Allow link attribute on all inline nodes.
- editor.document.schema.allow( { name: '$inline', attributes: 'linkHref' } );
+ editor.document.schema.allow( { name: '$inline', attributes: 'linkHref', inside: '$block' } );
// Build converter from model to view for data and editing pipelines.
buildModelConverter().for( data.modelToView, editing.modelToView )
diff --git a/tests/linkengine.js b/tests/linkengine.js
index 2913a90..71173d9 100644
--- a/tests/linkengine.js
+++ b/tests/linkengine.js
@@ -7,7 +7,9 @@ import LinkEngine from '../src/linkengine';
import LinkCommand from '../src/linkcommand';
import LinkElement from '../src/linkelement';
import UnlinkCommand from '../src/unlinkcommand';
+
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
@@ -16,14 +18,12 @@ describe( 'LinkEngine', () => {
beforeEach( () => {
return VirtualTestEditor.create( {
- plugins: [ LinkEngine ]
+ plugins: [ Paragraph, LinkEngine ]
} )
.then( newEditor => {
editor = newEditor;
doc = editor.document;
-
- doc.schema.allow( { name: '$text', inside: '$root' } );
} );
} );
@@ -32,7 +32,8 @@ describe( 'LinkEngine', () => {
} );
it( 'should set proper schema rules', () => {
- expect( doc.schema.check( { name: '$inline', attributes: [ 'linkHref' ] } ) ).to.be.true;
+ expect( doc.schema.check( { name: '$inline', attributes: [ 'linkHref' ], inside: '$root' } ) ).to.be.false;
+ expect( doc.schema.check( { name: '$inline', attributes: [ 'linkHref' ], inside: '$block' } ) ).to.be.true;
} );
describe( 'command', () => {
@@ -55,24 +56,37 @@ describe( 'LinkEngine', () => {
describe( 'data pipeline conversions', () => {
it( 'should convert `` to `linkHref="url"` attribute', () => {
+ editor.setData( ' foobar foobar
foobar
' ); } ); } ); describe( 'editing pipeline conversion', () => { it( 'should convert attribute', () => { - setModelData( doc, '<$text linkHref="url">foo$text>bar' ); + setModelData( doc, 'foobar
' ); } ); it( 'should convert to `LinkElement` instance', () => { - setModelData( doc, '<$text linkHref="url">foo$text>bar' ); + setModelData( doc, '