1.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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 ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classic';
  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 Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  11. import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
  12. import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
  13. ClassicEditor.create( document.querySelector( '#editor' ), {
  14. plugins: [ Enter, Typing, Paragraph, Heading, Bold, Italic ],
  15. toolbar: [ 'headings', 'bold', 'italic' ]
  16. } )
  17. .then( editor => {
  18. window.editor = editor;
  19. const sel = editor.document.selection;
  20. sel.on( 'change', ( evt, data ) => {
  21. const date = new Date();
  22. console.log( `${ date.getSeconds() }s${ String( date.getMilliseconds() ).slice( 0, 2 ) }ms`, evt.name, data );
  23. } );
  24. } )
  25. .catch( err => {
  26. console.error( err.stack );
  27. } );