瀏覽代碼

Adjusted the code to API changes in ckeditor5-engine.

Kamil Piechaczek 5 年之前
父節點
當前提交
ce22ba958e

+ 1 - 1
packages/ckeditor5-image/src/imageupload/imageuploadediting.js

@@ -128,7 +128,7 @@ export default class ImageUploadEditing extends Plugin {
 				return;
 			}
 
-			const writer = new UpcastWriter();
+			const writer = new UpcastWriter( editor.editing.view.document );
 
 			for ( const fetchableImage of fetchableImages ) {
 				// Set attribute marking that the image was processed already.

+ 6 - 5
packages/ckeditor5-image/tests/image/utils.js

@@ -15,10 +15,11 @@ import { setData as setModelData, getData as getModelData } from '@ckeditor/cked
 import Image from '../../src/image/imageediting';
 
 describe( 'image widget utils', () => {
-	let element, image, writer;
+	let element, image, writer, viewDocument;
 
 	beforeEach( () => {
-		writer = new ViewDowncastWriter( new ViewDocument() );
+		viewDocument = new ViewDocument();
+		writer = new ViewDowncastWriter( viewDocument );
 		image = writer.createContainerElement( 'img' );
 		element = writer.createContainerElement( 'figure' );
 		writer.insert( writer.createPositionAt( element, 0 ), image );
@@ -62,7 +63,7 @@ describe( 'image widget utils', () => {
 
 		it( 'should return true when image widget is the only element in the selection', () => {
 			// We need to create a container for the element to be able to create a Range on this element.
-			frag = new ViewDocumentFragment( [ element ] );
+			frag = new ViewDocumentFragment( viewDocument, [ element ] );
 
 			const selection = writer.createSelection( element, 'on' );
 
@@ -73,7 +74,7 @@ describe( 'image widget utils', () => {
 			const notWidgetizedElement = writer.createContainerElement( 'p' );
 
 			// We need to create a container for the element to be able to create a Range on this element.
-			frag = new ViewDocumentFragment( [ notWidgetizedElement ] );
+			frag = new ViewDocumentFragment( viewDocument, [ notWidgetizedElement ] );
 
 			const selection = writer.createSelection( notWidgetizedElement, 'on' );
 
@@ -83,7 +84,7 @@ describe( 'image widget utils', () => {
 		it( 'should return false when widget element is not the only element in the selection', () => {
 			const notWidgetizedElement = writer.createContainerElement( 'p' );
 
-			frag = new ViewDocumentFragment( [ element, notWidgetizedElement ] );
+			frag = new ViewDocumentFragment( viewDocument, [ element, notWidgetizedElement ] );
 
 			const selection = writer.createSelection( writer.createRangeIn( frag ) );
 

+ 9 - 10
packages/ckeditor5-image/tests/imagecaption/utils.js

@@ -45,8 +45,7 @@ describe( 'image captioning utils', () => {
 		} );
 
 		it( 'should return false for other elements', () => {
-			const editable = new ViewEditableElement( 'figcaption', { contenteditable: true } );
-			editable._document = document;
+			const editable = new ViewEditableElement( document, 'figcaption', { contenteditable: true } );
 
 			expect( isCaption( editable ) ).to.be.false;
 		} );
@@ -70,34 +69,34 @@ describe( 'image captioning utils', () => {
 
 	describe( 'matchImageCaption', () => {
 		it( 'should return null for element that is not a figcaption', () => {
-			const element = new ViewElement( 'div' );
+			const element = new ViewElement( document, 'div' );
 
 			expect( matchImageCaption( element ) ).to.be.null;
 		} );
 
 		it( 'should return null if figcaption has no parent', () => {
-			const element = new ViewElement( 'figcaption' );
+			const element = new ViewElement( document, 'figcaption' );
 
 			expect( matchImageCaption( element ) ).to.be.null;
 		} );
 
 		it( 'should return null if figcaption\'s parent is not a figure', () => {
-			const element = new ViewElement( 'figcaption' );
-			new ViewElement( 'div', null, element ); // eslint-disable-line no-new
+			const element = new ViewElement( document, 'figcaption' );
+			new ViewElement( document, 'div', null, element ); // eslint-disable-line no-new
 
 			expect( matchImageCaption( element ) ).to.be.null;
 		} );
 
 		it( 'should return null if parent has no image class', () => {
-			const element = new ViewElement( 'figcaption' );
-			new ViewElement( 'figure', null, element ); // eslint-disable-line no-new
+			const element = new ViewElement( document, 'figcaption' );
+			new ViewElement( document, 'figure', null, element ); // eslint-disable-line no-new
 
 			expect( matchImageCaption( element ) ).to.be.null;
 		} );
 
 		it( 'should return object if element is a valid caption', () => {
-			const element = new ViewElement( 'figcaption' );
-			new ViewElement( 'figure', { class: 'image' }, element ); // eslint-disable-line no-new
+			const element = new ViewElement( document, 'figcaption' );
+			new ViewElement( document, 'figure', { class: 'image' }, element ); // eslint-disable-line no-new
 
 			expect( matchImageCaption( element ) ).to.deep.equal( { name: true } );
 		} );