8
0

editorconfig.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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' ], ( CKE, Config ) => {
  16. class EditorConfig extends Config {
  17. /**
  18. * @inheritdoc Config#get
  19. */
  20. get() {
  21. // Try to take it from this editor instance.
  22. let value = super.get.apply( this, arguments );
  23. // If the configuration is not defined in the instance, try to take it from CKEDITOR.config.
  24. if ( typeof value == 'undefined' ) {
  25. // There is a circular dependency issue here: CKEDITOR -> Editor -> EditorConfig -> CKEDITOR.
  26. // Therefore we need to require() it again here. That's why the parameter was named CKE.
  27. //
  28. // Note additionally that we still keep 'ckeditor' in the dependency list for correctness, to ensure
  29. // that the module is loaded.
  30. CKE = CKE || CKEDITOR.require( 'ckeditor' );
  31. value = super.get.apply( CKE.config, arguments );
  32. }
  33. return value;
  34. }
  35. }
  36. return EditorConfig;
  37. } );