creator-inline.js 1.1 KB

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