Browse Source

Merge branch 'master' into t/6

Maciej Gołaszewski 7 years ago
parent
commit
a9e90d1faf

+ 8 - 0
packages/ckeditor5-ckfinder/src/ckfindercommand.js

@@ -64,6 +64,9 @@ export default class CKFinderCommand extends Command {
 
 		options.chooseFiles = true;
 
+		// Cache the user-defined onInit method
+		const originalOnInit = options.onInit;
+
 		// Pass the lang code to the CKFinder if not defined by user.
 		if ( !options.language ) {
 			options.language = editor.locale.language;
@@ -71,6 +74,11 @@ export default class CKFinderCommand extends Command {
 
 		// The onInit method allows to extend CKFinder's behavior. It is used to attach event listeners to file choosing related events.
 		options.onInit = finder => {
+			// Call original options.onInit if it was defined by user.
+			if ( originalOnInit ) {
+				originalOnInit();
+			}
+
 			finder.on( 'files:choose', evt => {
 				const files = evt.data.files.toArray();
 

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

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

+ 8 - 0
packages/ckeditor5-ckfinder/tests/manual/ckfinder.html

@@ -1,5 +1,13 @@
 <script src="https://ckeditor.com/docs/ckfinder/demo/ckfinder3/ckfinder.js"></script>
 
+<style>
+	/* Override CKFinder's modal z-index (8999) which is lower manual test description z-index (9000).
+	 */
+	#ckf-modal {
+		z-index: 10000 !important;
+	}
+</style>
+
 <div id="editor">
 	<h2>CKFinder sample</h2>
 	<p>Use the toolbar icon to insert an image or link to a file to the content.</p>