8
0

blockquoteui.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module block-quote/blockquoteui
  7. */
  8. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  9. import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
  10. import quoteIcon from '@ckeditor/ckeditor5-core/theme/icons/quote.svg';
  11. import '../theme/blockquote.css';
  12. /**
  13. * The block quote UI plugin.
  14. *
  15. * It introduces the `'blockQuote'` button.
  16. *
  17. * @extends module:core/plugin~Plugin
  18. */
  19. export default class BlockQuoteUI extends Plugin {
  20. /**
  21. * @inheritDoc
  22. */
  23. init() {
  24. const editor = this.editor;
  25. const t = editor.t;
  26. editor.ui.componentFactory.add( 'blockQuote', locale => {
  27. const command = editor.commands.get( 'blockQuote' );
  28. const buttonView = new ButtonView( locale );
  29. buttonView.set( {
  30. label: t( 'Block quote' ),
  31. icon: quoteIcon,
  32. tooltip: true
  33. } );
  34. // Bind button model to command.
  35. buttonView.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
  36. // Execute command.
  37. this.listenTo( buttonView, 'execute', () => editor.execute( 'blockQuote' ) );
  38. return buttonView;
  39. } );
  40. }
  41. }