Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <template>
  2. <div>
  3. <ckeditor
  4. v-model="body"
  5. :editor="editor"
  6. :config="editorConfig">
  7. </ckeditor>
  8. </div>
  9. </template>
  10.  
  11. <script>
  12. import CKEditor from '@ckeditor/ckeditor5-vue';
  13. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  14. import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials';
  15. import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold';
  16. import LinkPlugin from '@ckeditor/ckeditor5-link/src/link';
  17. import MyCustomPlugin from '@/components/common/MyCustomPlugin';
  18.  
  19. export default {
  20. components: {
  21. ckeditor: CKEditor.component,
  22. },
  23. data: function() {
  24. return {
  25. editor: ClassicEditor,
  26. editorConfig: {
  27. plugins: [
  28. EssentialsPlugin,
  29. BoldPlugin,
  30. LinkPlugin,
  31. ],
  32. extraPlugins: [MyCustomPlugin,],
  33. toolbar: {
  34. items: [
  35. 'bold',
  36. 'link',
  37. 'myCustomPlugin'
  38. ]
  39. }
  40. },
  41.  
  42. };
  43. },
  44. };
  45. </script>
  46.  
  47. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  48. import imageIcon from '@ckeditor/ckeditor5-core/theme/icons/image.svg';
  49. import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
  50.  
  51. class MyCustomPlugin extends Plugin {
  52. init() {
  53. const editor = this.editor;
  54.  
  55. editor.ui.componentFactory.add( 'myCustomPlugin', locale => {
  56. const view = new ButtonView( locale );
  57.  
  58. view.set( {
  59. label: 'Insert image',
  60. icon: imageIcon,
  61. tooltip: true
  62. } );
  63.  
  64. view.on( 'execute', () => {
  65. console.log('dispatch some event');
  66. } );
  67.  
  68. return view;
  69. } );
  70. }
  71. }
  72.  
  73. export default MyCustomPlugin;
  74.  
  75. "@ckeditor/ckeditor5-basic-styles": "^11.0.0",
  76. "@ckeditor/ckeditor5-dev-utils": "^12.0.1",
  77. "@ckeditor/ckeditor5-dev-webpack-plugin": "^8.0.1",
  78. "@ckeditor/ckeditor5-editor-classic": "^12.0.0",
  79. "@ckeditor/ckeditor5-essentials": "^11.0.0",
  80. "@ckeditor/ckeditor5-font": "^10.0.4",
  81. "@ckeditor/ckeditor5-highlight": "^11.0.0",
  82. "@ckeditor/ckeditor5-link": "^11.0.0",
  83. "@ckeditor/ckeditor5-paragraph": "^11.0.0",
  84. "@ckeditor/ckeditor5-vue": "^1.0.0-beta.1",
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement