Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make XHR defualt option to upload a file #1507

Merged
merged 4 commits into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
*/