toolbar.js 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 BaseToolbar from '../../../ui/toolbar/toolbar.js';
  7. /**
  8. * The editor toolbar controller class.
  9. *
  10. * @memberOf core.ui.bindings
  11. * @extends ui.toolbar.Toolbar
  12. */
  13. export default class Toolbar extends BaseToolbar {
  14. /**
  15. * Creates a new toolbar instance.
  16. *
  17. * @param {core.ui.Model} model
  18. * @param {core.ui.View} view
  19. * @param {core.Editor} editor
  20. */
  21. constructor( model, view, editor ) {
  22. super( model, view );
  23. this.editor = editor;
  24. }
  25. /**
  26. * Adds buttons to the toolbar. Buttons are taken from the {@link core.editorUI.EditorUI#featureComponents}
  27. * factory.
  28. *
  29. * @param {String[]} buttons The name of the buttons to add to the toolbar.
  30. */
  31. addButtons( buttons ) {
  32. for ( let button of buttons ) {
  33. this.add( 'buttons', this.editor.ui.featureComponents.create( button ) );
  34. }
  35. }
  36. }