ballooneditor-data.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 BalloonEditor from '../../src/ballooneditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. window.editors = [];
  9. const container = document.querySelector( '.container' );
  10. function initEditor() {
  11. BalloonEditor
  12. .create( '<h2>Editor 1</h2><p>This is an editor instance.</p>', {
  13. plugins: [ ArticlePluginSet ],
  14. toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ]
  15. } )
  16. .then( editor => {
  17. window.editors.push( editor );
  18. container.appendChild( editor.element );
  19. } )
  20. .catch( err => {
  21. console.error( err.stack );
  22. } );
  23. }
  24. function destroyEditor() {
  25. window.editors.forEach( editor => {
  26. editor.destroy()
  27. .then( () => {
  28. editor.element.remove();
  29. } );
  30. } );
  31. }
  32. document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
  33. document.getElementById( 'destroyEditor' ).addEventListener( 'click', destroyEditor );