ソースを参照

Align code to the changes in conversion API.

Maciej Gołaszewski 7 年 前
コミット
7b014bb394

+ 5 - 7
packages/ckeditor5-link/src/linkediting.js

@@ -8,8 +8,6 @@
  */
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
-import { downcastAttributeToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
-import { upcastElementToAttribute } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';
 import LinkCommand from './linkcommand';
 import UnlinkCommand from './unlinkcommand';
 import { createLinkElement, ensureSafeUrl } from './utils';
@@ -38,15 +36,15 @@ export default class LinkEditing extends Plugin {
 		editor.model.schema.extend( '$text', { allowAttributes: 'linkHref' } );
 
 		editor.conversion.for( 'dataDowncast' )
-			.add( downcastAttributeToElement( { model: 'linkHref', view: createLinkElement } ) );
+			.attributeToElement( { model: 'linkHref', view: createLinkElement } );
 
 		editor.conversion.for( 'editingDowncast' )
-			.add( downcastAttributeToElement( { model: 'linkHref', view: ( href, writer ) => {
+			.attributeToElement( { model: 'linkHref', view: ( href, writer ) => {
 				return createLinkElement( ensureSafeUrl( href ), writer );
-			} } ) );
+			} } );
 
 		editor.conversion.for( 'upcast' )
-			.add( upcastElementToAttribute( {
+			.elementToAttribute( {
 				view: {
 					name: 'a',
 					attributes: {
@@ -57,7 +55,7 @@ export default class LinkEditing extends Plugin {
 					key: 'linkHref',
 					value: viewElement => viewElement.getAttribute( 'href' )
 				}
-			} ) );
+			} );
 
 		// Create linking commands.
 		editor.commands.add( 'link', new LinkCommand( editor ) );

+ 2 - 6
packages/ckeditor5-link/tests/linkediting.js

@@ -14,10 +14,6 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 import { isLinkElement } from '../src/utils';
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
-import {
-	downcastMarkerToHighlight,
-	downcastAttributeToElement
-} from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
 
 /* global document */
 
@@ -156,7 +152,7 @@ describe( 'LinkEditing', () => {
 		it( 'should should set priority for `linkHref` higher than all other attribute elements', () => {
 			model.schema.extend( '$text', { allowAttributes: 'foo' } );
 
-			editor.conversion.for( 'downcast' ).add( downcastAttributeToElement( { model: 'foo', view: 'f' } ) );
+			editor.conversion.for( 'downcast' ).attributeToElement( { model: 'foo', view: 'f' } );
 
 			setModelData( model,
 				'<paragraph>' +
@@ -328,7 +324,7 @@ describe( 'LinkEditing', () => {
 			} );
 
 			it( 'works for the addMarker and removeMarker events', () => {
-				downcastMarkerToHighlight( { model: 'fooMarker', view: {} } )( editor.editing.downcastDispatcher );
+				editor.conversion.for( 'editingDowncast' ).markerToHighlight( { model: 'fooMarker', view: {} } );
 
 				setModelData( model,
 					'<paragraph>foo <$text linkHref="url">li{}nk</$text> baz</paragraph>'