Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Feature: Allowed media embeds in table cells.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Jan 14, 2019
1 parent 731c479 commit 0fa7973
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
11 changes: 0 additions & 11 deletions src/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ export default class TableEditing extends Plugin {
}
} );

// Disallow media in table cell.
schema.addChildCheck( ( context, childDefinition ) => {
if ( !Array.from( context.getNames() ).includes( 'table' ) ) {
return;
}

if ( childDefinition.name == 'media' ) {
return false;
}
} );

// Table conversion.
conversion.for( 'upcast' ).add( upcastTable() );

Expand Down
15 changes: 13 additions & 2 deletions tests/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,25 @@ describe( 'TableEditing', () => {
.to.equal( '<table><tableRow><tableCell><image src="sample.png"></image></tableCell></tableRow></table>' );
} );

it( 'should convert table with media', () => {
it( 'should insert a paragraph when the cell content is unsupported', () => {
editor.setData(
'<table><tbody><tr><td><oembed url="https://www.youtube.com/watch?v=H08tGjXNHO4"></oembed></td></tr></tbody></table>'
'<table><tbody><tr><td><foo></foo></td></tr></tbody></table>'
);

expect( getModelData( model, { withoutSelection: true } ) )
.to.equal( '<table><tableRow><tableCell><paragraph></paragraph></tableCell></tableRow></table>' );
} );

it( 'should convert a table with media', () => {
editor.setData(
'<table><tbody><tr><td><oembed url="https://www.youtube.com/watch?v=H08tGjXNHO4"></oembed></td></tr></tbody></table>'
);

expect( getModelData( model, { withoutSelection: true } ) )
.to.equal( '<table><tableRow><tableCell>' +
'<media url="https://www.youtube.com/watch?v=H08tGjXNHO4"></media>' +
'</tableCell></tableRow></table>' );
} );
} );
} );

Expand Down

0 comments on commit 0fa7973

Please sign in to comment.