creator-classic.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/utils/_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. toolbar: [ 'bold', 'italic' ]
  19. } )
  20. .then( ( newEditor ) => {
  21. console.log( 'Editor was initialized', newEditor );
  22. console.log( 'You can now play with it using global `editor` variable.' );
  23. window.editor = editor = newEditor;
  24. observer = testUtils.createObserver();
  25. observer.observe( 'Editable', editor.editable );
  26. } );
  27. }
  28. function destroyEditor() {
  29. editor.destroy()
  30. .then( () => {
  31. window.editor = null;
  32. editor = null;
  33. observer.stopListening();
  34. observer = null;
  35. console.log( 'Editor was destroyed' );
  36. } );
  37. }
  38. document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
  39. document.getElementById( 'destroyEditor' ).addEventListener( 'click', destroyEditor );