8
0

multipleeditors.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* globals console, document */
  6. import { getPerformanceData, createPerformanceEditor, renderPerformanceDataButtons } from '../../_utils/utils';
  7. const editorCount = 5;
  8. renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
  9. const fixtures = getPerformanceData();
  10. const editorsWrapper = document.getElementById( 'editors-wrapper' );
  11. const buttons = document.querySelectorAll( '#test-controls button' );
  12. for ( let i = 0; i < editorCount; i++ ) {
  13. const editorElement = document.createElement( 'div' );
  14. editorElement.setAttribute( 'id', `editor_${ i }` );
  15. editorsWrapper.appendChild( editorElement );
  16. }
  17. for ( const button of buttons ) {
  18. const fixtureName = button.getAttribute( 'data-file-name' );
  19. const content = fixtures[ fixtureName ];
  20. button.addEventListener( 'click', function() {
  21. for ( let i = 0; i < editorCount; i++ ) {
  22. const editorElement = document.querySelector( `#editor_${ i }` );
  23. editorElement.innerHTML = content;
  24. createPerformanceEditor( editorElement )
  25. .catch( err => {
  26. console.error( err.stack );
  27. } );
  28. }
  29. } );
  30. button.disabled = false;
  31. }