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

Commit 2f2fe4a

Browse files
authored
Merge pull request #128 from ckeditor/t/124
Other: Media should not be allowed inside table cells for now. Closes #124.
2 parents effe586 + 3ae5795 commit 2f2fe4a

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@ckeditor/ckeditor5-editor-classic": "^11.0.0",
2323
"@ckeditor/ckeditor5-image": "^10.2.0",
2424
"@ckeditor/ckeditor5-list": "^11.0.1",
25+
"@ckeditor/ckeditor5-media-embed": "^0.0.1",
2526
"@ckeditor/ckeditor5-paragraph": "^10.0.2",
2627
"@ckeditor/ckeditor5-undo": "^10.0.2",
2728
"@ckeditor/ckeditor5-utils": "^10.2.0",

src/tableediting.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ export default class TableEditing extends Plugin {
8181
}
8282
} );
8383

84-
// Disallow image in table cell.
84+
// Disallow image and media in table cell.
8585
schema.addChildCheck( ( context, childDefinition ) => {
86-
if ( childDefinition.name == 'image' && Array.from( context.getNames() ).includes( 'table' ) ) {
86+
if ( !Array.from( context.getNames() ).includes( 'table' ) ) {
87+
return;
88+
}
89+
90+
if ( childDefinition.name == 'image' || childDefinition.name == 'media' ) {
8791
return false;
8892
}
8993
} );

tests/manual/tableblockcontent.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* List
77
* Heading
88
* Block Quote (with inner paragraph)
9-
* Image
109

1110
2. The third column consist blocks with text alignment.
1211
* Paragraph - should be rendered was `<p>` when alignment is set (apart from default) for single paragraph.

tests/tableediting.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import SplitCellCommand from '../src/commands/splitcellcommand';
2020
import MergeCellCommand from '../src/commands/mergecellcommand';
2121
import SetHeaderRowCommand from '../src/commands/setheaderrowcommand';
2222
import SetHeaderColumnCommand from '../src/commands/setheadercolumncommand';
23+
import MediaEmbedEditing from '@ckeditor/ckeditor5-media-embed/src/mediaembedediting';
2324

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

2728
beforeEach( () => {
2829
return VirtualTestEditor
2930
.create( {
30-
plugins: [ TableEditing, Paragraph, ImageEditing ]
31+
plugins: [ TableEditing, Paragraph, ImageEditing, MediaEmbedEditing ]
3132
} )
3233
.then( newEditor => {
3334
editor = newEditor;
@@ -184,6 +185,15 @@ describe( 'TableEditing', () => {
184185
expect( getModelData( model, { withoutSelection: true } ) )
185186
.to.equal( '<table><tableRow><tableCell><paragraph></paragraph></tableCell></tableRow></table>' );
186187
} );
188+
189+
it( 'should convert table with media', () => {
190+
editor.setData(
191+
'<table><tbody><tr><td><oembed url="https://www.youtube.com/watch?v=H08tGjXNHO4"></oembed></td></tr></tbody></table>'
192+
);
193+
194+
expect( getModelData( model, { withoutSelection: true } ) )
195+
.to.equal( '<table><tableRow><tableCell><paragraph></paragraph></tableCell></tableRow></table>' );
196+
} );
187197
} );
188198
} );
189199

0 commit comments

Comments
 (0)