8
0

ballooneditor-data.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  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. let counter = 1;
  11. function initEditor() {
  12. BalloonEditor
  13. .create( `<h2>Editor ${ counter }</h2><p>This is an editor instance.</p>`, {
  14. plugins: [ ArticlePluginSet ],
  15. toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ]
  16. } )
  17. .then( editor => {
  18. counter += 1;
  19. window.editors.push( editor );
  20. container.appendChild( editor.ui.element );
  21. } )
  22. .catch( err => {
  23. console.error( err.stack );
  24. } );
  25. }
  26. function destroyEditors() {
  27. window.editors.forEach( editor => {
  28. editor.destroy()
  29. .then( () => {
  30. editor.ui.element.remove();
  31. } );
  32. } );
  33. window.editors = [];
  34. counter = 1;
  35. }
  36. document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );
  37. document.getElementById( 'destroyEditors' ).addEventListener( 'click', destroyEditors );