editorconfig.js 1.2 KB

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