editorui.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 IconManager from '../iconmanager/iconmanager.js';
  11. import IconManagerView from '../iconmanager/iconmanagerview.js';
  12. import iconManagerModel from '../../../theme/iconmanagermodel.js';
  13. import mix from '../../utils/mix.js';
  14. /**
  15. * Base class for the editor main view controllers.
  16. *
  17. * @memberOf ui.editorUI
  18. * @extends ui.Controller
  19. * @mixes utils.ObservaleMixin
  20. */
  21. export default class EditorUI extends Controller {
  22. /**
  23. * Creates an EditorUI instance.
  24. *
  25. * @param {ckeditor5.Editor} editor
  26. */
  27. constructor( editor ) {
  28. super();
  29. /**
  30. * @readonly
  31. * @member {ckeditor5.Editor} ui.editorUI.EditorUI#editor
  32. */
  33. this.editor = editor;
  34. /**
  35. * @readonly
  36. * @member {ui.ComponentFactory} ui.editorUI.EditorUI#featureComponents
  37. */
  38. this.featureComponents = new ComponentFactory( editor );
  39. this.collections.add( new ControllerCollection( 'body' ) );
  40. }
  41. /**
  42. * Initializes EditorUI instance.
  43. *
  44. * @returns {Promise}
  45. */
  46. init() {
  47. this._setupIconManager();
  48. return super.init();
  49. }
  50. /**
  51. * Adds IconManager into DOM.
  52. *
  53. * @protected
  54. */
  55. _setupIconManager() {
  56. /**
  57. * Icons available in the UI.
  58. *
  59. * @readonly
  60. * @member {Array} ui.editorUI.EditorUI#icons
  61. */
  62. this.icons = iconManagerModel.icons;
  63. this.collections.get( 'body' ).add(
  64. new IconManager( iconManagerModel, new IconManagerView() )
  65. );
  66. }
  67. }
  68. mix( EditorUI, ObservableMixin );