8
0

editorui.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import Controller from '../controller.js';
  7. import ControllerCollection from '../controllercollection.js';
  8. import ComponentFactory from '../componentfactory.js';
  9. import ObservableMixin from '../../utils/observablemixin.js';
  10. import IconManagerView from '../iconmanagerview.js';
  11. import iconManagerModel from '../../../theme/iconmanagermodel.js';
  12. import mix from '../../utils/mix.js';
  13. /**
  14. * Base class for the editor main view controllers.
  15. *
  16. * @memberOf ui.editorUI
  17. * @extends ui.Controller
  18. * @mixes utils.ObservaleMixin
  19. */
  20. export default class EditorUI extends Controller {
  21. /**
  22. * Creates an EditorUI instance.
  23. *
  24. * @param {ckeditor5.Editor} editor
  25. */
  26. constructor( editor ) {
  27. super();
  28. /**
  29. * @readonly
  30. * @member {ckeditor5.Editor} ui.editorUI.EditorUI#editor
  31. */
  32. this.editor = editor;
  33. /**
  34. * Property used by the [CKEditor UI library](https://github.com/ckeditor/ckeditor5-ui) for storing
  35. * the main UI controller.
  36. *
  37. * @readonly
  38. * @member {ui.editorui.EditorUI} ckeditor5.Editor#ui
  39. */
  40. editor.ui = this;
  41. /**
  42. * @readonly
  43. * @member {ui.ComponentFactory} ui.editorUI.EditorUI#featureComponents
  44. */
  45. this.featureComponents = new ComponentFactory( editor );
  46. this.collections.add( new ControllerCollection( 'body' ) );
  47. }
  48. /**
  49. * Initializes EditorUI instance.
  50. *
  51. * @returns {Promise}
  52. */
  53. init() {
  54. this._setupIconManager();
  55. return super.init();
  56. }
  57. /**
  58. * Adds IconManager into DOM.
  59. *
  60. * @protected
  61. */
  62. _setupIconManager() {
  63. /**
  64. * Icons available in the UI.
  65. *
  66. * @readonly
  67. * @member {Array} ui.editorUI.EditorUI#icons
  68. */
  69. this.icons = iconManagerModel.icons;
  70. this.collections.get( 'body' ).add(
  71. new Controller( iconManagerModel, new IconManagerView( iconManagerModel ) )
  72. );
  73. }
  74. }
  75. mix( EditorUI, ObservableMixin );