1.js 1.1 KB

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