iconset.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global document, console, window */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
  8. import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  9. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  10. import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
  11. import imageIcon from '@ckeditor/ckeditor5-core/theme/icons/image.svg';
  12. import strikethroughIcon from '@ckeditor/ckeditor5-basic-styles/theme/icons/strikethrough.svg';
  13. import underlineIcon from '@ckeditor/ckeditor5-basic-styles/theme/icons/underline.svg';
  14. import unlinkIcon from '@ckeditor/ckeditor5-link/theme/icons/unlink.svg';
  15. class FakeIcons extends Plugin {
  16. init() {
  17. const editor = this.editor;
  18. editor.ui.componentFactory.add( 'insertImage', locale => {
  19. const view = new ButtonView( locale );
  20. view.set( {
  21. label: 'Insert image',
  22. icon: imageIcon,
  23. tooltip: true
  24. } );
  25. return view;
  26. } );
  27. editor.ui.componentFactory.add( 'strikethrough', locale => {
  28. const view = new ButtonView( locale );
  29. view.set( {
  30. label: 'Strikethrough',
  31. icon: strikethroughIcon,
  32. tooltip: true
  33. } );
  34. return view;
  35. } );
  36. editor.ui.componentFactory.add( 'underline', locale => {
  37. const view = new ButtonView( locale );
  38. view.set( {
  39. label: 'Underline',
  40. icon: underlineIcon,
  41. tooltip: true
  42. } );
  43. return view;
  44. } );
  45. editor.ui.componentFactory.add( 'unlink', locale => {
  46. const view = new ButtonView( locale );
  47. view.set( {
  48. label: 'Unlink',
  49. icon: unlinkIcon,
  50. tooltip: true
  51. } );
  52. return view;
  53. } );
  54. }
  55. }
  56. ClassicEditor
  57. .create( document.querySelector( '#editor' ), {
  58. plugins: [
  59. ArticlePluginSet, FakeIcons
  60. ],
  61. toolbar: [ 'headings', 'bold', 'italic', 'strikethrough', 'underline', 'link', 'unlink', 'bulletedList', 'numberedList', 'blockquote', 'undo', 'redo', 'imagestylefull', 'imagestyleside', 'imagetextalternative', 'insertImage' ]
  62. } )
  63. .then( editor => {
  64. window.editor = editor;
  65. } )
  66. .catch( err => {
  67. console.error( err.stack );
  68. } );