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

Commit

Permalink
Merge branch t/ckeditor5-upload/22
Browse files Browse the repository at this point in the history
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
  • Loading branch information
Reinmar committed Feb 2, 2018
2 parents 2fdf565 + 5a3a953 commit 761b8af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/uploadadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ export default class CKFinderUploadAdapter extends Plugin {
}

// Register CKFinderAdapter
this.editor.plugins.get( FileRepository ).createAdapter = loader => new Adapter( loader, url, this.editor.t );
this.editor.plugins.get( FileRepository ).createUploadAdapter = loader => new UploadAdapter( loader, url, this.editor.t );
}
}

/**
* Upload adapter for CKFinder.
*
* @private
* @implements module:upload/filerepository~Adapter
* @implements module:upload/filerepository~UploadAdapter
*/
class Adapter {
class UploadAdapter {
/**
* Creates a new adapter instance.
*
Expand Down Expand Up @@ -91,7 +91,7 @@ class Adapter {
/**
* Starts the upload process.
*
* @see module:upload/filerepository~Adapter#upload
* @see module:upload/filerepository~UploadAdapter#upload
* @returns {Promise}
*/
upload() {
Expand All @@ -105,7 +105,7 @@ class Adapter {
/**
* Aborts the upload process.
*
* @see module:upload/filerepository~Adapter#abort
* @see module:upload/filerepository~UploadAdapter#abort
* @returns {Promise}
*/
abort() {
Expand Down
4 changes: 2 additions & 2 deletions tests/manual/uploadadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle';
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
import List from '@ckeditor/ckeditor5-list/src/list';
import ImageUpload from '@ckeditor/ckeditor5-upload/src/imageupload';
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload';
import CKFinderUploadAdapter from '../../src/uploadadapter';

ClassicEditor
Expand All @@ -28,7 +28,7 @@ ClassicEditor
Enter, Typing, Paragraph, Heading, Undo, Bold, Italic, Heading, List, Image, ImageToolbar, Clipboard,
ImageCaption, ImageStyle, ImageUpload, CKFinderUploadAdapter
],
toolbar: [ 'headings', 'undo', 'redo', 'bold', 'italic', 'bulletedList', 'numberedList', 'insertImage' ],
toolbar: [ 'headings', 'undo', 'redo', 'bold', 'italic', 'bulletedList', 'numberedList', 'uploadImage' ],
ckfinder: {
// eslint-disable-next-line max-len
uploadUrl: 'https://cksource.com/weuy2g4ryt278ywiue/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json'
Expand Down
10 changes: 5 additions & 5 deletions tests/uploadadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* globals document */
import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
import Image from '@ckeditor/ckeditor5-image/src/image';
import ImageUpload from '@ckeditor/ckeditor5-upload/src/imageupload';
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload';
import CKFinderUploadAdapter from '../src/uploadadapter';
import FileRepository from '@ckeditor/ckeditor5-upload/src/filerepository';
import { createNativeFileMock } from '@ckeditor/ckeditor5-upload/tests/_utils/mocks';
Expand Down Expand Up @@ -42,15 +42,15 @@ describe( 'CKFinderUploadAdapter', () => {
expect( editor.plugins.get( CKFinderUploadAdapter ) ).to.be.instanceOf( CKFinderUploadAdapter );
} );

describe( 'Adapter', () => {
describe( 'UploadAdapter', () => {
let adapter, loaderMock;

beforeEach( () => {
const file = createNativeFileMock();
file.name = 'image.jpeg';
loaderMock = { file };

adapter = editor.plugins.get( FileRepository ).createAdapter( loaderMock );
adapter = editor.plugins.get( FileRepository ).createUploadAdapter( loaderMock );
} );

it( 'crateAdapter method should be registered and have upload and abort methods', () => {
Expand All @@ -59,7 +59,7 @@ describe( 'CKFinderUploadAdapter', () => {
expect( adapter.abort ).to.be.a( 'function' );
} );

it( 'should not set the FileRepository.createAdapter factory if not configured', () => {
it( 'should not set the FileRepository.createUploadAdapter factory if not configured', () => {
const editorElement = document.createElement( 'div' );
document.body.appendChild( editorElement );

Expand All @@ -70,7 +70,7 @@ describe( 'CKFinderUploadAdapter', () => {
.then( editor => {
const fileRepository = editor.plugins.get( FileRepository );

expect( fileRepository ).to.not.have.property( 'createAdapter' );
expect( fileRepository ).to.not.have.property( 'createUploadAdapter' );

editorElement.remove();

Expand Down

0 comments on commit 761b8af

Please sign in to comment.