editorinit.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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, window, document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. import { getPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
  9. renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
  10. const fixtures = getPerformanceData();
  11. const buttons = document.querySelectorAll( '#test-controls button' );
  12. for ( const button of buttons ) {
  13. const fixtureName = button.getAttribute( 'data-file-name' );
  14. const content = fixtures[ fixtureName ];
  15. const editorElement = document.querySelector( `#editor_${ fixtureName }` );
  16. // Put the source content in editor-related elements ahead of time, so that potentially
  17. // big `innerHTML` change does not affect the benchmark when pressing the button.
  18. editorElement.innerHTML = content;
  19. button.addEventListener( 'click', function() {
  20. ClassicEditor
  21. .create( editorElement, {
  22. plugins: [ ArticlePluginSet ],
  23. toolbar: [
  24. 'heading',
  25. '|',
  26. 'bold',
  27. 'italic',
  28. 'link',
  29. 'bulletedList',
  30. 'numberedList',
  31. '|',
  32. 'outdent',
  33. 'indent',
  34. '|',
  35. 'blockQuote',
  36. 'insertTable',
  37. 'mediaEmbed',
  38. 'undo',
  39. 'redo'
  40. ],
  41. image: {
  42. toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
  43. },
  44. table: {
  45. contentToolbar: [
  46. 'tableColumn',
  47. 'tableRow',
  48. 'mergeTableCells'
  49. ]
  50. }
  51. } )
  52. .then( editor => {
  53. window.editor = editor;
  54. } )
  55. .catch( err => {
  56. console.error( err.stack );
  57. } );
  58. } );
  59. button.disabled = false;
  60. }