1.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console, window, document */
  6. import ClassicEditor from 'ckeditor5/editor-classic/classic.js';
  7. import Enter from 'ckeditor5/enter/enter.js';
  8. import Typing from 'ckeditor5/typing/typing.js';
  9. import Heading from 'ckeditor5/heading/heading.js';
  10. import Paragraph from 'ckeditor5/paragraph/paragraph.js';
  11. import Bold from 'ckeditor5/basic-styles/bold.js';
  12. import Italic from 'ckeditor5/basic-styles/italic.js';
  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. } );