Browse Source

CKFinderCommand should clone configuration object when passing them to CKFinder instance.

Maciej Gołaszewski 7 years ago
parent
commit
cd77b9f814

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

@@ -58,7 +58,7 @@ export default class CKFinderCommand extends Command {
 			throw new CKEditorError( 'ckfinder-unknown-openerMethod: The openerMethod config option must by "popup" or "modal".' );
 		}
 
-		const options = this.editor.config.get( 'ckfinder.options' ) || {};
+		const options = Object.assign( {}, this.editor.config.get( 'ckfinder.options' ) );
 
 		options.chooseFiles = true;
 

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

@@ -384,6 +384,14 @@ describe( 'CKFinderCommand', () => {
 			expect( getModelData( model ) ).to.equal( '<other>[]</other>' );
 		} );
 
+		it( 'does not alter the original config', () => {
+			editor.config.set( 'ckfinder', { options: { foo: 'bar' } } );
+
+			command.execute();
+
+			expect( editor.config.get( 'ckfinder.options' ) ).to.deep.equal( { foo: 'bar' } );
+		} );
+
 		function mockFinderFile( url = 'foo/bar.jpg', isImage = true ) {
 			return {
 				isImage: () => isImage,