8
0

creator-classic.js 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. let editor;
  10. function initEditor() {
  11. CKEDITOR.create( '#editor', {
  12. creator: ClassicCreator,
  13. ui: {
  14. width: 400,
  15. height: 400
  16. }
  17. } )
  18. .then( ( newEditor ) => {
  19. console.log( 'Editor was initialized', newEditor );
  20. console.log( 'You can now play with it using global `editor` variable.' );
  21. window.editor = editor = newEditor;
  22. } );
  23. }
  24. function destroyEditor() {
  25. editor.destroy()
  26. .then( () => {
  27. window.editor = null;
  28. editor = null;
  29. console.log( 'Editor was destroyed' );
  30. } );
  31. }
  32. document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
  33. document.getElementById( 'destroyEditor' ).addEventListener( 'click', destroyEditor );