editorconfig.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. /**
  7. * Handles a configuration dictionary for an editor instance.
  8. *
  9. * The basic difference between {@link EditorConfig} and {@link Config} is that {@link EditorConfig#get} retrieves
  10. * configurations from {@link CKEDITOR#config} if they are not found.
  11. *
  12. * @class EditorConfig
  13. * @extends Config
  14. */
  15. CKEDITOR.define( [ 'ckeditor', 'config' ], function( CKE, Config ) {
  16. var EditorConfig = Config.extend( {
  17. /**
  18. * Creates an instance of the {@link EditorConfig} class.
  19. *
  20. * @param {Object} [configurations] The initial configurations to be set.
  21. * @constructor
  22. */
  23. constructor: function EditorConfig() {
  24. // Call super-constructor.
  25. Config.apply( this, arguments );
  26. },
  27. /**
  28. * @inheritdoc Config#get
  29. */
  30. get: function() {
  31. // Try to take it from this editor instance.
  32. var value = Config.prototype.get.apply( this, arguments );
  33. // If the configuration is not defined in the instance, try to take it from CKEDITOR.config.
  34. if ( typeof value == 'undefined' ) {
  35. // There is a circular dependency issue here: CKEDITOR -> Editor -> EditorConfig -> CKEDITOR.
  36. // Therefore we need to require() it again here. That's why the parameter was named CKE.
  37. //
  38. // Note additionally that we still keep 'ckeditor' in the dependency list for correctness, to ensure
  39. // that the module is loaded.
  40. CKE = CKE || CKEDITOR.require( 'ckeditor' );
  41. value = CKE.config.get.apply( CKE.config, arguments );
  42. }
  43. return value;
  44. }
  45. } );
  46. return EditorConfig;
  47. } );