8
0
فهرست منبع

Merge pull request #162 from ckeditor/t/161

Feature: Allowed media embeds in table cells. Closes #161.
Maciej 7 سال پیش
والد
کامیت
eb53b7c38a
2فایلهای تغییر یافته به همراه13 افزوده شده و 13 حذف شده
  1. 0 11
      packages/ckeditor5-table/src/tableediting.js
  2. 13 2
      packages/ckeditor5-table/tests/tableediting.js

+ 0 - 11
packages/ckeditor5-table/src/tableediting.js

@@ -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() );
 

+ 13 - 2
packages/ckeditor5-table/tests/tableediting.js

@@ -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>' );
+			} );
 		} );
 	} );