editorinit.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
  8. const fixtures = getPerformanceData();
  9. const buttons = document.querySelectorAll( '#test-controls button' );
  10. for ( const button of buttons ) {
  11. const fixtureName = button.getAttribute( 'data-file-name' );
  12. const content = fixtures[ fixtureName ];
  13. const editorElement = document.querySelector( `#editor_${ fixtureName }` );
  14. // Put the source content in editor-related elements ahead of time, so that potentially
  15. // big `innerHTML` change does not affect the benchmark when pressing the button.
  16. editorElement.innerHTML = content;
  17. button.addEventListener( 'click', function() {
  18. createPerformanceEditor( editorElement )
  19. .catch( err => {
  20. console.error( err.stack );
  21. } );
  22. } );
  23. button.disabled = false;
  24. }