|
@@ -45,7 +45,7 @@ describe( 'DataController', () => {
|
|
|
|
|
|
|
|
describe( 'parse()', () => {
|
|
describe( 'parse()', () => {
|
|
|
it( 'should set text', () => {
|
|
it( 'should set text', () => {
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
const output = data.parse( '<p>foo<b>bar</b></p>' );
|
|
const output = data.parse( '<p>foo<b>bar</b></p>' );
|
|
|
|
|
|
|
|
expect( output ).to.instanceof( ModelDocumentFragment );
|
|
expect( output ).to.instanceof( ModelDocumentFragment );
|
|
@@ -53,7 +53,7 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should set paragraph', () => {
|
|
it( 'should set paragraph', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
|
|
|
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
|
|
|
|
|
@@ -64,7 +64,7 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should set two paragraphs', () => {
|
|
it( 'should set two paragraphs', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
|
|
|
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
|
|
|
|
|
@@ -75,7 +75,7 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should set paragraphs with bold', () => {
|
|
it( 'should set paragraphs with bold', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
schema.allow( { name: '$text', attributes: [ 'bold' ], inside: '$block' } );
|
|
schema.allow( { name: '$text', attributes: [ 'bold' ], inside: '$block' } );
|
|
|
|
|
|
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
@@ -102,7 +102,7 @@ describe( 'DataController', () => {
|
|
|
|
|
|
|
|
describe( 'toModel()', () => {
|
|
describe( 'toModel()', () => {
|
|
|
beforeEach( () => {
|
|
beforeEach( () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
|
|
|
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
buildViewConverter().for( data.viewToModel ).fromElement( 'p' ).toElement( 'paragraph' );
|
|
|
} );
|
|
} );
|
|
@@ -126,8 +126,8 @@ describe( 'DataController', () => {
|
|
|
it( 'should accept parsing context', () => {
|
|
it( 'should accept parsing context', () => {
|
|
|
modelDocument.createRoot( 'inlineRoot', 'inlineRoot' );
|
|
modelDocument.createRoot( 'inlineRoot', 'inlineRoot' );
|
|
|
|
|
|
|
|
- schema.registerItem( 'inlineRoot' );
|
|
|
|
|
- schema.allow( { name: '$text', inside: 'inlineRoot' } );
|
|
|
|
|
|
|
+ schema.register( 'inlineRoot' );
|
|
|
|
|
+ schema.extend( '$text', { allowIn: 'inlineRoot' } );
|
|
|
|
|
|
|
|
const viewFragment = new ViewDocumentFragment( [ parseView( 'foo' ) ] );
|
|
const viewFragment = new ViewDocumentFragment( [ parseView( 'foo' ) ] );
|
|
|
|
|
|
|
@@ -141,14 +141,14 @@ describe( 'DataController', () => {
|
|
|
|
|
|
|
|
describe( 'set()', () => {
|
|
describe( 'set()', () => {
|
|
|
it( 'should set data to root', () => {
|
|
it( 'should set data to root', () => {
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
data.set( 'foo' );
|
|
data.set( 'foo' );
|
|
|
|
|
|
|
|
expect( getData( model, { withoutSelection: true } ) ).to.equal( 'foo' );
|
|
expect( getData( model, { withoutSelection: true } ) ).to.equal( 'foo' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should create a batch', () => {
|
|
it( 'should create a batch', () => {
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
data.set( 'foo' );
|
|
data.set( 'foo' );
|
|
|
|
|
|
|
|
expect( count( modelDocument.history.getDeltas() ) ).to.equal( 1 );
|
|
expect( count( modelDocument.history.getDeltas() ) ).to.equal( 1 );
|
|
@@ -157,7 +157,7 @@ describe( 'DataController', () => {
|
|
|
it( 'should fire #changesDone', () => {
|
|
it( 'should fire #changesDone', () => {
|
|
|
const spy = sinon.spy();
|
|
const spy = sinon.spy();
|
|
|
|
|
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
modelDocument.on( 'changesDone', spy );
|
|
modelDocument.on( 'changesDone', spy );
|
|
|
|
|
|
|
|
data.set( 'foo' );
|
|
data.set( 'foo' );
|
|
@@ -166,7 +166,7 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should get root name as a parameter', () => {
|
|
it( 'should get root name as a parameter', () => {
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
data.set( 'foo', 'main' );
|
|
data.set( 'foo', 'main' );
|
|
|
data.set( 'Bar', 'title' );
|
|
data.set( 'Bar', 'title' );
|
|
|
|
|
|
|
@@ -179,7 +179,7 @@ describe( 'DataController', () => {
|
|
|
// This case was added when order of params was different and it really didn't work. Let's keep it
|
|
// This case was added when order of params was different and it really didn't work. Let's keep it
|
|
|
// if anyone will ever try to change this.
|
|
// if anyone will ever try to change this.
|
|
|
it( 'should allow setting empty data', () => {
|
|
it( 'should allow setting empty data', () => {
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
|
|
|
|
|
data.set( 'foo', 'title' );
|
|
data.set( 'foo', 'title' );
|
|
|
|
|
|
|
@@ -193,7 +193,7 @@ describe( 'DataController', () => {
|
|
|
|
|
|
|
|
describe( 'get()', () => {
|
|
describe( 'get()', () => {
|
|
|
it( 'should get paragraph with text', () => {
|
|
it( 'should get paragraph with text', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
setData( model, '<paragraph>foo</paragraph>' );
|
|
setData( model, '<paragraph>foo</paragraph>' );
|
|
|
|
|
|
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
@@ -202,7 +202,7 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should get empty paragraph', () => {
|
|
it( 'should get empty paragraph', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
setData( model, '<paragraph></paragraph>' );
|
|
setData( model, '<paragraph></paragraph>' );
|
|
|
|
|
|
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
@@ -211,7 +211,7 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should get two paragraphs', () => {
|
|
it( 'should get two paragraphs', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
setData( model, '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
|
|
setData( model, '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
|
|
|
|
|
|
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
@@ -220,14 +220,14 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should get text directly in root', () => {
|
|
it( 'should get text directly in root', () => {
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
setData( model, 'foo' );
|
|
setData( model, 'foo' );
|
|
|
|
|
|
|
|
expect( data.get() ).to.equal( 'foo' );
|
|
expect( data.get() ).to.equal( 'foo' );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should get paragraphs without bold', () => {
|
|
it( 'should get paragraphs without bold', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
|
|
setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
|
|
|
|
|
|
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
@@ -236,7 +236,7 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should get paragraphs with bold', () => {
|
|
it( 'should get paragraphs with bold', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
|
|
setData( model, '<paragraph>foo<$text bold="true">bar</$text></paragraph>' );
|
|
|
|
|
|
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
@@ -246,8 +246,8 @@ describe( 'DataController', () => {
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should get root name as a parameter', () => {
|
|
it( 'should get root name as a parameter', () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
- schema.allow( { name: '$text', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
|
|
+ schema.extend( '$text', { allowIn: '$root' } );
|
|
|
|
|
|
|
|
setData( model, '<paragraph>foo</paragraph>', { rootName: 'main' } );
|
|
setData( model, '<paragraph>foo</paragraph>', { rootName: 'main' } );
|
|
|
setData( model, 'Bar', { rootName: 'title' } );
|
|
setData( model, 'Bar', { rootName: 'title' } );
|
|
@@ -263,11 +263,11 @@ describe( 'DataController', () => {
|
|
|
|
|
|
|
|
describe( 'stringify()', () => {
|
|
describe( 'stringify()', () => {
|
|
|
beforeEach( () => {
|
|
beforeEach( () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
- schema.registerItem( 'div' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
|
|
+ schema.register( 'div' );
|
|
|
|
|
|
|
|
- schema.allow( { name: '$block', inside: 'div' } );
|
|
|
|
|
- schema.allow( { name: 'div', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$block', { allowIn: 'div' } );
|
|
|
|
|
+ schema.extend( 'div', { allowIn: '$root' } );
|
|
|
|
|
|
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
|
} );
|
|
} );
|
|
@@ -287,11 +287,11 @@ describe( 'DataController', () => {
|
|
|
|
|
|
|
|
describe( 'toView()', () => {
|
|
describe( 'toView()', () => {
|
|
|
beforeEach( () => {
|
|
beforeEach( () => {
|
|
|
- schema.registerItem( 'paragraph', '$block' );
|
|
|
|
|
- schema.registerItem( 'div' );
|
|
|
|
|
|
|
+ schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
|
|
+ schema.register( 'div' );
|
|
|
|
|
|
|
|
- schema.allow( { name: '$block', inside: 'div' } );
|
|
|
|
|
- schema.allow( { name: 'div', inside: '$root' } );
|
|
|
|
|
|
|
+ schema.extend( '$block', { allowIn: 'div' } );
|
|
|
|
|
+ schema.extend( 'div', { allowIn: '$root' } );
|
|
|
|
|
|
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
|
|
|
} );
|
|
} );
|