diff --git a/CHANGES.md b/CHANGES.md index 767a7ff8e71..4749ea5a9c1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,10 @@ CKEditor 4 Changelog ## CKEditor 4.5.1 +Fixed Issues: + +* [#13486](http://dev.ckeditor.com/ticket/13486): Fixed: Upload image should log an error, not throw an error when upload URL is not set. + ## CKEditor 4.5 New Features: diff --git a/plugins/filetools/plugin.js b/plugins/filetools/plugin.js index 94b324a7930..c967e0243d9 100644 --- a/plugins/filetools/plugin.js +++ b/plugins/filetools/plugin.js @@ -718,7 +718,7 @@ * * @param {Object} config The configuration file. * @param {String} [type] Upload file type. - * @returns {String} Upload URL. + * @returns {String/null} Upload URL or `null` if none of the config options was defined. */ getUploadUrl: function( config, type ) { var capitalize = CKEDITOR.tools.capitalize; @@ -733,7 +733,7 @@ return config.filebrowserUploadUrl + '&responseType=json'; } - throw 'Upload URL is not defined.'; + return null; }, /** diff --git a/plugins/uploadimage/plugin.js b/plugins/uploadimage/plugin.js index 7421ce07065..fdf27c91f08 100644 --- a/plugins/uploadimage/plugin.js +++ b/plugins/uploadimage/plugin.js @@ -26,6 +26,14 @@ var fileTools = CKEDITOR.fileTools, uploadUrl = fileTools.getUploadUrl( editor.config, 'image' ); + if ( !uploadUrl ) { + window.console && window.console.log( + 'Error: Upload URL for the Upload Image feature was not defined. ' + + 'For more information visit: http://docs.ckeditor.com/#!/guide/dev_file_upload' + ); + return; + } + // Handle images which are available in the dataTransfer. fileTools.addUploadWidget( editor, 'uploadimage', { supportedTypes: /image\/(jpeg|png|gif)/, diff --git a/tests/plugins/filetools/filetools.js b/tests/plugins/filetools/filetools.js index a589e9c6a3c..698ba8f1d9b 100644 --- a/tests/plugins/filetools/filetools.js +++ b/tests/plugins/filetools/filetools.js @@ -94,12 +94,9 @@ }, 'test getUploadUrl - throw error if no matching config': function() { - try { - getUploadUrl( {} ); - assert.fail( 'getUploadUrl should throw error if no matching configuration option was found.' ); - } catch ( err ) { - assert.areSame( 'Upload URL is not defined.', err ); - } + var uploadUrl = getUploadUrl( {} ); + + assert.isNull( uploadUrl, 'null returned when none of upload URLs is defined' ); }, 'test isTypeSupported 1': function() { diff --git a/tests/plugins/uploadimage/manual/configerror.html b/tests/plugins/uploadimage/manual/configerror.html new file mode 100644 index 00000000000..c4f395cca73 --- /dev/null +++ b/tests/plugins/uploadimage/manual/configerror.html @@ -0,0 +1,7 @@ +
+

I'm working!

+
+ + \ No newline at end of file diff --git a/tests/plugins/uploadimage/manual/configerror.md b/tests/plugins/uploadimage/manual/configerror.md new file mode 100644 index 00000000000..c4daf54c113 --- /dev/null +++ b/tests/plugins/uploadimage/manual/configerror.md @@ -0,0 +1,10 @@ +@bender-ui: collapsed +@bender-tags: 4.5.1, tc, 13486, filetools +@bender-ckeditor-plugins: uploadimage, wysiwygarea, toolbar, basicstyles + +Run this test with the console opened. + +Expected: + +* Editor should be fully functional except the `uploadimage` plugin. +* No errors on IE8-9, an error logged in the console that `upload URL` was not set on other browsers. \ No newline at end of file