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

t/97: Implemented the responsive image support in the SimpleUploadAdapter. #98

Merged
merged 1 commit into from
Aug 1, 2019

Conversation

oleq
Copy link
Member

@oleq oleq commented Aug 1, 2019

Suggested merge commit message (convention)

Feature: Implemented the responsive image support in the SimpleUploadAdapter. Closes ckeditor/ckeditor5#2840.

@oleq oleq requested a review from jodator August 1, 2019 12:36
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 4e2f287 on t/97 into 83d552f on master.

@oleq
Copy link
Member Author

oleq commented Aug 1, 2019

Express server to test with

const express = require( 'express' );
const cors = require( 'cors' )
const app = express();

app.use( cors() );

app.listen( 3000, () => {
	console.log( 'Server running on http://localhost:3000' );
} );

app.post( '/upload', ( req, res, next ) => {
	res.json( {
		urls: {
			default: 'https://ckeditor.com/assets/images/home/home-product-screenshot-cke5-a0798e948f.png',
			'800': 'https://ckeditor.com/assets/images/composition/ckeditor-5/perfect-ui@2x-0a9ba53b0f.png',
			'1024': 'https://ckeditor.com/assets/images/composition/ckeditor-5/multiple-purposes-0307420f72.png'
		}
	} );
} );

And the existing manual test to use the adapter:

diff --git a/tests/manual/imageupload.html b/tests/manual/imageupload.html
index 5d12738..bb44fe8 100644
--- a/tests/manual/imageupload.html
+++ b/tests/manual/imageupload.html
@@ -1,3 +1,6 @@
+<head>
+         <meta http-equiv="Content-Security-Policy" content="default-src 'none'; connect-src *; script-src *; img-src * data:; style-src * 'unsafe-inline'; frame-src *">
+</head>
 <div id="editor">
          <h2>Image upload</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla finibus consequat placerat. Vestibulum id tellus et mauris sagittis tincidunt quis id mauris. Curabitur consectetur lectus sit amet tellus mattis, non lobortis leo interdum.</p>
diff --git a/tests/manual/imageupload.js b/tests/manual/imageupload.js
index 2951f4c..7328747 100644
--- a/tests/manual/imageupload.js
+++ b/tests/manual/imageupload.js
@@ -21,6 +21,7 @@ import ImageToolbar from '../../src/imagetoolbar';
 import Image from '../../src/image';
 import ImageCaption from '../../src/imagecaption';
 import ImageUpload from '../../src/imageupload';
+import SimpleUploadAdapter from '@ckeditor/ckeditor5-upload/src/adapters/simpleuploadadapter';

 const buttonContainer = document.getElementById( 'button-container' );

@@ -28,23 +29,19 @@ ClassicEditor
          .create( document.querySelector( '#editor' ), {
                   plugins: [
                            Enter, Typing, Paragraph, Heading, Undo, Bold, Italic, Heading, List, Image, ImageToolbar, Clipboard,
-                           ImageCaption, ImageStyle, ImageUpload
+                           ImageCaption, ImageStyle, ImageUpload,
+                           SimpleUploadAdapter
                   ],
                   toolbar: [ 'heading', '|', 'undo', 'redo', 'bold', 'italic', 'bulletedList', 'numberedList', 'imageUpload' ],
                   image: {
                            toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
+                  },
+                  simpleUpload: {
+                           uploadUrl: 'http://localhost:3000/upload'
                   }
          } )
          .then( editor => {
                   window.editor = editor;
-
-                  // Register fake adapter.
-                  editor.plugins.get( 'FileRepository' ).createUploadAdapter = loader => {
-                           const adapterMock = new UploadAdapterMock( loader );
-                           createProgressButton( loader, adapterMock );
-
-                           return adapterMock;
-                  };
          } )
          .catch( err => {
                   console.error( err.stack );

Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM I was wondering if we should add a manual test for this as we have similar for mentions but I think that we can live without it for now.

@jodator jodator merged commit b5092a4 into master Aug 1, 2019
@jodator jodator deleted the t/97 branch August 1, 2019 15:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SimpleUploadAdapter] Consider responsive images in server response
3 participants