imitatefeatures.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 {core.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. } );
  21. boldModel.on( 'execute', () => {
  22. /* global console */
  23. console.log( 'bold executed' );
  24. boldModel.isOn = !boldModel.isOn;
  25. } );
  26. editor.ui.featureComponents.add( 'bold', Button, ButtonView, boldModel );
  27. const italicModel = new Model( {
  28. isEnabled: true,
  29. isOn: false,
  30. label: t( 'Italic' )
  31. } );
  32. italicModel.on( 'execute', () => {
  33. /* global console */
  34. console.log( 'italic executed' );
  35. italicModel.isOn = !italicModel.isOn;
  36. } );
  37. editor.ui.featureComponents.add( 'italic', Button, ButtonView, italicModel );
  38. window.boldModel = boldModel;
  39. window.italicModel = italicModel;
  40. }
  41. export function imitateDestroyFeatures() {
  42. delete window.boldModel;
  43. delete window.italicModel;
  44. }