multipleeditors.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. const editorCount = 5;
  10. renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
  11. loadPerformanceData()
  12. .then( fixtures => {
  13. const editorsWrapper = document.getElementById( 'editors-wrapper' );
  14. const buttons = document.querySelectorAll( '#test-controls button' );
  15. for ( let i = 0; i < editorCount; i++ ) {
  16. const editorElement = document.createElement( 'div' );
  17. editorElement.setAttribute( 'id', `editor_${ i }` );
  18. editorsWrapper.appendChild( editorElement );
  19. }
  20. for ( const button of buttons ) {
  21. const fixtureName = button.getAttribute( 'data-file-name' );
  22. const content = fixtures[ fixtureName ];
  23. button.addEventListener( 'click', function() {
  24. for ( let i = 0; i < editorCount; i++ ) {
  25. const editorElement = document.querySelector( `#editor_${ i }` );
  26. editorElement.innerHTML = content;
  27. ClassicEditor
  28. .create( editorElement, {
  29. plugins: [ ArticlePluginSet ],
  30. toolbar: [
  31. 'heading',
  32. '|',
  33. 'bold',
  34. 'italic',
  35. 'link',
  36. 'bulletedList',
  37. 'numberedList',
  38. '|',
  39. 'outdent',
  40. 'indent',
  41. '|',
  42. 'blockQuote',
  43. 'insertTable',
  44. 'mediaEmbed',
  45. 'undo',
  46. 'redo'
  47. ],
  48. image: {
  49. toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
  50. },
  51. table: {
  52. contentToolbar: [
  53. 'tableColumn',
  54. 'tableRow',
  55. 'mergeTableCells'
  56. ]
  57. }
  58. } )
  59. .then( editor => {
  60. window.editor = editor;
  61. } )
  62. .catch( err => {
  63. console.error( err.stack );
  64. } );
  65. }
  66. } );
  67. button.disabled = false;
  68. }
  69. } );