瀏覽代碼

Simplified image converters.

Piotr Jasiun 8 年之前
父節點
當前提交
e36cc3ff3a
共有 1 個文件被更改,包括 4 次插入12 次删除
  1. 4 12
      packages/ckeditor5-image/src/image/converters.js

+ 4 - 12
packages/ckeditor5-image/src/image/converters.js

@@ -76,15 +76,11 @@ export function srcsetAttributeConverter() {
 	};
 
 	function converter( evt, data, consumable, conversionApi ) {
-		const parts = evt.name.split( ':' );
-		const consumableType = parts[ 0 ] + ':' + parts[ 1 ];
-		const modelImage = data.item;
-
-		if ( !consumable.consume( modelImage, consumableType ) ) {
+		if ( !consumable.consume( data.item, evt.name ) ) {
 			return;
 		}
 
-		const figure = conversionApi.mapper.toViewElement( modelImage );
+		const figure = conversionApi.mapper.toViewElement( data.item );
 		const img = figure.getChild( 0 );
 
 		if ( data.attributeNewValue === null ) {
@@ -120,15 +116,11 @@ export function modelToViewAttributeConverter( attributeKey ) {
 	};
 
 	function converter( evt, data, consumable, conversionApi ) {
-		const parts = evt.name.split( ':' );
-		const consumableType = parts[ 0 ] + ':' + parts[ 1 ];
-		const modelImage = data.item;
-
-		if ( !consumable.consume( modelImage, consumableType ) ) {
+		if ( !consumable.consume( data.item, evt.name ) ) {
 			return;
 		}
 
-		const figure = conversionApi.mapper.toViewElement( modelImage );
+		const figure = conversionApi.mapper.toViewElement( data.item );
 		const img = figure.getChild( 0 );
 
 		if ( data.attributeNewValue !== null ) {