8
0

editorinit.js 1.9 KB

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