Przeglądaj źródła

Merge pull request #160 from ckeditor/t/157

Removed global CKEDITOR.config.
Piotrek Koszuliński 9 lat temu
rodzic
commit
fd0d3de93f
6 zmienionych plików z 4 dodań i 109 usunięć
  1. 0 10
      ckeditor.js
  2. 2 6
      src/editor.js
  3. 0 35
      src/editorconfig.js
  4. 0 7
      tests/ckeditor.js
  5. 2 10
      tests/editor/editor.js
  6. 0 41
      tests/editorconfig.js

+ 0 - 10
ckeditor.js

@@ -7,7 +7,6 @@
 
 import Editor from './ckeditor5/editor.js';
 import Collection from './ckeditor5/utils/collection.js';
-import Config from './ckeditor5/utils/config.js';
 import CKEditorError from './ckeditor5/utils/ckeditorerror.js';
 import isArrayLike from './ckeditor5/utils/lib/lodash/isArrayLike.js';
 import clone from './ckeditor5/utils/lib/lodash/clone.js';
@@ -27,15 +26,6 @@ const CKEDITOR = {
 	 */
 	instances: new Collection(),
 
-	/**
-	 * Holds global configuration defaults, which will be used by editor instances when such configurations are not
-	 * available on them directly.
-	 *
-	 * @readonly
-	 * @member {utils.Config} CKEDITOR.config
-	 */
-	config: new Config(),
-
 	/**
 	 * Creates an editor instance for the provided DOM element.
 	 *

+ 2 - 6
src/editor.js

@@ -6,7 +6,7 @@
 'use strict';
 
 import ObservableMixin from './utils/observablemixin.js';
-import EditorConfig from './editorconfig.js';
+import Config from './utils/config.js';
 import PluginCollection from './plugincollection.js';
 import EditableCollection from './editablecollection.js';
 import CKEditorError from './utils/ckeditorerror.js';
@@ -52,14 +52,10 @@ export default class Editor {
 		/**
 		 * Holds all configurations specific to this editor instance.
 		 *
-		 * This instance of the {@link utils.Config} class is customized so its {@link utils.Config#get} method will retrieve
-		 * global configurations available in {@link CKEDITOR.config} if configurations are not found in the
-		 * instance itself.
-		 *
 		 * @readonly
 		 * @member {utils.Config} ckeditor5.Editor#config
 		 */
-		this.config = config = new EditorConfig( config );
+		this.config = config = new Config( config );
 
 		/**
 		 * The plugins loaded and in use by this editor instance.

+ 0 - 35
src/editorconfig.js

@@ -1,35 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import CKEDITOR from '../ckeditor.js';
-import Config from './utils/config.js';
-
-/**
- * Handles a configuration dictionary for an editor instance.
- *
- * The basic difference between {@link ckeditor5.EditorConfig} and {@link utils.Config} is that {@link ckeditor5.EditorConfig#get} retrieves
- * configurations from {@link CKEDITOR#config} if they are not found.
- *
- * @memberOf ckeditor5
- * @extends utils.Config
- */
-export default class EditorConfig extends Config {
-	/**
-	 * @inheritDoc
-	 */
-	get() {
-		// Try to take it from this editor instance.
-		let value = super.get.apply( this, arguments );
-
-		// If the configuration is not defined in the instance, try to take it from CKEDITOR.config.
-		if ( typeof value == 'undefined' ) {
-			value = super.get.apply( CKEDITOR.config, arguments );
-		}
-
-		return value;
-	}
-}

+ 0 - 7
tests/ckeditor.js

@@ -9,7 +9,6 @@ import testUtils from '/tests/ckeditor5/_utils/utils.js';
 
 import CKEDITOR from '/ckeditor.js';
 import Editor from '/ckeditor5/editor.js';
-import Config from '/ckeditor5/utils/config.js';
 import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
 
 const content = document.getElementById( 'content' );
@@ -212,9 +211,3 @@ describe( 'create', () => {
 		}
 	} );
 } );
-
-describe( 'config', () => {
-	it( 'should be an instance of Config', () => {
-		expect( CKEDITOR.config ).to.be.an.instanceof( Config );
-	} );
-} );

+ 2 - 10
tests/editor/editor.js

@@ -10,7 +10,7 @@
 import moduleUtils from '/tests/ckeditor5/_utils/module.js';
 import testUtils from '/tests/ckeditor5/_utils/utils.js';
 import Editor from '/ckeditor5/editor.js';
-import EditorConfig from '/ckeditor5/editorconfig.js';
+import Config from '/ckeditor5/utils/config.js';
 import PluginCollection from '/ckeditor5/plugincollection.js';
 import EditableCollection from '/ckeditor5/editablecollection.js';
 import Plugin from '/ckeditor5/plugin.js';
@@ -41,7 +41,7 @@ describe( 'Editor', () => {
 			const editor = new Editor();
 
 			expect( editor ).to.have.property( 'elements', null );
-			expect( editor.config ).to.be.an.instanceof( EditorConfig );
+			expect( editor.config ).to.be.an.instanceof( Config );
 			expect( editor.editables ).to.be.an.instanceof( EditableCollection );
 			expect( editor.commands ).to.be.an.instanceof( Map );
 
@@ -50,14 +50,6 @@ describe( 'Editor', () => {
 		} );
 	} );
 
-	describe( 'config', () => {
-		it( 'should be an instance of EditorConfig', () => {
-			const editor = new Editor();
-
-			expect( editor.config ).to.be.an.instanceof( EditorConfig );
-		} );
-	} );
-
 	describe( 'locale', () => {
 		it( 'is instantiated and t() is exposed', () => {
 			const editor = new Editor();

+ 0 - 41
tests/editorconfig.js

@@ -1,41 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import EditorConfig from '/ckeditor5/editorconfig.js';
-import CKEDITOR from '/ckeditor.js';
-
-let config;
-
-beforeEach( () => {
-	config = new EditorConfig( {
-		test: 1
-	} );
-} );
-
-describe( 'constructor', () => {
-	it( 'should set configurations', () => {
-		expect( config ).to.have.property( 'test' ).to.equal( 1 );
-	} );
-} );
-
-describe( 'get', () => {
-	it( 'should retrieve a configuration', () => {
-		expect( config.get( 'test' ) ).to.equal( 1 );
-	} );
-
-	it( 'should fallback to CKEDITOR.config', () => {
-		CKEDITOR.config.set( {
-			globalConfig: 2
-		} );
-
-		expect( config.get( 'globalConfig' ) ).to.equal( 2 );
-	} );
-
-	it( 'should return undefined for non existing configuration', () => {
-		expect( config.get( 'invalid' ) ).to.be.undefined();
-	} );
-} );