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

Commit

Permalink
Merge branch t/ckeditor5-engine/1556
Browse files Browse the repository at this point in the history
Internal: Align code to the latest changes in conversion helpers API, introduced in engine t/1556.
  • Loading branch information
Piotr Jasiun committed Dec 21, 2018
2 parents a23b0c4 + 51b6aca commit f628629
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/mediaembedediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { modelToViewUrlAttributeConverter } from './converters';
import MediaEmbedCommand from './mediaembedcommand';
import MediaRegistry from './mediaregistry';
import { toMediaWidget, createMediaFigureElement } from './utils';
import { downcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';

import '../theme/mediaembedediting.css';

Expand Down Expand Up @@ -170,7 +168,7 @@ export default class MediaEmbedEditing extends Plugin {
} );

// Model -> Data
conversion.for( 'dataDowncast' ).add( downcastElementToElement( {
conversion.for( 'dataDowncast' ).elementToElement( {
model: 'media',
view: ( modelElement, viewWriter ) => {
const url = modelElement.getAttribute( 'url' );
Expand All @@ -179,7 +177,7 @@ export default class MediaEmbedEditing extends Plugin {
renderMediaPreview: url && renderMediaPreview
} );
}
} ) );
} );

// Model -> Data (url -> data-oembed-url)
conversion.for( 'dataDowncast' ).add(
Expand All @@ -188,7 +186,7 @@ export default class MediaEmbedEditing extends Plugin {
} ) );

// Model -> View (element)
conversion.for( 'editingDowncast' ).add( downcastElementToElement( {
conversion.for( 'editingDowncast' ).elementToElement( {
model: 'media',
view: ( modelElement, viewWriter ) => {
const url = modelElement.getAttribute( 'url' );
Expand All @@ -198,7 +196,7 @@ export default class MediaEmbedEditing extends Plugin {

return toMediaWidget( figure, viewWriter, t( 'media widget' ) );
}
} ) );
} );

// Model -> View (url -> data-oembed-url)
conversion.for( 'editingDowncast' ).add(
Expand All @@ -209,7 +207,7 @@ export default class MediaEmbedEditing extends Plugin {
// View -> Model (data-oembed-url -> url)
conversion.for( 'upcast' )
// Upcast semantic media.
.add( upcastElementToElement( {
.elementToElement( {
view: {
name: 'oembed',
attributes: {
Expand All @@ -223,9 +221,9 @@ export default class MediaEmbedEditing extends Plugin {
return modelWriter.createElement( 'media', { url } );
}
}
} ) )
} )
// Upcast non-semantic media.
.add( upcastElementToElement( {
.elementToElement( {
view: {
name: 'div',
attributes: {
Expand All @@ -239,6 +237,6 @@ export default class MediaEmbedEditing extends Plugin {
return modelWriter.createElement( 'media', { url } );
}
}
} ) );
} );
}
}

0 comments on commit f628629

Please sign in to comment.