Skip to content

Commit

Permalink
Merge branch 't/13486'
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Jul 2, 2015
2 parents 89a3e16 + e64912d commit 5b1c6c4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions plugins/filetools/plugin.js
Expand Up @@ -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;
Expand All @@ -733,7 +733,7 @@
return config.filebrowserUploadUrl + '&responseType=json';
}

throw 'Upload URL is not defined.';
return null;
},

/**
Expand Down
8 changes: 8 additions & 0 deletions plugins/uploadimage/plugin.js
Expand Up @@ -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)/,
Expand Down
9 changes: 3 additions & 6 deletions tests/plugins/filetools/filetools.js
Expand Up @@ -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() {
Expand Down
7 changes: 7 additions & 0 deletions tests/plugins/uploadimage/manual/configerror.html
@@ -0,0 +1,7 @@
<div id="editor">
<p>I'm working!</p>
</div>

<script>
CKEDITOR.replace( 'editor' );
</script>
10 changes: 10 additions & 0 deletions 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.

0 comments on commit 5b1c6c4

Please sign in to comment.