Explorar o código

Pass CKFinder instance to a user-defined onInit() function.

Maciej Gołaszewski %!s(int64=6) %!d(string=hai) anos
pai
achega
b6064dd2b0

+ 1 - 1
packages/ckeditor5-ckfinder/src/ckfindercommand.js

@@ -73,7 +73,7 @@ export default class CKFinderCommand extends Command {
 		options.onInit = finder => {
 			// Call original options.onInit if it was defined by user.
 			if ( originalOnInit ) {
-				originalOnInit();
+				originalOnInit( finder );
 			}
 
 			finder.on( 'files:choose', evt => {

+ 10 - 0
packages/ckeditor5-ckfinder/tests/ckfindercommand.js

@@ -204,6 +204,16 @@ describe( 'CKFinderCommand', () => {
 			sinon.assert.calledOnce( spy );
 		} );
 
+		it( 'should pass CKFinder instance to a user defined config.onInit() function', () => {
+			const spy = sinon.spy();
+
+			editor.config.set( 'ckfinder.options.onInit', spy );
+
+			command.execute();
+
+			sinon.assert.calledWithExactly( spy, finderMock );
+		} );
+
 		it( 'should pass editor default language to the CKFinder instance', () => {
 			const spy = sinon.spy( window.CKFinder, 'modal' );
 			command.execute();