Skip to content

Commit

Permalink
Merge pull request #1507 from ckeditor/t/1365
Browse files Browse the repository at this point in the history
Make XHR defualt option to upload a file
  • Loading branch information
mlewand authored Feb 1, 2018
2 parents 806636a + bcc9235 commit c7f4658
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
New Features:

* [#1338](https://github.com/ckeditor/ckeditor-dev/issues/1338): Keystroke labels are displayed for function keys (like F7, F8).
* [#933](https://github.com/ckeditor/ckeditor-dev/issues/933): [File Browser](https://ckeditor.com/cke4/addon/filetools) plugin can now upload files using XHR requests. This allows for setting custom HTTP headers using [`config.fileTools_requestHeaders`](http://docs.ckeditor.test/#!/api/CKEDITOR.config-cfg-fileTools_requestHeaders) configuration option.
* [#933](https://github.com/ckeditor/ckeditor-dev/issues/933): [File Browser](https://ckeditor.com/cke4/addon/filebrowser) plugin can now upload files using XHR requests. This allows for setting custom HTTP headers using [`config.fileTools_requestHeaders`](http://docs.ckeditor.test/#!/api/CKEDITOR.config-cfg-fileTools_requestHeaders) configuration option.
* [#1365](https://github.com/ckeditor/ckeditor-dev/issues/1365): [File Browser](https://ckeditor.com/cke4/addon/filebrowser) plugin uses XHR requests by default.
* [#1399](https://github.com/ckeditor/ckeditor-dev/issues/1399): Added possibility to set [`CKEDITOR.config.startupFocus`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-startupFocus) as `start` or `end` to specify where editor focus should be after initialization.
* [#1441](https://github.com/ckeditor/ckeditor-dev/issues/1441): [Magic Line](https://ckeditor.com/cke4/addon/magicline) line element can now be identified by `data-cke-magic-line="1"` attribute.

Expand Down
14 changes: 6 additions & 8 deletions plugins/filebrowser/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@

if ( uploadFile.call( sender, evt ) ) {
// Use one of two upload strategies, either form or XHR based (#643).
if ( editor.config.filebrowserUploadMethod !== 'xhr' || !isFileUploadApiSupported ) {
if ( editor.config.filebrowserUploadMethod === 'form' || !isFileUploadApiSupported ) {
// Append token preventing CSRF attacks.
appendToken( fileInput );
return true;
Expand Down Expand Up @@ -604,21 +604,19 @@
*
* Available values:
*
* * `'xhr'` - XMLHttpRequest is used to upload file. Using this option allows to set up with Additional XHR headers with
* * `'xhr'` - XMLHttpRequest is used to upload file. Using this option allows to set up with additional XHR headers with
* {@link CKEDITOR.config#fileTools_requestHeaders} option.
* * `'form'` - (default) File is uploaded by submitting a traditional `<form>` element.
* * `null` - The default method is used.
* * `'form'` - File is uploaded by submitting a traditional `<form>` element. _Note: That was the only option available until CKEditor 4.9.0._
*
* Note: please be aware that `'xhr'` requires the [File Tools](https://ckeditor.com/cke4/addon/filetools) plugin to work
* properly. Without the plugin or using a browser that does not support
* {@link CKEDITOR.fileTools#isFileUploadSupported file uploading}, will fallback to the `'form'` method despite configuration
* option.
*
* // Modern browsers will use XMLHttpRequest to upload files.
* // IE8 and IE9 will use form submit even though the config option is set to 'xhr'.
* config.filebrowserUploadMethod = 'xhr';
* // All browsers will use form element with submit method to upload a file.
* config.filebrowserUploadMethod = 'form';
*
* @since 4.9.0
* @cfg {String/null} [filebrowserUploadMethod=null]
* @cfg {String} [filebrowserUploadMethod='xhr']
* @member CKEDITOR.config
*/

0 comments on commit c7f4658

Please sign in to comment.