Browse Source

Fixing after changes introduced in t/ckeditor5-engine/1236

Szymon Cofalik 7 years ago
parent
commit
e7d5428d06

+ 5 - 3
packages/ckeditor5-widget/src/highlightstack.js

@@ -11,12 +11,14 @@ import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 
 /**
- * Class used to handle correct order of
- * {@link module:engine/conversion/buildmodelconverter~ModelConverterBuilder#toHighlight highlights} on
- * elements. When different highlights are applied to same element correct order should be preserved:
+ * Class used to handle correct order of highlights on elements.
+ *
+ * When different highlights are applied to same element correct order should be preserved:
+ *
  * * highlight with highest priority should be applied,
  * * if two highlights have same priority - sort by CSS class provided in
  * {@link module:engine/conversion/model-to-view-converters~HighlightDescriptor}.
+ *
  * This way, highlight will be applied with the same rules it is applied on texts.
  */
 export default class HighlightStack {

+ 1 - 1
packages/ckeditor5-widget/src/widget.js

@@ -54,7 +54,7 @@ export default class Widget extends Plugin {
 
 		// Model to view selection converter.
 		// Converts selection placed over widget element to fake selection
-		this.editor.editing.modelToView.on( 'selection', ( evt, data, consumable, conversionApi ) => {
+		this.editor.editing.downcastDispatcher.on( 'selection', ( evt, data, consumable, conversionApi ) => {
 			// Remove selected class from previously selected widgets.
 			this._clearPreviouslySelectedWidgets();
 

+ 24 - 37
packages/ckeditor5-widget/tests/widget.js

@@ -7,7 +7,7 @@ import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtest
 import Widget from '../src/widget';
 import Typing from '@ckeditor/ckeditor5-typing/src/typing';
 import MouseObserver from '@ckeditor/ckeditor5-engine/src/view/observer/mouseobserver';
-import buildModelConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildmodelconverter';
+import { downcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
 import { toWidget } from '../src/utils';
 import ViewContainer from '@ckeditor/ckeditor5-engine/src/view/containerelement';
 import ViewEditable from '@ckeditor/ckeditor5-engine/src/view/editableelement';
@@ -70,42 +70,29 @@ describe( 'Widget', () => {
 					allowIn: [ 'blockQuote', 'div' ]
 				} );
 
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'paragraph' )
-					.toElement( 'p' );
-
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'widget' )
-					.toElement( () => {
-						const b = new AttributeContainer( 'b' );
-						const div = new ViewContainer( 'div', null, b );
-
-						return toWidget( div, { label: 'element label' } );
-					} );
-
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'inline' )
-					.toElement( 'figure' );
-
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'nested' )
-					.toElement( () => new ViewEditable( 'figcaption', { contenteditable: true } ) );
-
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'editable' )
-					.toElement( () => new ViewEditable( 'figcaption', { contenteditable: true } ) );
-
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'image' )
-					.toElement( 'img' );
-
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'blockQuote' )
-					.toElement( 'blockquote' );
-
-				buildModelConverter().for( editor.editing.modelToView )
-					.fromElement( 'div' )
-					.toElement( 'div' );
+				editor.conversion.for( 'downcast' )
+					.add( downcastElementToElement( { model: 'paragraph', view: 'p' } ) )
+					.add( downcastElementToElement( { model: 'inline', view: 'figure' } ) )
+					.add( downcastElementToElement( { model: 'image', view: 'img' } ) )
+					.add( downcastElementToElement( { model: 'blockQuote', view: 'blockquote' } ) )
+					.add( downcastElementToElement( { model: 'div', view: 'div' } ) )
+					.add( downcastElementToElement( {
+						model: 'widget',
+						view: () => {
+							const b = new AttributeContainer( 'b' );
+							const div = new ViewContainer( 'div', null, b );
+
+							return toWidget( div, { label: 'element label' } );
+						}
+					} ) )
+					.add( downcastElementToElement( {
+						model: 'nested',
+						view: () => new ViewEditable( 'figcaption', { contenteditable: true } )
+					} ) )
+					.add( downcastElementToElement( {
+						model: 'editable',
+						view: () => new ViewEditable( 'figcaption', { contenteditable: true } )
+					} ) );
 			} );
 	} );