8
0

italic.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 Feature from '../feature.js';
  7. import ItalicEngine from './italicengine.js';
  8. import ButtonController from '../ui/button/button.js';
  9. import ButtonView from '../ui/button/buttonview.js';
  10. import Model from '../ui/model.js';
  11. export default class Italic extends Feature {
  12. static get requires() {
  13. return [ ItalicEngine ];
  14. }
  15. init() {
  16. const editor = this.editor;
  17. const t = editor.t;
  18. const ui = editor.ui;
  19. const command = editor.commands.get( 'italic' );
  20. // Create button model.
  21. const buttonModel = new Model( {
  22. isEnabled: true,
  23. isOn: false,
  24. label: t( 'Italic' ),
  25. icon: 'italic',
  26. iconAlign: 'LEFT'
  27. } );
  28. // Bind button model to command.
  29. buttonModel.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
  30. // Execute command.
  31. this.listenTo( buttonModel, 'execute', () => editor.execute( 'italic' ) );
  32. // Add bold button to feature components.
  33. ui.featureComponents.add( 'italic', ButtonController, ButtonView, buttonModel );
  34. }
  35. }