editorui.js 2.0 KB

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