8
0

inline-editor.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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-editor-inline/src/inlineeditor';
  7. import fullSizeIcon from '@ckeditor/ckeditor5-core/theme/icons/object-center.svg';
  8. import alignLeftIcon from '@ckeditor/ckeditor5-core/theme/icons/object-left.svg';
  9. import alignRightIcon from '@ckeditor/ckeditor5-core/theme/icons/object-right.svg';
  10. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  11. const inlineInjectElements = document.querySelectorAll( '#snippet-inline-editor [data-inline-inject]' );
  12. Array.prototype.map.call( inlineInjectElements, inlineElement => {
  13. const config = {
  14. plugins: [ ArticlePluginSet ],
  15. toolbar: [ 'headings', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
  16. image: {
  17. toolbar: [ 'imageTextAlternative', '|', 'imageStyleLeft', 'imageStyleFull', 'imageStyleRight' ],
  18. styles: [
  19. {
  20. name: 'imageStyleFull',
  21. title: 'Full size image',
  22. icon: fullSizeIcon,
  23. isDefault: true
  24. },
  25. {
  26. name: 'imageStyleLeft',
  27. title: 'Left aligned image',
  28. icon: alignLeftIcon,
  29. className: 'image-style-left'
  30. },
  31. {
  32. name: 'imageStyleRight',
  33. title: 'Right aligned image',
  34. icon: alignRightIcon,
  35. className: 'image-style-right'
  36. }
  37. ]
  38. }
  39. };
  40. if ( inlineElement.tagName.toLowerCase() == 'header' ) {
  41. config.removePlugins = [ 'Blockquote', 'Image', 'ImageToolbar', 'List' ];
  42. config.toolbar = [ 'headings', 'bold', 'italic', 'link' ];
  43. }
  44. InlineEditor.create( inlineElement, config )
  45. .then( editor => {
  46. window.editor = editor;
  47. } )
  48. .catch( err => {
  49. console.error( err );
  50. } );
  51. } );