creator-inline.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 InlineCreator from '/tests/core/creator/manual/_utils/creator/inlinecreator.js';
  9. import testUtils from '/tests/core/_utils/utils.js';
  10. let editor, observer;
  11. function initEditor() {
  12. CKEDITOR.create( '#editor', {
  13. creator: InlineCreator
  14. } )
  15. .then( ( newEditor ) => {
  16. console.log( 'Editor was initialized', newEditor );
  17. console.log( 'You can now play with it using global `editor` variable.' );
  18. window.editor = editor = newEditor;
  19. observer = testUtils.createObserver();
  20. observer.observe( 'Editable', editor.editable );
  21. } );
  22. }
  23. function destroyEditor() {
  24. editor.destroy()
  25. .then( () => {
  26. window.editor = null;
  27. editor = null;
  28. observer.stopListening();
  29. observer = null;
  30. console.log( 'Editor was destroyed' );
  31. } );
  32. }
  33. document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
  34. document.getElementById( 'destroyEditor' ).addEventListener( 'click', destroyEditor );