todo-list.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* globals console, window, document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import Enter from '@ckeditor/ckeditor5-enter/src/enter';
  8. import Typing from '@ckeditor/ckeditor5-typing/src/typing';
  9. import Heading from '@ckeditor/ckeditor5-heading/src/heading';
  10. import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
  11. import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight';
  12. import Link from '@ckeditor/ckeditor5-link/src/link';
  13. import Table from '@ckeditor/ckeditor5-table/src/table';
  14. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  15. import Undo from '@ckeditor/ckeditor5-undo/src/undo';
  16. import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
  17. import List from '../../src/list';
  18. import FontSize from '@ckeditor/ckeditor5-font/src/fontsize';
  19. import TodoList from '../../src/todolist';
  20. ClassicEditor
  21. .create( document.querySelector( '#editor' ), {
  22. plugins: [ Enter, Typing, Heading, Highlight, Table, Bold, Paragraph, Undo, List, TodoList, Clipboard, Link, FontSize ],
  23. toolbar: [
  24. 'heading',
  25. '|',
  26. 'bulletedList', 'numberedList', 'todoList',
  27. '|',
  28. 'bold', 'link', 'highlight', 'insertTable', 'fontSize',
  29. '|',
  30. 'undo', 'redo'
  31. ],
  32. table: {
  33. contentToolbar: [
  34. 'tableColumn',
  35. 'tableRow',
  36. 'mergeTableCells'
  37. ]
  38. }
  39. } )
  40. .then( editor => {
  41. window.editor = editor;
  42. const contentPreviewBox = document.getElementById( 'preview' );
  43. contentPreviewBox.innerHTML = editor.getData();
  44. editor.model.document.on( 'change:data', () => {
  45. contentPreviewBox.innerHTML = editor.getData();
  46. } );
  47. } )
  48. .catch( err => {
  49. console.error( err.stack );
  50. } );