inline-editor.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 { TOKEN_URL } from '@ckeditor/ckeditor5-cloudservices/tests/_utils/cloudservices-config';
  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. cloudServices: {
  19. tokenUrl: TOKEN_URL
  20. }
  21. };
  22. if ( inlineElement.tagName.toLowerCase() == 'header' ) {
  23. config.removePlugins = [
  24. 'Blockquote',
  25. 'Image',
  26. 'ImageCaption',
  27. 'ImageStyle',
  28. 'ImageToolbar',
  29. 'ImageUpload',
  30. 'List',
  31. 'EasyImage',
  32. 'CKFinderUploadAdapter'
  33. ];
  34. config.toolbar.items = [ 'headings', 'bold', 'italic', 'link' ];
  35. }
  36. InlineEditor
  37. .create( inlineElement, config )
  38. .then( editor => {
  39. window.editor = editor;
  40. } )
  41. .catch( err => {
  42. console.error( err );
  43. } );
  44. } );