list-styles.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
  8. import Code from '@ckeditor/ckeditor5-basic-styles/src/code';
  9. import Heading from '@ckeditor/ckeditor5-heading/src/heading';
  10. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  11. import Table from '@ckeditor/ckeditor5-table/src/table';
  12. import TablePropertiesEditing from '@ckeditor/ckeditor5-table/src/tableproperties/tablepropertiesediting';
  13. import TableCellPropertiesEditing from '@ckeditor/ckeditor5-table/src/tablecellproperties/tablecellpropertiesediting';
  14. import List from '../../src/list';
  15. import ListStyles from '../../src/liststyles';
  16. import Indent from '@ckeditor/ckeditor5-indent/src/indent';
  17. import IndentBlock from '@ckeditor/ckeditor5-indent/src/indentblock';
  18. import TodoList from '../../src/todolist';
  19. ClassicEditor
  20. .create( document.querySelector( '#editor' ), {
  21. plugins: [
  22. Essentials,
  23. Code,
  24. Heading,
  25. List,
  26. TodoList,
  27. Paragraph,
  28. ListStyles,
  29. Table,
  30. TablePropertiesEditing,
  31. TableCellPropertiesEditing,
  32. Indent,
  33. IndentBlock
  34. ],
  35. toolbar: [
  36. 'heading',
  37. '|',
  38. 'bulletedList', 'numberedList', 'todoList',
  39. '|',
  40. 'outdent',
  41. 'indent',
  42. '|',
  43. 'undo', 'redo'
  44. ]
  45. } )
  46. .then( editor => {
  47. window.editor = editor;
  48. // TODO: Remove.
  49. for ( const button of [ ...document.querySelectorAll( '.list-styles-ui button' ) ] ) {
  50. button.addEventListener( 'click', () => {
  51. editor.execute( 'listStyles', { type: button.getAttribute( 'data-list' ) } );
  52. } );
  53. }
  54. } )
  55. .catch( err => {
  56. console.error( err.stack );
  57. } );