imitatefeatures.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Model from '/ckeditor5/ui/model.js';
  7. import Button from '/ckeditor5/ui/button/button.js';
  8. import ButtonView from '/ckeditor5/ui/button/buttonview.js';
  9. /**
  10. * Immitates that some features were loaded and did their job.
  11. *
  12. * @param {ckeditor5.Editor} editor
  13. */
  14. export function imitateFeatures( editor ) {
  15. const t = editor.t;
  16. const boldModel = new Model( {
  17. isEnabled: true,
  18. isOn: false,
  19. label: t( 'Bold' ),
  20. icon: 'bold'
  21. } );
  22. boldModel.on( 'execute', () => {
  23. /* global console */
  24. console.log( 'bold executed' );
  25. boldModel.isOn = !boldModel.isOn;
  26. } );
  27. editor.ui.featureComponents.add( 'bold', Button, ButtonView, boldModel );
  28. const italicModel = new Model( {
  29. isEnabled: true,
  30. isOn: false,
  31. label: t( 'Italic' ),
  32. icon: 'italic'
  33. } );
  34. italicModel.on( 'execute', () => {
  35. /* global console */
  36. console.log( 'italic executed' );
  37. italicModel.isOn = !italicModel.isOn;
  38. } );
  39. editor.ui.featureComponents.add( 'italic', Button, ButtonView, italicModel );
  40. window.boldModel = boldModel;
  41. window.italicModel = italicModel;
  42. }
  43. export function imitateDestroyFeatures() {
  44. delete window.boldModel;
  45. delete window.italicModel;
  46. }