inline-editor.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console, window, document */
  6. import InlineEditor from '@ckeditor/ckeditor5-build-inline/src/ckeditor';
  7. import getToken from '@ckeditor/ckeditor5-easy-image/tests/_utils/gettoken';
  8. const inlineInjectElements = document.querySelectorAll( '#snippet-inline-editor [data-inline-inject]' );
  9. Array.from( inlineInjectElements ).forEach( inlineElement => {
  10. const config = {
  11. image: {
  12. toolbar: [ 'imageTextAlternative', '|', 'imageStyleAlignLeft', 'imageStyleFull', 'imageStyleAlignRight' ],
  13. styles: [ 'imageStyleFull', 'imageStyleAlignLeft', 'imageStyleAlignRight' ]
  14. },
  15. toolbar: {
  16. viewportTopOffset: 60
  17. }
  18. };
  19. if ( inlineElement.tagName.toLowerCase() == 'header' ) {
  20. config.removePlugins = [ 'Blockquote', 'Image', 'ImageToolbar', 'List', 'EasyImage', 'ImageUpload', 'CKFinderUploadAdapter' ];
  21. config.toolbar.items = [ 'headings', 'bold', 'italic', 'link' ];
  22. }
  23. getToken()
  24. .then( token => {
  25. config.cloudServices = { token };
  26. return InlineEditor
  27. .create( inlineElement, config )
  28. .then( editor => {
  29. window.editor = editor;
  30. } );
  31. } )
  32. .catch( err => {
  33. console.error( err );
  34. } );
  35. } );