inlineeditor-data.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console:false, document, window */
  6. import InlineEditor from '../../src/inlineeditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. window.editors = [];
  9. function initEditor() {
  10. InlineEditor
  11. .create( '<h2>Editor 1</h2><p>This is an editor instance.</p>', {
  12. plugins: [ ArticlePluginSet ],
  13. toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ]
  14. } )
  15. .then( editor => {
  16. window.editors.push( editor );
  17. document.body.appendChild( editor.element );
  18. } )
  19. .catch( err => {
  20. console.error( err.stack );
  21. } );
  22. }
  23. function destroyEditor() {
  24. window.editors.forEach( editor => {
  25. editor.destroy()
  26. .then( () => {
  27. editor.element.remove();
  28. } );
  29. } );
  30. }
  31. document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
  32. document.getElementById( 'destroyEditor' ).addEventListener( 'click', destroyEditor );