|
|
@@ -3,131 +3,88 @@
|
|
|
* For licensing, see LICENSE.md.
|
|
|
*/
|
|
|
|
|
|
-/* global requirejs, define, require */
|
|
|
-
|
|
|
'use strict';
|
|
|
|
|
|
// This file is shared by the dev and release versions of CKEditor. It bootstraps the API.
|
|
|
|
|
|
-( function( root ) {
|
|
|
- const CKEDITOR = root.CKEDITOR = {
|
|
|
- /**
|
|
|
- * Computes the value of the `basePath` property.
|
|
|
- *
|
|
|
- * @private
|
|
|
- * @method
|
|
|
- * @returns {String} A full URL.
|
|
|
- */
|
|
|
- _getBasePath: getBasePath,
|
|
|
-
|
|
|
- /**
|
|
|
- * The list of dependencies of **named** AMD modules created with `CKEDITOR.define`. This is mainly used to
|
|
|
- * trace the dependency tree of plugins.
|
|
|
- */
|
|
|
- _dependencies: {},
|
|
|
-
|
|
|
- /**
|
|
|
- * The full URL for the CKEditor installation directory.
|
|
|
- *
|
|
|
- * It is possible to manually provide the base path by setting a global variable named `CKEDITOR_BASEPATH`. This
|
|
|
- * global variable must be set **before** the editor script loading.
|
|
|
- *
|
|
|
- * console.log( CKEDITOR.basePath ); // e.g. 'http://www.example.com/ckeditor/'
|
|
|
- *
|
|
|
- * @property {String}
|
|
|
- */
|
|
|
- basePath: getBasePath(),
|
|
|
-
|
|
|
- /**
|
|
|
- * Whether the app should work in the "debug mode" (aka "verbose mode").
|
|
|
- *
|
|
|
- * You can use the `CKEDITOR.isDebug` condition in order to wrap code that should be removed in the build version:
|
|
|
- *
|
|
|
- * if ( CKEDITOR.isDebug ) {
|
|
|
- * if ( doSomeSuperUnnecessaryDebugChecks() ) {
|
|
|
- * throw new CKEditorError( 'sth-broke: Kaboom!' );
|
|
|
- * }
|
|
|
- * }
|
|
|
- *
|
|
|
- * See also {@link #isDev}.
|
|
|
- *
|
|
|
- * @property
|
|
|
- */
|
|
|
- isDebug: true,
|
|
|
-
|
|
|
- /**
|
|
|
- * Defines an AMD module.
|
|
|
- *
|
|
|
- * See https://github.com/ckeditor/ckeditor5-design/wiki/AMD for more details about our AMD API.
|
|
|
- *
|
|
|
- * @method
|
|
|
- * @member CKEDITOR
|
|
|
- */
|
|
|
- define( name, deps ) {
|
|
|
- // If this is a named module with dependencies, save this in the dependency list.
|
|
|
- if ( Array.isArray( deps ) && name && !this._dependencies[ name ] ) {
|
|
|
- this._dependencies[ name ] = deps;
|
|
|
- }
|
|
|
-
|
|
|
- return define.apply( this, arguments );
|
|
|
- },
|
|
|
+import CKEDITOR_CORE from './ckeditor5-core/ckeditor.js';
|
|
|
+import utilsObject from './ckeditor5-core/lib/lodash/object.js';
|
|
|
+
|
|
|
+const CKEDITOR = {
|
|
|
+ /**
|
|
|
+ * The full URL for the CKEditor installation directory.
|
|
|
+ *
|
|
|
+ * It is possible to manually provide the base path by setting a global variable named `CKEDITOR_BASEPATH`. This
|
|
|
+ * global variable must be set **before** the editor script loading.
|
|
|
+ *
|
|
|
+ * console.log( CKEDITOR.basePath ); // e.g. 'http://www.example.com/ckeditor/'
|
|
|
+ *
|
|
|
+ * @readonly
|
|
|
+ * @property {String}
|
|
|
+ */
|
|
|
+ basePath: getBasePath(),
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Whether the app should work in the "debug mode" (aka "verbose mode").
|
|
|
+ *
|
|
|
+ * You can use the `CKEDITOR.isDebug` condition in order to wrap code that should be removed in the build version:
|
|
|
+ *
|
|
|
+ * if ( CKEDITOR.isDebug ) {
|
|
|
+ * if ( doSomeSuperUnnecessaryDebugChecks() ) {
|
|
|
+ * throw new CKEditorError( 'sth-broke: Kaboom!' );
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ *
|
|
|
+ * See also {@link #isDev}.
|
|
|
+ *
|
|
|
+ * @readonly
|
|
|
+ */
|
|
|
+ isDebug: true,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * A flag specifying whether CKEditor is running in development mode (original source code).
|
|
|
+ *
|
|
|
+ * This property is not defined in production (compiled, build code).
|
|
|
+ *
|
|
|
+ * See also {@link #isDebug}.
|
|
|
+ *
|
|
|
+ * @readonly
|
|
|
+ */
|
|
|
+ isDev: true,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Computes the value of the `basePath` property.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @method
|
|
|
+ * @returns {String} A full URL.
|
|
|
+ */
|
|
|
+ _getBasePath: getBasePath
|
|
|
+};
|
|
|
+
|
|
|
+utilsObject.extend( CKEDITOR, CKEDITOR_CORE );
|
|
|
+
|
|
|
+function getBasePath() {
|
|
|
+ if ( window.CKEDITOR_BASEPATH ) {
|
|
|
+ return window.CKEDITOR_BASEPATH;
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * Retrieves one or more AMD modules.
|
|
|
- *
|
|
|
- * Note that the CKEditor AMD API does not download modules on demand so be sure to have their relative scripts
|
|
|
- * available in the page.
|
|
|
- *
|
|
|
- * See https://github.com/ckeditor/ckeditor5-design/wiki/AMD for more details about our AMD API.
|
|
|
- *
|
|
|
- * @method
|
|
|
- * @member CKEDITOR
|
|
|
- */
|
|
|
- require: require
|
|
|
- };
|
|
|
+ const scripts = document.getElementsByTagName( 'script' );
|
|
|
+ const basePathSrcPattern = /(^|.*[\\\/])ckeditor\.js(?:\?.*|;.*)?$/i;
|
|
|
+ let path;
|
|
|
|
|
|
- requirejs.config( {
|
|
|
- // Modules are generally relative to the core project.
|
|
|
- baseUrl: CKEDITOR.basePath + 'node_modules/ckeditor5-core/src/',
|
|
|
+ // Find the first script that src matches ckeditor.js.
|
|
|
+ Array.from( scripts ).some( ( script ) => {
|
|
|
+ const match = script.src.match( basePathSrcPattern );
|
|
|
|
|
|
- // These configurations will make no difference in the build version because the following paths will be
|
|
|
- // already defined there.
|
|
|
- paths: {
|
|
|
- // Hide the core "ckeditor" under a different name.
|
|
|
- 'ckeditor-core': CKEDITOR.basePath + 'node_modules/ckeditor5-core/src/ckeditor',
|
|
|
+ if ( match ) {
|
|
|
+ path = match[ 1 ];
|
|
|
|
|
|
- // The dev version overrides for the "ckeditor" module. This is empty on release.
|
|
|
- 'ckeditor-dev': CKEDITOR.basePath + 'src/ckeditor-dev'
|
|
|
+ return true;
|
|
|
}
|
|
|
} );
|
|
|
|
|
|
- // Define a new "ckeditor" module, which overrides the core one with the above and the dev stuff.
|
|
|
- define( 'ckeditor', [ 'ckeditor-core', 'ckeditor-dev', 'utils' ], ( core, dev, utils ) => {
|
|
|
- root.CKEDITOR = utils.extend( {}, core, root.CKEDITOR, ( dev || /* istanbul ignore next */ {} ) );
|
|
|
-
|
|
|
- return root.CKEDITOR;
|
|
|
- } );
|
|
|
-
|
|
|
- function getBasePath() {
|
|
|
- if ( window.CKEDITOR_BASEPATH ) {
|
|
|
- return window.CKEDITOR_BASEPATH;
|
|
|
- }
|
|
|
-
|
|
|
- const scripts = document.getElementsByTagName( 'script' );
|
|
|
- const basePathSrcPattern = /(^|.*[\\\/])ckeditor\.js(?:\?.*|;.*)?$/i;
|
|
|
- let path;
|
|
|
+ return path;
|
|
|
+}
|
|
|
|
|
|
- // Find the first script that src matches ckeditor.js.
|
|
|
- [].some.call( scripts, ( script ) => {
|
|
|
- const match = script.src.match( basePathSrcPattern );
|
|
|
-
|
|
|
- if ( match ) {
|
|
|
- path = match[ 1 ];
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
- } );
|
|
|
-
|
|
|
- return path;
|
|
|
- }
|
|
|
-} )( window );
|
|
|
+export default CKEDITOR;
|