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

Commit

Permalink
Merge pull request #128 from ckeditor/t/124
Browse files Browse the repository at this point in the history
Other: Media should not be allowed inside table cells for now. Closes #124.
  • Loading branch information
Reinmar committed Sep 28, 2018
2 parents effe586 + 3ae5795 commit 2f2fe4a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@ckeditor/ckeditor5-editor-classic": "^11.0.0",
"@ckeditor/ckeditor5-image": "^10.2.0",
"@ckeditor/ckeditor5-list": "^11.0.1",
"@ckeditor/ckeditor5-media-embed": "^0.0.1",
"@ckeditor/ckeditor5-paragraph": "^10.0.2",
"@ckeditor/ckeditor5-undo": "^10.0.2",
"@ckeditor/ckeditor5-utils": "^10.2.0",
Expand Down
8 changes: 6 additions & 2 deletions src/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ export default class TableEditing extends Plugin {
}
} );

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

if ( childDefinition.name == 'image' || childDefinition.name == 'media' ) {
return false;
}
} );
Expand Down
1 change: 0 additions & 1 deletion tests/manual/tableblockcontent.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* List
* Heading
* Block Quote (with inner paragraph)
* Image

2. The third column consist blocks with text alignment.
* Paragraph - should be rendered was `<p>` when alignment is set (apart from default) for single paragraph.
Expand Down
12 changes: 11 additions & 1 deletion tests/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import SplitCellCommand from '../src/commands/splitcellcommand';
import MergeCellCommand from '../src/commands/mergecellcommand';
import SetHeaderRowCommand from '../src/commands/setheaderrowcommand';
import SetHeaderColumnCommand from '../src/commands/setheadercolumncommand';
import MediaEmbedEditing from '@ckeditor/ckeditor5-media-embed/src/mediaembedediting';

describe( 'TableEditing', () => {
let editor, model;

beforeEach( () => {
return VirtualTestEditor
.create( {
plugins: [ TableEditing, Paragraph, ImageEditing ]
plugins: [ TableEditing, Paragraph, ImageEditing, MediaEmbedEditing ]
} )
.then( newEditor => {
editor = newEditor;
Expand Down Expand Up @@ -184,6 +185,15 @@ describe( 'TableEditing', () => {
expect( getModelData( model, { withoutSelection: true } ) )
.to.equal( '<table><tableRow><tableCell><paragraph></paragraph></tableCell></tableRow></table>' );
} );

it( 'should convert 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><paragraph></paragraph></tableCell></tableRow></table>' );
} );
} );
} );

Expand Down

0 comments on commit 2f2fe4a

Please sign in to comment.