8
0

creator-classic.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global console:false */
  6. 'use strict';
  7. import CKEDITOR from '/ckeditor.js';
  8. import ClassicCreator from '/tests/core/creator/manual/_utils/creator/classiccreator.js';
  9. import testUtils from '/tests/core/_utils/utils.js';
  10. let editor, observer;
  11. function initEditor() {
  12. CKEDITOR.create( '#editor', {
  13. creator: ClassicCreator,
  14. ui: {
  15. width: 400,
  16. height: 400
  17. }
  18. } )
  19. .then( ( newEditor ) => {
  20. console.log( 'Editor was initialized', newEditor );
  21. console.log( 'You can now play with it using global `editor` variable.' );
  22. window.editor = editor = newEditor;
  23. observer = testUtils.createObserver();
  24. observer.observe( 'Editable', editor.editable );
  25. } );
  26. }
  27. function destroyEditor() {
  28. editor.destroy()
  29. .then( () => {
  30. window.editor = null;
  31. editor = null;
  32. observer.stopListening();
  33. observer = null;
  34. console.log( 'Editor was destroyed' );
  35. } );
  36. }
  37. document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
  38. document.getElementById( 'destroyEditor' ).addEventListener( 'click', destroyEditor );