Szymon Kupś 9 anni fa
parent
commit
fab350e81d

+ 9 - 9
packages/ckeditor5-image/src/imageengine.js

@@ -30,28 +30,28 @@ export default class ImageEngine extends Plugin {
 	 */
 	init() {
 		const editor = this.editor;
-		const document = editor.document;
-		const dataPipeline = editor.data;
-		const editingPipeline = editor.editing;
+		const doc = editor.document;
+		const data = editor.data;
+		const editing = editor.editing;
 
 		// Configure schema.
-		document.schema.registerItem( 'image', '$block' );
-		document.schema.allow( { name: 'image', attributes: [ 'src', 'alt' ] } );
+		doc.schema.registerItem( 'image', '$block' );
+		doc.schema.allow( { name: 'image', attributes: [ 'src', 'alt' ] } );
 
 		// Build converter from model to view for data pipeline.
-		buildModelConverter().for( dataPipeline.modelToView )
+		buildModelConverter().for( data.modelToView )
 			.fromElement( 'image' )
 			.toElement( ( data ) => modelToViewImage( data.item ) );
 
 		// Build converter from model to view for editing pipeline.
-		buildModelConverter().for( editingPipeline.modelToView )
+		buildModelConverter().for( editing.modelToView )
 			.fromElement( 'image' )
 			.toElement( ( data ) => toImageWidget( modelToViewImage( data.item ) ) );
 
 		// Converter for figure element from view to model.
-		dataPipeline.viewToModel.on( 'element:figure', viewToModelImage() );
+		data.viewToModel.on( 'element:figure', viewToModelImage() );
 
 		// Creates fake selection label if selection is placed around image widget.
-		editingPipeline.modelToView.on( 'selection', modelToViewSelection( editor.t ), { priority: 'lowest' } );
+		editing.modelToView.on( 'selection', modelToViewSelection( editor.t ), { priority: 'lowest' } );
 	}
 }

+ 8 - 1
packages/ckeditor5-image/src/widget/utils.js

@@ -42,9 +42,16 @@ export function isWidget( element ) {
  */
 export function widgetize( element ) {
 	element.setAttribute( 'contenteditable', false );
-	element.getFillerOffset = () => null;
+	element.getFillerOffset = getFillerOffset;
 	element.addClass( WIDGET_CLASS_NAME );
 	element.setCustomProperty( widgetSymbol, true );
 
 	return element;
 }
+
+// Default filler offset function applied to all widget elements.
+//
+// @returns {null}
+function getFillerOffset() {
+	return null;
+}

+ 3 - 3
packages/ckeditor5-image/src/widget/widget.js

@@ -64,12 +64,12 @@ export default class Widget extends Plugin {
 		}
 
 		// Create model selection over widget.
-		const document = editor.document;
+		const modelDocument = editor.document;
 		const modelElement = editor.editing.mapper.toModelElement( widgetElement );
 		const modelRange = ModelRange.createOn( modelElement );
 
-		document.enqueueChanges( ( ) => {
-			document.selection.setRanges( [ modelRange ] );
+		modelDocument.enqueueChanges( ( ) => {
+			modelDocument.selection.setRanges( [ modelRange ] );
 		} );
 	}
 }