-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2988 from ckeditor/t/2962
Introduced Promise support
- Loading branch information
Showing
15 changed files
with
1,353 additions
and
2,126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ The following libraries are included in CKEditor under the MIT license (see Appe | |
* CKSource Samples Framework (included in the samples) - Copyright (c) 2014-2019, CKSource - Frederico Knabben. | ||
* PicoModal (included in `samples/js/sf.js`) - Copyright (c) 2012 James Frasca. | ||
* CodeMirror (included in the samples) - Copyright (C) 2014 by Marijn Haverbeke <[email protected]> and others. | ||
* ES6Promise - Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors. | ||
|
||
Parts of code taken from the following libraries are included in CKEditor under the MIT license (see Appendix D): | ||
|
||
|
@@ -61,7 +62,6 @@ The following libraries are included only in the development version of CKEditor | |
* CKBuilder - Copyright (c) 2012-2019, CKSource - Frederico Knabben. | ||
* CKLangTool - Copyright (c) 2012-2019, CKSource - Frederico Knabben. | ||
* Optimist - Copyright 2010 James Halliday ([email protected]). | ||
* Q - Copyright 2009–2014 Kristopher Michael Kowal. | ||
* Tmp - Copyright (c) 2014 KARASZI István. | ||
* Mkdirp - Copyright 2010 James Halliday ([email protected]). | ||
* Bender.js - Copyright (c) 2014-2019, CKSource - Frederico Knabben. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* global Promise, ES6Promise */ | ||
|
||
( function() { | ||
'use strict'; | ||
|
||
if ( window.Promise ) { | ||
CKEDITOR.tools.promise = Promise; | ||
} else { | ||
var polyfillURL = CKEDITOR.getUrl( 'vendor/promise.js' ); | ||
|
||
CKEDITOR.scriptLoader.load( polyfillURL, function( success ) { | ||
if ( success ) { | ||
CKEDITOR.tools.promise = ES6Promise; | ||
} else { | ||
CKEDITOR.error( 'no-vendor-lib', { | ||
path: polyfillURL | ||
} ); | ||
} | ||
} ); | ||
} | ||
|
||
/** | ||
* Alias for [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) | ||
* object representing asynchronous operation. | ||
* | ||
* Uses native `Promise` browser implementation if available. For older browsers with lack of `Promise` support, the | ||
* [ES6-Promise](https://github.com/stefanpenner/es6-promise) polyfill is used. | ||
* See [Promise Browser Compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Browser_compatibility) | ||
* to learn more. | ||
* | ||
* Refer to [MDN Using Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises) guide for | ||
* more details how to work with promises. | ||
* | ||
* **NOTE:** `catch` and `finally` are reserved keywords in IE < 9 browsers. Use bracket notation instead: | ||
* | ||
* ```javascript | ||
* promise[ 'catch' ]( function( err ) { | ||
* // ... | ||
* } ); | ||
* | ||
* promise[ 'finally' ]( function() { | ||
* // ... | ||
* } ); | ||
* ``` | ||
* | ||
* @since 4.12.0 | ||
* @class CKEDITOR.tools.promise | ||
*/ | ||
|
||
/** | ||
* Creates new `Promise` instance. | ||
* | ||
* ```js | ||
* new CKEDITOR.tools.promise( function( resolve, reject ) { | ||
* setTimeout( function() { | ||
* var timestamp; | ||
* try { | ||
* timestamp = ( new Date() ).getTime(); | ||
* } catch ( e ) { | ||
* reject( e ); | ||
* } | ||
* resolve( timestamp ); | ||
* }, 5000 ); | ||
* } ); | ||
* ``` | ||
* | ||
* @param {Function} resolver | ||
* @param {Function} resolver.resolve | ||
* @param {Function} resolver.reject | ||
* @constructor | ||
*/ | ||
|
||
} )(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.