Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( 'should merge table cells', () => {
setData( model, modelTable( [
[ '00', '01' ],
[ '10', '[]11' ]
] ) );
command.execute();
expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
[ '00', { rowspan: 2, contents: '[0111]' } ],
[ '10' ]
] ) );
} );
it( 'should decrease rowspan if cell overlaps removed row', () => {
setData( model, modelTable( [
[ '00', { rowspan: 2, contents: '01' }, { rowspan: 3, contents: '02' } ],
[ '10' ],
[ '20', '21' ]
] ) );
selectNodes( [
[ 0, 0, 0 ],
[ 0, 1, 0 ],
[ 0, 2, 0 ]
] );
command.execute();
expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
[
{ rowspan: 2, contents: '[001020]' },
'01',
{ rowspan: 2, contents: '02' }
],
[ '21' ]
] ) );
} );
it( 'should not convert from view to model if class is not defined', () => {
editor.setData( '<figure class="image foo-bar"><img src="foo.png"></figure>' );
expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<img src="foo.png">' );
expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
'<figure class="ck ck-widget image"><img src="foo.png"></figure>'
);
} );
it( 'should not convert from view to model when not in image figure', () => {
editor.setData( '<figure class="side-class"></figure>' );
expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '' );
expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal( '' );
} );
it( 'should not insert image nor crash when image could not be inserted', () => {
model.schema.register( 'other', {
allowIn: '$root',
isLimit: true
} );
model.schema.extend( '$text', { allowIn: 'other' } );
editor.conversion.for( 'downcast' ).elementToElement( { model: 'other', view: 'p' } );
setModelData( model, '[]' );
model.change( writer => {
insertImage( writer, model );
} );
expect( getModelData( model ) ).to.equal( '[]' );
} );
} );
it( 'should fix the wrong rowspan attribute of a table cell inside the header', () => {
const parsed = parse( modelTable( [
[ { rowspan: 2, contents: '00' }, { rowspan: 3, contents: '01' }, '02' ],
[ { rowspan: 8, contents: '12' } ],
[ '20', '21', '22' ]
], { headingRows: 2 } ), model.schema );
model.change( writer => {
writer.remove( Range.createIn( root ) );
writer.insert( parsed, root );
} );
expect( formatTable( getModelData( model, { withoutSelection: true } ) ) ).to.equal( formattedModelTable( [
[ { rowspan: 2, contents: '00' }, { rowspan: 2, contents: '01' }, '02' ],
[ '12' ],
[ '20', '21', '22' ]
], { headingRows: 2 } ) );
} );
it( 'should set data of the first root', () => {
editor.model.document.createRoot();
editor.model.document.createRoot( '$root', 'secondRoot' );
editor.editing.createRoot( 'div' );
editor.editing.createRoot( 'div', 'secondRoot' );
editor.setData( 'foo' );
expect( getData( editor.model, { rootName: 'main', withoutSelection: true } ) ).to.equal( 'foo' );
} );
} );
it( 'should convert table', () => {
editor.setData( '<table><tbody><tr><td>foo</td></tr></tbody></table>' );
expect( getModelData( model, { withoutSelection: true } ) )
.to.equal( 'foo<table></table>' );
} );
} );
function expectModel( data ) {
expect( getModelData( model, { withoutSelection: true } ) ).to.equal( data );
}
.then( newEditor => {
newEditor.setData(
'<figure class="media"></figure>' +
'<figure class="media"></figure>' );
expect( getModelData( newEditor.model, { withoutSelection: true } ) )
.to.equal( '' );
return newEditor.destroy();
} );
} );